# HG changeset patch # User Vladimir Kvashin # Date 1300099303 -10800 # Node ID b6403bbcab935daa06d537645769066781792b90 # Parent d290f4bd3c4d9ab64cb55ab3c8687883ec5dd342 fix for #196302 - Changing tool collection in full remote project hide sources and break code model diff -r d290f4bd3c4d -r b6403bbcab93 cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/ProjectSupport.java --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/ProjectSupport.java Mon Mar 14 11:34:23 2011 +0300 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/ProjectSupport.java Mon Mar 14 13:41:43 2011 +0300 @@ -62,6 +62,7 @@ import org.netbeans.modules.cnd.makeproject.api.configurations.MakeConfigurationDescriptor; import org.netbeans.modules.cnd.utils.CndPathUtilitities; import org.netbeans.modules.cnd.utils.CndUtils; +import org.netbeans.modules.cnd.utils.cache.CndFileUtils; import org.netbeans.modules.nativeexecution.api.ExecutionEnvironment; import org.netbeans.modules.nativeexecution.api.util.ConnectionManager; import org.netbeans.modules.remote.spi.FileSystemProvider; @@ -149,7 +150,12 @@ case REL: return CndPathUtilitities.toRelativePath(base, path); case ABS: - return CndPathUtilitities.toAbsolutePath(base, path); + try { + return CndFileUtils.getCanonicalFileObject(path).getPath(); + } catch (IOException e) { + e.printStackTrace(System.err); + return path.getPath(); + } default: throw new IllegalStateException("Unexpected path mode: " + pathMode); //NOI18N } diff -r d290f4bd3c4d -r b6403bbcab93 cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/MakeConfigurationDescriptor.java --- a/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/MakeConfigurationDescriptor.java Mon Mar 14 11:34:23 2011 +0300 +++ b/cnd.makeproject/src/org/netbeans/modules/cnd/makeproject/api/configurations/MakeConfigurationDescriptor.java Mon Mar 14 13:41:43 2011 +0300 @@ -95,10 +95,13 @@ import org.netbeans.modules.cnd.utils.MIMEExtensions; import org.netbeans.modules.cnd.utils.cache.CndFileUtils; import org.netbeans.modules.cnd.utils.ui.ModalMessageDlg; +import org.netbeans.modules.remote.spi.FileSystemProvider; import org.netbeans.spi.project.support.ant.AntProjectHelper; import org.openide.DialogDisplayer; import org.openide.NotifyDescriptor; import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileStateInvalidException; +import org.openide.filesystems.FileSystem; import org.openide.filesystems.FileUtil; import org.openide.util.Exceptions; import org.openide.util.ImageUtilities; @@ -133,6 +136,7 @@ * For any other project they are the same */ private final FileObject baseDirFO; + private final FileSystem baseDirFS; private final FileObject projectDirFO; private boolean modified = false; @@ -159,6 +163,11 @@ Parameters.notNull("projectDirFO", projectDirFO); Parameters.notNull("baseDirFO", baseDirFO); this.baseDirFO = baseDirFO; + try { + baseDirFS = baseDirFO.getFileSystem(); + } catch (FileStateInvalidException ex) { + throw new IllegalStateException("Exception when getting file system for project folder object", ex); //NOI18N + } this.projectDirFO = projectDirFO; rootFolder = new Folder(this, null, "root", "root", true, Folder.Kind.ROOT); // NOI18N projectItems = new ConcurrentHashMap(); @@ -1105,10 +1114,10 @@ * Don't add if root is subdir of existing root */ public void addSourceRoot(String path) { - String absPath = CndPathUtilitities.toAbsolutePath(getBaseDir(), path); + String absPath = CndPathUtilitities.toAbsolutePath(getBaseDirFileObject(), path); String canonicalPath = null; try { - canonicalPath = new File(absPath).getCanonicalPath(); + canonicalPath = FileSystemProvider.getCanonicalPath(baseDirFS, absPath); } catch (IOException ioe) { canonicalPath = null; } diff -r d290f4bd3c4d -r b6403bbcab93 cnd.utils/src/org/netbeans/modules/cnd/utils/CndPathUtilitities.java --- a/cnd.utils/src/org/netbeans/modules/cnd/utils/CndPathUtilitities.java Mon Mar 14 11:34:23 2011 +0300 +++ b/cnd.utils/src/org/netbeans/modules/cnd/utils/CndPathUtilitities.java Mon Mar 14 13:41:43 2011 +0300 @@ -44,11 +44,16 @@ package org.netbeans.modules.cnd.utils; import java.io.File; +import java.io.IOException; import java.util.ArrayList; import java.util.Stack; import java.util.StringTokenizer; import org.netbeans.modules.cnd.utils.cache.CharSequenceUtils; +import org.netbeans.modules.cnd.utils.cache.CndFileUtils; import org.openide.filesystems.FileObject; +import org.openide.filesystems.FileStateInvalidException; +import org.openide.filesystems.FileSystem; +import org.openide.util.Exceptions; import org.openide.util.Utilities; /** @@ -188,11 +193,30 @@ } public static String toAbsolutePath(FileObject base, String path) { - return toAbsolutePath(base.getPath(), path); - } - - public static String toAbsolutePath(FileObject base, FileObject path) { - return toAbsolutePath(base, path.getPath()); // TODO: use smarter logic (compare file systems, etc) + String newPath = path; + if (newPath == null || newPath.length() == 0) { + newPath = "."; // NOI18N + } // NOI18N + if (isPathAbsolute(newPath)) { + return newPath; + } else { + FileObject fo = base.getFileObject(newPath); + if (fo != null && fo.isValid()) { + try { + return CndFileUtils.getCanonicalPath(fo); + } catch (IOException ex) { + Exceptions.printStackTrace(ex); + return fo.getPath(); + } + } + try { + FileSystem fs = base.getFileSystem(); + return base.getPath() + CndFileUtils.getFileSeparatorChar(fs) + path; + } catch (FileStateInvalidException ex) { + Exceptions.printStackTrace(ex); + return base.getPath() + '/' + path; + } + } } /*