1 |
iliev |
1205 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
|
|
* Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com> |
5 |
|
|
* |
6 |
|
|
* This file is part of JSampler. |
7 |
|
|
* |
8 |
|
|
* JSampler is free software; you can redistribute it and/or modify |
9 |
|
|
* it under the terms of the GNU General Public License version 2 |
10 |
|
|
* as published by the Free Software Foundation. |
11 |
|
|
* |
12 |
|
|
* JSampler is distributed in the hope that it will be useful, |
13 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 |
|
|
* GNU General Public License for more details. |
16 |
|
|
* |
17 |
|
|
* You should have received a copy of the GNU General Public License |
18 |
|
|
* along with JSampler; if not, write to the Free Software |
19 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
20 |
|
|
* MA 02111-1307 USA |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
package org.jsampler.view.classic; |
24 |
|
|
|
25 |
|
|
import java.awt.Dimension; |
26 |
|
|
import java.awt.GridBagConstraints; |
27 |
|
|
import java.awt.GridBagLayout; |
28 |
|
|
import java.awt.Insets; |
29 |
|
|
|
30 |
|
|
import javax.swing.JLabel; |
31 |
|
|
import javax.swing.JPanel; |
32 |
|
|
import javax.swing.JSeparator; |
33 |
|
|
import javax.swing.JTextArea; |
34 |
|
|
|
35 |
|
|
import org.linuxsampler.lscp.DbInstrumentInfo; |
36 |
|
|
|
37 |
|
|
import static org.jsampler.view.classic.ClassicI18n.i18n; |
38 |
|
|
|
39 |
|
|
|
40 |
|
|
/** |
41 |
|
|
* |
42 |
|
|
* @author Grigor Iliev |
43 |
|
|
*/ |
44 |
|
|
public class DbInstrumentPropsPane extends JPanel { |
45 |
|
|
private final JLabel lName = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lName")); |
46 |
|
|
private final JLabel lLocation = |
47 |
|
|
new JLabel(i18n.getLabel("DbInstrumentPropsPane.lLocation")); |
48 |
|
|
|
49 |
|
|
private final JLabel lSize = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lSize")); |
50 |
|
|
|
51 |
|
|
private final JLabel lFormat = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lFormat")); |
52 |
|
|
private final JLabel lType = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lType")); |
53 |
|
|
private final JLabel lDesc = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lDesc")); |
54 |
|
|
private final JLabel lCreated = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lCreated")); |
55 |
|
|
private final JLabel lModified = |
56 |
|
|
new JLabel(i18n.getLabel("DbInstrumentPropsPane.lModified")); |
57 |
|
|
|
58 |
|
|
private final JLabel lFile = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lFile")); |
59 |
|
|
private final JLabel lIndex = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lIndex")); |
60 |
|
|
private final JLabel lProduct = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lProduct")); |
61 |
|
|
private final JLabel lArtists = new JLabel(i18n.getLabel("DbInstrumentPropsPane.lArtists")); |
62 |
|
|
private final JLabel lKeywords = |
63 |
|
|
new JLabel(i18n.getLabel("DbInstrumentPropsPane.lKeywords")); |
64 |
|
|
|
65 |
|
|
private final TextArea taName = new TextArea(); |
66 |
|
|
private final TextArea taLocation = new TextArea(); |
67 |
|
|
private final TextArea taSize = new TextArea(); |
68 |
|
|
private final TextArea taFormat = new TextArea(); |
69 |
|
|
private final TextArea taType = new TextArea(); |
70 |
|
|
private final TextArea taDesc = new TextArea(); |
71 |
|
|
private final TextArea taCreated = new TextArea(); |
72 |
|
|
private final TextArea taModified = new TextArea(); |
73 |
|
|
private final TextArea taFile = new TextArea(); |
74 |
|
|
private final TextArea taIndex = new TextArea(); |
75 |
|
|
private final TextArea taProduct = new TextArea(); |
76 |
|
|
private final TextArea taArtists = new TextArea(); |
77 |
|
|
private final TextArea taKeywords = new TextArea(); |
78 |
|
|
|
79 |
|
|
/** Creates a new instance of <code>DbInstrumentPropsPane</code> */ |
80 |
|
|
public DbInstrumentPropsPane(DbInstrumentInfo instrInfo) { |
81 |
|
|
setInstrumentInfo(instrInfo); |
82 |
|
|
|
83 |
|
|
GridBagLayout gridbag = new GridBagLayout(); |
84 |
|
|
GridBagConstraints c = new GridBagConstraints(); |
85 |
|
|
|
86 |
|
|
setLayout(gridbag); |
87 |
|
|
|
88 |
|
|
c.fill = GridBagConstraints.NONE; |
89 |
|
|
|
90 |
|
|
c.gridx = 0; |
91 |
|
|
c.gridy = 0; |
92 |
|
|
c.anchor = GridBagConstraints.NORTHEAST; |
93 |
|
|
c.insets = new Insets(3, 3, 3, 3); |
94 |
|
|
gridbag.setConstraints(lName, c); |
95 |
|
|
add(lName); |
96 |
|
|
|
97 |
|
|
c.gridx = 0; |
98 |
|
|
c.gridy = 2; |
99 |
|
|
gridbag.setConstraints(lLocation, c); |
100 |
|
|
add(lLocation); |
101 |
|
|
|
102 |
|
|
c.gridx = 0; |
103 |
|
|
c.gridy = 3; |
104 |
|
|
gridbag.setConstraints(lSize, c); |
105 |
|
|
add(lSize); |
106 |
|
|
|
107 |
|
|
c.gridx = 0; |
108 |
|
|
c.gridy = 4; |
109 |
|
|
gridbag.setConstraints(lFormat, c); |
110 |
|
|
add(lFormat); |
111 |
|
|
|
112 |
|
|
c.gridx = 0; |
113 |
|
|
c.gridy = 5; |
114 |
|
|
gridbag.setConstraints(lType, c); |
115 |
|
|
add(lType); |
116 |
|
|
|
117 |
|
|
c.gridx = 0; |
118 |
|
|
c.gridy = 6; |
119 |
|
|
gridbag.setConstraints(lDesc, c); |
120 |
|
|
add(lDesc); |
121 |
|
|
|
122 |
|
|
c.gridx = 0; |
123 |
|
|
c.gridy = 8; |
124 |
|
|
gridbag.setConstraints(lCreated, c); |
125 |
|
|
add(lCreated); |
126 |
|
|
|
127 |
|
|
c.gridx = 0; |
128 |
|
|
c.gridy = 9; |
129 |
|
|
gridbag.setConstraints(lModified, c); |
130 |
|
|
add(lModified); |
131 |
|
|
|
132 |
|
|
c.gridx = 0; |
133 |
|
|
c.gridy = 11; |
134 |
|
|
gridbag.setConstraints(lFile, c); |
135 |
|
|
add(lFile); |
136 |
|
|
|
137 |
|
|
c.gridx = 0; |
138 |
|
|
c.gridy = 12; |
139 |
|
|
gridbag.setConstraints(lIndex, c); |
140 |
|
|
add(lIndex); |
141 |
|
|
|
142 |
|
|
c.gridx = 0; |
143 |
|
|
c.gridy = 14; |
144 |
|
|
gridbag.setConstraints(lProduct, c); |
145 |
|
|
add(lProduct); |
146 |
|
|
|
147 |
|
|
c.gridx = 0; |
148 |
|
|
c.gridy = 15; |
149 |
|
|
gridbag.setConstraints(lArtists, c); |
150 |
|
|
add(lArtists); |
151 |
|
|
|
152 |
|
|
c.gridx = 0; |
153 |
|
|
c.gridy = 16; |
154 |
|
|
gridbag.setConstraints(lKeywords, c); |
155 |
|
|
add(lKeywords); |
156 |
|
|
|
157 |
|
|
c.fill = GridBagConstraints.HORIZONTAL; |
158 |
|
|
c.gridx = 1; |
159 |
|
|
c.gridy = 0; |
160 |
|
|
c.weightx = 1.0; |
161 |
|
|
c.anchor = GridBagConstraints.NORTHWEST; |
162 |
|
|
gridbag.setConstraints(taName, c); |
163 |
|
|
add(taName); |
164 |
|
|
|
165 |
|
|
c.gridx = 1; |
166 |
|
|
c.gridy = 2; |
167 |
|
|
gridbag.setConstraints(taLocation, c); |
168 |
|
|
add(taLocation); |
169 |
|
|
|
170 |
|
|
c.gridx = 1; |
171 |
|
|
c.gridy = 3; |
172 |
|
|
gridbag.setConstraints(taSize, c); |
173 |
|
|
add(taSize); |
174 |
|
|
|
175 |
|
|
c.gridx = 1; |
176 |
|
|
c.gridy = 4; |
177 |
|
|
gridbag.setConstraints(taFormat, c); |
178 |
|
|
add(taFormat); |
179 |
|
|
|
180 |
|
|
c.gridx = 1; |
181 |
|
|
c.gridy = 5; |
182 |
|
|
gridbag.setConstraints(taType, c); |
183 |
|
|
add(taType); |
184 |
|
|
|
185 |
|
|
c.gridx = 1; |
186 |
|
|
c.gridy = 6; |
187 |
|
|
gridbag.setConstraints(taDesc, c); |
188 |
|
|
add(taDesc); |
189 |
|
|
|
190 |
|
|
c.gridx = 1; |
191 |
|
|
c.gridy = 8; |
192 |
|
|
gridbag.setConstraints(taCreated, c); |
193 |
|
|
add(taCreated); |
194 |
|
|
|
195 |
|
|
c.gridx = 1; |
196 |
|
|
c.gridy = 9; |
197 |
|
|
gridbag.setConstraints(taModified, c); |
198 |
|
|
add(taModified); |
199 |
|
|
|
200 |
|
|
c.gridx = 1; |
201 |
|
|
c.gridy = 11; |
202 |
|
|
gridbag.setConstraints(taFile, c); |
203 |
|
|
add(taFile); |
204 |
|
|
|
205 |
|
|
c.gridx = 1; |
206 |
|
|
c.gridy = 12; |
207 |
|
|
gridbag.setConstraints(taIndex, c); |
208 |
|
|
add(taIndex); |
209 |
|
|
|
210 |
|
|
c.gridx = 1; |
211 |
|
|
c.gridy = 14; |
212 |
|
|
gridbag.setConstraints(taProduct, c); |
213 |
|
|
add(taProduct); |
214 |
|
|
|
215 |
|
|
c.gridx = 1; |
216 |
|
|
c.gridy = 15; |
217 |
|
|
gridbag.setConstraints(taArtists, c); |
218 |
|
|
add(taArtists); |
219 |
|
|
|
220 |
|
|
c.gridx = 1; |
221 |
|
|
c.gridy = 16; |
222 |
|
|
gridbag.setConstraints(taKeywords, c); |
223 |
|
|
add(taKeywords); |
224 |
|
|
|
225 |
|
|
JSeparator sep = new JSeparator(); |
226 |
|
|
c.gridx = 0; |
227 |
|
|
c.gridy = 1; |
228 |
|
|
c.gridwidth = 2; |
229 |
|
|
gridbag.setConstraints(sep, c); |
230 |
|
|
add(sep); |
231 |
|
|
|
232 |
|
|
sep = new JSeparator(); |
233 |
|
|
c.gridx = 0; |
234 |
|
|
c.gridy = 7; |
235 |
|
|
gridbag.setConstraints(sep, c); |
236 |
|
|
add(sep); |
237 |
|
|
|
238 |
|
|
sep = new JSeparator(); |
239 |
|
|
c.gridx = 0; |
240 |
|
|
c.gridy = 10; |
241 |
|
|
gridbag.setConstraints(sep, c); |
242 |
|
|
add(sep); |
243 |
|
|
|
244 |
|
|
sep = new JSeparator(); |
245 |
|
|
c.gridx = 0; |
246 |
|
|
c.gridy = 13; |
247 |
|
|
gridbag.setConstraints(sep, c); |
248 |
|
|
add(sep); |
249 |
|
|
|
250 |
|
|
JPanel p = new JPanel(); |
251 |
|
|
p.setOpaque(false); |
252 |
|
|
c.gridx = 0; |
253 |
|
|
c.gridy = 17; |
254 |
|
|
c.weightx = 1.0; |
255 |
|
|
c.weighty = 1.0; |
256 |
|
|
c.fill = GridBagConstraints.BOTH; |
257 |
|
|
gridbag.setConstraints(p, c); |
258 |
|
|
add(p); |
259 |
|
|
|
260 |
|
|
Dimension d = getPreferredSize(); |
261 |
|
|
int w = d.width > 300 ? d.width : 300; |
262 |
|
|
int h = d.height > 300 ? d.height : 300; |
263 |
|
|
setPreferredSize(new Dimension(w, h)); |
264 |
|
|
} |
265 |
|
|
|
266 |
|
|
public void |
267 |
|
|
setInstrumentInfo(DbInstrumentInfo instrInfo) { |
268 |
|
|
taName.setText(instrInfo.getName()); |
269 |
|
|
taLocation.setText(instrInfo.getDirectoryPath()); |
270 |
|
|
|
271 |
|
|
String s = instrInfo.getFormatedSize(); |
272 |
|
|
s += " (" + String.valueOf(instrInfo.getSize()) + " bytes)"; |
273 |
|
|
taSize.setText(s); |
274 |
|
|
|
275 |
|
|
s = instrInfo.getFormatFamily(); |
276 |
|
|
if(s.equals("GIG")) s = "GigaSampler"; |
277 |
|
|
String ver = instrInfo.getFormatVersion(); |
278 |
|
|
if(ver != null & ver.length() > 0) s += ", version " + ver; |
279 |
|
|
taFormat.setText(s); |
280 |
|
|
|
281 |
|
|
if(instrInfo.isDrum()) taType.setText(i18n.getLabel("DbInstrumentPropsPane.drum")); |
282 |
|
|
else taType.setText(i18n.getLabel("DbInstrumentPropsPane.chromatic")); |
283 |
|
|
|
284 |
|
|
taDesc.setText(instrInfo.getDescription()); |
285 |
|
|
taCreated.setText(instrInfo.getDateCreated().toString()); |
286 |
|
|
taModified.setText(instrInfo.getDateModified().toString()); |
287 |
|
|
taFile.setText(instrInfo.getFilePath()); |
288 |
|
|
taIndex.setText(String.valueOf(instrInfo.getInstrumentIndex())); |
289 |
|
|
taProduct.setText(instrInfo.getProduct()); |
290 |
|
|
taArtists.setText(instrInfo.getArtists()); |
291 |
|
|
taKeywords.setText(instrInfo.getKeywords()); |
292 |
|
|
} |
293 |
|
|
|
294 |
|
|
private class |
295 |
|
|
TextArea extends JTextArea { |
296 |
|
|
TextArea() { |
297 |
|
|
setLineWrap(true); |
298 |
|
|
setEditable(false); |
299 |
|
|
setOpaque(false); |
300 |
|
|
} |
301 |
|
|
} |
302 |
|
|
} |