1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.gui.table;
21
22 import javax.swing.SwingUtilities;
23
24 import org.xnap.event.StateEvent;
25 import org.xnap.event.StateListener;
26 import org.xnap.transfer.AbstractTransferManager;
27 import org.xnap.transfer.Transfer;
28 import org.xnap.transfer.TransferContainer;
29
30 /***
31 * The model for the upload and download table.
32 *
33 * @see xnap.gui.TransferPanel
34 */
35 public class FilteredTransferTableModel extends TransferTableModel
36 implements StateListener {
37
38
39
40
41
42
43
44 public FilteredTransferTableModel(AbstractTransferManager queue)
45 {
46 super(queue, false);
47 }
48
49
50
51 public void add(Transfer t)
52 {
53 t.addStateListener(this);
54 if (t instanceof TransferContainer) {
55 FilteredTransferContainerTreeTableNode node
56 = new FilteredTransferContainerTreeTableNode(this, t);
57 add(node);
58 node.addExistingChildren();
59 }
60 else {
61 add(new TransferTreeTableNode(this, t));
62 }
63 }
64
65 public void remove(Transfer t)
66 {
67 t.removeStateListener(this);
68 super.remove(t);
69 }
70
71 /***
72 * @see xnap.event.StateListener#stateChanged(xnap.event.StateEvent)
73 */
74 public void stateChanged(StateEvent event)
75 {
76 final Transfer t = (Transfer)event.getSource();
77 if (t.isDone()) {
78 Runnable runner = new Runnable()
79 {
80 public void run()
81 {
82 remove(t);
83 }
84 };
85 SwingUtilities.invokeLater(runner);
86 }
87 }
88
89 }