# HG changeset patch # User Vladimir Kvashin # Date 1394607738 -14400 # Node ID 58b54dbddedb183a1053283125202e48cc1c7eab # Parent c0026876594580751dd74b36eb95b3afc20b995d fixed #242815 - Path completion in remote project chooser does not work on Windows diff -r c00268765945 -r 58b54dbddedb dlight.remote/src/org/netbeans/modules/remote/api/ui/FileChooserBuilder.java --- a/dlight.remote/src/org/netbeans/modules/remote/api/ui/FileChooserBuilder.java Wed Mar 12 10:20:26 2014 +0400 +++ b/dlight.remote/src/org/netbeans/modules/remote/api/ui/FileChooserBuilder.java Wed Mar 12 11:02:18 2014 +0400 @@ -116,6 +116,8 @@ */ /*package*/ public abstract boolean isUnix(); + /*package*/ public abstract char getFileSeparatorChar(); + @Override public final File getCurrentDirectory() { return curFile; @@ -257,6 +259,11 @@ } @Override + public char getFileSeparatorChar() { + return File.separatorChar; + } + + @Override public void setCurrentDirectory(FileObject dir) { if (dir != null && dir.isFolder()) { File file = FileUtil.toFile(dir); @@ -398,6 +405,11 @@ } @Override + public char getFileSeparatorChar() { + return '/'; + } + + @Override protected void setup(FileSystemView view) { super.setup(view); } diff -r c00268765945 -r 58b54dbddedb dlight.remote/src/org/netbeans/modules/remote/api/ui/FileChooserUIImpl.java --- a/dlight.remote/src/org/netbeans/modules/remote/api/ui/FileChooserUIImpl.java Wed Mar 12 10:20:26 2014 +0400 +++ b/dlight.remote/src/org/netbeans/modules/remote/api/ui/FileChooserUIImpl.java Wed Mar 12 11:02:18 2014 +0400 @@ -287,10 +287,13 @@ private FileFilter actualFileFilter = null; private GlobFilter globFilter = null; + private final char fileSeparatorChar; + public FileChooserUIImpl(FileChooserBuilder.JFileChooserEx filechooser) { super(filechooser); approveSelectionAction = new ApproveSelectionAction(); cancelSelectionAction = new CancelSelectionAction(); + fileSeparatorChar = filechooser.getFileSeparatorChar(); } @Override @@ -1140,7 +1143,7 @@ private void updateCompletions() { if (showPopupCompletion) { final String name = normalizeFile(getFileName()); - int slash = name.lastIndexOf(File.separatorChar); + int slash = name.lastIndexOf(fileSeparatorChar); if (slash != -1) { String prefix = name.substring(0, slash + 1); File[] children; @@ -1238,7 +1241,7 @@ } - private static String normalizeFile(String text) { + private String normalizeFile(String text) { // See #21690 for background. // XXX what are legal chars for var names? bash manual says only: // "The braces are required when PARAMETER [...] is followed by a @@ -1257,9 +1260,9 @@ text = text.substring(0, m.end(1)) + var + text.substring(m.end(2)); } if (text.equals("~")) {//NOI18N - return System.getProperty("user.home");//NOI18N - } else if (text.startsWith("~" + File.separatorChar)) {//NOI18N - return System.getProperty("user.home") + text.substring(1);//NOI18N + return fileChooser.getHomePath(); //NOI18N + } else if (text.startsWith("~" + fileSeparatorChar)) {//NOI18N + return fileChooser.getHomePath() + text.substring(1);//NOI18N } else { int i = text.lastIndexOf("//");//NOI18N if (i != -1) { @@ -1267,10 +1270,10 @@ // (so that you can use "//" to start a new path, without selecting & deleting) return text.substring(i + 1); } - i = text.lastIndexOf(File.separatorChar + "~" + File.separatorChar);//NOI18N + i = text.lastIndexOf(fileSeparatorChar + "~" + fileSeparatorChar);//NOI18N if (i != -1) { // Treat /usr/local/~/stuff as /home/me/stuff - return System.getProperty("user.home") + text.substring(i + 2);//NOI18N + return fileChooser.getHomePath() + text.substring(i + 2);//NOI18N } return text; } @@ -2521,7 +2524,7 @@ } private void changeTreeDirectory(File dir) { - if (File.separatorChar == '\\' && dir.getPath().endsWith(".lnk")) {//NOI18N + if (fileSeparatorChar == '\\' && dir.getPath().endsWith(".lnk")) {//NOI18N File linkLocation = getShellFolderForFileLinkLoc(dir); if (linkLocation != null && fileChooser.isTraversable(linkLocation)) { dir = linkLocation; @@ -3415,10 +3418,10 @@ } } - private static boolean isGlobPattern(String filename) { - return ((File.separatorChar == '\\' && (filename.indexOf('*') >= 0 + private boolean isGlobPattern(String filename) { + return ((fileSeparatorChar == '\\' && (filename.indexOf('*') >= 0 || filename.indexOf('?') >= 0)) - || (File.separatorChar == '/' && (filename.indexOf('*') >= 0 + || (fileSeparatorChar == '/' && (filename.indexOf('*') >= 0 || filename.indexOf('?') >= 0 || filename.indexOf('[') >= 0))); } @@ -3434,7 +3437,7 @@ public void setPattern(String globPattern) { char[] gPat = globPattern.toCharArray(); char[] rPat = new char[gPat.length * 2]; - boolean isWin32 = (File.separatorChar == '\\'); + boolean isWin32 = (fileSeparatorChar == '\\'); boolean inBrackets = false; int j = 0; diff -r c00268765945 -r 58b54dbddedb dlight.remote/src/org/netbeans/modules/remote/api/ui/FileCompletionPopup.java --- a/dlight.remote/src/org/netbeans/modules/remote/api/ui/FileCompletionPopup.java Wed Mar 12 10:20:26 2014 +0400 +++ b/dlight.remote/src/org/netbeans/modules/remote/api/ui/FileCompletionPopup.java Wed Mar 12 11:02:18 2014 +0400 @@ -79,11 +79,11 @@ */ class FileCompletionPopup extends JPopupMenu implements KeyListener { - private JList list; - private JTextField textField; - private JFileChooser chooser; + private final JList list; + private final JTextField textField; + private final FileChooserBuilder.JFileChooserEx chooser; - public FileCompletionPopup(JFileChooser chooser, JTextField textField, Vector files) { + public FileCompletionPopup(FileChooserBuilder.JFileChooserEx chooser, JTextField textField, Vector files) { this.list = new JList(files); this.textField = textField; this.chooser = chooser; @@ -255,7 +255,7 @@ if (file.isDirectory()) { try { Document doc = textField.getDocument(); - doc.insertString(doc.getLength(), File.separator, null); + doc.insertString(doc.getLength(), String.valueOf(chooser.getFileSeparatorChar()), null); } catch (BadLocationException ex) { Logger.getLogger(getClass().getName()).log( Level.FINE, "Cannot append directory separator.", ex);//NOI18N