6776856: Code with useShellFolder field shuold be simplify
Reviewed-by: peterz
This commit is contained in:
parent
e7c2dc0b7a
commit
5a8c6c3bf7
@ -70,7 +70,6 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
||||
private JTextField filenameTextField;
|
||||
private FilePane filePane;
|
||||
private WindowsPlacesBar placesBar;
|
||||
private boolean useShellFolder;
|
||||
|
||||
private JButton approveButton;
|
||||
private JButton cancelButton;
|
||||
@ -210,10 +209,6 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
||||
public ListSelectionListener createListSelectionListener() {
|
||||
return WindowsFileChooserUI.this.createListSelectionListener(getFileChooser());
|
||||
}
|
||||
|
||||
public boolean usesShellFolder() {
|
||||
return useShellFolder;
|
||||
}
|
||||
}
|
||||
|
||||
public void installComponents(JFileChooser fc) {
|
||||
@ -625,15 +620,8 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
||||
// 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 extends BasicFileChooserUI {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean useShellFolder = FilePane.usesShellFolder(chooser);
|
||||
|
||||
directories.clear();
|
||||
|
||||
File[] baseFolders;
|
||||
|
@ -68,8 +68,6 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
||||
private JToggleButton listViewButton;
|
||||
private JToggleButton detailsViewButton;
|
||||
|
||||
private boolean useShellFolder;
|
||||
|
||||
private JButton approveButton;
|
||||
private JButton cancelButton;
|
||||
|
||||
@ -204,10 +202,6 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
||||
public ListSelectionListener createListSelectionListener() {
|
||||
return MetalFileChooserUI.this.createListSelectionListener(getFileChooser());
|
||||
}
|
||||
|
||||
public boolean usesShellFolder() {
|
||||
return useShellFolder;
|
||||
}
|
||||
}
|
||||
|
||||
public void installComponents(JFileChooser fc) {
|
||||
@ -219,8 +213,6 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
||||
filePane = new FilePane(new MetalFileChooserUIAccessor());
|
||||
fc.addPropertyChangeListener(filePane);
|
||||
|
||||
updateUseShellFolder();
|
||||
|
||||
// ********************************* //
|
||||
// **** Construct the top panel **** //
|
||||
// ********************************* //
|
||||
@ -448,19 +440,6 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
||||
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() {
|
||||
if (buttonPanel == null) {
|
||||
buttonPanel = new JPanel();
|
||||
@ -786,7 +765,6 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
||||
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 BasicFileChooserUI {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean useShellFolder = FilePane.usesShellFolder(chooser);
|
||||
|
||||
directories.clear();
|
||||
|
||||
File[] baseFolders;
|
||||
|
@ -689,7 +689,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
|
||||
|
||||
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 implements PropertyChangeListener {
|
||||
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 implements PropertyChangeListener {
|
||||
public Action getNewFolderAction();
|
||||
public MouseListener createDoubleClickListener(JList list);
|
||||
public ListSelectionListener createListSelectionListener();
|
||||
public boolean usesShellFolder();
|
||||
}
|
||||
}
|
||||
|
@ -71,8 +71,6 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
|
||||
private JToggleButton listViewButton;
|
||||
private JToggleButton detailsViewButton;
|
||||
|
||||
private boolean useShellFolder;
|
||||
|
||||
private boolean readOnly;
|
||||
|
||||
private JPanel buttonPanel;
|
||||
@ -185,10 +183,6 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
|
||||
public ListSelectionListener createListSelectionListener() {
|
||||
return SynthFileChooserUIImpl.this.createListSelectionListener(getFileChooser());
|
||||
}
|
||||
|
||||
public boolean usesShellFolder() {
|
||||
return useShellFolder;
|
||||
}
|
||||
}
|
||||
|
||||
protected void installDefaults(JFileChooser fc) {
|
||||
@ -201,8 +195,6 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
|
||||
|
||||
SynthContext context = getContext(fc, ENABLED);
|
||||
|
||||
updateUseShellFolder();
|
||||
|
||||
fc.setLayout(new BorderLayout(0, 11));
|
||||
|
||||
// ********************************* //
|
||||
@ -432,20 +424,6 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
|
||||
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;
|
||||
@ -761,6 +739,8 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
|
||||
return;
|
||||
}
|
||||
|
||||
boolean useShellFolder = FilePane.usesShellFolder(chooser);
|
||||
|
||||
int oldSize = directories.size();
|
||||
directories.clear();
|
||||
if (oldSize > 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user