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 JTextField filenameTextField;
|
||||||
private FilePane filePane;
|
private FilePane filePane;
|
||||||
private WindowsPlacesBar placesBar;
|
private WindowsPlacesBar placesBar;
|
||||||
private boolean useShellFolder;
|
|
||||||
|
|
||||||
private JButton approveButton;
|
private JButton approveButton;
|
||||||
private JButton cancelButton;
|
private JButton cancelButton;
|
||||||
@ -210,10 +209,6 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
|||||||
public ListSelectionListener createListSelectionListener() {
|
public ListSelectionListener createListSelectionListener() {
|
||||||
return WindowsFileChooserUI.this.createListSelectionListener(getFileChooser());
|
return WindowsFileChooserUI.this.createListSelectionListener(getFileChooser());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean usesShellFolder() {
|
|
||||||
return useShellFolder;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void installComponents(JFileChooser fc) {
|
public void installComponents(JFileChooser fc) {
|
||||||
@ -625,15 +620,8 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
|||||||
// Decide whether to use the ShellFolder class to populate shortcut
|
// Decide whether to use the ShellFolder class to populate shortcut
|
||||||
// panel and combobox.
|
// panel and combobox.
|
||||||
JFileChooser fc = getFileChooser();
|
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 (OS_VERSION.compareTo(OSInfo.WINDOWS_ME) >= 0) {
|
||||||
if (useShellFolder) {
|
if (FilePane.usesShellFolder(fc)) {
|
||||||
if (placesBar == null && !UIManager.getBoolean("FileChooser.noPlacesBar")) {
|
if (placesBar == null && !UIManager.getBoolean("FileChooser.noPlacesBar")) {
|
||||||
placesBar = new WindowsPlacesBar(fc, XPStyle.getXP() != null);
|
placesBar = new WindowsPlacesBar(fc, XPStyle.getXP() != null);
|
||||||
fc.add(placesBar, BorderLayout.BEFORE_LINE_BEGINS);
|
fc.add(placesBar, BorderLayout.BEFORE_LINE_BEGINS);
|
||||||
@ -1149,6 +1137,8 @@ public class WindowsFileChooserUI extends BasicFileChooserUI {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean useShellFolder = FilePane.usesShellFolder(chooser);
|
||||||
|
|
||||||
directories.clear();
|
directories.clear();
|
||||||
|
|
||||||
File[] baseFolders;
|
File[] baseFolders;
|
||||||
|
@ -68,8 +68,6 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
|||||||
private JToggleButton listViewButton;
|
private JToggleButton listViewButton;
|
||||||
private JToggleButton detailsViewButton;
|
private JToggleButton detailsViewButton;
|
||||||
|
|
||||||
private boolean useShellFolder;
|
|
||||||
|
|
||||||
private JButton approveButton;
|
private JButton approveButton;
|
||||||
private JButton cancelButton;
|
private JButton cancelButton;
|
||||||
|
|
||||||
@ -204,10 +202,6 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
|||||||
public ListSelectionListener createListSelectionListener() {
|
public ListSelectionListener createListSelectionListener() {
|
||||||
return MetalFileChooserUI.this.createListSelectionListener(getFileChooser());
|
return MetalFileChooserUI.this.createListSelectionListener(getFileChooser());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean usesShellFolder() {
|
|
||||||
return useShellFolder;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void installComponents(JFileChooser fc) {
|
public void installComponents(JFileChooser fc) {
|
||||||
@ -219,8 +213,6 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
|||||||
filePane = new FilePane(new MetalFileChooserUIAccessor());
|
filePane = new FilePane(new MetalFileChooserUIAccessor());
|
||||||
fc.addPropertyChangeListener(filePane);
|
fc.addPropertyChangeListener(filePane);
|
||||||
|
|
||||||
updateUseShellFolder();
|
|
||||||
|
|
||||||
// ********************************* //
|
// ********************************* //
|
||||||
// **** Construct the top panel **** //
|
// **** Construct the top panel **** //
|
||||||
// ********************************* //
|
// ********************************* //
|
||||||
@ -448,19 +440,6 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
|||||||
groupLabels(new AlignedLabel[] { fileNameLabel, filesOfTypeLabel });
|
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() {
|
protected JPanel getButtonPanel() {
|
||||||
if (buttonPanel == null) {
|
if (buttonPanel == null) {
|
||||||
buttonPanel = new JPanel();
|
buttonPanel = new JPanel();
|
||||||
@ -786,7 +765,6 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
|||||||
cc.applyComponentOrientation(o);
|
cc.applyComponentOrientation(o);
|
||||||
}
|
}
|
||||||
} else if (s == "FileChooser.useShellFolder") {
|
} else if (s == "FileChooser.useShellFolder") {
|
||||||
updateUseShellFolder();
|
|
||||||
doDirectoryChanged(e);
|
doDirectoryChanged(e);
|
||||||
} else if (s.equals("ancestor")) {
|
} else if (s.equals("ancestor")) {
|
||||||
if (e.getOldValue() == null && e.getNewValue() != null) {
|
if (e.getOldValue() == null && e.getNewValue() != null) {
|
||||||
@ -953,6 +931,8 @@ public class MetalFileChooserUI extends BasicFileChooserUI {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean useShellFolder = FilePane.usesShellFolder(chooser);
|
||||||
|
|
||||||
directories.clear();
|
directories.clear();
|
||||||
|
|
||||||
File[] baseFolders;
|
File[] baseFolders;
|
||||||
|
@ -689,7 +689,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
|
|||||||
|
|
||||||
void updateColumnInfo() {
|
void updateColumnInfo() {
|
||||||
File dir = chooser.getCurrentDirectory();
|
File dir = chooser.getCurrentDirectory();
|
||||||
if (dir != null && fileChooserUIAccessor.usesShellFolder()) {
|
if (dir != null && usesShellFolder(chooser)) {
|
||||||
try {
|
try {
|
||||||
dir = ShellFolder.getShellFolder(dir);
|
dir = ShellFolder.getShellFolder(dir);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
@ -1947,7 +1947,7 @@ public class FilePane extends JPanel implements PropertyChangeListener {
|
|||||||
if (f instanceof ShellFolder) {
|
if (f instanceof ShellFolder) {
|
||||||
return ((ShellFolder) f).isFileSystem();
|
return ((ShellFolder) f).isFileSystem();
|
||||||
} else {
|
} else {
|
||||||
if (fileChooserUIAccessor.usesShellFolder()) {
|
if (usesShellFolder(getFileChooser())) {
|
||||||
try {
|
try {
|
||||||
return ShellFolder.getShellFolder(f).isFileSystem();
|
return ShellFolder.getShellFolder(f).isFileSystem();
|
||||||
} catch (FileNotFoundException ex) {
|
} catch (FileNotFoundException ex) {
|
||||||
@ -1985,6 +1985,5 @@ public class FilePane extends JPanel implements PropertyChangeListener {
|
|||||||
public Action getNewFolderAction();
|
public Action getNewFolderAction();
|
||||||
public MouseListener createDoubleClickListener(JList list);
|
public MouseListener createDoubleClickListener(JList list);
|
||||||
public ListSelectionListener createListSelectionListener();
|
public ListSelectionListener createListSelectionListener();
|
||||||
public boolean usesShellFolder();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,8 +71,6 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
|
|||||||
private JToggleButton listViewButton;
|
private JToggleButton listViewButton;
|
||||||
private JToggleButton detailsViewButton;
|
private JToggleButton detailsViewButton;
|
||||||
|
|
||||||
private boolean useShellFolder;
|
|
||||||
|
|
||||||
private boolean readOnly;
|
private boolean readOnly;
|
||||||
|
|
||||||
private JPanel buttonPanel;
|
private JPanel buttonPanel;
|
||||||
@ -185,10 +183,6 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
|
|||||||
public ListSelectionListener createListSelectionListener() {
|
public ListSelectionListener createListSelectionListener() {
|
||||||
return SynthFileChooserUIImpl.this.createListSelectionListener(getFileChooser());
|
return SynthFileChooserUIImpl.this.createListSelectionListener(getFileChooser());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean usesShellFolder() {
|
|
||||||
return useShellFolder;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void installDefaults(JFileChooser fc) {
|
protected void installDefaults(JFileChooser fc) {
|
||||||
@ -201,8 +195,6 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
|
|||||||
|
|
||||||
SynthContext context = getContext(fc, ENABLED);
|
SynthContext context = getContext(fc, ENABLED);
|
||||||
|
|
||||||
updateUseShellFolder();
|
|
||||||
|
|
||||||
fc.setLayout(new BorderLayout(0, 11));
|
fc.setLayout(new BorderLayout(0, 11));
|
||||||
|
|
||||||
// ********************************* //
|
// ********************************* //
|
||||||
@ -432,20 +424,6 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
|
|||||||
super.uninstallListeners(fc);
|
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) {
|
private String fileNameString(File file) {
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
return null;
|
return null;
|
||||||
@ -761,6 +739,8 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean useShellFolder = FilePane.usesShellFolder(chooser);
|
||||||
|
|
||||||
int oldSize = directories.size();
|
int oldSize = directories.size();
|
||||||
directories.clear();
|
directories.clear();
|
||||||
if (oldSize > 0) {
|
if (oldSize > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user