Author: scabanovich
Date: 2008-02-27 07:03:20 -0500 (Wed, 27 Feb 2008)
New Revision: 6595
Added:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/IAutoLoad.java
Modified:
trunk/common/plugins/org.jboss.tools.common.model/META-INF/MANIFEST.MF
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelConstants.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ProjectHome.java
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
Log:
JBIDE-1714
Modified: trunk/common/plugins/org.jboss.tools.common.model/META-INF/MANIFEST.MF
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/META-INF/MANIFEST.MF 2008-02-27
11:39:26 UTC (rev 6594)
+++ trunk/common/plugins/org.jboss.tools.common.model/META-INF/MANIFEST.MF 2008-02-27
12:03:20 UTC (rev 6595)
@@ -80,6 +80,7 @@
org.eclipse.ltk.core.refactoring,
org.eclipse.ltk.ui.refactoring,
org.eclipse.wst.common.uriresolver,
+ org.eclipse.wst.common.modulecore,
org.eclipse.core.resources;visibility:=reexport,
org.eclipse.core.runtime;visibility:=reexport
Bundle-Version: 2.0.0
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelConstants.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelConstants.java 2008-02-27
11:39:26 UTC (rev 6594)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/XModelConstants.java 2008-02-27
12:03:20 UTC (rev 6595)
@@ -25,6 +25,8 @@
public static String XMODEL_ENTITY_ATTR = "model-entity";
public static String XMODEL_ENTITY_ATTR_OLD = "ENTITY";
+
+ public static String AUTOLOAD = "autoload";
private XModelConstants() {}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java 2008-02-27
11:39:26 UTC (rev 6594)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemsLoader.java 2008-02-27
12:03:20 UTC (rev 6595)
@@ -22,6 +22,7 @@
import org.jboss.tools.common.model.loaders.*;
import org.jboss.tools.common.model.loaders.impl.*;
import org.jboss.tools.common.model.plugin.ModelPlugin;
+import org.jboss.tools.common.model.project.IAutoLoad;
import org.jboss.tools.common.model.project.IModelNature;
import org.jboss.tools.common.model.util.*;
import org.jboss.tools.common.model.project.WatcherLoader;
@@ -39,6 +40,11 @@
public boolean save(XModelObject object) {
if(!fsutil.isModified(object)) return true;
+
+ if(object.getModel().getProperties().get(XModelConstants.AUTOLOAD) != null) {
+ return true;
+ }
+
String s = getEclipseFileName(object, false);
boolean b = (s == null) ? super.save(object.copy(1)) :
saveEclipse(object.copy(1));
@@ -71,6 +77,20 @@
public void load(XModelObject object) {
if(EclipseResourceUtil.isProjectFragment(object.getModel())) return;
+
+ IAutoLoad auto =
(IAutoLoad)object.getModel().getProperties().get(XModelConstants.AUTOLOAD);
+ if(auto != null) {
+ auto.load(object.getModel());
+ updateLibs(object);
+ _updateSrcs(object);
+ try {
+ ((FileSystemsImpl)object).updateOverlapped();
+ } catch (Exception e) {
+ ModelPlugin.getPluginLog().logError(e);
+ }
+ return;
+ }
+
String f = getEclipseFileName(object, true);
if(f == null) super.load(object);
else util().load(new File(f), object);
@@ -219,11 +239,16 @@
}
return lib;
}
-
+
public void updateSrcs(XModelObject object) {
- if(WatcherLoader.isLocked(object.getModel())) {
+ IAutoLoad auto =
(IAutoLoad)object.getModel().getProperties().get(XModelConstants.AUTOLOAD);
+ if(auto == null && WatcherLoader.isLocked(object.getModel())) {
return;
}
+ _updateSrcs(object);
+ }
+
+ private void _updateSrcs(XModelObject object) {
IProject p = EclipseResourceUtil.getProject(object);
if(p == null || !p.isAccessible()) return;
String[] srcs = EclipseResourceUtil.getJavaProjectSrcLocations(p);
Added:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/IAutoLoad.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/IAutoLoad.java
(rev 0)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/IAutoLoad.java 2008-02-27
12:03:20 UTC (rev 6595)
@@ -0,0 +1,9 @@
+package org.jboss.tools.common.model.project;
+
+import org.jboss.tools.common.model.XModel;
+
+public interface IAutoLoad {
+
+ public void load(XModel model);
+
+}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java 2008-02-27
11:39:26 UTC (rev 6594)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ModelNature.java 2008-02-27
12:03:20 UTC (rev 6595)
@@ -96,8 +96,21 @@
}
Properties p = new Properties();
p.putAll(System.getProperties());
- p.setProperty(XModelConstants.WORKSPACE, getWorkspaceHome());
- p.setProperty(XModelConstants.WORKSPACE_OLD, getWorkspaceHome());
+
+ String home = getWorkspaceHome();
+ if(home != null && home.length() > 0) {
+ p.setProperty(XModelConstants.WORKSPACE, home);
+ p.setProperty(XModelConstants.WORKSPACE_OLD, home);
+ } else {
+ IAutoLoad auto = createAutoLoad();
+ boolean result = auto != null && ProjectHome.getLocation(project, p);
+ if(result) {
+ p.put(XModelConstants.AUTOLOAD, auto);
+ } else {
+ p.setProperty(XModelConstants.WORKSPACE, "");
+ p.setProperty(XModelConstants.WORKSPACE_OLD, "");
+ }
+ }
p.setProperty(ECLIPSE_PROJECT, project.getLocation().toString());
p.setProperty(ECLIPSE_PROJECT_OLD, project.getLocation().toString());
p.put("project", project);
@@ -116,6 +129,10 @@
updateListener();
}
+ protected IAutoLoad createAutoLoad() {
+ return null;
+ }
+
protected void addToBuildSpec(String builderID) throws CoreException {
IProjectDescription description = getProject().getDescription();
ICommand command = null;
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ProjectHome.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ProjectHome.java 2008-02-27
11:39:26 UTC (rev 6594)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/project/ProjectHome.java 2008-02-27
12:03:20 UTC (rev 6595)
@@ -11,8 +11,18 @@
package org.jboss.tools.common.model.project;
import java.io.File;
+import java.util.Properties;
+
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
+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.wst.common.componentcore.ComponentCore;
+import org.eclipse.wst.common.componentcore.resources.IVirtualComponent;
+import org.eclipse.wst.common.componentcore.resources.IVirtualFolder;
+import org.jboss.tools.common.model.XModelConstants;
import org.jboss.tools.common.model.plugin.ModelPlugin;
import org.jboss.tools.common.model.util.*;
import org.w3c.dom.Element;
@@ -63,4 +73,31 @@
return q;
}
+ ////
+
+ public static boolean getLocation(IProject project, Properties p) {
+ IPath webInfPath = null;
+
+ if(ComponentCore.createComponent(project)!=null) {
+ webInfPath = getWebInfPath(project);
+ }
+
+ if(webInfPath == null) return false;
+
+ IFolder webInfFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(webInfPath);
+
+ p.setProperty(XModelConstants.WORKSPACE, webInfFolder.getLocation().toString());
+ p.setProperty(XModelConstants.WORKSPACE_OLD, webInfFolder.getLocation().toString());
+
+ return true;
+ }
+
+ //Taken from J2EEUtils and modified
+ public static IPath getWebInfPath(IProject project) {
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ IVirtualFolder webInfDir = component.getRootFolder().getFolder(new
Path("/WEB-INF"));
+ IPath modulePath = webInfDir.getWorkspaceRelativePath();
+ return (!webInfDir.exists()) ? null : modulePath;
+ }
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2008-02-27
11:39:26 UTC (rev 6594)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/util/EclipseResourceUtil.java 2008-02-27
12:03:20 UTC (rev 6595)
@@ -28,6 +28,7 @@
import org.jboss.tools.common.meta.action.XActionInvoker;
import org.jboss.tools.common.model.*;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.filesystems.XFileObject;
import org.jboss.tools.common.model.filesystems.impl.*;
import org.jboss.tools.common.model.icons.impl.*;
@@ -95,7 +96,7 @@
if(resource == null) return null;
IPath path = resource.getLocation();
if (model != null) {
- FileSystemsImpl fso = (FileSystemsImpl)model.getByPath("FileSystems");
+ FileSystemsImpl fso = (FileSystemsImpl)FileSystemsHelper.getFileSystems(model);
if(fso == null) return null;
fso.updateOverlapped();
XModelObject[] fs = fso.getChildren("FileSystemFolder");
@@ -124,7 +125,7 @@
}
public static XModelObject findFileSystem(IResource resource, XModel model) {
- XModelObject fss = model.getByPath("FileSystems");
+ XModelObject fss = FileSystemsHelper.getFileSystems(model);
if(fss == null) return null;
XModelObject[] fs = fss.getChildren();
XModelObject result = null;
@@ -146,7 +147,7 @@
}
public static XModelObject addFileSystem(IResource resource, XModel model) {
- XModelObject fss = model.getByPath("FileSystems");
+ XModelObject fss = FileSystemsHelper.getFileSystems(model);
if(fss == null) return null;
while(resource != null && resource != resource.getProject() &&
resource.getParent() != null && resource.getParent() != resource.getProject()) {
resource = resource.getParent();
@@ -276,7 +277,7 @@
XModel model = models.get(project);
if(model != null) {
- validateJarSystem(model.getByPath("FileSystems"), resource);
+ validateJarSystem(FileSystemsHelper.getFileSystems(model), resource);
return getObjectByResource(model, resource);
}
@@ -294,7 +295,7 @@
model = XModelFactory.getModel(properties);
models.put(project, model);
- XModelObject fs = model.getByPath("FileSystems");
+ XModelObject fs = FileSystemsHelper.getFileSystems(model);
if(fs == null) {
ModelPlugin.getPluginLog().logInfo("Cannot create file systems for project "
+ project);
return null;
@@ -392,7 +393,7 @@
properties.setProperty(XModelConstants.WORKSPACE, f.getParent());
properties.put("isProjectFragment", "true");
XModel model = XModelFactory.getModel(properties);
- XModelObject fs = model.getByPath("FileSystems");
+ XModelObject fs = FileSystemsHelper.getFileSystems(model);
if(fs == null) {
ModelPlugin.getPluginLog().logInfo("Cannot create file systems for model at
" + location);
return null;