Author: dgolovin
Date: 2007-12-28 20:49:25 -0500 (Fri, 28 Dec 2007)
New Revision: 5479
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/Change.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeListConverter.java
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/SeamVersion.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreferenceInitializer.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1490
1. JUnit test for JBIDE-1490 was added
2. Javadoc comments were added
3. Coding style was improved to reduce amount of Checkstyle violations
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/Change.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/Change.java 2007-12-29
01:47:45 UTC (rev 5478)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/event/Change.java 2007-12-29
01:49:25 UTC (rev 5479)
@@ -26,11 +26,18 @@
List<Change> children;
/**
+ * Constructs object with initial values
*
* @param target
- * @param property - name of property changed or null, if change is adding/removing a
child.
- * @param oldValue - old value; if null and property = null, then child (newValue) is
added
- * @param newValue - new value; if null and property = null, then child (oldValue) is
removed
+ * @param property
+ * name of property changed or null, if change is adding/removing
+ * a child.
+ * @param oldValue
+ * old value; if null and property = null, then child (newValue)
+ * is added
+ * @param newValue
+ * new value; if null and property = null, then child (oldValue)
+ * is removed
*/
public Change(Object target, String property, Object oldValue, Object newValue) {
this.target = target;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java 2007-12-29
01:47:45 UTC (rev 5478)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamProjectPreferences.java 2007-12-29
01:49:25 UTC (rev 5479)
@@ -7,34 +7,73 @@
*
* 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 {
- public static final String SEAM_DEFAULT_RUNTIME_NAME
- = SeamCorePlugin.PLUGIN_ID + ".project.facet.default.runtime.name";
//$NON-NLS-1$
- public static final String SEAM_DEFAULT_CONNECTION_PROFILE
- = SeamCorePlugin.PLUGIN_ID + ".project.facet.default.conn.profile";
//$NON-NLS-1$
- public static final String RUNTIME_CONFIG_FORMAT_VERSION
- = SeamCorePlugin.PLUGIN_ID + ".runtime.config.format.version"; //$NON-NLS-1$
- public static final String RUNTIME_LIST
- = SeamCorePlugin.PLUGIN_ID+".runtime.list"; //$NON-NLS-1$
- public static final String RUNTIME_DEFAULT
- = SeamCorePlugin.PLUGIN_ID+".runtime.default"; //$NON-NLS-1$
- public static final String JBOSS_AS_DEFAULT_DEPLOY_AS
- = SeamCorePlugin.PLUGIN_ID + ".project.default.deployment.type";
//$NON-NLS-1$
- public static final String HIBERNATE_DEFAULT_DB_TYPE
- = SeamCorePlugin.PLUGIN_ID + ".hibernate.default.db.type"; //$NON-NLS-1$
- public static final String SEAM_LAST_SERVER_NAME
- = SeamCorePlugin.PLUGIN_ID + ".project.facet.last.server.name"; //$NON-NLS-1$
-
+ /**
+ * Last selected SeamRuntime name
+ */
+ public static final String SEAM_DEFAULT_RUNTIME_NAME = SeamCorePlugin.PLUGIN_ID
+ + ".project.facet.default.runtime.name"; //$NON-NLS-1$
+
+ /**
+ * 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$
+
+ /**
+ * TODO
+ */
+ public static final String RUNTIME_DEFAULT = SeamCorePlugin.PLUGIN_ID
+ + ".runtime.default"; //$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);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java 2007-12-29
01:47:45 UTC (rev 5478)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntime.java 2007-12-29
01:49:25 UTC (rev 5479)
@@ -7,124 +7,174 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.core.project.facet;
/**
+ * Class represent Seam Runtime parameters:
+ * <ul>
+ * <li>name</li>
+ * <li>path to home directory</li>
+ * <li>version number</li>
+ * <li>default flag</li>
+ * </ul>
+ * and provide methods to get path to most relevant folders:
+ * <ul>
+ * <li>root templates</li>
+ * <li>source templates</li>
+ * <li>test templates</li>
+ * <li>view templates</li>
+ * </ul>
+
* @author eskimo
- *
+ *
*/
public class SeamRuntime {
-
- /**
- *
- */
+
SeamVersion version = null;
-
- /**
- *
- */
+
String name = null;
-
- /**
- *
- */
+
String homeDir = null;
- /**
- *
- */
boolean defaultRt = false;
-
+
/**
- *
+ * Default constructor
*/
- public SeamRuntime() {}
-
+ public SeamRuntime() {
+ }
+
/**
+ * Get SeamVersion for Runtime
*
* @return
+ *
+ * SeamVersion constant
*/
public SeamVersion getVersion() {
return version;
}
-
+
/**
+ * Get SeamRuntime name
*
- * @return
+ * @return name
*/
public String getName() {
return name;
}
-
+
/**
+ * Get path to home directory
*
- * @return
+ * @return home directory path as string
*/
public String getHomeDir() {
return homeDir;
}
/**
+ * Set SeamVersion
*
* @param version
+ * new SeamVersion
*/
public void setVersion(SeamVersion version) {
this.version = version;
}
/**
+ * Set SeamRuntime name
*
* @param name
+ * new SeamRuntime name
*/
public void setName(String name) {
this.name = name;
}
/**
+ * Set home directory
*
* @param homeDir
+ * new SeamRuntime's home directory
*/
public void setHomeDir(String homeDir) {
this.homeDir = homeDir;
}
/**
+ * Mark runtime as default
+ *
* @param b
+ * new value for default property
*/
public void setDefault(boolean b) {
- this.defaultRt = b;
+ this.defaultRt = b;
}
-
+
/**
- * @return
+ * Get default flag
+ *
+ * @return default property
*/
public boolean isDefault() {
return defaultRt;
}
-
+
+ /**
+ * Calculate path to seam-gen
+ *
+ * @return absolute path to seam-gen folder
+ */
public String getSeamGenDir() {
- return getHomeDir()+"/seam-gen"; //$NON-NLS-1$
+ return getHomeDir() + "/seam-gen"; //$NON-NLS-1$
}
-
+
+ /**
+ * Calculate path to source templates
+ *
+ * @return absolute path to source templates
+ */
public String getSrcTemplatesDir() {
- return getSeamGenDir()+"/src"; //$NON-NLS-1$
+ return getSeamGenDir() + "/src"; //$NON-NLS-1$
}
-
+
+ /**
+ * Calculate path to view templates
+ *
+ * @return absolute path to view templates
+ */
public String getViewTemplatesDir() {
- return getSeamGenDir()+"/view"; //$NON-NLS-1$
+ return getSeamGenDir() + "/view"; //$NON-NLS-1$
}
-
+
+ /**
+ * Calculate path to resource templates
+ *
+ * @return absolute path to resource templates
+ */
public String getResourceTemplatesDir() {
- return getSeamGenDir()+"/resources"; //$NON-NLS-1$
+ return getSeamGenDir() + "/resources"; //$NON-NLS-1$
}
-
+
+ /**
+ * Calculate path to test templates
+ *
+ * @return absolute path to test templates
+ */
public String getTestTemplatesDir() {
- return getSeamGenDir()+"/test"; //$NON-NLS-1$
+ return getSeamGenDir() + "/test"; //$NON-NLS-1$
}
-
+
+ /**
+ * Calculate path to templates root directory
+ *
+ * @return absolute path to templates root directory
+ */
public String getTemplatesDir() {
return getSeamGenDir();
}
-
+
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeListConverter.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeListConverter.java 2007-12-29
01:47:45 UTC (rev 5478)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeListConverter.java 2007-12-29
01:49:25 UTC (rev 5479)
@@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.core.project.facet;
import java.util.HashMap;
@@ -15,56 +15,94 @@
import java.util.StringTokenizer;
/**
+ * Converter is responsible for transformation String to
+ * Map<String, SeamRuntime> and vice versa
+ *
* @author eskimo
- *
*/
public class SeamRuntimeListConverter {
-
- public Map<String,SeamRuntime> getMap(String input) {
-
- Map<String,SeamRuntime> result = new HashMap<String,SeamRuntime>();
- if(input==null || "".equals(input.trim())) { //$NON-NLS-1$
+
+ /*
+ * Constants definitions
+ */
+ private static final String REGEXP_ESCAPE = "\\";
+ private static final String COMMA = ",";
+ private static final String EMPTY_STRING = "";
+ private static final String FIELD_SEPARATOR = "|";
+ private static final String DEFAULT = "default";
+ private static final String VERSION = "version";
+ private static final String HOME_DIR = "homeDir";
+ private static final String NAME = "name";
+
+ /**
+ * Load String to SeamRuntime map from String
+ * @param input
+ * String representation of map
+ * @return
+ * Map<String, SeamRuntime> loaded from string
+ * TODO - switch to XML?
+ * TODO - write converter from old serialization format to XML?
+ * TODO - handle errors in string format
+ */
+ public Map<String, SeamRuntime> getMap(String input) {
+
+ Map<String, SeamRuntime> result = new HashMap<String, SeamRuntime>();
+ if (input == null || EMPTY_STRING.equals(input.trim())) {
return result;
}
-
- StringTokenizer runtimes = new StringTokenizer(input,","); //$NON-NLS-1$
+ StringTokenizer runtimes = new StringTokenizer(input, COMMA);
while (runtimes.hasMoreTokens()) {
String runtime = runtimes.nextToken();
- String[] map = runtime.split("\\|"); //$NON-NLS-1$
+ String[] map = runtime.split(REGEXP_ESCAPE + FIELD_SEPARATOR);
SeamRuntime rt = new SeamRuntime();
- for (int i=0;i<map.length;i+=2) {
+ final int step = 2;
+ for (int i = 0; i < map.length; i += step) {
String name = map[i];
- String value = i+1<map.length?map[i+1]:""; //$NON-NLS-1$
- if("name".equals(name)) { //$NON-NLS-1$
+ String value = i + 1 < map.length ? map[i + 1] : EMPTY_STRING;
+ if (NAME.equals(name)) {
rt.setName(value);
- } else if("homeDir".equals(name)) { //$NON-NLS-1$
+ } else if (HOME_DIR.equals(name)) {
rt.setHomeDir(value);
- } else if ("version".equals(name)) { //$NON-NLS-1$
+ } else if (VERSION.equals(name)) {
rt.setVersion(SeamVersion.parseFromString(value));
- } else if("default".equals(name)) { //$NON-NLS-1$
+ } else if (DEFAULT.equals(name)) {
rt.setDefault(Boolean.parseBoolean(value));
}
}
- result.put(rt.getName(),rt);
+ result.put(rt.getName(), rt);
}
-
+
return result;
}
- public String getString(Map<String,SeamRuntime> runtimeMap) {
+ /**
+ * Convert map String to SeamRUntime to string representation
+ * @param runtimeMap
+ * Map<String, SeamRuntime> - map of String to Seam Runtime to convert
+ * in String
+ * @return
+ * String representation of String to Seam Runtime map
+ */
+ public String getString(Map<String, SeamRuntime> runtimeMap) {
StringBuffer buffer = new StringBuffer();
- SeamRuntime[] runtimes = runtimeMap.values().toArray(new
SeamRuntime[runtimeMap.size()]);
- for (int i=0;i<runtimes.length;i++) {
- buffer.append("name|"); //$NON-NLS-1$
+ SeamRuntime[] runtimes = runtimeMap.values().toArray(
+ new SeamRuntime[runtimeMap.size()]);
+ for (int i = 0; i < runtimes.length; i++) {
+ buffer.append(NAME).append(FIELD_SEPARATOR);
buffer.append(runtimes[i].getName());
- buffer.append("|version|"); //$NON-NLS-1$
+ buffer.append(FIELD_SEPARATOR).append(VERSION).append(
+ FIELD_SEPARATOR);
buffer.append(runtimes[i].getVersion().toString());
- buffer.append("|homeDir|"); //$NON-NLS-1$
+ buffer.append(FIELD_SEPARATOR).append(HOME_DIR).append(
+ FIELD_SEPARATOR);
buffer.append(runtimes[i].getHomeDir());
- buffer.append("|default|"); //$NON-NLS-1$
+ buffer.append(FIELD_SEPARATOR).append(DEFAULT).append(
+ FIELD_SEPARATOR);
buffer.append(runtimes[i].isDefault());
- if(i!=runtimes.length-1) buffer.append(","); //$NON-NLS-1$
- }
+ if (i != runtimes.length - 1) {
+ buffer.append(COMMA);
+ }
+ }
return buffer.toString();
}
}
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 2007-12-29
01:47:45 UTC (rev 5478)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2007-12-29
01:49:25 UTC (rev 5479)
@@ -7,7 +7,7 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.core.project.facet;
import java.io.IOException;
@@ -28,94 +28,115 @@
import org.jboss.tools.seam.internal.core.validation.SeamRuntimeValidation;
/**
+ * 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 SeamRuntimeValidation validator = new SeamRuntimeValidation();
-
+
/**
- *
+ * 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
*
- */
- private SeamRuntimeManager() {
- String configVersion = SeamProjectPreferences.getStringPreference(
- SeamProjectPreferences.RUNTIME_CONFIG_FORMAT_VERSION);
- String runtimeListString = SeamProjectPreferences.getStringPreference(
- SeamProjectPreferences.RUNTIME_LIST);
-
- runtimes = converter.getMap(runtimeListString);
- }
-
- /**
- *
* @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);
+ 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) {
+ if (runtimes.size() == 0) {
runtime.setDefault(true);
- }
-
- if(getDefaultRuntime()!=null && runtime.isDefault()) {
+ }
+
+ if (getDefaultRuntime() != null && runtime.isDefault()) {
getDefaultRuntime().setDefault(false);
}
- runtimes.put(runtime.getName(),runtime);
+ runtimes.put(runtime.getName(), runtime);
save();
validateProjects();
}
-
+
/**
+ * 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)
{
+ public void addRuntime(String name, String path, SeamVersion version,
+ boolean defaultRt) {
SeamRuntime seamRt = new SeamRuntime();
seamRt.setVersion(version);
seamRt.setHomeDir(path);
@@ -123,88 +144,134 @@
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;
+ 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());
validateProjects();
}
-
+
/**
+ * 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);
+ 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) {
+ SeamProjectPreferences.RUNTIME_LIST,
+ converter.getString(runtimes));
+ IPreferenceStore store = SeamCorePlugin.getDefault()
+ .getPreferenceStore();
+ if (store instanceof IPersistentPreferenceStore) {
try {
- ((IPersistentPreferenceStore)store).save();
+ ((IPersistentPreferenceStore) store).save();
} catch (IOException e) {
- SeamCorePlugin.getPluginLog().logError(e);
+ SeamCorePlugin.getPluginLog().logError(
+ "Seam Runtime List was not saved", e);
}
}
}
/**
+ * Return first default SeamRuntime
*
* @return
+ * SeamRuntime
*/
public SeamRuntime getDefaultRuntime() {
for (SeamRuntime rt : runtimes.values()) {
- if(rt.isDefault())return rt;
+ if (rt.isDefault()) {
+ return rt;
+ }
}
return null;
}
+
+ /**
+ * 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()) {
+ 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) {
+ 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) {
+ for (SeamRuntime seamRuntime : rts) {
result.add(seamRuntime.getName());
}
return result;
@@ -214,7 +281,9 @@
IProject[] ps = ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (int i = 0; i < ps.length; i++) {
ISeamProject sp = SeamCorePlugin.getSeamProject(ps[i], false);
- if(sp == null) continue;
+ if (sp == null) {
+ continue;
+ }
try {
validator.validate(sp);
} catch (CoreException e) {
@@ -222,24 +291,31 @@
}
}
}
-
+
+ /**
+ * 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) {
+ if (o == null) {
return;
}
o.setName(newName);
- onRuntimeNameChanged(oldName, 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())) {
+ if (sp != null && oldName.equals(sp.getRuntimeName())) {
sp.setRuntimeName(newName);
}
}
}
-
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamVersion.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamVersion.java 2007-12-29
01:47:45 UTC (rev 5478)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamVersion.java 2007-12-29
01:49:25 UTC (rev 5479)
@@ -7,39 +7,61 @@
*
* Contributors:
* Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
+ ******************************************************************************/
package org.jboss.tools.seam.core.project.facet;
import org.eclipse.osgi.util.NLS;
/**
+ * Seam Versions enumeration
+ *
* @author eskimo
- *
*/
-public enum SeamVersion{
- SEAM_1_2("1.2"), SEAM_2_0("2.0"); //$NON-NLS-1$ //$NON-NLS-2$
+
+public enum SeamVersion {
+ /**
+ * Seam versions 1.2.X
+ */
+ SEAM_1_2("1.2"),
+ /**
+ * Seam versions 2.0.X
+ */
+ SEAM_2_0("2.0"); //$NON-NLS-1$ //$NON-NLS-2$
+
String version = ""; //$NON-NLS-1$
-
- public static final String V_1_2 = "1.2"; //$NON-NLS-1$
-
- public static final String V_2_0 = "2.0"; //$NON-NLS-1$
-
+
SeamVersion(String version) {
this.version = version;
}
-
+
+ /**
+ * Return string representation of version
+ *
+ * @return
+ * version number as string
+ */
public String toString() {
return version;
}
-
- static public SeamVersion parseFromString(String version) {
- if(V_1_2.equals(version)) {
+
+ /**
+ * Get enumeration by string
+ * TODO support for compatible version? should 1.2.1 return SEAM_1_2?
+ *
+ * @param version
+ * string representation of version
+ * @return
+ * version enumeration corresponding to version string
+ */
+ public static SeamVersion parseFromString(String version) {
+ if (SEAM_1_2.toString().equals(version)) {
return SEAM_1_2;
- } else if(V_2_0.equals(version)) {
+ } else if (SEAM_2_0.toString().equals(version)) {
return SEAM_2_0;
}
- throw new IllegalArgumentException(NLS.bind("Seam version ''{0}''
is not supported",version)); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new IllegalArgumentException(NLS.bind(
+ "Seam version ''{0}'' is not supported", version));
//$NON-NLS-1$ //$NON-NLS-2$
}
-
+
}
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 2007-12-29
01:47:45 UTC (rev 5478)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetPreferenceInitializer.java 2007-12-29
01:49:25 UTC (rev 5479)
@@ -93,7 +93,7 @@
if(seamFolder.exists() && seamFolder.isDirectory()) {
SeamRuntime rt = new SeamRuntime();
rt.setHomeDir(seamGenBuildPath);
- rt.setName("Seam " + SeamVersion.V_1_2+".AP"); //$NON-NLS-1$
//$NON-NLS-2$
+ 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);