/[svn]/jsampler/trunk/src/org/jsampler/view/classic/DbDirectoryPropsPane.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/classic/DbDirectoryPropsPane.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1205 - (show annotations) (download)
Thu May 24 21:55:41 2007 UTC (16 years, 10 months ago) by iliev
File size: 6637 byte(s)
* upgrading to version 0.5a

1 /*
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 net.sf.juife.Task;
36
37 import net.sf.juife.event.TaskEvent;
38 import net.sf.juife.event.TaskListener;
39
40 import org.jsampler.CC;
41 import org.jsampler.task.InstrumentsDb;
42
43 import org.linuxsampler.lscp.DbDirectoryInfo;
44
45 import static org.jsampler.view.classic.ClassicI18n.i18n;
46
47
48 /**
49 *
50 * @author Grigor Iliev
51 */
52 public class DbDirectoryPropsPane extends JPanel {
53 private final JLabel lName = new JLabel(i18n.getLabel("DbDirectoryPropsPane.lName"));
54 private final JLabel lType = new JLabel(i18n.getLabel("DbDirectoryPropsPane.lType"));
55 private final JLabel lLocation = new JLabel(i18n.getLabel("DbDirectoryPropsPane.lLocation"));
56 private final JLabel lContains = new JLabel(i18n.getLabel("DbDirectoryPropsPane.lContains"));
57 private final JLabel lCreated = new JLabel(i18n.getLabel("DbDirectoryPropsPane.lCreated"));
58 private final JLabel lModified = new JLabel(i18n.getLabel("DbDirectoryPropsPane.lModified"));
59 private final JLabel lDesc = new JLabel(i18n.getLabel("DbDirectoryPropsPane.lDesc"));
60
61 private final TextArea taName = new TextArea();
62 private final TextArea taType = new TextArea();
63 private final TextArea taLocation = new TextArea();
64 private final TextArea taContains = new TextArea();
65 private final TextArea taCreated = new TextArea();
66 private final TextArea taModified = new TextArea();
67 private final TextArea taDesc = new TextArea();
68
69 private DbDirectoryInfo directoryInfo;
70
71
72 /** Creates a new instance of <code>DbDirectoryPropsPane</code> */
73 public
74 DbDirectoryPropsPane(DbDirectoryInfo dirInfo) {
75 setDirectoryInfo(dirInfo);
76
77 GridBagLayout gridbag = new GridBagLayout();
78 GridBagConstraints c = new GridBagConstraints();
79
80 setLayout(gridbag);
81
82 c.fill = GridBagConstraints.NONE;
83
84 c.gridx = 0;
85 c.gridy = 0;
86 c.anchor = GridBagConstraints.NORTHEAST;
87 c.insets = new Insets(3, 3, 3, 3);
88 gridbag.setConstraints(lName, c);
89 add(lName);
90
91 c.gridx = 0;
92 c.gridy = 2;
93 gridbag.setConstraints(lType, c);
94 add(lType);
95
96 c.gridx = 0;
97 c.gridy = 3;
98 gridbag.setConstraints(lLocation, c);
99 add(lLocation);
100
101 c.gridx = 0;
102 c.gridy = 4;
103 gridbag.setConstraints(lContains, c);
104 add(lContains);
105
106 c.gridx = 0;
107 c.gridy = 6;
108 gridbag.setConstraints(lCreated, c);
109 add(lCreated);
110
111 c.gridx = 0;
112 c.gridy = 7;
113 gridbag.setConstraints(lModified, c);
114 add(lModified);
115
116 c.gridx = 0;
117 c.gridy = 9;
118 gridbag.setConstraints(lDesc, c);
119 add(lDesc);
120
121 c.fill = GridBagConstraints.HORIZONTAL;
122 c.gridx = 1;
123 c.gridy = 0;
124 c.weightx = 1.0;
125 c.anchor = GridBagConstraints.NORTHWEST;
126 gridbag.setConstraints(taName, c);
127 add(taName);
128
129 c.gridx = 1;
130 c.gridy = 2;
131 gridbag.setConstraints(taType, c);
132 add(taType);
133
134 c.gridx = 1;
135 c.gridy = 3;
136 gridbag.setConstraints(taLocation, c);
137 add(taLocation);
138
139 c.gridx = 1;
140 c.gridy = 4;
141 gridbag.setConstraints(taContains, c);
142 add(taContains);
143
144 c.gridx = 1;
145 c.gridy = 6;
146 gridbag.setConstraints(taCreated, c);
147 add(taCreated);
148
149 c.gridx = 1;
150 c.gridy = 7;
151 gridbag.setConstraints(taModified, c);
152 add(taModified);
153
154 c.gridx = 1;
155 c.gridy = 9;
156 gridbag.setConstraints(taDesc, c);
157 add(taDesc);
158
159 JSeparator sep = new JSeparator();
160 c.gridx = 0;
161 c.gridy = 1;
162 c.gridwidth = 2;
163 gridbag.setConstraints(sep, c);
164 add(sep);
165
166 sep = new JSeparator();
167 c.gridx = 0;
168 c.gridy = 5;
169 gridbag.setConstraints(sep, c);
170 add(sep);
171
172 sep = new JSeparator();
173 c.gridx = 0;
174 c.gridy = 8;
175 gridbag.setConstraints(sep, c);
176 add(sep);
177
178 JPanel p = new JPanel();
179 p.setOpaque(false);
180 c.gridx = 0;
181 c.gridy = 10;
182 c.weightx = 1.0;
183 c.weighty = 1.0;
184 c.fill = GridBagConstraints.BOTH;
185 gridbag.setConstraints(p, c);
186 add(p);
187
188 Dimension d = getPreferredSize();
189 int w = d.width > 300 ? d.width : 300;
190 int h = d.height > 300 ? d.height : 300;
191 setPreferredSize(new Dimension(w, h));
192 }
193
194 public DbDirectoryInfo
195 getDirectoryInfo() { return directoryInfo; }
196
197 public void
198 setDirectoryInfo(DbDirectoryInfo dirInfo) {
199 directoryInfo = dirInfo;
200
201 taName.setText(dirInfo.getName());
202 taType.setText(i18n.getLabel("DbDirectoryPropsPane.folder"));
203 taLocation.setText(dirInfo.getParentDirectoryPath());
204 taCreated.setText(dirInfo.getDateCreated().toString());
205 taModified.setText(dirInfo.getDateModified().toString());
206 taDesc.setText(dirInfo.getDescription());
207
208 updateContentInfo();
209 }
210
211 private void
212 updateContentInfo() {
213 taContains.setText(i18n.getLabel("DbDirectoryPropsPane.calc"));
214
215 final Task<Integer> t1, t2;
216 t1 = new InstrumentsDb.GetInstrumentCount(directoryInfo.getDirectoryPath(), true);
217 t2 = new InstrumentsDb.GetDirectoryCount(directoryInfo.getDirectoryPath(), true);
218
219 t1.addTaskListener(new TaskListener() {
220 public void
221 taskPerformed(TaskEvent e) {
222 if(t1.doneWithErrors()) {
223 String s = i18n.getLabel("DbDirectoryPropsPane.unknown");
224 taContains.setText(s);
225 return;
226 }
227
228 CC.getTaskQueue().add(t2);
229 }
230 });
231
232 t2.addTaskListener(new TaskListener() {
233 public void
234 taskPerformed(TaskEvent e) {
235 if(t2.doneWithErrors()) {
236 String s = i18n.getLabel("DbDirectoryPropsPane.unknown");
237 taContains.setText(s);
238 return;
239 }
240
241 int ic = t1.getResult();
242 int dc = t2.getResult();
243 String s = i18n.getLabel("DbDirectoryPropsPane.contains", ic, dc);
244 taContains.setText(s);
245 }
246 });
247
248 CC.getTaskQueue().add(t1);
249 }
250
251 private class
252 TextArea extends JTextArea {
253 TextArea() {
254 setLineWrap(true);
255 setEditable(false);
256 setOpaque(false);
257 }
258 }
259 }

  ViewVC Help
Powered by ViewVC