190 |
{ |
{ |
191 |
if (!listView) |
if (!listView) |
192 |
{ |
{ |
193 |
int index = fileTable.getSelectedRow(); |
int[] index = fileTable.getSelectedRows(); |
194 |
listView = true; |
listView = true; |
195 |
JFileChooser fc = getFileChooser(); |
JFileChooser fc = getFileChooser(); |
196 |
fc.remove(fileListPanel); |
fc.remove(fileTablePanel); |
197 |
fileListPanel = createList(fc); |
fileListPanel = createList(fc); |
198 |
|
|
199 |
if (index >= 0) |
fileList.getSelectionModel().clearSelection(); |
200 |
fileList.getSelectionModel().setSelectionInterval(index, index); |
if (index.length > 0) |
201 |
else |
{ |
202 |
fileList.getSelectionModel().clearSelection(); |
|
203 |
|
for (int i = 0; i < index.length; i++) |
204 |
|
fileList.getSelectionModel().addSelectionInterval(index[i], index[i]); |
205 |
|
} |
206 |
|
|
207 |
fc.add(fileListPanel, BorderLayout.CENTER); |
fc.add(fileListPanel, BorderLayout.CENTER); |
208 |
fc.revalidate(); |
fc.revalidate(); |
227 |
{ |
{ |
228 |
if (listView) |
if (listView) |
229 |
{ |
{ |
230 |
int index = fileList.getSelectedIndex(); |
int[] index = fileList.getSelectedIndices(); |
231 |
JFileChooser fc = getFileChooser(); |
JFileChooser fc = getFileChooser(); |
232 |
listView = false; |
listView = false; |
233 |
fc.remove(fileListPanel); |
fc.remove(fileListPanel); |
|
fileListPanel = createDetailsView(fc); |
|
234 |
|
|
235 |
if (index >= 0) |
if (fileTable == null) |
236 |
fileTable.getSelectionModel().setSelectionInterval(index, index); |
fileTablePanel = createDetailsView(fc); |
237 |
else |
else |
238 |
fileTable.getSelectionModel().clearSelection(); |
updateTable(); |
239 |
|
|
240 |
|
fileTable.getSelectionModel().clearSelection(); |
241 |
|
if (index.length > 0) |
242 |
|
{ |
243 |
|
for (int i = 0; i < index.length; i++) |
244 |
|
fileTable.getSelectionModel().addSelectionInterval(index[i], index[i]); |
245 |
|
} |
246 |
|
|
247 |
fc.add(fileListPanel, BorderLayout.CENTER); |
fc.add(fileTablePanel, BorderLayout.CENTER); |
248 |
fc.revalidate(); |
fc.revalidate(); |
249 |
fc.repaint(); |
fc.repaint(); |
250 |
} |
} |
307 |
} |
} |
308 |
else |
else |
309 |
{ |
{ |
310 |
fileTable.getSelectionModel().setSelectionInterval(index, index); |
fileTable.getSelectionModel().addSelectionInterval(index, index); |
311 |
fileTable.scrollRectToVisible(fileTable.getCellRect(index, 0, true)); |
fileTable.scrollRectToVisible(fileTable.getCellRect(index, 0, true)); |
312 |
fileTable.revalidate(); |
fileTable.revalidate(); |
313 |
fileTable.repaint(); |
fileTable.repaint(); |
1197 |
/** The panel containing the file list. */ |
/** The panel containing the file list. */ |
1198 |
JPanel fileListPanel; |
JPanel fileListPanel; |
1199 |
|
|
1200 |
|
/** The panel containing the file table. */ |
1201 |
|
JPanel fileTablePanel; |
1202 |
|
|
1203 |
/** The filter combo box model. */ |
/** The filter combo box model. */ |
1204 |
private FilterComboBoxModel filterModel; |
private FilterComboBoxModel filterModel; |
1205 |
|
|
1329 |
fc.remove(bottomPanel); |
fc.remove(bottomPanel); |
1330 |
bottomPanel = null; |
bottomPanel = null; |
1331 |
fc.remove(fileListPanel); |
fc.remove(fileListPanel); |
1332 |
|
fc.remove(fileTablePanel); |
1333 |
|
fileTablePanel = null; |
1334 |
fileListPanel = null; |
fileListPanel = null; |
1335 |
fc.remove(topPanel); |
fc.remove(topPanel); |
1336 |
topPanel = null; |
topPanel = null; |
1413 |
doubleClickList = this.createDoubleClickListener(fc, fileList); |
doubleClickList = this.createDoubleClickListener(fc, fileList); |
1414 |
singleClickList = new SingleClickListener(fileList); |
singleClickList = new SingleClickListener(fileList); |
1415 |
directoryComboBox.setAction(new DirectoryComboBoxAction()); |
directoryComboBox.setAction(new DirectoryComboBoxAction()); |
|
fileList.addListSelectionListener(listSelList); |
|
|
fileList.addMouseListener(doubleClickList); |
|
|
fileList.addMouseListener(singleClickList); |
|
1416 |
fc.addPropertyChangeListener(filterModel); |
fc.addPropertyChangeListener(filterModel); |
1417 |
super.installListeners(fc); |
super.installListeners(fc); |
1418 |
} |
} |
1461 |
protected JPanel createList(JFileChooser fc) |
protected JPanel createList(JFileChooser fc) |
1462 |
{ |
{ |
1463 |
JPanel panel = new JPanel(new BorderLayout()); |
JPanel panel = new JPanel(new BorderLayout()); |
1464 |
fileList = new JList(getModel()); |
if (fileList == null) |
1465 |
|
fileList = new JList(); |
1466 |
|
fileList.setModel(getModel()); |
1467 |
|
|
1468 |
|
fileList.removeListSelectionListener(listSelList); |
1469 |
|
fileList.removeMouseListener(doubleClickList); |
1470 |
|
fileList.removeMouseListener(singleClickList); |
1471 |
|
|
1472 |
|
fileList.setModel(getModel()); |
1473 |
// FIXME: fileList.setLayoutOrientation(JList.VERTICAL_WRAP); |
// FIXME: fileList.setLayoutOrientation(JList.VERTICAL_WRAP); |
1474 |
|
|
1475 |
|
if (fc.isMultiSelectionEnabled()) |
1476 |
|
fileList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
1477 |
|
else |
1478 |
|
fileList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
1479 |
|
|
1480 |
|
fileList.addListSelectionListener(listSelList); |
1481 |
|
fileList.addMouseListener(doubleClickList); |
1482 |
|
fileList.addMouseListener(singleClickList); |
1483 |
|
|
1484 |
fileList.setCellRenderer(new FileRenderer()); |
fileList.setCellRenderer(new FileRenderer()); |
1485 |
scrollPane = new JScrollPane(fileList); |
scrollPane = new JScrollPane(fileList); |
1486 |
panel.add(scrollPane); |
panel.add(scrollPane); |
1487 |
return panel; |
return panel; |
1488 |
} |
} |
1489 |
|
|
1496 |
*/ |
*/ |
1497 |
protected JPanel createDetailsView(JFileChooser fc) |
protected JPanel createDetailsView(JFileChooser fc) |
1498 |
{ |
{ |
1499 |
|
fileTablePanel = new JPanel(new BorderLayout()); |
1500 |
|
|
1501 |
Object[] cols = new Object[] {"Name", "Size", "Modified"}; |
Object[] cols = new Object[] {"Name", "Size", "Modified"}; |
1502 |
Object[][] rows = new Object[fileList.getModel().getSize()][3]; |
Object[][] rows = new Object[fileList.getModel().getSize()][3]; |
1503 |
|
|
1504 |
fileTable = new JTable(new DefaultTableModel(rows, cols), null, |
fileTable = new JTable(new DefaultTableModel(rows, cols)); |
1505 |
fileList.getSelectionModel()); |
|
1506 |
|
if (fc.isMultiSelectionEnabled()) |
1507 |
|
fileTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); |
1508 |
|
else |
1509 |
|
fileTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); |
1510 |
|
|
1511 |
fileTable.setShowGrid(false); |
fileTable.setShowGrid(false); |
1512 |
fileTable.setIntercellSpacing(new Dimension(0, 0)); |
fileTable.setIntercellSpacing(new Dimension(0, 0)); |
1513 |
fileTable.setColumnSelectionAllowed(false); |
fileTable.setColumnSelectionAllowed(false); |
1555 |
scrollPane.setColumnHeaderView(fileTable.getTableHeader()); |
scrollPane.setColumnHeaderView(fileTable.getTableHeader()); |
1556 |
scrollPane.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE); |
scrollPane.getViewport().setScrollMode(JViewport.BACKINGSTORE_SCROLL_MODE); |
1557 |
|
|
1558 |
fileListPanel.removeAll(); |
fileTablePanel.removeAll(); |
1559 |
fileListPanel.add(scrollPane); |
fileTablePanel.add(scrollPane); |
1560 |
} |
} |
1561 |
return fileListPanel; |
return fileTablePanel; |
1562 |
} |
} |
1563 |
|
|
1564 |
/** |
/** |