Author: scabanovich
Date: 2011-07-28 15:37:21 -0400 (Thu, 28 Jul 2011)
New Revision: 33321
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/filesystems/impl/FileSystemImpl.java
Log:
JBIDE-9420
https://issues.jboss.org/browse/JBIDE-9420
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 2011-07-28
19:13:29 UTC (rev 33320)
+++ trunk/common/plugins/org.jboss.tools.common.model/META-INF/MANIFEST.MF 2011-07-28
19:37:21 UTC (rev 33321)
@@ -82,7 +82,8 @@
org.eclipse.jem.util;bundle-version="2.1.2",
org.eclipse.wst.common.emfworkbench.integration;bundle-version="1.2.100",
org.eclipse.core.resources;visibility:=reexport;bundle-version="3.7.100",
- org.eclipse.core.runtime;visibility:=reexport;bundle-version="3.7.0"
+ org.eclipse.core.runtime;visibility:=reexport;bundle-version="3.7.0",
+ org.eclipse.core.filesystem
Bundle-Version: 3.3.0.qualifier
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: org.jboss.tools.common.model.jar
Modified:
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemImpl.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemImpl.java 2011-07-28
19:13:29 UTC (rev 33320)
+++
trunk/common/plugins/org.jboss.tools.common.model/src/org/jboss/tools/common/model/filesystems/impl/FileSystemImpl.java 2011-07-28
19:37:21 UTC (rev 33321)
@@ -12,8 +12,10 @@
import java.io.File;
import java.io.IOException;
+import java.net.URI;
import org.eclipse.core.resources.*;
+import org.eclipse.core.filesystem.URIUtil;
import org.eclipse.core.runtime.*;
import org.jboss.tools.common.model.XModelObjectConstants;
import org.jboss.tools.common.model.plugin.ModelPlugin;
@@ -87,17 +89,42 @@
return resource = f;
}
- IFolder f = project.getFolder(new Path(XModelObjectConstants.SEPARATOR +
getAttributeValue(XModelObjectConstants.ATTR_NAME)));
- if(!f.exists()) {
- try {
- f.createLink(new Path(thloc), IFolder.FORCE, null);
- resource = f;
- } catch (CoreException e) {
- ModelPlugin.getPluginLog().logError("Cannot create link: " +
e.getMessage()); //$NON-NLS-1$
- ModelPlugin.getPluginLog().logError("Project path=" + prloc);
//$NON-NLS-1$
- ModelPlugin.getPluginLog().logError(" Link path=" + thloc);
//$NON-NLS-1$
- }
- } else resource = f;
+ IContainer f = null;
+ URI uri = URIUtil.toURI(thloc, true);
+ IContainer[] cs =
ResourcesPlugin.getWorkspace().getRoot().findContainersForLocationURI(uri);
+ for (IContainer c: cs) {
+ if(f == null || !c.isLinked()) {
+ f = c;
+ }
+ }
+ if(f != null && (!f.exists() &&
!f.isSynchronized(IResource.DEPTH_ONE))) {
+ try {
+ f.refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
+ } catch (CoreException e) {
+ ModelPlugin.getPluginLog().logError(e);
+ }
+ }
+ resource = f;
+
+ if(resource == null) {
+ f = project.getFolder(new Path(XModelObjectConstants.SEPARATOR +
getAttributeValue(XModelObjectConstants.ATTR_NAME)));
+ if(!f.exists()) {
+ try {
+ if(new File(thloc).exists()) {
+ //only create link if actual resource exists and
+ //all other means to find resource in workspace failed.
+ ((IFolder)f).createLink(new Path(thloc), IFolder.FORCE, null);
+ resource = f;
+ }
+ } catch (CoreException e) {
+ ModelPlugin.getPluginLog().logError("Cannot create link: " +
e.getMessage()); //$NON-NLS-1$
+ ModelPlugin.getPluginLog().logError("Project path=" + prloc);
//$NON-NLS-1$
+ ModelPlugin.getPluginLog().logError(" Link path=" + thloc);
//$NON-NLS-1$
+ }
+ } else {
+ resource = f;
+ }
+ }
return resource;
}