summaryrefslogtreecommitdiffstats
path: root/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
diff options
context:
space:
mode:
authormark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2006-08-14 23:12:35 +0000
committermark <mark@138bc75d-0d04-0410-961f-82ee72b054a4>2006-08-14 23:12:35 +0000
commitffde862e033a0825e1e9972a89c0f1f80b261a8e (patch)
tree97037d2c09c8384d80531f67ec36a01205df6bdb /libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
parentb415ff10527e977c3758234fd930e2c027bfa17d (diff)
downloadppe42-gcc-ffde862e033a0825e1e9972a89c0f1f80b261a8e.tar.gz
ppe42-gcc-ffde862e033a0825e1e9972a89c0f1f80b261a8e.zip
2006-08-14 Mark Wielaard <mark@klomp.org>
Imported GNU Classpath 0.92 * HACKING: Add more importing hints. Update automake version requirement. * configure.ac (gconf-peer): New enable AC argument. Add --disable-gconf-peer and --enable-default-preferences-peer to classpath configure when gconf is disabled. * scripts/makemake.tcl: Set gnu/java/util/prefs/gconf and gnu/java/awt/dnd/peer/gtk to bc. Classify gnu/java/security/Configuration.java as generated source file. * gnu/java/lang/management/VMGarbageCollectorMXBeanImpl.java, gnu/java/lang/management/VMMemoryPoolMXBeanImpl.java, gnu/java/lang/management/VMClassLoadingMXBeanImpl.java, gnu/java/lang/management/VMRuntimeMXBeanImpl.java, gnu/java/lang/management/VMMemoryManagerMXBeanImpl.java, gnu/java/lang/management/VMThreadMXBeanImpl.java, gnu/java/lang/management/VMMemoryMXBeanImpl.java, gnu/java/lang/management/VMCompilationMXBeanImpl.java: New VM stub classes. * java/lang/management/VMManagementFactory.java: Likewise. * java/net/VMURLConnection.java: Likewise. * gnu/java/nio/VMChannel.java: Likewise. * java/lang/Thread.java (getState): Add stub implementation. * java/lang/Class.java (isEnum): Likewise. * java/lang/Class.h (isEnum): Likewise. * gnu/awt/xlib/XToolkit.java (getClasspathTextLayoutPeer): Removed. * javax/naming/spi/NamingManager.java: New override for StackWalker functionality. * configure, sources.am, Makefile.in, gcj/Makefile.in, include/Makefile.in, testsuite/Makefile.in: Regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@116139 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java')
-rw-r--r--libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java57
1 files changed, 41 insertions, 16 deletions
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
index 1356db4aeec..dc1c051225c 100644
--- a/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
+++ b/libjava/classpath/javax/swing/plaf/basic/BasicFileChooserUI.java
@@ -160,6 +160,8 @@ public class BasicFileChooserUI extends FileChooserUI
else
{
File f = new File(filechooser.getCurrentDirectory(), getFileName());
+ if ( selectedDir != null )
+ f = selectedDir;
if (filechooser.isTraversable(f))
{
filechooser.setCurrentDirectory(f);
@@ -266,7 +268,14 @@ public class BasicFileChooserUI extends FileChooserUI
*/
public String getName(File f)
{
- return f.getName();
+ String name = null;
+ if (f != null)
+ {
+ JFileChooser c = getFileChooser();
+ FileSystemView v = c.getFileSystemView();
+ name = v.getSystemDisplayName(f);
+ }
+ return name;
}
/**
@@ -409,7 +418,7 @@ public class BasicFileChooserUI extends FileChooserUI
closeDialog();
}
}
- else
+ else // single click
{
String path = p.toString();
File f = fsv.createFileObject(path);
@@ -436,10 +445,11 @@ public class BasicFileChooserUI extends FileChooserUI
}
lastSelected = path;
parentPath = path.substring(0, path.lastIndexOf("/") + 1);
+
if (f.isFile())
setFileName(path.substring(path.lastIndexOf("/") + 1));
- else if (filechooser.getFileSelectionMode() ==
- JFileChooser.DIRECTORIES_ONLY)
+ else if (filechooser.getFileSelectionMode() !=
+ JFileChooser.FILES_ONLY)
setFileName(path);
}
}
@@ -538,7 +548,7 @@ public class BasicFileChooserUI extends FileChooserUI
}
/**
- * DOCUMENT ME!
+ * Sets the JFileChooser to the selected file on an update
*
* @param e DOCUMENT ME!
*/
@@ -550,9 +560,15 @@ public class BasicFileChooserUI extends FileChooserUI
return;
File file = filechooser.getFileSystemView().createFileObject(f.toString());
if (! filechooser.isTraversable(file))
- filechooser.setSelectedFile(file);
+ {
+ selectedDir = null;
+ filechooser.setSelectedFile(file);
+ }
else
- filechooser.setSelectedFile(null);
+ {
+ selectedDir = file;
+ filechooser.setSelectedFile(null);
+ }
}
}
@@ -752,6 +768,13 @@ public class BasicFileChooserUI extends FileChooserUI
* @see #getUpdateAction()
*/
private UpdateAction updateAction;
+
+ /**
+ * When in FILES_ONLY, mode a directory cannot be selected, so
+ * we save a reference to any it here. This is used to enter
+ * the directory on "Open" when in that mode.
+ */
+ private File selectedDir;
// -- end private --
@@ -874,7 +897,9 @@ public class BasicFileChooserUI extends FileChooserUI
protected void installListeners(JFileChooser fc)
{
propertyChangeListener = createPropertyChangeListener(filechooser);
- filechooser.addPropertyChangeListener(propertyChangeListener);
+ if (propertyChangeListener != null)
+ filechooser.addPropertyChangeListener(propertyChangeListener);
+ fc.addPropertyChangeListener(getModel());
}
/**
@@ -884,8 +909,12 @@ public class BasicFileChooserUI extends FileChooserUI
*/
protected void uninstallListeners(JFileChooser fc)
{
- filechooser.removePropertyChangeListener(propertyChangeListener);
- propertyChangeListener = null;
+ if (propertyChangeListener != null)
+ {
+ filechooser.removePropertyChangeListener(propertyChangeListener);
+ propertyChangeListener = null;
+ }
+ fc.removePropertyChangeListener(getModel());
}
/**
@@ -1046,12 +1075,8 @@ public class BasicFileChooserUI extends FileChooserUI
*/
public PropertyChangeListener createPropertyChangeListener(JFileChooser fc)
{
- return new PropertyChangeListener()
- {
- public void propertyChange(PropertyChangeEvent e)
- {
- }
- };
+ // The RI returns null here, so do we.
+ return null;
}
/**
OpenPOWER on IntegriCloud