1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.xnap.plugin.freeway;
20
21 import java.awt.event.ActionEvent;
22
23 import javax.swing.Action;
24 import javax.swing.Icon;
25
26 import org.gnu.freeway.protocol.afs.esed2.RootNode;
27 import org.xnap.XNap;
28 import org.xnap.gui.action.AbstractDownloadAction;
29 import org.xnap.gui.util.FocusManager;
30 import org.xnap.peer.Peer;
31 import org.xnap.plugin.Plugin;
32 import org.xnap.search.AbstractSearchResult;
33 import org.xnap.search.SearchResult;
34 import org.xnap.search.SearchResultContainer;
35 import org.xnap.transfer.DownloadManager;
36 import org.xnap.util.Formatter;
37
38 /***
39 *
40 */
41 public class FreewaySearchResult extends AbstractSearchResult
42 {
43
44 RootNode node;
45
46 /***
47 *
48 */
49 public FreewaySearchResult(RootNode node)
50 {
51 this.node = node;
52
53 put(XNap.tr("Filesize"), Formatter.formatSize(getFilesize()));
54 put(XNap.tr("CRC"), new Integer(node.getFileIdentifier().getFileCRC()));
55 put(XNap.tr("Description"), node.getDescription());
56 put(XNap.tr("Mimetype"), node.getMimeType());
57 put(XNap.tr("URI"), node.getFileIdentifier().toURI());
58 put(XNap.tr("Query Hash"), node.getFileIdentifier().chk.query.toHex());
59 put(XNap.tr("Key Hash"), node.getFileIdentifier().chk.key.toHex());
60 }
61
62
63
64
65 public boolean canGroup(SearchResult result)
66 {
67 return false;
68 }
69
70
71
72
73 public SearchResultContainer createContainer()
74 {
75 return null;
76 }
77
78 public Icon getIcon()
79 {
80 return FreewayPlugin.ICON_16;
81 }
82
83
84
85
86 public Action[] getActions()
87 {
88 return new Action[] { new FreewayDownloadAction() };
89 }
90
91
92
93
94 public int getAvailability()
95 {
96 return 0;
97 }
98
99
100
101
102 public String getFilename()
103 {
104 return node.getFileName();
105 }
106
107
108
109
110 public long getFilesize()
111 {
112 return node.getFileIdentifier().getFileLength();
113 }
114
115
116
117
118 public Object getHash()
119 {
120 return new Integer(node.getFileIdentifier().getFileCRC());
121 }
122
123
124
125
126 public Plugin getPlugin()
127 {
128 return null;
129 }
130
131
132
133
134 public Peer getPeer()
135 {
136 return null;
137 }
138
139 private class FreewayDownloadAction extends AbstractDownloadAction
140 {
141 public void actionPerformed(ActionEvent e)
142 {
143 DownloadManager.getInstance().add(new FreewayDownload(node));
144 FocusManager.setFocusTo("transfer",e);
145 }
146 }
147 }