提交 977404b2 编写于 作者: R rupashka

7021058: The Create folder button produces error in the Details mode (JFileChooser)

Reviewed-by: malenkov
上级 11f13da0
...@@ -763,7 +763,7 @@ public class FilePane extends JPanel implements PropertyChangeListener { ...@@ -763,7 +763,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
public void setValueAt(Object value, int row, int col) { public void setValueAt(Object value, int row, int col) {
if (col == COLUMN_FILENAME) { if (col == COLUMN_FILENAME) {
JFileChooser chooser = getFileChooser(); final JFileChooser chooser = getFileChooser();
File f = (File)getValueAt(row, col); File f = (File)getValueAt(row, col);
if (f != null) { if (f != null) {
String oldDisplayName = chooser.getName(f); String oldDisplayName = chooser.getName(f);
...@@ -782,18 +782,25 @@ public class FilePane extends JPanel implements PropertyChangeListener { ...@@ -782,18 +782,25 @@ public class FilePane extends JPanel implements PropertyChangeListener {
// rename // rename
FileSystemView fsv = chooser.getFileSystemView(); FileSystemView fsv = chooser.getFileSystemView();
File f2 = fsv.createFileObject(f.getParentFile(), newFileName); final File f2 = fsv.createFileObject(f.getParentFile(), newFileName);
if (f2.exists()) { if (f2.exists()) {
JOptionPane.showMessageDialog(chooser, MessageFormat.format(renameErrorFileExistsText, JOptionPane.showMessageDialog(chooser, MessageFormat.format(renameErrorFileExistsText,
oldFileName), renameErrorTitleText, JOptionPane.ERROR_MESSAGE); oldFileName), renameErrorTitleText, JOptionPane.ERROR_MESSAGE);
} else { } else {
if (FilePane.this.getModel().renameFile(f, f2)) { if (FilePane.this.getModel().renameFile(f, f2)) {
if (fsv.isParent(chooser.getCurrentDirectory(), f2)) { if (fsv.isParent(chooser.getCurrentDirectory(), f2)) {
// The setSelectedFile method produces a new setValueAt invocation while the JTable
// is editing. Postpone file selection to be sure that edit mode of the JTable
// is completed
SwingUtilities.invokeLater(new Runnable() {
public void run() {
if (chooser.isMultiSelectionEnabled()) { if (chooser.isMultiSelectionEnabled()) {
chooser.setSelectedFiles(new File[]{f2}); chooser.setSelectedFiles(new File[]{f2});
} else { } else {
chooser.setSelectedFile(f2); chooser.setSelectedFile(f2);
} }
}
});
} else { } else {
// Could be because of delay in updating Desktop folder // Could be because of delay in updating Desktop folder
// chooser.setSelectedFile(null); // chooser.setSelectedFile(null);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册