fracpete/vfsjfilechooser2

Constructor fails with non-file FileObject

GoogleCodeExporter opened this issue · 4 comments

What steps will reproduce the problem?
1. Create a FileObject which is not backed by a file:/// URI 
2. Create a VFSJFileChooser(FileObject)

    java.lang.IllegalArgumentException: URI scheme is not "file"
        at java.io.File.<init>(File.java:395)
        at com.googlecode.vfsjfilechooser2.utils.DefaultFileObjectConverter.convertFileObject(DefaultFileObjectConverter.java:51)
        at com.googlecode.vfsjfilechooser2.VFSJFileChooser.getCurrentDirectory(VFSJFileChooser.java:541)
        at com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI$DirectoryComboBoxAction.actionPerformed(MetalVFSFileChooserUI.java:1569)
        at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1260)
        at javax.swing.JComboBox.setSelectedItem(JComboBox.java:588)
        at com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.doDirectoryChanged(MetalVFSFileChooserUI.java:804)
        at com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.access$600(MetalVFSFileChooserUI.java:94)
        at com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI$6.propertyChange(MetalVFSFileChooserUI.java:958)
        at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:327)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
        at java.awt.Component.firePropertyChange(Component.java:8382)
        at com.googlecode.vfsjfilechooser2.VFSJFileChooser.setCurrentDirectoryObject(VFSJFileChooser.java:635)
        at com.googlecode.vfsjfilechooser2.VFSJFileChooser.<init>(VFSJFileChooser.java:229)
        at com.googlecode.vfsjfilechooser2.VFSJFileChooser.<init>(VFSJFileChooser.java:209)

Defeats the point, a little. :-(

Original issue reported on code.google.com by shevek.h...@googlemail.com on 6 Jan 2014 at 6:49

If you construct empty and then set the CWD later, you get this:

    java.lang.IllegalArgumentException: URI scheme is not "file"
        at java.io.File.<init>(File.java:395)
        at com.googlecode.vfsjfilechooser2.utils.DefaultFileObjectConverter.convertFileObject(DefaultFileObjectConverter.java:51)
        at com.googlecode.vfsjfilechooser2.VFSJFileChooser.getCurrentDirectory(VFSJFileChooser.java:541)
        at com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI$DirectoryComboBoxAction.actionPerformed(MetalVFSFileChooserUI.java:1569)
        at javax.swing.JComboBox.fireActionEvent(JComboBox.java:1260)
        at javax.swing.JComboBox.setSelectedItem(JComboBox.java:588)
        at com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.doDirectoryChanged(MetalVFSFileChooserUI.java:804)
        at com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI.access$600(MetalVFSFileChooserUI.java:94)
        at com.googlecode.vfsjfilechooser2.plaf.metal.MetalVFSFileChooserUI$6.propertyChange(MetalVFSFileChooserUI.java:958)
        at java.beans.PropertyChangeSupport.fire(PropertyChangeSupport.java:335)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:327)
        at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:263)
        at java.awt.Component.firePropertyChange(Component.java:8382)
        at com.googlecode.vfsjfilechooser2.VFSJFileChooser.setCurrentDirectoryObject(VFSJFileChooser.java:635)


Original comment by shevek.h...@googlemail.com on 6 Jan 2014 at 6:52

If you set multiple selection, then you get a GUI, but if you click on a file, 
you get this:

    Failed to convert 'xxx:///foo.txt' into file!
    java.lang.IllegalArgumentException: URI scheme is not "file"
        at java.io.File.<init>(File.java:395)
        at com.googlecode.vfsjfilechooser2.utils.DefaultFileObjectConverter.convertFileObject(DefaultFileObjectConverter.java:51)
        at com.googlecode.vfsjfilechooser2.VFSJFileChooser.getSelectedFiles(VFSJFileChooser.java:469)
        at com.googlecode.vfsjfilechooser2.filepane.VFSFilePane$Handler.mouseClicked(VFSFilePane.java:2069)
        at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:270)
        at java.awt.Component.processMouseEvent(Component.java:6508)
        at javax.swing.JComponent.processMouseEvent(JComponent.java:3312)
        at java.awt.Component.processEvent(Component.java:6270)
        at java.awt.Container.processEvent(Container.java:2229)
        at java.awt.Component.dispatchEventImpl(Component.java:4861)
        at java.awt.Container.dispatchEventImpl(Container.java:2287)
        at java.awt.Component.dispatchEvent(Component.java:4687)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
        at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4501)
        at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
        at java.awt.Container.dispatchEventImpl(Container.java:2273)
        at java.awt.Window.dispatchEventImpl(Window.java:2719)
        at java.awt.Component.dispatchEvent(Component.java:4687)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:735)
        at java.awt.EventQueue.access$200(EventQueue.java:103)
        at java.awt.EventQueue$3.run(EventQueue.java:694)
        at java.awt.EventQueue$3.run(EventQueue.java:692)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
        at java.awt.EventQueue$4.run(EventQueue.java:708)
        at java.awt.EventQueue$4.run(EventQueue.java:706)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:705)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:154)
        at java.awt.WaitDispatchSupport$2.run(WaitDispatchSupport.java:182)
        at java.awt.WaitDispatchSupport$4.run(WaitDispatchSupport.java:221)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.awt.WaitDispatchSupport.enter(WaitDispatchSupport.java:219)
        at java.awt.Dialog.show(Dialog.java:1082)
        at java.awt.Component.show(Component.java:1651)
        at java.awt.Component.setVisible(Component.java:1603)
        at java.awt.Window.setVisible(Window.java:1014)
        at java.awt.Dialog.setVisible(Dialog.java:1005)
        at com.googlecode.vfsjfilechooser2.VFSJFileChooser.showDialog(VFSJFileChooser.java:802)
        at com.googlecode.vfsjfilechooser2.VFSJFileChooser.showOpenDialog(VFSJFileChooser.java:701)


I has a sad. :-( I is very sad kitten. Please fix me. I want to use nonlocal 
files.

Original comment by shevek.h...@googlemail.com on 6 Jan 2014 at 6:54

The issue is caused by this: 
http://code.google.com/p/vfsjfilechooser2/wiki/Differences - changing the 
behaviour of methods without changing when they are called.

I was very familiar with the original vfsjfilechooser, so I know it worked OK 
for my needs.

Original comment by shevek.h...@googlemail.com on 6 Jan 2014 at 6:56

fixed in commit b3caf69