Hi,
I committed the attached patch.
- Object path = filechooser.getCurrentDirectory();
+ File path = filechooser.getCurrentDirectory();
if (path != null)
- parentPath =
path.toString().substring(path.toString().lastIndexOf("/"));
+ parentPath = path.getParent();
Why do we have crap like this in cvs? There's really no excuse for code
this badly written.
Regards,
Jeroen
2006-08-17 Jeroen Frijters <[EMAIL PROTECTED]>
* javax/swing/filechooser/FileSystemView.java
(getFileSystemView): Always return UnixFileSystemView, since
that's the only one we got. Marked with NotImplementedException.
* javax/swing/plaf/basic/BasicFileChooserUI.java
(mouseClicked, installUI): Don't parse path by hand.
Index: javax/swing/filechooser/FileSystemView.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/javax/swing/filechooser/FileSystemView.java,v
retrieving revision 1.11
diff -u -r1.11 FileSystemView.java
--- javax/swing/filechooser/FileSystemView.java 2 Aug 2006 11:31:44 -0000
1.11
+++ javax/swing/filechooser/FileSystemView.java 17 Aug 2006 15:58:15 -0000
@@ -37,6 +37,8 @@
package javax.swing.filechooser;
+import gnu.classpath.NotImplementedException;
+
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
@@ -169,16 +171,12 @@
* @return A default [EMAIL PROTECTED] FileSystemView} appropriate for the
platform.
*/
public static FileSystemView getFileSystemView()
+ throws NotImplementedException
{
if (defaultFileSystemView == null)
{
- if (File.separator.equals("/"))
- defaultFileSystemView = new UnixFileSystemView();
- // FIXME: need to implement additional views
- // else if (File.Separator.equals("\"))
- // return new Win32FileSystemView();
- // else
- // return new GenericFileSystemView();
+ // FIXME: We need to support other file systems too.
+ defaultFileSystemView = new UnixFileSystemView();
}
return defaultFileSystemView;
}
Index: javax/swing/plaf/basic/BasicFileChooserUI.java
===================================================================
RCS file:
/cvsroot/classpath/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java,v
retrieving revision 1.29
diff -u -r1.29 BasicFileChooserUI.java
--- javax/swing/plaf/basic/BasicFileChooserUI.java 2 Aug 2006 15:20:37
-0000 1.29
+++ javax/swing/plaf/basic/BasicFileChooserUI.java 17 Aug 2006 15:45:10
-0000
@@ -444,10 +444,10 @@
setDirectory(null);
}
lastSelected = path;
- parentPath = path.substring(0, path.lastIndexOf("/") + 1);
+ parentPath = f.getParent();
if (f.isFile())
- setFileName(path.substring(path.lastIndexOf("/") + 1));
+ setFileName(f.getName());
else if (filechooser.getFileSelectionMode() !=
JFileChooser.FILES_ONLY)
setFileName(path);
@@ -827,9 +827,9 @@
installComponents(fc);
installListeners(fc);
- Object path = filechooser.getCurrentDirectory();
+ File path = filechooser.getCurrentDirectory();
if (path != null)
- parentPath =
path.toString().substring(path.toString().lastIndexOf("/"));
+ parentPath = path.getParent();
}
}