Author: dgolovin
Date: 2009-08-27 04:44:22 -0400 (Thu, 27 Aug 2009)
New Revision: 17291
Modified:
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/plugin.xml
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreferenceInitializer.java
branches/jbosstools-3.0.x/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
revisions 14543,14544, 14734 were merged to branch
Modified: branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/plugin.xml
===================================================================
--- branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2009-08-27
08:35:38 UTC (rev 17290)
+++ branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/plugin.xml 2009-08-27
08:44:22 UTC (rev 17291)
@@ -240,10 +240,6 @@
facet="jst.java"/>
<fixed
facet="jst.web"/>
- <!--fixed
- facet="jst.seam"/>
- <fixed
- facet="jst.jsf"/-->
<preset
id="jst.seam.preset">
</preset>
@@ -258,14 +254,24 @@
facet="jst.java"/>
<fixed
facet="jst.web"/>
- <!--fixed
- facet="jst.seam"/>
- <fixed
- facet="jst.jsf"/-->
<preset
id="jst.seam2.preset">
</preset>
</template>
+
+ <template
+ id="template.jst.seam21">
+ <label>
+ Seam 2.1 Web Project
+ </label>
+ <fixed
+ facet="jst.java"/>
+ <fixed
+ facet="jst.web"/>
+ <preset
+ id="jst.seam21.preset">
+ </preset>
+ </template>
</extension>
<extension
@@ -318,9 +324,9 @@
<extension
point="org.eclipse.wst.common.project.facet.core.runtimes">
- <supported>
- <runtime-component
- any="true">
+ <supported>
+ <runtime-component
+ any="true">
</runtime-component>
<facet
id="jst.seam"
@@ -383,142 +389,142 @@
</dependentValidator>
</validator>
</extension>
-
- <extension
- point="org.eclipse.wst.validation.validator"
- id="SeamProjectPropertyValidator"
- name="Seam Project Property Validator">
- <validator>
- <filter objectClass="org.eclipse.core.resources.IFolder"
nameFilter="*"/>
- <filter objectClass="org.eclipse.core.resources.IProject"
nameFilter="*"/>
- <filter objectClass="org.eclipse.core.resources.IFile"
nameFilter="org.jboss.tools.seam.core.prefs"/>
- <helper class="org.jboss.tools.seam.internal.core.validation.SeamValidationHelper"/>
- <markerId markerIdValue="seamProjectProblem"/>
- <run
-
class="org.jboss.tools.seam.internal.core.validation.SeamProjectPropertyValidator"
- incremental="true"
- fullBuild="true"
- />
- </validator>
- </extension>
-
+
<extension
+ point="org.eclipse.wst.validation.validator"
+ id="SeamProjectPropertyValidator"
+ name="Seam Project Property Validator">
+ <validator>
+ <filter objectClass="org.eclipse.core.resources.IFolder"
nameFilter="*"/>
+ <filter objectClass="org.eclipse.core.resources.IProject"
nameFilter="*"/>
+ <filter objectClass="org.eclipse.core.resources.IFile"
nameFilter="org.jboss.tools.seam.core.prefs"/>
+ <helper class="org.jboss.tools.seam.internal.core.validation.SeamValidationHelper"/>
+ <markerId markerIdValue="seamProjectProblem"/>
+ <run
+
class="org.jboss.tools.seam.internal.core.validation.SeamProjectPropertyValidator"
+ incremental="true"
+ fullBuild="true"
+ />
+ </validator>
+ </extension>
+
+ <extension
id="seamProblem"
name="Seam Problem"
point="org.eclipse.core.resources.markers">
- <super type="org.eclipse.wst.validation.problemmarker"/>
+ <super type="org.eclipse.wst.validation.problemmarker"/>
<attribute name="kind"/>
<persistent
value="true">
</persistent>
</extension>
-
- <extension
- id="seamProjectProblem"
- name="Seam Project Problem"
- point="org.eclipse.core.resources.markers">
- <super type="org.eclipse.wst.validation.problemmarker"/>
- <attribute name="kind"/>
- <persistent
- value="true">
- </persistent>
- </extension>
-
- <extension
- point="org.eclipse.wst.validation.validator"
- id="SeamEarProjectValidator"
- name="Seam Ear Project Validator">
- <validator>
- <enablement>
- <and>
- <test
property="org.eclipse.wst.common.project.facet.core.projectFacet"
value="jst.ear"/>
- </and>
- </enablement>
- <filter objectClass="org.eclipse.core.resources.IFile"
nameFilter="application.xml"/>
- <helper class="org.jboss.tools.seam.internal.core.validation.SeamValidationHelper"/>
- <markerId markerIdValue="seamEarProjectProblem"/>
- <run
-
class="org.jboss.tools.seam.internal.core.validation.SeamEarProjectValidator"
- incremental="true"
- fullBuild="true"
- />
- </validator>
- </extension>
-
- <extension
- id="seamEarProjectProblem"
- name="Seam Ear Project Problem"
- point="org.eclipse.core.resources.markers">
- <super type="org.eclipse.wst.validation.problemmarker"/>
- <attribute name="kind"/>
- <persistent value="true"/>
- </extension>
+ <extension
+ id="seamProjectProblem"
+ name="Seam Project Problem"
+ point="org.eclipse.core.resources.markers">
+ <super type="org.eclipse.wst.validation.problemmarker"/>
+ <attribute name="kind"/>
+ <persistent
+ value="true">
+ </persistent>
+ </extension>
+
+ <extension
+ point="org.eclipse.wst.validation.validator"
+ id="SeamEarProjectValidator"
+ name="Seam Ear Project Validator">
+ <validator>
+ <enablement>
+ <and>
+ <test
property="org.eclipse.wst.common.project.facet.core.projectFacet"
value="jst.ear"/>
+ </and>
+ </enablement>
+ <filter objectClass="org.eclipse.core.resources.IFile"
nameFilter="application.xml"/>
+ <helper class="org.jboss.tools.seam.internal.core.validation.SeamValidationHelper"/>
+ <markerId markerIdValue="seamEarProjectProblem"/>
+ <run
+
class="org.jboss.tools.seam.internal.core.validation.SeamEarProjectValidator"
+ incremental="true"
+ fullBuild="true"
+ />
+ </validator>
+ </extension>
+
+ <extension
+ id="seamEarProjectProblem"
+ name="Seam Ear Project Problem"
+ point="org.eclipse.core.resources.markers">
+ <super type="org.eclipse.wst.validation.problemmarker"/>
+ <attribute name="kind"/>
+ <persistent value="true"/>
+ </extension>
+
<extension point="org.jboss.tools.common.model.classes">
<xclass id="org.jboss.tools.seam.internal.core.el.SeamPromptingProvider"
class="org.jboss.tools.seam.internal.core.el.SeamPromptingProvider"/>
</extension>
- <extension
- point="org.eclipse.ltk.core.refactoring.renameParticipants">
- <renameParticipant
-
class="org.jboss.tools.seam.internal.core.refactoring.SeamProjectRenameParticipant"
-
id="org.jboss.tools.seam.internal.core.refactoring.SeamProjectRenameParticipant"
- name="seam-RenameProjectParticipant">
- <enablement>
- <with variable="element">
- <or>
- <instanceof
value="org.eclipse.core.resources.IProject"/>
- </or>
- </with>
- </enablement>
- </renameParticipant>
- <renameParticipant
-
class="org.jboss.tools.seam.internal.core.refactoring.SeamFolderRenameParticipant"
-
id="org.jboss.tools.seam.internal.core.refactoring.SeamFolderRenameParticipant"
- name="seam-RenameFolderParticipant">
- <enablement>
- <with variable="element">
- <or>
- <instanceof
value="org.eclipse.core.resources.IFolder"/>
- </or>
- </with>
- </enablement>
- </renameParticipant>
- <renameParticipant
-
class="org.jboss.tools.seam.internal.core.refactoring.SeamJavaPackageRenameParticipant"
-
id="org.jboss.tools.seam.internal.core.refactoring.SeamJavaPackageRenameParticipant"
- name="seam-JavaPackageRenameParticipant">
- <enablement>
- <with variable="element">
- <or>
- <instanceof
value="org.eclipse.jdt.core.IPackageFragment"/>
- </or>
- </with>
- </enablement>
- </renameParticipant>
- </extension>
-
- <extension
- point="org.eclipse.ltk.core.refactoring.moveParticipants">
- <moveParticipant
-
class="org.jboss.tools.seam.internal.core.refactoring.SeamFolderMoveParticipant"
-
id="org.jboss.tools.seam.internal.core.refactoring.SeamFolderMoveParticipant"
- name="name">
- <enablement>
- <with variable="element">
- <or>
- <instanceof
value="org.eclipse.core.resources.IFolder"/>
- </or>
- </with>
- </enablement>
- </moveParticipant>
- </extension>
-
- <extension
- point="org.eclipse.jst.jsf.core.variableresolver">
- <variableresolver
- class="org.jboss.tools.seam.internal.core.el.VariableResolver"
- id="org.jboss.tools.seam.el.variableresolver"/>
- </extension>
+ <extension
+ point="org.eclipse.ltk.core.refactoring.renameParticipants">
+ <renameParticipant
+
class="org.jboss.tools.seam.internal.core.refactoring.SeamProjectRenameParticipant"
+
id="org.jboss.tools.seam.internal.core.refactoring.SeamProjectRenameParticipant"
+ name="seam-RenameProjectParticipant">
+ <enablement>
+ <with variable="element">
+ <or>
+ <instanceof
value="org.eclipse.core.resources.IProject"/>
+ </or>
+ </with>
+ </enablement>
+ </renameParticipant>
+ <renameParticipant
+
class="org.jboss.tools.seam.internal.core.refactoring.SeamFolderRenameParticipant"
+
id="org.jboss.tools.seam.internal.core.refactoring.SeamFolderRenameParticipant"
+ name="seam-RenameFolderParticipant">
+ <enablement>
+ <with variable="element">
+ <or>
+ <instanceof
value="org.eclipse.core.resources.IFolder"/>
+ </or>
+ </with>
+ </enablement>
+ </renameParticipant>
+ <renameParticipant
+
class="org.jboss.tools.seam.internal.core.refactoring.SeamJavaPackageRenameParticipant"
+
id="org.jboss.tools.seam.internal.core.refactoring.SeamJavaPackageRenameParticipant"
+ name="seam-JavaPackageRenameParticipant">
+ <enablement>
+ <with variable="element">
+ <or>
+ <instanceof
value="org.eclipse.jdt.core.IPackageFragment"/>
+ </or>
+ </with>
+ </enablement>
+ </renameParticipant>
+ </extension>
+
+ <extension
+ point="org.eclipse.ltk.core.refactoring.moveParticipants">
+ <moveParticipant
+
class="org.jboss.tools.seam.internal.core.refactoring.SeamFolderMoveParticipant"
+
id="org.jboss.tools.seam.internal.core.refactoring.SeamFolderMoveParticipant"
+ name="name">
+ <enablement>
+ <with variable="element">
+ <or>
+ <instanceof
value="org.eclipse.core.resources.IFolder"/>
+ </or>
+ </with>
+ </enablement>
+ </moveParticipant>
+ </extension>
+
+ <extension
+ point="org.eclipse.jst.jsf.core.variableresolver">
+ <variableresolver
+ class="org.jboss.tools.seam.internal.core.el.VariableResolver"
+ id="org.jboss.tools.seam.el.variableresolver"/>
+ </extension>
</plugin>
\ No newline at end of file
Modified:
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java
===================================================================
---
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java 2009-08-27
08:35:38 UTC (rev 17290)
+++
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java 2009-08-27
08:44:22 UTC (rev 17291)
@@ -1,68 +1,74 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.seam.core.project.facet;
-
-import org.jboss.tools.seam.core.SeamCorePlugin;
-
-/**
- * Seam project related preferences constants
- *
- * @author eskimo
- */
-public class SeamProjectPreferences {
- /**
- * Last selected connection profile
- */
- public static final String SEAM_DEFAULT_CONNECTION_PROFILE = SeamCorePlugin.PLUGIN_ID
- + ".project.facet.default.conn.profile"; //$NON-NLS-1$
-
- /**
- * TODO
- */
- public static final String RUNTIME_CONFIG_FORMAT_VERSION = SeamCorePlugin.PLUGIN_ID
- + ".runtime.config.format.version"; //$NON-NLS-1$
-
- /**
- * String represents list of available runtimes
- */
- public static final String RUNTIME_LIST = SeamCorePlugin.PLUGIN_ID
- + ".runtime.list"; //$NON-NLS-1$
-
- /**
- * Last selected deployment type
- */
- public static final String JBOSS_AS_DEFAULT_DEPLOY_AS = SeamCorePlugin.PLUGIN_ID
- + ".project.default.deployment.type"; //$NON-NLS-1$
-
- /**
- * Last selected DB type
- */
- public static final String HIBERNATE_DEFAULT_DB_TYPE = SeamCorePlugin.PLUGIN_ID
- + ".hibernate.default.db.type"; //$NON-NLS-1$
-
- /**
- * Last selected server
- */
- public static final String SEAM_LAST_SERVER_NAME = SeamCorePlugin.PLUGIN_ID
- + ".project.facet.last.server.name"; //$NON-NLS-1$
-
- /**
- * Return String value from SeamCore preferences by name
- *
- * @param name
- * preference property name
- * @return preference property value
- */
- public static String getStringPreference(final String name) {
- return SeamCorePlugin.getDefault().getPreferenceStore().getString(name);
- }
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.seam.core.project.facet;
+
+import org.jboss.tools.seam.core.SeamCorePlugin;
+
+/**
+ * Seam project related preferences constants
+ *
+ * @author eskimo
+ */
+public class SeamProjectPreferences {
+ /**
+ * Last selected connection profile
+ */
+ public static final String SEAM_DEFAULT_CONNECTION_PROFILE = SeamCorePlugin.PLUGIN_ID
+ + ".project.facet.default.conn.profile"; //$NON-NLS-1$
+
+ /**
+ * TODO
+ */
+ public static final String RUNTIME_CONFIG_FORMAT_VERSION = SeamCorePlugin.PLUGIN_ID
+ + ".runtime.config.format.version"; //$NON-NLS-1$
+
+ /**
+ * String represents list of available runtimes
+ */
+ public static final String RUNTIME_LIST = SeamCorePlugin.PLUGIN_ID
+ + ".runtime.list"; //$NON-NLS-1$
+
+ /**
+ * Last selected deployment type
+ */
+ public static final String JBOSS_AS_DEFAULT_DEPLOY_AS = SeamCorePlugin.PLUGIN_ID
+ + ".project.default.deployment.type"; //$NON-NLS-1$
+
+ /**
+ * Last selected Seam configuration template
+ */
+ public static final String SEAM_CONFIG_TEMPLATE = SeamCorePlugin.PLUGIN_ID
+ + ".project.facet.config.template"; //$NON-NLS-1$
+
+ /**
+ * Last selected DB type
+ */
+ public static final String HIBERNATE_DEFAULT_DB_TYPE = SeamCorePlugin.PLUGIN_ID
+ + ".hibernate.default.db.type"; //$NON-NLS-1$
+
+ /**
+ * Last selected server
+ */
+ public static final String SEAM_LAST_SERVER_NAME = SeamCorePlugin.PLUGIN_ID
+ + ".project.facet.last.server.name"; //$NON-NLS-1$
+
+ /**
+ * Return String value from SeamCore preferences by name
+ *
+ * @param name
+ * preference property name
+ * @return preference property value
+ */
+ public static String getStringPreference(final String name) {
+ return SeamCorePlugin.getDefault().getPreferenceStore().getString(name);
+ }
}
\ No newline at end of file
Modified:
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
===================================================================
---
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2009-08-27
08:35:38 UTC (rev 17290)
+++
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2009-08-27
08:44:22 UTC (rev 17291)
@@ -1,346 +1,367 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.seam.core.project.facet;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.preference.IPersistentPreferenceStore;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.wst.common.project.facet.core.IFacetedProject;
-import org.eclipse.wst.common.project.facet.core.IProjectFacet;
-import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
-import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
-import org.jboss.tools.seam.core.ISeamProject;
-import org.jboss.tools.seam.core.SeamCorePlugin;
-import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
-import org.jboss.tools.seam.internal.core.project.facet.SeamFacetPreferenceInitializer;
-
-/**
- * This class is responsible for managing available SeamRuntime list.
- *
- * @author eskimo
- */
-public class SeamRuntimeManager {
-
- private static SeamRuntimeListConverter converter = new SeamRuntimeListConverter();
-
- private Map<String, SeamRuntime> runtimes = new HashMap<String,
SeamRuntime>();
-
- private SeamRuntime defaultRt = null;
-
- /**
- * Private constructor
- */
- private SeamRuntimeManager() {
- String configVersion = SeamProjectPreferences
- .getStringPreference(SeamProjectPreferences.RUNTIME_CONFIG_FORMAT_VERSION);
- String runtimeListString = SeamProjectPreferences
- .getStringPreference(SeamProjectPreferences.RUNTIME_LIST);
-
- runtimes = converter.getMap(runtimeListString);
- }
-
- /**
- * This class make Java Runtime responsible for solving synchronization
- * problems during initialization if there is any
- *
- * @author eskimo
- */
- static class SeamRuntimeManagerHolder {
- private static final SeamRuntimeManager INSTANCE = new SeamRuntimeManager();
- }
-
- /**
- * Return SeamRuntimeManaher instance
- *
- * @return
- * SeamRuntimeManager instance
- */
- public static SeamRuntimeManager getInstance() {
- return SeamRuntimeManagerHolder.INSTANCE;
- }
-
- /**
- * Return Array of configured SeamRuntimes
- *
- * @return
- * SeamRuntime[]
- */
- public SeamRuntime[] getRuntimes() {
- Collection<SeamRuntime> c = runtimes.values();
- return c.toArray(new SeamRuntime[runtimes.size()]);
- }
-
- /**
- * Return array of SeamRuntimes that is compatible with given version
- *
- * @param version
- * SeamVersion
- * @return
- * SeamRuntime[]
- */
- public SeamRuntime[] getRuntimes(SeamVersion version) {
- Collection<SeamRuntime> c = runtimes.values();
- List<SeamRuntime> rts = new ArrayList<SeamRuntime>();
- for (SeamRuntime seamRuntime : c) {
- if (seamRuntime.getVersion() == version) {
- rts.add(seamRuntime);
- }
- }
- return rts.toArray(new SeamRuntime[rts.size()]);
- }
-
- /**
- * Add new SeamRuntime
- *
- * @param runtime
- * SeamRuntime
- */
- public void addRuntime(SeamRuntime runtime) {
- if (runtimes.size() == 0) {
- runtime.setDefault(true);
- }
-
- SeamRuntime oldDefaultRuntime = getDefaultRuntime(runtime.getVersion());
- if (oldDefaultRuntime != null && runtime.isDefault()) {
- oldDefaultRuntime.setDefault(false);
- }
- runtimes.put(runtime.getName(), runtime);
- save();
- }
-
- /**
- * Add new SeamRuntime with given parameters
- *
- * @param name
- * String - runtime name
- * @param path
- * String - runtime home folder
- * @param version
- * String - string representation of version number
- * @param defaultRt
- * boolean - default flag
- */
- public void addRuntime(String name, String path, SeamVersion version,
- boolean defaultRt) {
- SeamRuntime seamRt = new SeamRuntime();
- seamRt.setVersion(version);
- seamRt.setHomeDir(path);
- seamRt.setName(name);
- seamRt.setDefault(defaultRt);
- addRuntime(seamRt);
- }
-
- /**
- * Return SeamRuntime by given name
- *
- * @param name
- * String - SeamRuntime name
- * @return
- * SeamRuntime - found SeamRuntime instance or null
- */
- public SeamRuntime findRuntimeByName(String name) {
- for (SeamRuntime seamRuntime : runtimes.values()) {
- if (seamRuntime.getName().equals(name)) {
- return seamRuntime;
- }
- }
- return null;
- }
-
- /**
- * Remove given SeamRuntime from manager
- * @param rt
- * SeamRuntime
- */
- public void removeRuntime(SeamRuntime rt) {
- runtimes.remove(rt.getName());
- }
-
- /**
- * Return SeamRuntime instance for given project
- *
- * @param project
- * IProject
- * @return
- * SeamRuntime - instance of available SeamRuntime or null
- */
- public SeamRuntime getRuntimeForProject(IProject project) {
- ISeamProject seamProject = SeamCorePlugin
- .getSeamProject(project, false);
- return (seamProject == null) ? null : seamProject.getRuntime();
- }
-
- /**
- * Save preference value and force save changes to disk
- */
- public void save() {
- SeamCorePlugin.getDefault().getPluginPreferences().setValue(
- SeamProjectPreferences.RUNTIME_LIST,
- converter.getString(runtimes));
- IPreferenceStore store = SeamCorePlugin.getDefault()
- .getPreferenceStore();
- if (store instanceof IPersistentPreferenceStore) {
- try {
- ((IPersistentPreferenceStore) store).save();
- } catch (IOException e) {
- SeamCorePlugin.getPluginLog().logError(
- "Seam Runtime List was not saved", e);
- }
- }
- }
-
- /**
- * Marks this runtime as default. Marks other runtimes with the same version as not
default.
- * @param runtime
- */
- public void setDefaultRuntime(SeamRuntime runtime) {
- SeamRuntime[] runtimes = getRuntimes(runtime.getVersion());
- for (int i = 0; i < runtimes.length; i++) {
- runtimes[i].setDefault(false);
- }
- runtime.setDefault(true);
- }
-
- /**
- * Return first default SeamRuntime
- *
- * @return
- * SeamRuntime
- */
- public SeamRuntime getDefaultRuntime() {
- for (SeamRuntime rt : runtimes.values()) {
- if (rt.isDefault()) {
- return rt;
- }
- }
- return null;
- }
-
- /**
- * If project has seam facet then this method returns default seam runtime for proper
version of facet.
- * Otherwise return first default runtime.
- * @param project
- * @return
- */
- public static SeamRuntime getDefaultRuntimeForProject(IProject project) {
- if(project==null) {
- throw new IllegalArgumentException("Project must not be null.");
- }
- try {
- IProjectFacet facet =
ProjectFacetsManager.getProjectFacet(ISeamFacetDataModelProperties.SEAM_FACET_ID);
- IFacetedProject facetedProject = ProjectFacetsManager.create(project);
- if(facetedProject!=null) {
- IProjectFacetVersion facetVersion = facetedProject.getInstalledVersion(facet);
- if(facetVersion==null) return null;
- SeamVersion seamVersion =
SeamVersion.parseFromString(facetVersion.getVersionString());
- return getInstance().getDefaultRuntime(seamVersion);
- }
- } catch (CoreException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- } catch (IllegalArgumentException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- }
- return getInstance().getDefaultRuntime();
- }
-
- /**
- * Return default runtime for given SeamVersion
- *
- * @param version
- * given SeamVersion
- * @return
- * Default SeamRuntime for given version
- */
- public SeamRuntime getDefaultRuntime(SeamVersion version) {
- for (SeamRuntime rt : runtimes.values()) {
- if (rt.isDefault() && rt.getVersion() == version) {
- return rt;
- }
- }
- return null;
- }
-
- /**
- * Return version of configuration
- *
- * @return
- * String - string representation of version
- */
- public String getConfigurationVersion() {
- return SeamFacetPreferenceInitializer.RUNTIME_CONFIG_FORMAT_VERSION;
- }
-
- /**
- * Return list of available SeamRuntime names
- *
- * @return
- * List<String>
- */
- public List<String> getRuntimeNames() {
- SeamRuntime[] rts = getRuntimes(SeamVersion.SEAM_1_2);
- List<String> result = new ArrayList<String>();
- for (SeamRuntime seamRuntime : rts) {
- result.add(seamRuntime.getName());
- }
- return result;
- }
-
- /**
- * Return a list of all runtime names
- *
- * @return
- * List of all runtime names
- */
- public List<String> getAllRuntimeNames() {
- SeamRuntime[] rts = getRuntimes();
- List<String> result = new ArrayList<String>();
- for (SeamRuntime seamRuntime : rts) {
- result.add(seamRuntime.getName());
- }
- return result;
- }
-
- /**
- * TBD
- *
- * @param oldName
- * old runtime name
- * @param newName
- * new runtime name
- */
- public void changeRuntimeName(String oldName, String newName) {
- SeamRuntime o = findRuntimeByName(oldName);
- if (o == null) {
- return;
- }
- o.setName(newName);
- onRuntimeNameChanged(oldName, newName);
- }
-
- private void onRuntimeNameChanged(String oldName, String newName) {
- IProject[] ps = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- for (int i = 0; i < ps.length; i++) {
- ISeamProject sp = SeamCorePlugin.getSeamProject(ps[i], false);
- if (sp != null && oldName.equals(sp.getRuntimeName())) {
- sp.setRuntimeName(newName);
- }
- }
- }
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.core.project.facet;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.preference.IPersistentPreferenceStore;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.wst.common.project.facet.core.IFacetedProject;
+import org.eclipse.wst.common.project.facet.core.IProjectFacet;
+import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
+import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.internal.core.project.facet.ISeamFacetDataModelProperties;
+import org.jboss.tools.seam.internal.core.project.facet.SeamFacetPreferenceInitializer;
+
+/**
+ * This class is responsible for managing available SeamRuntime list.
+ *
+ * @author eskimo
+ */
+public class SeamRuntimeManager {
+
+ private static SeamRuntimeListConverter converter = new SeamRuntimeListConverter();
+
+ private Map<String, SeamRuntime> runtimes = new HashMap<String,
SeamRuntime>();
+
+ private SeamRuntime defaultRt = null;
+
+ /**
+ * Private constructor
+ */
+ private SeamRuntimeManager() {
+ String configVersion = SeamProjectPreferences
+ .getStringPreference(SeamProjectPreferences.RUNTIME_CONFIG_FORMAT_VERSION);
+ String runtimeListString = SeamProjectPreferences
+ .getStringPreference(SeamProjectPreferences.RUNTIME_LIST);
+
+ runtimes = converter.getMap(runtimeListString);
+ }
+
+ /**
+ * This class make Java Runtime responsible for solving synchronization
+ * problems during initialization if there is any
+ *
+ * @author eskimo
+ */
+ static class SeamRuntimeManagerHolder {
+ private static final SeamRuntimeManager INSTANCE = new SeamRuntimeManager();
+ }
+
+ /**
+ * Return SeamRuntimeManaher instance
+ *
+ * @return
+ * SeamRuntimeManager instance
+ */
+ public static SeamRuntimeManager getInstance() {
+ return SeamRuntimeManagerHolder.INSTANCE;
+ }
+
+ /**
+ * Return Array of configured SeamRuntimes
+ *
+ * @return
+ * SeamRuntime[]
+ */
+ public SeamRuntime[] getRuntimes() {
+ Collection<SeamRuntime> c = runtimes.values();
+ return c.toArray(new SeamRuntime[runtimes.size()]);
+ }
+
+ /**
+ * @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
+ * SeamVersion
+ * @return
+ * SeamRuntime[]
+ */
+ public SeamRuntime[] getRuntimes(SeamVersion version) {
+ Collection<SeamRuntime> c = runtimes.values();
+ List<SeamRuntime> rts = new ArrayList<SeamRuntime>();
+ for (SeamRuntime seamRuntime : c) {
+ if (seamRuntime.getVersion() == version) {
+ rts.add(seamRuntime);
+ }
+ }
+ return rts.toArray(new SeamRuntime[rts.size()]);
+ }
+
+ /**
+ * Add new SeamRuntime
+ *
+ * @param runtime
+ * SeamRuntime
+ */
+ public void addRuntime(SeamRuntime runtime) {
+ if (runtimes.size() == 0) {
+ runtime.setDefault(true);
+ }
+
+ SeamRuntime oldDefaultRuntime = getDefaultRuntime(runtime.getVersion());
+ if (oldDefaultRuntime != null && runtime.isDefault()) {
+ oldDefaultRuntime.setDefault(false);
+ }
+ runtimes.put(runtime.getName(), runtime);
+ save();
+ }
+
+ /**
+ * Add new SeamRuntime with given parameters
+ *
+ * @param name
+ * String - runtime name
+ * @param path
+ * String - runtime home folder
+ * @param version
+ * String - string representation of version number
+ * @param defaultRt
+ * boolean - default flag
+ */
+ public void addRuntime(String name, String path, SeamVersion version,
+ boolean defaultRt) {
+ SeamRuntime seamRt = new SeamRuntime();
+ seamRt.setVersion(version);
+ seamRt.setHomeDir(path);
+ seamRt.setName(name);
+ seamRt.setDefault(defaultRt);
+ addRuntime(seamRt);
+ }
+
+ /**
+ * Return SeamRuntime by given name
+ *
+ * @param name
+ * String - SeamRuntime name
+ * @return
+ * SeamRuntime - found SeamRuntime instance or null
+ */
+ public SeamRuntime findRuntimeByName(String name) {
+ for (SeamRuntime seamRuntime : runtimes.values()) {
+ if (seamRuntime.getName().equals(name)) {
+ return seamRuntime;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Remove given SeamRuntime from manager
+ * @param rt
+ * SeamRuntime
+ */
+ public void removeRuntime(SeamRuntime rt) {
+ runtimes.remove(rt.getName());
+ }
+
+ /**
+ * Return SeamRuntime instance for given project
+ *
+ * @param project
+ * IProject
+ * @return
+ * SeamRuntime - instance of available SeamRuntime or null
+ */
+ public SeamRuntime getRuntimeForProject(IProject project) {
+ ISeamProject seamProject = SeamCorePlugin
+ .getSeamProject(project, false);
+ return (seamProject == null) ? null : seamProject.getRuntime();
+ }
+
+ /**
+ * Save preference value and force save changes to disk
+ */
+ public void save() {
+ SeamCorePlugin.getDefault().getPluginPreferences().setValue(
+ SeamProjectPreferences.RUNTIME_LIST,
+ converter.getString(runtimes));
+ IPreferenceStore store = SeamCorePlugin.getDefault()
+ .getPreferenceStore();
+ if (store instanceof IPersistentPreferenceStore) {
+ try {
+ ((IPersistentPreferenceStore) store).save();
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(
+ "Seam Runtime List was not saved", e);
+ }
+ }
+ }
+
+ /**
+ * Marks this runtime as default. Marks other runtimes with the same version as not
default.
+ * @param runtime
+ */
+ public void setDefaultRuntime(SeamRuntime runtime) {
+ SeamRuntime[] runtimes = getRuntimes(runtime.getVersion());
+ for (int i = 0; i < runtimes.length; i++) {
+ runtimes[i].setDefault(false);
+ }
+ runtime.setDefault(true);
+ }
+
+ /**
+ * Return first default SeamRuntime
+ *
+ * @return
+ * SeamRuntime
+ */
+ public SeamRuntime getDefaultRuntime() {
+ for (SeamRuntime rt : runtimes.values()) {
+ if (rt.isDefault()) {
+ return rt;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * If project has seam facet then this method returns default seam runtime for proper
version of facet.
+ * Otherwise return first default runtime.
+ * @param project
+ * @return
+ */
+ public static SeamRuntime getDefaultRuntimeForProject(IProject project) {
+ if(project==null) {
+ throw new IllegalArgumentException("Project must not be null.");
+ }
+ try {
+ IProjectFacet facet =
ProjectFacetsManager.getProjectFacet(ISeamFacetDataModelProperties.SEAM_FACET_ID);
+ IFacetedProject facetedProject = ProjectFacetsManager.create(project);
+ if(facetedProject!=null) {
+ IProjectFacetVersion facetVersion = facetedProject.getInstalledVersion(facet);
+ if(facetVersion==null) return null;
+ SeamVersion seamVersion =
SeamVersion.parseFromString(facetVersion.getVersionString());
+ return getInstance().getDefaultRuntime(seamVersion);
+ }
+ } catch (CoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ } catch (IllegalArgumentException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ return getInstance().getDefaultRuntime();
+ }
+
+ /**
+ * Return default runtime for given SeamVersion
+ *
+ * @param version
+ * given SeamVersion
+ * @return
+ * Default SeamRuntime for given version
+ */
+ public SeamRuntime getDefaultRuntime(SeamVersion version) {
+ for (SeamRuntime rt : runtimes.values()) {
+ if (rt.isDefault() && rt.getVersion() == version) {
+ return rt;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return version of configuration
+ *
+ * @return
+ * String - string representation of version
+ */
+ public String getConfigurationVersion() {
+ return SeamFacetPreferenceInitializer.RUNTIME_CONFIG_FORMAT_VERSION;
+ }
+
+ /**
+ * Return list of available SeamRuntime names
+ *
+ * @return
+ * List<String>
+ */
+ public List<String> getRuntimeNames() {
+ SeamRuntime[] rts = getRuntimes(SeamVersion.SEAM_1_2);
+ List<String> result = new ArrayList<String>();
+ for (SeamRuntime seamRuntime : rts) {
+ result.add(seamRuntime.getName());
+ }
+ return result;
+ }
+
+ /**
+ * Return a list of all runtime names
+ *
+ * @return
+ * List of all runtime names
+ */
+ public List<String> getAllRuntimeNames() {
+ SeamRuntime[] rts = getRuntimes();
+ List<String> result = new ArrayList<String>();
+ for (SeamRuntime seamRuntime : rts) {
+ result.add(seamRuntime.getName());
+ }
+ return result;
+ }
+
+ /**
+ * TBD
+ *
+ * @param oldName
+ * old runtime name
+ * @param newName
+ * new runtime name
+ */
+ public void changeRuntimeName(String oldName, String newName) {
+ SeamRuntime o = findRuntimeByName(oldName);
+ if (o == null) {
+ return;
+ }
+ o.setName(newName);
+ onRuntimeNameChanged(oldName, newName);
+ }
+
+ private void onRuntimeNameChanged(String oldName, String newName) {
+ IProject[] ps = ResourcesPlugin.getWorkspace().getRoot().getProjects();
+ for (int i = 0; i < ps.length; i++) {
+ ISeamProject sp = SeamCorePlugin.getSeamProject(ps[i], false);
+ if (sp != null && oldName.equals(sp.getRuntimeName())) {
+ sp.setRuntimeName(newName);
+ }
+ }
+ }
}
\ No newline at end of file
Modified:
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreferenceInitializer.java
===================================================================
---
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreferenceInitializer.java 2009-08-27
08:35:38 UTC (rev 17290)
+++
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreferenceInitializer.java 2009-08-27
08:44:22 UTC (rev 17291)
@@ -1,111 +1,112 @@
-/*******************************************************************************
- * Copyright (c) 2007 Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is 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:
- * Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-
-package org.jboss.tools.seam.internal.core.project.facet;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.core.runtime.preferences.DefaultScope;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-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.SeamRuntimeListConverter;
-import org.jboss.tools.seam.core.project.facet.SeamVersion;
-import org.osgi.service.prefs.BackingStoreException;
-
-/**
- * @author eskimo
- *
- */
-public class SeamFacetPreferenceInitializer extends
- AbstractPreferenceInitializer {
-
- public static String RUNTIME_CONFIG_FORMAT_VERSION = "1.0"; //$NON-NLS-1$
-
- public static final String SEAM_1_2_HOME = "../../../seam1"; //$NON-NLS-1$
- public static final String SEAM_2_0_HOME = "../../../seam"; //$NON-NLS-1$
-
- /**
- *
- */
- public SeamFacetPreferenceInitializer() {}
-
- @Override
- public void initializeDefaultPreferences() {
- IEclipsePreferences node = (IEclipsePreferences)
- Platform.getPreferencesService()
- .getRootNode()
- .node(DefaultScope.SCOPE)
- .node(SeamCorePlugin.PLUGIN_ID);
-
- 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$
- node.put(SeamProjectPreferences.SEAM_DEFAULT_CONNECTION_PROFILE,
"DefaultDS"); //$NON-NLS-1$
- Map<String, SeamRuntime> map = new HashMap<String,SeamRuntime>();
-
- // Initialize Seam 1.2 Runtime from JBoss EAP
- String seamGenBuildPath = getSeamGenBuildPath(SEAM_1_2_HOME);
- File seamFolder = new File(seamGenBuildPath);
- if(seamFolder.exists() && seamFolder.isDirectory()) {
- SeamRuntime rt = new SeamRuntime();
- rt.setHomeDir(seamGenBuildPath);
- rt.setName("Seam " + SeamVersion.SEAM_1_2 + ".AP"); //$NON-NLS-1$
//$NON-NLS-2$
- rt.setDefault(true);
- rt.setVersion(SeamVersion.SEAM_1_2);
- map.put(rt.getName(), rt);
- }
- // Initialize Seam 2.0 Runtime from JBoss EAP
- seamGenBuildPath = getSeamGenBuildPath(SEAM_2_0_HOME);
- seamFolder = new File(seamGenBuildPath);
- if(seamFolder.exists() && seamFolder.isDirectory()) {
- SeamRuntime rt = new SeamRuntime();
- rt.setHomeDir(seamGenBuildPath);
- rt.setName("Seam " + SeamVersion.SEAM_2_1); //$NON-NLS-1$ //$NON-NLS-2$
- rt.setDefault(true);
- rt.setVersion(SeamVersion.SEAM_2_1);
- map.put(rt.getName(), rt);
- }
- node.put(SeamProjectPreferences.RUNTIME_LIST, new
SeamRuntimeListConverter().getString(map));
- try {
- node.flush();
- } catch (BackingStoreException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- }
- }
-
-
-
- private String getSeamGenBuildPath(String seamHomePath) {
- String pluginLocation=null;
- try {
- pluginLocation =
FileLocator.resolve(SeamCorePlugin.getDefault().getBundle().getEntry("/")).getFile();
//$NON-NLS-1$
- } catch (IOException e) {
- SeamCorePlugin.getPluginLog().logError(e);
- };
- File seamGenDir = new File(pluginLocation, seamHomePath);
- Path p = new Path(seamGenDir.getPath());
- p.makeAbsolute();
- if(p.toFile().exists()) {
- return p.toOSString();
- } else {
- return ""; //$NON-NLS-1$
- }
- }
-}
+/*******************************************************************************
+ * Copyright (c) 2007 Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.seam.internal.core.project.facet;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+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.SeamRuntimeListConverter;
+import org.jboss.tools.seam.core.project.facet.SeamVersion;
+import org.osgi.service.prefs.BackingStoreException;
+
+/**
+ * @author eskimo
+ *
+ */
+public class SeamFacetPreferenceInitializer extends
+ AbstractPreferenceInitializer {
+
+ public static String RUNTIME_CONFIG_FORMAT_VERSION = "1.0"; //$NON-NLS-1$
+
+ public static final String SEAM_1_2_HOME = "../../../seam1"; //$NON-NLS-1$
+ public static final String SEAM_2_0_HOME = "../../../seam"; //$NON-NLS-1$
+
+ /**
+ *
+ */
+ public SeamFacetPreferenceInitializer() {}
+
+ @Override
+ public void initializeDefaultPreferences() {
+ IEclipsePreferences node = (IEclipsePreferences)
+ Platform.getPreferencesService()
+ .getRootNode()
+ .node(DefaultScope.SCOPE)
+ .node(SeamCorePlugin.PLUGIN_ID);
+
+// 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$
+ node.put(SeamProjectPreferences.SEAM_DEFAULT_CONNECTION_PROFILE,
"DefaultDS"); //$NON-NLS-1$
+ Map<String, SeamRuntime> map = new HashMap<String,SeamRuntime>();
+
+ // Initialize Seam 1.2 Runtime from JBoss EAP
+ String seamGenBuildPath = getSeamGenBuildPath(SEAM_1_2_HOME);
+ File seamFolder = new File(seamGenBuildPath);
+ if(seamFolder.exists() && seamFolder.isDirectory()) {
+ SeamRuntime rt = new SeamRuntime();
+ rt.setHomeDir(seamGenBuildPath);
+ rt.setName("Seam " + SeamVersion.SEAM_1_2 + ".AP"); //$NON-NLS-1$
//$NON-NLS-2$
+ rt.setDefault(true);
+ rt.setVersion(SeamVersion.SEAM_1_2);
+ map.put(rt.getName(), rt);
+ }
+ // Initialize Seam 2.0 Runtime from JBoss EAP
+ seamGenBuildPath = getSeamGenBuildPath(SEAM_2_0_HOME);
+ seamFolder = new File(seamGenBuildPath);
+ if(seamFolder.exists() && seamFolder.isDirectory()) {
+ SeamRuntime rt = new SeamRuntime();
+ rt.setHomeDir(seamGenBuildPath);
+ rt.setName("Seam " + SeamVersion.SEAM_2_1); //$NON-NLS-1$ //$NON-NLS-2$
+ rt.setDefault(true);
+ rt.setVersion(SeamVersion.SEAM_2_1);
+ map.put(rt.getName(), rt);
+ }
+ node.put(SeamProjectPreferences.RUNTIME_LIST, new
SeamRuntimeListConverter().getString(map));
+ try {
+ node.flush();
+ } catch (BackingStoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+
+
+
+ private String getSeamGenBuildPath(String seamHomePath) {
+ String pluginLocation=null;
+ try {
+ pluginLocation =
FileLocator.resolve(SeamCorePlugin.getDefault().getBundle().getEntry("/")).getFile();
//$NON-NLS-1$
+ } catch (IOException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ };
+ File seamGenDir = new File(pluginLocation, seamHomePath);
+ Path p = new Path(seamGenDir.getPath());
+ p.makeAbsolute();
+ if(p.toFile().exists()) {
+ return p.toOSString();
+ } else {
+ return ""; //$NON-NLS-1$
+ }
+ }
+}
Modified:
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java
===================================================================
---
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2009-08-27
08:35:38 UTC (rev 17290)
+++
branches/jbosstools-3.0.x/seam/plugins/org.jboss.tools.seam.ui/src/org/jboss/tools/seam/ui/wizard/SeamProjectWizard.java 2009-08-27
08:44:22 UTC (rev 17291)
@@ -13,7 +13,9 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IProject;
@@ -25,6 +27,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Preferences;
import org.eclipse.jdt.core.IClasspathContainer;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
@@ -54,6 +57,7 @@
import org.eclipse.wst.common.frameworks.internal.datamodel.ui.DataModelSynchHelper;
import org.eclipse.wst.common.project.facet.core.IFacetedProjectTemplate;
import org.eclipse.wst.common.project.facet.core.IFacetedProjectWorkingCopy;
+import org.eclipse.wst.common.project.facet.core.IPreset;
import org.eclipse.wst.common.project.facet.core.IProjectFacet;
import org.eclipse.wst.common.project.facet.core.IProjectFacetVersion;
import org.eclipse.wst.common.project.facet.core.ProjectFacetsManager;
@@ -69,13 +73,13 @@
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;
-import org.jboss.tools.seam.internal.core.project.facet.Seam2ProjectCreator;
import
org.jboss.tools.seam.internal.core.project.facet.SeamFacetProjectCreationDataModelProvider;
-import org.jboss.tools.seam.internal.core.project.facet.SeamProjectCreator;
import org.jboss.tools.seam.ui.ISeamHelpContextIds;
import org.jboss.tools.seam.ui.SeamGuiPlugin;
import org.jboss.tools.seam.ui.SeamUIMessages;
@@ -88,6 +92,14 @@
*/
public class SeamProjectWizard extends WebProjectWizard {
+ private SeamWebProjectFirstPage firstPage;
+ private String seamConfigTemplate;
+
+ // We need these controls there to listen to them to set seam action models.
+ private Combo matchedServerTargetCombo;
+ private Control[] dependentServerControls;
+ private Combo serverRuntimeTargetCombo;
+
public SeamProjectWizard() {
super();
setWindowTitle(SeamUIMessages.SEAM_PROJECT_WIZARD_NEW_SEAM_PROJECT);
@@ -102,8 +114,6 @@
return DataModelFactory.createDataModel(new
SeamFacetProjectCreationDataModelProvider());
}
- private SeamWebProjectFirstPage firstPage;
-
@Override
protected IWizardPage createFirstPage() {
firstPage = new SeamWebProjectFirstPage(model, "first.page"); //$NON-NLS-1$
@@ -114,11 +124,21 @@
return firstPage;
}
- // We need these controls there to listen to them to set seam action models.
- private Combo matchedServerTargetCombo;
- private Control[] dependentServerControls;
- private Combo serverRuntimeTargetCombo;
+ 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", 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) {
+ this.seamConfigTemplate = seamConfigTemplate;
+ }
+
@Override
public void createPageControls(Composite container) {
super.createPageControls(container);
@@ -130,6 +150,12 @@
}, IFacetedProjectEvent.Type.PROJECT_FACETS_CHANGED);
getFacetedProjectWorkingCopy().addListener(new IFacetedProjectListener() {
public void handleEvent(IFacetedProjectEvent event) {
+ IPreset preset = getFacetedProjectWorkingCopy().getSelectedPreset();
+ setSeamConfigTemplate(templates.get(preset.getId()));
+ }
+ }, IFacetedProjectEvent.Type.SELECTED_PRESET_CHANGED);
+ getFacetedProjectWorkingCopy().addListener(new IFacetedProjectListener() {
+ public void handleEvent(IFacetedProjectEvent event) {
Set<Action> actions = getFacetedProjectWorkingCopy().getProjectFacetActions();
for (Action action : actions) {
if(ISeamFacetDataModelProperties.SEAM_FACET_ID.equals(action.getProjectFacetVersion().getProjectFacet().getId()))
{
@@ -203,7 +229,22 @@
}
protected IFacetedProjectTemplate getTemplate() {
- return ProjectFacetsManager.getTemplate("template.jst.seam"); //$NON-NLS-1$
+ seamConfigTemplate = null;
//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);
}
/* (non-Javadoc)
@@ -503,12 +544,18 @@
public void storeDefaultSettings() {
super.storeDefaultSettings();
+ Preferences preferences = SeamCorePlugin.getDefault().getPluginPreferences();
String serverName =
SeamFacetProjectCreationDataModelProvider.getServerName(model);
if (serverName != null && serverName.length() > 0) {
- SeamCorePlugin.getDefault().getPluginPreferences().setValue(
+ preferences.setValue(
SeamProjectPreferences.SEAM_LAST_SERVER_NAME,
serverName);
}
+ if(seamConfigTemplate!=null) {
+ preferences.setValue(
+ SeamProjectPreferences.SEAM_CONFIG_TEMPLATE,
+ seamConfigTemplate);
+ }
}
}
}
\ No newline at end of file