6776856: Code with useShellFolder field shuold be simplify
authorrupashka
Wed Nov 26 19:38:46 2008 +0300 (15 months ago)
changeset 10028b842701af50
parent 1001be2b6b030a79
child 10035784f5dfe3ac
6776856: Code with useShellFolder field shuold be simplify
Reviewed-by: peterz
src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java
src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java
src/share/classes/sun/swing/FilePane.java
src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java
--- a/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java Wed Nov 26 19:08:41 2008 +0300
+++ b/src/share/classes/com/sun/java/swing/plaf/windows/WindowsFileChooserUI.java Wed Nov 26 19:38:46 2008 +0300
@@ -70,7 +70,6 @@ public class WindowsFileChooserUI extend
private JTextField filenameTextField;
private FilePane filePane;
private WindowsPlacesBar placesBar;
- private boolean useShellFolder;
private JButton approveButton;
private JButton cancelButton;
@@ -209,10 +208,6 @@ public class WindowsFileChooserUI extend
public ListSelectionListener createListSelectionListener() {
return WindowsFileChooserUI.this.createListSelectionListener(getFileChooser());
- }
-
- public boolean usesShellFolder() {
- return useShellFolder;
}
}
@@ -625,15 +620,8 @@ public class WindowsFileChooserUI extend
// Decide whether to use the ShellFolder class to populate shortcut
// panel and combobox.
JFileChooser fc = getFileChooser();
- Boolean prop =
- (Boolean)fc.getClientProperty("FileChooser.useShellFolder");
- if (prop != null) {
- useShellFolder = prop.booleanValue();
- } else {
- useShellFolder = fc.getFileSystemView().equals(FileSystemView.getFileSystemView());
- }
if (OS_VERSION.compareTo(OSInfo.WINDOWS_ME) >= 0) {
- if (useShellFolder) {
+ if (FilePane.usesShellFolder(fc)) {
if (placesBar == null && !UIManager.getBoolean("FileChooser.noPlacesBar")) {
placesBar = new WindowsPlacesBar(fc, XPStyle.getXP() != null);
fc.add(placesBar, BorderLayout.BEFORE_LINE_BEGINS);
@@ -1149,6 +1137,8 @@ public class WindowsFileChooserUI extend
return;
}
+ boolean useShellFolder = FilePane.usesShellFolder(chooser);
+
directories.clear();
File[] baseFolders;
--- a/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java Wed Nov 26 19:08:41 2008 +0300
+++ b/src/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java Wed Nov 26 19:38:46 2008 +0300
@@ -68,8 +68,6 @@ public class MetalFileChooserUI extends
private JToggleButton listViewButton;
private JToggleButton detailsViewButton;
- private boolean useShellFolder;
-
private JButton approveButton;
private JButton cancelButton;
@@ -204,10 +202,6 @@ public class MetalFileChooserUI extends
public ListSelectionListener createListSelectionListener() {
return MetalFileChooserUI.this.createListSelectionListener(getFileChooser());
}
-
- public boolean usesShellFolder() {
- return useShellFolder;
- }
}
public void installComponents(JFileChooser fc) {
@@ -218,8 +212,6 @@ public class MetalFileChooserUI extends
filePane = new FilePane(new MetalFileChooserUIAccessor());
fc.addPropertyChangeListener(filePane);
-
- updateUseShellFolder();
// ********************************* //
// **** Construct the top panel **** //
@@ -446,19 +438,6 @@ public class MetalFileChooserUI extends
}
groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel });
- }
-
- private void updateUseShellFolder() {
- // Decide whether to use the ShellFolder class to populate shortcut
- // panel and combobox.
- JFileChooser fc = getFileChooser();
- Boolean prop =
- (Boolean)fc.getClientProperty("FileChooser.useShellFolder");
- if (prop != null) {
- useShellFolder = prop.booleanValue();
- } else {
- useShellFolder = fc.getFileSystemView().equals(FileSystemView.getFileSystemView());
- }
}
protected JPanel getButtonPanel() {
@@ -786,7 +765,6 @@ public class MetalFileChooserUI extends
cc.applyComponentOrientation(o);
}
} else if (s == "FileChooser.useShellFolder") {
- updateUseShellFolder();
doDirectoryChanged(e);
} else if (s.equals("ancestor")) {
if (e.getOldValue() == null && e.getNewValue() != null) {
@@ -953,6 +931,8 @@ public class MetalFileChooserUI extends
return;
}
+ boolean useShellFolder = FilePane.usesShellFolder(chooser);
+
directories.clear();
File[] baseFolders;
--- a/src/share/classes/sun/swing/FilePane.java Wed Nov 26 19:08:41 2008 +0300
+++ b/src/share/classes/sun/swing/FilePane.java Wed Nov 26 19:38:46 2008 +0300
@@ -689,7 +689,7 @@ public class FilePane extends JPanel imp
void updateColumnInfo() {
File dir = chooser.getCurrentDirectory();
- if (dir != null && fileChooserUIAccessor.usesShellFolder()) {
+ if (dir != null && usesShellFolder(chooser)) {
try {
dir = ShellFolder.getShellFolder(dir);
} catch (FileNotFoundException e) {
@@ -1947,7 +1947,7 @@ public class FilePane extends JPanel imp
if (f instanceof ShellFolder) {
return ((ShellFolder) f).isFileSystem();
} else {
- if (fileChooserUIAccessor.usesShellFolder()) {
+ if (usesShellFolder(getFileChooser())) {
try {
return ShellFolder.getShellFolder(f).isFileSystem();
} catch (FileNotFoundException ex) {
@@ -1985,6 +1985,5 @@ public class FilePane extends JPanel imp
public Action getNewFolderAction();
public MouseListener createDoubleClickListener(JList list);
public ListSelectionListener createListSelectionListener();
- public boolean usesShellFolder();
}
}
--- a/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java Wed Nov 26 19:08:41 2008 +0300
+++ b/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java Wed Nov 26 19:38:46 2008 +0300
@@ -71,8 +71,6 @@ public class SynthFileChooserUIImpl exte
private JToggleButton listViewButton;
private JToggleButton detailsViewButton;
- private boolean useShellFolder;
-
private boolean readOnly;
private JPanel buttonPanel;
@@ -185,10 +183,6 @@ public class SynthFileChooserUIImpl exte
public ListSelectionListener createListSelectionListener() {
return SynthFileChooserUIImpl.this.createListSelectionListener(getFileChooser());
}
-
- public boolean usesShellFolder() {
- return useShellFolder;
- }
}
protected void installDefaults(JFileChooser fc) {
@@ -200,8 +194,6 @@ public class SynthFileChooserUIImpl exte
super.installComponents(fc);
SynthContext context = getContext(fc, ENABLED);
-
- updateUseShellFolder();
fc.setLayout(new BorderLayout(0, 11));
@@ -432,20 +424,6 @@ public class SynthFileChooserUIImpl exte
super.uninstallListeners(fc);
}
- private void updateUseShellFolder() {
- // Decide whether to use the ShellFolder class to populate shortcut
- // panel and combobox.
- JFileChooser fc = getFileChooser();
- Boolean prop =
- (Boolean)fc.getClientProperty("FileChooser.useShellFolder");
- if (prop != null) {
- useShellFolder = prop.booleanValue();
- } else {
- useShellFolder = fc.getFileSystemView().equals(FileSystemView.getFileSystemView());
- }
- }
-
-
private String fileNameString(File file) {
if (file == null) {
return null;
@@ -760,6 +738,8 @@ public class SynthFileChooserUIImpl exte
if (directory == null) {
return;
}
+
+ boolean useShellFolder = FilePane.usesShellFolder(chooser);
int oldSize = directories.size();
directories.clear();