< prev index next >
src/share/classes/sun/swing/FilePane.java
Print this page
rev 1492 : 7032018: The file list in JFileChooser does not have an accessible name
Reviewed-by: rupashka, coffeys
rev 1527 : 6727662: Code improvement and warnings removing from swing packages
Summary: Removed unnecessary castings and other warnings
Reviewed-by: malenkov
@@ -33,10 +33,11 @@
import java.text.DateFormat;
import java.text.MessageFormat;
import java.util.*;
import java.util.List;
+import javax.accessibility.AccessibleContext;
import javax.swing.*;
import javax.swing.border.*;
import javax.swing.event.*;
import javax.swing.filechooser.*;
import javax.swing.plaf.basic.*;
@@ -80,10 +81,13 @@
private int viewType = -1;
private JPanel[] viewPanels = new JPanel[VIEWTYPE_COUNT];
private JPanel currentViewPanel;
private String[] viewTypeActionNames;
+ private String filesListAccessibleName = null;
+ private String filesDetailsAccessibleName = null;
+
private JPopupMenu contextMenu;
private JMenu viewMenu;
private String viewMenuLabelText;
private String refreshActionLabelText;
@@ -447,10 +451,13 @@
kiloByteString = UIManager.getString("FileChooser.fileSizeKiloBytes", l);
megaByteString = UIManager.getString("FileChooser.fileSizeMegaBytes", l);
gigaByteString = UIManager.getString("FileChooser.fileSizeGigaBytes", l);
fullRowSelection = UIManager.getBoolean("FileView.fullRowSelection");
+ filesListAccessibleName = UIManager.getString("FileChooser.filesListAccessibleName", l);
+ filesDetailsAccessibleName = UIManager.getString("FileChooser.filesDetailsAccessibleName", l);
+
renameErrorTitleText = UIManager.getString("FileChooser.renameErrorTitleText", l);
renameErrorText = UIManager.getString("FileChooser.renameErrorText", l);
}
/**
@@ -544,12 +551,11 @@
}
public static void addActionsToMap(ActionMap map, Action[] actions) {
if (map != null && actions != null) {
- for (int i = 0; i < actions.length; i++) {
- Action a = actions[i];
+ for (Action a : actions) {
String cmd = (String)a.getValue(Action.ACTION_COMMAND_KEY);
if (cmd == null) {
cmd = (String)a.getValue(Action.NAME);
}
map.put(cmd, a);
@@ -631,10 +637,13 @@
list.setBackground(listViewBackground);
}
if (listViewBorder != null) {
scrollpane.setBorder(listViewBorder);
}
+
+ list.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, filesListAccessibleName);
+
p.add(scrollpane, BorderLayout.CENTER);
return p;
}
/**
@@ -713,17 +722,17 @@
columns = new ShellFolderColumnInfo[visibleColumns.size()];
visibleColumns.toArray(columns);
columnMap = Arrays.copyOf(columnMap, columns.length);
- List<RowSorter.SortKey> sortKeys =
+ List<? extends RowSorter.SortKey> sortKeys =
(rowSorter == null) ? null : rowSorter.getSortKeys();
fireTableStructureChanged();
restoreSortKeys(sortKeys);
}
- private void restoreSortKeys(List<RowSorter.SortKey> sortKeys) {
+ private void restoreSortKeys(List<? extends RowSorter.SortKey> sortKeys) {
if (sortKeys != null) {
// check if preserved sortKeys are valid for this folder
for (int i = 0; i < sortKeys.size(); i++) {
RowSorter.SortKey sortKey = sortKeys.get(i);
if (sortKey.getColumn() >= columns.length) {
@@ -881,11 +890,11 @@
rowSorter = new DetailsTableRowSorter();
}
return rowSorter;
}
- private class DetailsTableRowSorter extends TableRowSorter {
+ private class DetailsTableRowSorter extends TableRowSorter<TableModel> {
public DetailsTableRowSorter() {
setModelWrapper(new SorterModelWrapper());
}
public void updateComparators(ShellFolderColumnInfo [] columns) {
@@ -901,12 +910,12 @@
public void modelStructureChanged() {
super.modelStructureChanged();
updateComparators(detailsTableModel.getColumns());
}
- private class SorterModelWrapper extends ModelWrapper {
- public Object getModel() {
+ private class SorterModelWrapper extends ModelWrapper<TableModel, Integer> {
+ public TableModel getModel() {
return getDetailsTableModel();
}
public int getColumnCount() {
return getDetailsTableModel().getColumnCount();
@@ -918,11 +927,11 @@
public Object getValueAt(int row, int column) {
return FilePane.this.getModel().getElementAt(row);
}
- public Object getIdentifier(int row) {
+ public Integer getIdentifier(int row) {
return row;
}
}
}
@@ -1205,10 +1214,12 @@
}
p.add(scrollpane, BorderLayout.CENTER);
detailsTableModel.fireTableStructureChanged();
+ detailsTable.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, filesDetailsAccessibleName);
+
return p;
} // createDetailsView
private class AlignableTableHeaderRenderer implements TableCellRenderer {
TableCellRenderer wrappedRenderer;
@@ -1708,13 +1719,13 @@
}
private void updateViewMenu() {
if (viewMenu != null) {
Component[] comps = viewMenu.getMenuComponents();
- for (int i = 0; i < comps.length; i++) {
- if (comps[i] instanceof JRadioButtonMenuItem) {
- JRadioButtonMenuItem mi = (JRadioButtonMenuItem)comps[i];
+ for (Component comp : comps) {
+ if (comp instanceof JRadioButtonMenuItem) {
+ JRadioButtonMenuItem mi = (JRadioButtonMenuItem) comp;
if (((ViewTypeAction)mi.getAction()).viewType == viewType) {
mi.setSelected(true);
}
}
}
< prev index next >