1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005 Grigor Kirilov Iliev |
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.MediaTracker; |
27 |
|
28 |
import java.awt.event.ActionEvent; |
29 |
import java.awt.event.ActionListener; |
30 |
|
31 |
import java.net.URL; |
32 |
|
33 |
import java.util.logging.Level; |
34 |
|
35 |
import javax.swing.BorderFactory; |
36 |
import javax.swing.Box; |
37 |
import javax.swing.BoxLayout; |
38 |
import javax.swing.ImageIcon; |
39 |
import javax.swing.JLabel; |
40 |
import javax.swing.JPanel; |
41 |
import javax.swing.JSeparator; |
42 |
|
43 |
import net.sf.juife.LinkButton; |
44 |
import net.sf.juife.NavigationPage; |
45 |
|
46 |
import org.jsampler.CC; |
47 |
|
48 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
49 |
import static org.jsampler.view.classic.LeftPane.getLeftPane; |
50 |
|
51 |
|
52 |
/** |
53 |
* |
54 |
* @author Grigor Iliev |
55 |
*/ |
56 |
public class TasksPage extends NavigationPage { |
57 |
private LinkButton lnkMidiDevices = |
58 |
new LinkButton(i18n.getButtonLabel("TasksPage.lnkMidiDevices")); |
59 |
private LinkButton lnkNewMidiDevice = |
60 |
new LinkButton(i18n.getButtonLabel("TasksPage.lnkNewMidiDevice")); |
61 |
private LinkButton lnkAudioDevices = |
62 |
new LinkButton(i18n.getButtonLabel("TasksPage.lnkAudioDevices")); |
63 |
private LinkButton lnkNewAudioDevice = |
64 |
new LinkButton(i18n.getButtonLabel("TasksPage.lnkNewAudioDevice")); |
65 |
private LinkButton lnkNewChannel = |
66 |
new LinkButton(i18n.getButtonLabel("TasksPage.lnkNewChannel")); |
67 |
private LinkButton lnkNewChannelWizard = |
68 |
new LinkButton(i18n.getButtonLabel("TasksPage.lnkNewChannelWizard")); |
69 |
private LinkButton lnkOrchestras = |
70 |
new LinkButton(i18n.getButtonLabel("TasksPage.lnkOrchestras")); |
71 |
private LinkButton lnkManageOrchestras = |
72 |
new LinkButton(i18n.getButtonLabel("TasksPage.lnkManageOrchestras")); |
73 |
|
74 |
|
75 |
private LinkButton lnkRefreshSampler = |
76 |
new LinkButton(i18n.getButtonLabel("TasksPage.lnkRefreshSampler")); |
77 |
|
78 |
/** Creates a new instance of <code>TasksPage</code> */ |
79 |
public |
80 |
TasksPage() { |
81 |
setTitle(i18n.getLabel("TasksPage.title")); |
82 |
|
83 |
int h = lnkRefreshSampler.getPreferredSize().height; |
84 |
try { |
85 |
URL url = ClassLoader.getSystemClassLoader().getResource ( |
86 |
"org/jsampler/view/classic/res/icons/Refresh16.gif" |
87 |
); |
88 |
|
89 |
ImageIcon icon = new ImageIcon(url); |
90 |
if(icon.getImageLoadStatus() == MediaTracker.COMPLETE) |
91 |
lnkRefreshSampler.setIcon(icon); |
92 |
} catch(Exception x) { CC.getLogger().log(Level.INFO, x.getMessage(), x); } |
93 |
|
94 |
lnkRefreshSampler.setText(i18n.getButtonLabel("TasksPage.lnkRefreshSampler")); |
95 |
lnkRefreshSampler.setMaximumSize(lnkRefreshSampler.getPreferredSize()); |
96 |
setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
97 |
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
98 |
|
99 |
JLabel lChannels = new JLabel(i18n.getLabel("TasksPage.lChannels")); |
100 |
add(lChannels); |
101 |
|
102 |
JSeparator sep = new JSeparator(); |
103 |
sep.setMaximumSize(new Dimension(Short.MAX_VALUE, sep.getPreferredSize().height)); |
104 |
add(sep); |
105 |
|
106 |
JPanel p = new JPanel(); |
107 |
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); |
108 |
p.setBorder(BorderFactory.createEmptyBorder(6, 12, 17, 0)); |
109 |
|
110 |
p.add(lnkNewChannel); |
111 |
p.add(lnkNewChannelWizard); |
112 |
p.add(Box.createGlue()); |
113 |
p.setMaximumSize(p.getPreferredSize()); |
114 |
|
115 |
add(p); |
116 |
|
117 |
JLabel lMidiDevices = new JLabel(i18n.getLabel("TasksPage.lMidiDevices")); |
118 |
add(lMidiDevices); |
119 |
sep = new JSeparator(); |
120 |
sep.setMaximumSize(new Dimension(Short.MAX_VALUE, sep.getPreferredSize().height)); |
121 |
add(sep); |
122 |
|
123 |
p = new JPanel(); |
124 |
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); |
125 |
p.setBorder(BorderFactory.createEmptyBorder(6, 12, 17, 0)); |
126 |
|
127 |
p.add(lnkNewMidiDevice); |
128 |
p.add(lnkMidiDevices); |
129 |
p.add(Box.createGlue()); |
130 |
p.setMaximumSize(p.getPreferredSize()); |
131 |
|
132 |
add(p); |
133 |
|
134 |
JLabel lAudioDevices = new JLabel(i18n.getLabel("TasksPage.lAudioDevices")); |
135 |
add(lAudioDevices); |
136 |
|
137 |
sep = new JSeparator(); |
138 |
sep.setMaximumSize(new Dimension(Short.MAX_VALUE, sep.getPreferredSize().height)); |
139 |
add(sep); |
140 |
|
141 |
p = new JPanel(); |
142 |
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); |
143 |
p.setBorder(BorderFactory.createEmptyBorder(6, 12, 17, 0)); |
144 |
|
145 |
p.add(lnkNewAudioDevice); |
146 |
p.add(lnkAudioDevices); |
147 |
p.add(Box.createGlue()); |
148 |
p.setMaximumSize(p.getPreferredSize()); |
149 |
|
150 |
add(p); |
151 |
|
152 |
JLabel lOrchestras = new JLabel(i18n.getLabel("TasksPage.lOrchestras")); |
153 |
add(lOrchestras); |
154 |
|
155 |
sep = new JSeparator(); |
156 |
sep.setMaximumSize(new Dimension(Short.MAX_VALUE, sep.getPreferredSize().height)); |
157 |
add(sep); |
158 |
|
159 |
p = new JPanel(); |
160 |
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); |
161 |
p.setBorder(BorderFactory.createEmptyBorder(6, 12, 17, 0)); |
162 |
|
163 |
p.add(lnkOrchestras); |
164 |
p.add(lnkManageOrchestras); |
165 |
p.add(Box.createGlue()); |
166 |
p.setMaximumSize(p.getPreferredSize()); |
167 |
|
168 |
add(p); |
169 |
|
170 |
add(Box.createGlue()); |
171 |
|
172 |
sep = new JSeparator(); |
173 |
sep.setMaximumSize(new Dimension(Short.MAX_VALUE, sep.getPreferredSize().height)); |
174 |
add(sep); |
175 |
|
176 |
p = new JPanel(); |
177 |
p.setLayout(new BoxLayout(p, BoxLayout.Y_AXIS)); |
178 |
p.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0)); |
179 |
|
180 |
p.add(lnkRefreshSampler); |
181 |
p.add(Box.createGlue()); |
182 |
p.setMaximumSize(p.getPreferredSize()); |
183 |
|
184 |
add(p); |
185 |
|
186 |
lnkNewChannel.addActionListener(new ActionListener() { |
187 |
public void |
188 |
actionPerformed(ActionEvent e) { |
189 |
A4n.newChannel.actionPerformed(null); |
190 |
} |
191 |
}); |
192 |
|
193 |
lnkNewChannelWizard.addActionListener(new ActionListener() { |
194 |
public void |
195 |
actionPerformed(ActionEvent e) { |
196 |
A4n.newChannelWizard.actionPerformed(null); |
197 |
} |
198 |
}); |
199 |
|
200 |
lnkNewMidiDevice.addActionListener(new ActionListener() { |
201 |
public void |
202 |
actionPerformed(ActionEvent e) { |
203 |
A4n.addMidiDevice.actionPerformed(null); |
204 |
} |
205 |
}); |
206 |
|
207 |
lnkMidiDevices.addActionListener(new ActionListener() { |
208 |
public void |
209 |
actionPerformed(ActionEvent e) { getLeftPane().showMidiDevicesPage(); } |
210 |
}); |
211 |
|
212 |
lnkNewAudioDevice.addActionListener(new ActionListener() { |
213 |
public void |
214 |
actionPerformed(ActionEvent e) { |
215 |
A4n.addAudioDevice.actionPerformed(null); |
216 |
} |
217 |
}); |
218 |
|
219 |
lnkAudioDevices.addActionListener(new ActionListener() { |
220 |
public void |
221 |
actionPerformed(ActionEvent e) { getLeftPane().showAudioDevicesPage(); } |
222 |
}); |
223 |
|
224 |
lnkOrchestras.addActionListener(new ActionListener() { |
225 |
public void |
226 |
actionPerformed(ActionEvent e) { getLeftPane().showOrchestrasPage(); } |
227 |
}); |
228 |
|
229 |
lnkManageOrchestras.addActionListener(new ActionListener() { |
230 |
public void |
231 |
actionPerformed(ActionEvent e) { getLeftPane().showManageOrchestrasPage(); } |
232 |
}); |
233 |
|
234 |
lnkRefreshSampler.addActionListener(new ActionListener() { |
235 |
public void |
236 |
actionPerformed(ActionEvent e) { A4n.refresh.actionPerformed(null); } |
237 |
}); |
238 |
} |
239 |
|
240 |
} |