/[svn]/jsampler/trunk/src/org/jsampler/view/std/JSDbDirectoryPropsPane.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/std/JSDbDirectoryPropsPane.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1343 - (show annotations) (download)
Tue Sep 11 15:38:28 2007 UTC (16 years, 7 months ago) by iliev
File size: 7059 byte(s)
* JS Classic: Added new button to sampler channels
  for starting an instrument editor
* The last used instrument selection method is now
  saved for the next session
* Fantasia: Removed the lock border from non-editable
  text fields in properties panes and LS Console

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

  ViewVC Help
Powered by ViewVC