Author: scabanovich
Date: 2008-05-30 10:03:04 -0400 (Fri, 30 May 2008)
New Revision: 8477
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/JSFAutoLoad.java
Log:
JBIDE-830
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/JSFAutoLoad.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/JSFAutoLoad.java 2008-05-30
14:02:43 UTC (rev 8476)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/project/JSFAutoLoad.java 2008-05-30
14:03:04 UTC (rev 8477)
@@ -1,15 +1,21 @@
package org.jboss.tools.jsf.project;
+import java.io.IOException;
import java.util.Properties;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
import org.jboss.tools.common.model.XModel;
import org.jboss.tools.common.model.XModelConstants;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
import org.jboss.tools.common.model.filesystems.impl.FileSystemImpl;
import org.jboss.tools.common.model.project.IAutoLoad;
+import org.jboss.tools.common.model.project.ProjectHome;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.model.util.XModelObjectUtil;
public class JSFAutoLoad implements IAutoLoad {
@@ -35,10 +41,13 @@
webinf.setAttributeValue("name", "WEB-INF"); //$NON-NLS-1$
//$NON-NLS-2$
webinf.setAttributeValue("location", XModelConstants.WORKSPACE_REF);
//$NON-NLS-1$
fs.addChild(webinf);
+
+ String webInfLocation = XModelObjectUtil.expand(XModelConstants.WORKSPACE_REF, model,
null);
+ String webRootLocation = getWebRootPath(project, webInfLocation);
XModelObject webroot = model.createModelObject("FileSystemFolder", null);
//$NON-NLS-1$
webroot.setAttributeValue("name", "WEB-ROOT"); //$NON-NLS-1$
//$NON-NLS-2$
- webroot.setAttributeValue("location", XModelConstants.WORKSPACE_REF +
"/.."); //$NON-NLS-1$ //$NON-NLS-2$
+ webroot.setAttributeValue("location", webRootLocation); //$NON-NLS-1$
//$NON-NLS-2$
fs.addChild(webroot);
XModelObject lib = model.createModelObject("FileSystemFolder", null);
//$NON-NLS-1$
@@ -48,4 +57,32 @@
}
+ static String getWebRootPath(IProject project, String webInfLocation) {
+ String webRootLocation = XModelConstants.WORKSPACE_REF + "/..";
+
+ IPath wrp = ProjectHome.getFirstWebContentPath(project);
+ IPath wip = ProjectHome.getWebInfPath(project);
+
+ if(wrp == null || wip == null) {
+ return webRootLocation;
+ }
+
+ IResource wrpc = ResourcesPlugin.getWorkspace().getRoot().findMember(wrp);
+ IResource wipc = ResourcesPlugin.getWorkspace().getRoot().findMember(wip);
+ if(wrpc != null && wipc != null && wipc.isLinked()) {
+ IPath p = wrpc.getLocation();
+ if(p != null) {
+ try {
+ webRootLocation = p.toFile().getCanonicalPath().replace('\\', '/');
+ } catch (IOException e) {
+ }
+ String relative =
org.jboss.tools.common.util.FileUtil.getRelativePath(webInfLocation, webRootLocation);
+ if(relative != null) {
+ webRootLocation = XModelConstants.WORKSPACE_REF + relative;
+ }
+ }
+ }
+ return webRootLocation;
+ }
+
}
Show replies by date