This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 186302 - "Up One Level" button in remote file chooser works only once
Summary: "Up One Level" button in remote file chooser works only once
Status: VERIFIED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Directory Chooser (show other bugs)
Version: 6.x
Hardware: PC Windows Vista
: P1 normal (vote)
Assignee: David Simonek
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-05-18 14:07 UTC by Alexander Pepin
Modified: 2010-05-21 15:54 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Patch for o.n.swing.dirchooser.DirectoryChooserUI (697 bytes, patch)
2010-05-19 13:14 UTC, Alexey Vladykin
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Pepin 2010-05-18 14:07:48 UTC
Steps to reproduce:
- add remote solaris host using local user account (tester)
- call Add New Tool Collection
- press "Browse" in "Add New Tool Collection" dialog, it shows content of /export/home/tester
- in File Chooser dialog press "Up One Level" button, File Chooser navigates one level up (/export/home)
- press "Up One Level" button once again
Result: Nothing happens. The button does not work either if I return back to /export/home/tester
Comment 1 Alexander Pepin 2010-05-18 14:10:49 UTC
Escalated to P2 as file chooser is unusable without this button as I cannot navigate to the root directory to add any tool collection from e.g. /shared/dp/...
Comment 2 Alexey Vladykin 2010-05-18 15:45:50 UTC
"Up One Level" button works for me. But I can't go in opposite direction: clicking or pressing Enter on any directory has no effect.
Comment 3 Alexey Vladykin 2010-05-18 16:17:57 UTC
Hey, I've just upgraded my JDK from 1.6.0.13 to 1.6.0.20 and the problem is gone.
Alexander, what is your JDK version? Does upgrading help?
Comment 4 Alexander Pepin 2010-05-18 16:22:02 UTC
1.6.0.16
Comment 5 Alexey Vladykin 2010-05-19 10:49:37 UTC
I've found the reason for the problem I saw with JDK 1.6.0.13.
javax.swing.plaf.basic.BasicFileChooserUI.changeDirectory(File dir) looks like:

private void changeDirectory(File dir) {
    JFileChooser fc = getFileChooser();
    // Traverse shortcuts on Windows
    if (dir != null) {
        try {
            ShellFolder shellFolder = ShellFolder.getShellFolder(dir);
            // code skipped
        } catch (FileNotFoundException ex) {
            return;
        }
    }
    fc.setCurrentDirectory(dir);
    // code skipped
}

Here ShellFolder.getShellFolder(dir) throws an exception, so the directory is not changed. Here dir is our RemoteFileObjectBasedFile.

In JDK 1.6.0.16 and 1.6.0.20 the BasicFileChooserUI.changeDirectory(File dir) is slightly different:

private void changeDirectory(File dir) {
    JFileChooser fc = getFileChooser();
    // Traverse shortcuts on Windows
    if (dir != null && FilePane.usesShellFolder(fc)) {
        try {
            ShellFolder shellFolder = ShellFolder.getShellFolder(dir);
            // code skipped
        } catch (FileNotFoundException ex) {
            return;
        }
    }
    fc.setCurrentDirectory(dir);
    // code skipped
}

Here we don't get into if block, ShellFolder.getShellFolder(dir) is not called, and changing directory succeeds.

I'll look into ShellFolder.getShellFolder() to see if we can make it work without throwing an exception to make remote file chooser useful for older JDK users as well.

However this problem must be different from the problem you saw, because you have JDK 1.6.0.16 which works for me. So I still can not reproduce your problem.
Comment 6 Alexey Vladykin 2010-05-19 11:10:00 UTC
About my previous comment #5:
- typo: "RemoteFileObjectBasedFile" should be "FileObjectBasedFile"
- the JDK problem is known: http://bugs.sun.com/view_bug.do?bug_id=6698013. Looks like we can't work it around. It is fixed in JDK 1.6.0.14.
Comment 7 Alexey Vladykin 2010-05-19 12:29:11 UTC
I can reproduce the problem if I press "Add..." and then "Browse" buttons in Tools->Options->C/C++->Build Tools.
But if I press "..." button next to any compiler, the file chooser works correctly.
Comment 8 Alexey Vladykin 2010-05-19 13:14:43 UTC
Created attachment 99206 [details]
Patch for o.n.swing.dirchooser.DirectoryChooserUI

I've tracked the problem down to o.n.swing.dirchooser.DirectoryChooserUI. It unconditionally uses getShellFolderForFile() with our remote file and fails. The problem is similar to the mentioned BasicFileChooserUI JDK problem. Fix is also similar.
Comment 9 Alexey Vladykin 2010-05-19 13:18:04 UTC
Please review my fix and integrate if you agree. This bug makes remote directory chooser in CND unusable.
Comment 10 Alexander Pepin 2010-05-20 11:21:07 UTC
Starting showstopper process.
Comment 11 David Simonek 2010-05-20 14:21:40 UTC
Changeset: 3b27e2474127
Author:    Dafe Simonek <dsimonek@netbeans.org>
Date:      2010-05-20 16:21
Message:   #186302: use getShellFolderForFile() only when useShellFolder is true
Issue #186302 - "Up One Level" button in remote file chooser works only once
Comment 12 David Simonek 2010-05-20 14:24:23 UTC
Stando could you please review the fix in order to be able to transplant to release69 branch? Thank you.
Comment 13 Stanislav Aubrecht 2010-05-20 14:32:53 UTC
fix reviewed, seems to be ok
Comment 14 Alexander Pepin 2010-05-21 15:54:38 UTC
Verified in rc1 build.