01: package net.sf.jftp.gui.base.dir;
02:
03: import java.util.Vector;
04:
05: import javax.swing.JTable;
06: import javax.swing.event.ListSelectionEvent;
07: import javax.swing.event.ListSelectionListener;
08:
09: import net.sf.jftp.config.Settings;
10:
11: public class DirComponent extends DirPanel implements
12: ListSelectionListener {
13:
14: public JTable table = new JTable();
15: DirPanel target;
16:
17: public DirComponent() {
18:
19: table.setDefaultRenderer(Object.class,
20: new ColoredCellRenderer());
21: table.getSelectionModel().addListSelectionListener(this );
22:
23: //table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
24: table.setRowSelectionAllowed(true);
25: table.setColumnSelectionAllowed(false);
26: }
27:
28: public void update() {
29: if (Settings.getUseJTableLayout()) {
30: Vector colNames = new Vector();
31: colNames.add("");
32: colNames.add("Name");
33: colNames.add("Size");
34: colNames.add("##");
35:
36: TableUtils.layoutTable(jl, table, colNames);
37: }
38: }
39:
40: /**
41: * This manages the selections
42: */
43: public void valueChanged(ListSelectionEvent e) {
44: if (e.getValueIsAdjusting() == false) {
45: if (Settings.getUseJTableLayout()) {
46: TableUtils.copyTableSelectionsToJList(jl, table);
47: }
48:
49: // ui refresh bugfix
50: int index = jl.getSelectedIndex() - 1;
51:
52: if ((index < 0) || (dirEntry == null)
53: || (dirEntry.length < index)
54: || (dirEntry[index] == null)) {
55: return;
56: } else { // -------------------- local --------------------------
57:
58: String tgt = (String) jl.getSelectedValue().toString();
59:
60: for (int i = 0; i < dirEntry.length; i++) {
61: dirEntry[i].setSelected(jl.isSelectedIndex(i + 1));
62: }
63: }
64: }
65: }
66:
67: }
|