1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.xnap.plugin.opennap.net;
21
22 import javax.swing.Action;
23
24 import java.awt.event.ActionEvent;
25 import java.util.Iterator;
26
27 import org.xnap.gui.action.AbstractDownloadAction;
28 import org.xnap.plugin.opennap.OpenNapPlugin;
29 import org.xnap.search.AbstractSearchResultContainer;
30 import org.xnap.search.SearchResult;
31
32 /***
33 *
34 */
35 public class OpenNapSearchResultContainer extends AbstractSearchResultContainer {
36
37
38
39
40
41
42
43 public OpenNapSearchResultContainer()
44 {
45 }
46
47
48
49 public synchronized boolean add(SearchResult result)
50 {
51 for (Iterator i = iterator(); i.hasNext();) {
52 if (i.next().equals(result)) {
53
54 return false;
55 }
56 }
57 return super.add(result);
58 }
59
60 public Action[] getActions()
61 {
62 return new Action[] { new DownloadAction(), };
63 }
64
65 public OpenNapSearchResult[] getResults()
66 {
67 return (OpenNapSearchResult[])results.toArray(new OpenNapSearchResult[0]);
68 }
69
70
71
72
73 private class DownloadAction extends AbstractDownloadAction {
74
75 /***
76 *
77 */
78 public void actionPerformed(ActionEvent e)
79 {
80 if (isNotInLibrary(getShortFilename())) {
81 OpenNapPlugin.getTransferManager().download(getResults());
82 }
83 }
84
85 }
86
87 }