Author: scabanovich
Date: 2008-05-30 10:03:24 -0400 (Fri, 30 May 2008)
New Revision: 8478
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/InnerModelHelper.java
Log:
JBIDE-830
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/InnerModelHelper.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/InnerModelHelper.java 2008-05-30
14:03:04 UTC (rev 8477)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/InnerModelHelper.java 2008-05-30
14:03:24 UTC (rev 8478)
@@ -11,8 +11,11 @@
package org.jboss.tools.seam.internal.core;
+import java.io.IOException;
+
import org.eclipse.core.resources.IFolder;
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.eclipse.core.runtime.Path;
@@ -23,7 +26,9 @@
import org.jboss.tools.common.model.XModelConstants;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.project.IModelNature;
+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 InnerModelHelper {
@@ -35,12 +40,8 @@
XModelObject webinf = model.getByPath("FileSystems/WEB-INF"); //$NON-NLS-1$
if(webinf != null) return model;
- IPath webInfPath = null;
+ IPath webInfPath = getWebInfPath(project);
- if(ComponentCore.createComponent(project)!=null) {
- webInfPath = getWebInfPath(project);
- }
-
if(webInfPath == null) return model;
IFolder webInfFolder = ResourcesPlugin.getWorkspace().getRoot().getFolder(webInfPath);
@@ -54,9 +55,12 @@
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$
@@ -69,10 +73,39 @@
//Taken from J2EEUtils and modified
public static IPath getWebInfPath(IProject project) {
- IVirtualComponent component = ComponentCore.createComponent(project);
+ IVirtualComponent component = ComponentCore.createComponent(project);
+ if(component == null) return null;
IVirtualFolder webInfDir = component.getRootFolder().getFolder(new
Path("/WEB-INF"));
IPath modulePath = webInfDir.getWorkspaceRelativePath();
return (!webInfDir.exists()) ? null : modulePath;
}
+ 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