Author: scabanovich
Date: 2007-10-15 11:19:24 -0400 (Mon, 15 Oct 2007)
New Revision: 4193
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/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
Log:
JBIDE-982
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-10-15
15:05:23 UTC (rev 4192)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2007-10-15
15:19:24 UTC (rev 4193)
@@ -30,6 +30,19 @@
public IProject getProject();
/**
+ * Test or EJB project have WAR project as the parent.
+ * The method returns the parent project name,
+ * or null if project has no parent project.
+ */
+ public String getParentProjectName();
+
+ /**
+ * Returns Seam runtime name.
+ * @return
+ */
+ public String getRuntimeName();
+
+ /**
* Returns Seam runtime object.
* @return
*/
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-10-15
15:05:23 UTC (rev 4192)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-10-15
15:19:24 UTC (rev 4193)
@@ -49,6 +49,7 @@
import org.jboss.tools.seam.core.ScopeType;
import org.jboss.tools.seam.core.SeamCoreBuilder;
import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.SeamPreferences;
import org.jboss.tools.seam.core.event.Change;
import org.jboss.tools.seam.core.event.ISeamProjectChangeListener;
import org.jboss.tools.seam.core.event.SeamProjectChangeEvent;
@@ -72,6 +73,7 @@
boolean useDefaultRuntime = false;
+ String runtimeName = null;
SeamRuntime runtime = null;
Set<IPath> sourcePaths = new HashSet<IPath>();
@@ -137,20 +139,51 @@
/**
*
*/
+ public String getRuntimeName() {
+ String parent = getParentProjectName();
+ if(parent != null) {
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(parent);
+ if(p == null || !p.isAccessible()) return null;
+ ISeamProject sp = SeamCorePlugin.getSeamProject(p, false);
+ return sp == null ? null : sp.getRuntimeName();
+ }
+ if(useDefaultRuntime) {
+ SeamRuntime runtime = SeamRuntimeManager.getInstance().getDefaultRuntime();
+ return runtime != null ? runtime.getName() : null;
+ }
+ return runtimeName;
+ }
+ /**
+ *
+ */
public SeamRuntime getRuntime() {
+ String parent = getParentProjectName();
+ if(parent != null) {
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(parent);
+ if(p == null || !p.isAccessible()) return null;
+ ISeamProject sp = SeamCorePlugin.getSeamProject(p, false);
+ return sp == null ? null : sp.getRuntime();
+ }
if(useDefaultRuntime) {
return SeamRuntimeManager.getInstance().getDefaultRuntime();
}
return runtime;
}
+ public String getParentProjectName() {
+ IEclipsePreferences p = getSeamPreferences();
+ return p == null ? null : p.get("seam.parent.project", null);
+ }
+
public void setRuntime(SeamRuntime runtime) {
if(this.runtime == runtime) return;
useDefaultRuntime = runtime == SeamRuntimeManager.getInstance().getDefaultRuntime();
if(useDefaultRuntime) {
this.runtime = null;
+ this.runtimeName = null;
} else {
this.runtime = runtime;
+ this.runtimeName = runtime == null ? null : runtime.getName();
}
storeRuntime();
}
@@ -221,7 +254,7 @@
void loadRuntime() {
IEclipsePreferences prefs = getSeamPreferences();
if(prefs == null) return;
- String runtimeName = prefs.get(RUNTIME_NAME, null);
+ runtimeName = prefs.get(RUNTIME_NAME, null);
if(runtimeName != null) {
runtime = SeamRuntimeManager.getInstance().findRuntimeByName(runtimeName);
} else {
@@ -233,6 +266,7 @@
public void propertyChange(Preferences.PropertyChangeEvent event) {
if(SeamFacetPreference.RUNTIME_LIST.equals(event.getProperty()) && runtime !=
null && runtime.isDefault()) {
runtime = null;
+ runtimeName = null;
useDefaultRuntime = true;
storeRuntime();
}
@@ -383,21 +417,19 @@
void storeRuntime() {
IEclipsePreferences prefs = getSeamPreferences();
String runtimeName = prefs.get(RUNTIME_NAME, null);
- if((runtime == null || runtime.isDefault()) && runtimeName != null) {
+ boolean changed = (this.runtimeName == null) ? runtimeName != null :
!this.runtimeName.equals(runtimeName);
+ if(!changed) return;
+
+ if(this.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);
- }
+ } else {
+ prefs.put(RUNTIME_NAME, this.runtimeName);
}
+ try {
+ prefs.flush();
+ } catch (BackingStoreException e) {
+ SeamCorePlugin.getPluginLog().logError(e);
+ }
}
/*
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-10-15
15:05:23 UTC (rev 4192)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-10-15
15:19:24 UTC (rev 4193)
@@ -107,7 +107,17 @@
if(o.getParent() instanceof FolderImpl) {
IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(source);
- if(f != null && f.exists()) ((FolderImpl)o.getParent()).updateChildFile(o,
f.getLocation().toFile());
+ if(f != null && f.exists()) {
+ ((FolderImpl)o.getParent()).updateChildFile(o, f.getLocation().toFile());
+ if(o.getParent() == null) {
+ boolean b = isLikelyComponentSource(f);
+ System.out.println("--1 " + b);
+ if(!b) return null;
+ o = EclipseResourceUtil.getObjectByResource(o.getModel(), f);
+ System.out.println("--2 " + o);
+ if(o == null) return null;
+ }
+ }
}
LoadedDeclarations ds = new LoadedDeclarations();
Show replies by date