Author: scabanovich
Date: 2007-09-07 10:17:51 -0400 (Fri, 07 Sep 2007)
New Revision: 3489
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.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/internal/core/SeamProject.java
Log:
JBIDE-825 Added method getRuntime() to ISeamProject, and runtime loaded from project
preferences.
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2007-09-07
13:54:39 UTC (rev 3488)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2007-09-07
14:17:51 UTC (rev 3489)
@@ -16,15 +16,24 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.event.ISeamProjectChangeListener;
+import org.jboss.tools.seam.core.project.facet.SeamRuntime;
public interface ISeamProject extends ISeamElement {
public static String NATURE_ID = "org.jboss.tools.seam.core.seamnature";
+ public static String RUNTIME_NAME = "seam.runtime.name";
+
/**
* Returns Eclipse project.
*/
public IProject getProject();
+
+ /**
+ * Returns Seam runtime object.
+ * @return
+ */
+ public SeamRuntime getRuntime();
/**
* Returns list of scope objects for all scope types.
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-09-07
13:54:39 UTC (rev 3488)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2007-09-07
14:17:51 UTC (rev 3489)
@@ -19,6 +19,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
import org.jboss.tools.seam.internal.core.SeamPreferenceInitializer;
import org.jboss.tools.seam.internal.core.project.facet.SeamFacetPreferenceInitializer;
@@ -140,7 +141,8 @@
* @return
*/
public SeamRuntime getRuntimeForProject(IProject project) {
- return null;
+ ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, false);
+ return (seamProject == null) ? null : seamProject.getRuntime();
}
/**
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-09-07
13:54:39 UTC (rev 3488)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-09-07
14:17:51 UTC (rev 3489)
@@ -27,10 +27,13 @@
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ProjectScope;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
import org.jboss.tools.common.xml.XMLUtilities;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
@@ -48,9 +51,12 @@
import org.jboss.tools.seam.core.event.Change;
import org.jboss.tools.seam.core.event.ISeamProjectChangeListener;
import org.jboss.tools.seam.core.event.SeamProjectChangeEvent;
+import org.jboss.tools.seam.core.project.facet.SeamRuntime;
+import org.jboss.tools.seam.core.project.facet.SeamRuntimeManager;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
import org.jboss.tools.seam.internal.core.scanner.lib.ClassPath;
import org.jboss.tools.seam.internal.core.validation.SeamValidationContext;
+import org.osgi.service.prefs.BackingStoreException;
import org.w3c.dom.Element;
/**
@@ -60,6 +66,8 @@
IProject project;
ClassPath classPath = new ClassPath(this);
+ SeamRuntime runtime = null;
+
Set<IPath> sourcePaths = new HashSet<IPath>();
private boolean isStorageResolved = false;
@@ -102,6 +110,10 @@
return project;
}
+ public SeamRuntime getRuntime() {
+ return runtime;
+ }
+
/**
* Returns list of scope objects for all scope types.
* @return
@@ -143,9 +155,27 @@
setSourcePath(project.getFullPath());
resource = project;
classPath.init();
+ loadRuntime();
// load();
}
+ void loadRuntime() {
+ IEclipsePreferences prefs = getSeamPreferences();
+ if(prefs == null) return;
+ String runtimeName = prefs.get(RUNTIME_NAME, null);
+ if(runtimeName != null) {
+ runtime = SeamRuntimeManager.getInstance().findRuntimeByName(runtimeName);
+ } else {
+ runtime = SeamRuntimeManager.getInstance().getDefaultRuntime();
+ storeRuntime();
+ }
+ }
+
+ public IEclipsePreferences getSeamPreferences() {
+ IScopeContext projectScope = new ProjectScope(project);
+ return projectScope.getNode(SeamCorePlugin.PLUGIN_ID);
+ }
+
public void addSeamProject(SeamProject p) {
if(dependsOn.contains(p)) return;
dependsOn.add(p);
@@ -249,6 +279,26 @@
XMLUtilities.serialize(root, file.getAbsolutePath());
}
+ void storeRuntime() {
+ IEclipsePreferences prefs = getSeamPreferences();
+ String runtimeName = prefs.get(RUNTIME_NAME, null);
+ if((runtime == null || runtime.isDefault()) && runtimeName != null) {
+ prefs.remove(RUNTIME_NAME);
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ } else if(runtime != null && !runtime.isDefault() &&
!runtime.getName().equals(runtimeName)) {
+ prefs.put(RUNTIME_NAME, runtime.getName());
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
+ }
+ }
+
private void storeSourcePaths(Element root) {
Element sourcePathsElement = XMLUtilities.createElement(root,
"source-paths");
for (IPath path : sourcePaths) {