src/share/classes/sun/swing/FilePane.java
Print this page
*** 238,248 ****
} else if (source instanceof JTable) {
repaintTableSelection((JTable)source);
}
}
! private void repaintListSelection(JList list) {
int[] indices = list.getSelectedIndices();
for (int i : indices) {
Rectangle bounds = list.getCellBounds(i, i);
list.repaint(bounds);
}
--- 238,248 ----
} else if (source instanceof JTable) {
repaintTableSelection((JTable)source);
}
}
! private void repaintListSelection(JList<?> list) {
int[] indices = list.getSelectedIndices();
for (int i : indices) {
Rectangle bounds = list.getCellBounds(i, i);
list.repaint(bounds);
}
*** 270,280 ****
private boolean listViewWindowsStyle;
private boolean readOnly;
private boolean fullRowSelection = false;
private ListSelectionModel listSelectionModel;
! private JList list;
private JTable detailsTable;
private static final int COLUMN_FILENAME = 0;
// Provides a way to recognize a newly created folder, so it can
--- 270,280 ----
private boolean listViewWindowsStyle;
private boolean readOnly;
private boolean fullRowSelection = false;
private ListSelectionModel listSelectionModel;
! private JList<?> list;
private JTable detailsTable;
private static final int COLUMN_FILENAME = 0;
// Provides a way to recognize a newly created folder, so it can
*** 330,340 ****
createdViewPanel = fileChooserUIAccessor.createList();
if (createdViewPanel == null) {
createdViewPanel = createList();
}
! list = (JList) findChildComponent(createdViewPanel, JList.class);
if (listSelectionModel == null) {
listSelectionModel = list.getSelectionModel();
if (detailsTable != null) {
detailsTable.setSelectionModel(listSelectionModel);
}
--- 330,340 ----
createdViewPanel = fileChooserUIAccessor.createList();
if (createdViewPanel == null) {
createdViewPanel = createList();
}
! list = findChildComponent(createdViewPanel, JList.class);
if (listSelectionModel == null) {
listSelectionModel = list.getSelectionModel();
if (detailsTable != null) {
detailsTable.setSelectionModel(listSelectionModel);
}
*** 351,361 ****
createdViewPanel = fileChooserUIAccessor.createDetailsView();
if (createdViewPanel == null) {
createdViewPanel = createDetailsView();
}
! detailsTable = (JTable) findChildComponent(createdViewPanel, JTable.class);
detailsTable.setRowHeight(Math.max(detailsTable.getFont().getSize() + 4, 16 + 1));
if (listSelectionModel != null) {
detailsTable.setSelectionModel(listSelectionModel);
}
}
--- 351,361 ----
createdViewPanel = fileChooserUIAccessor.createDetailsView();
if (createdViewPanel == null) {
createdViewPanel = createDetailsView();
}
! detailsTable = findChildComponent(createdViewPanel, JTable.class);
detailsTable.setRowHeight(Math.max(detailsTable.getFont().getSize() + 4, 16 + 1));
if (listSelectionModel != null) {
detailsTable.setSelectionModel(listSelectionModel);
}
}
*** 567,577 ****
}
}
}
! private void updateListRowCount(JList list) {
if (smallIconsView) {
list.setVisibleRowCount(getModel().getSize() / 3);
} else {
list.setVisibleRowCount(-1);
}
--- 567,577 ----
}
}
}
! private void updateListRowCount(JList<?> list) {
if (smallIconsView) {
list.setVisibleRowCount(getModel().getSize() / 3);
} else {
list.setVisibleRowCount(-1);
}
*** 582,592 ****
final JFileChooser fileChooser = getFileChooser();
@SuppressWarnings("serial") // anonymous class
final JList<Object> list = new JList<Object>() {
public int getNextMatch(String prefix, int startIndex, Position.Bias bias) {
! ListModel model = getModel();
int max = model.getSize();
if (prefix == null || startIndex < 0 || startIndex >= max) {
throw new IllegalArgumentException();
}
// start search from the next element before/after the selected element
--- 582,592 ----
final JFileChooser fileChooser = getFileChooser();
@SuppressWarnings("serial") // anonymous class
final JList<Object> list = new JList<Object>() {
public int getNextMatch(String prefix, int startIndex, Position.Bias bias) {
! ListModel<?> model = getModel();
int max = model.getSize();
if (prefix == null || startIndex < 0 || startIndex >= max) {
throw new IllegalArgumentException();
}
// start search from the next element before/after the selected element
*** 916,926 ****
setModelWrapper(new SorterModelWrapper());
}
public void updateComparators(ShellFolderColumnInfo [] columns) {
for (int i = 0; i < columns.length; i++) {
! Comparator c = columns[i].getComparator();
if (c != null) {
c = new DirectoriesFirstComparatorWrapper(i, c);
}
setComparator(i, c);
}
--- 916,926 ----
setModelWrapper(new SorterModelWrapper());
}
public void updateComparators(ShellFolderColumnInfo [] columns) {
for (int i = 0; i < columns.length; i++) {
! Comparator<?> c = columns[i].getComparator();
if (c != null) {
c = new DirectoriesFirstComparatorWrapper(i, c);
}
setComparator(i, c);
}
*** 967,982 ****
/**
* This class sorts directories before files, comparing directory to
* directory and file to file using the wrapped comparator.
*/
private class DirectoriesFirstComparatorWrapper implements Comparator<File> {
! private Comparator comparator;
private int column;
! public DirectoriesFirstComparatorWrapper(int column, Comparator comparator) {
this.column = column;
! this.comparator = comparator;
}
public int compare(File f1, File f2) {
if (f1 != null && f2 != null) {
boolean traversable1 = getFileChooser().isTraversable(f1);
--- 967,983 ----
/**
* This class sorts directories before files, comparing directory to
* directory and file to file using the wrapped comparator.
*/
private class DirectoriesFirstComparatorWrapper implements Comparator<File> {
! private Comparator<Object> comparator;
private int column;
! @SuppressWarnings("unchecked")
! public DirectoriesFirstComparatorWrapper(int column, Comparator<?> comparator) {
this.column = column;
! this.comparator = (Comparator<Object>)comparator;
}
public int compare(File f1, File f2) {
if (f1 != null && f2 != null) {
boolean traversable1 = getFileChooser().isTraversable(f1);
*** 1490,1500 ****
}
@SuppressWarnings("serial") // JDK-implementation class
protected class FileRenderer extends DefaultListCellRenderer {
! public Component getListCellRendererComponent(JList list, Object value,
int index, boolean isSelected,
boolean cellHasFocus) {
if (listViewWindowsStyle && !list.isFocusOwner()) {
isSelected = false;
--- 1491,1501 ----
}
@SuppressWarnings("serial") // JDK-implementation class
protected class FileRenderer extends DefaultListCellRenderer {
! public Component getListCellRendererComponent(JList<?> list, Object value,
int index, boolean isSelected,
boolean cellHasFocus) {
if (listViewWindowsStyle && !list.isFocusOwner()) {
isSelected = false;
*** 1966,1983 ****
*/
protected File getDirectory() {
return fileChooserUIAccessor.getDirectory();
}
! private Component findChildComponent(Container container, Class cls) {
int n = container.getComponentCount();
for (int i = 0; i < n; i++) {
Component comp = container.getComponent(i);
if (cls.isInstance(comp)) {
! return comp;
} else if (comp instanceof Container) {
! Component c = findChildComponent((Container)comp, cls);
if (c != null) {
return c;
}
}
}
--- 1967,1984 ----
*/
protected File getDirectory() {
return fileChooserUIAccessor.getDirectory();
}
! private <T> T findChildComponent(Container container, Class<T> cls) {
int n = container.getComponentCount();
for (int i = 0; i < n; i++) {
Component comp = container.getComponent(i);
if (cls.isInstance(comp)) {
! return cls.cast(comp);
} else if (comp instanceof Container) {
! T c = findChildComponent((Container)comp, cls);
if (c != null) {
return c;
}
}
}
*** 2027,2035 ****
public boolean isDirectorySelected();
public File getDirectory();
public Action getApproveSelectionAction();
public Action getChangeToParentDirectoryAction();
public Action getNewFolderAction();
! public MouseListener createDoubleClickListener(JList list);
public ListSelectionListener createListSelectionListener();
}
}
--- 2028,2036 ----
public boolean isDirectorySelected();
public File getDirectory();
public Action getApproveSelectionAction();
public Action getChangeToParentDirectoryAction();
public Action getNewFolderAction();
! public MouseListener createDoubleClickListener(JList<?> list);
public ListSelectionListener createListSelectionListener();
}
}