1 |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
4 |
* Copyright (C) 2005-2008 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.fantasia; |
24 |
|
25 |
import java.awt.BorderLayout; |
26 |
import java.awt.Dimension; |
27 |
import java.awt.Graphics; |
28 |
import java.awt.Insets; |
29 |
|
30 |
import java.beans.PropertyChangeEvent; |
31 |
import java.beans.PropertyChangeListener; |
32 |
|
33 |
import javax.swing.BorderFactory; |
34 |
import javax.swing.JPanel; |
35 |
|
36 |
import org.jdesktop.swingx.JXTaskPane; |
37 |
|
38 |
import org.jvnet.substance.SubstanceLookAndFeel; |
39 |
import org.jvnet.substance.api.SubstanceConstants.FocusKind; |
40 |
import org.jvnet.substance.shaper.ClassicButtonShaper; |
41 |
|
42 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
43 |
import static org.jsampler.view.fantasia.FantasiaPrefs.*; |
44 |
|
45 |
/** |
46 |
* |
47 |
* @author Grigor Iliev |
48 |
*/ |
49 |
public class DevicesPane extends FantasiaPanel { |
50 |
private final TaskPaneContainer taskPaneContainer = new TaskPaneContainer(); |
51 |
private final JXTaskPane midiDevicesTaskPane = new FantasiaTaskPane(); |
52 |
private final JXTaskPane audioDevicesTaskPane = new FantasiaTaskPane(); |
53 |
|
54 |
private final MidiDevicesPane midiDevicesPane = new MidiDevicesPane(); |
55 |
private final AudioDevicesPane audioDevicesPane = new AudioDevicesPane(); |
56 |
|
57 |
/** Creates a new instance of <code>DevicesPane</code> */ |
58 |
public |
59 |
DevicesPane() { |
60 |
setOpaque(false); |
61 |
setLayout(new BorderLayout()); |
62 |
midiDevicesTaskPane.setTitle(i18n.getLabel("DevicesPane.midiDevicesTaskPane")); |
63 |
midiDevicesTaskPane.setAnimated(preferences().getBoolProperty(ANIMATED)); |
64 |
|
65 |
preferences().addPropertyChangeListener(ANIMATED, new PropertyChangeListener() { |
66 |
public void |
67 |
propertyChange(PropertyChangeEvent e) { |
68 |
boolean b = preferences().getBoolProperty(ANIMATED); |
69 |
midiDevicesTaskPane.setAnimated(b); |
70 |
} |
71 |
}); |
72 |
|
73 |
audioDevicesTaskPane.setTitle(i18n.getLabel("DevicesPane.audioDevicesTaskPane")); |
74 |
audioDevicesTaskPane.setAnimated(preferences().getBoolProperty(ANIMATED)); |
75 |
|
76 |
preferences().addPropertyChangeListener(ANIMATED, new PropertyChangeListener() { |
77 |
public void |
78 |
propertyChange(PropertyChangeEvent e) { |
79 |
boolean b = preferences().getBoolProperty(ANIMATED); |
80 |
audioDevicesTaskPane.setAnimated(b); |
81 |
} |
82 |
}); |
83 |
|
84 |
midiDevicesTaskPane.putClientProperty ( |
85 |
SubstanceLookAndFeel.FOCUS_KIND, FocusKind.NONE |
86 |
); |
87 |
|
88 |
taskPaneContainer.putClientProperty ( |
89 |
SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY, new ClassicButtonShaper() |
90 |
); |
91 |
|
92 |
taskPaneContainer.add(midiDevicesTaskPane); |
93 |
taskPaneContainer.add(audioDevicesTaskPane); |
94 |
taskPaneContainer.setBorder(BorderFactory.createEmptyBorder()); |
95 |
add(taskPaneContainer); |
96 |
|
97 |
FantasiaSubPanel fsp = new FantasiaSubPanel(false, true, false); |
98 |
fsp.add(midiDevicesPane); |
99 |
midiDevicesTaskPane.add(fsp); |
100 |
|
101 |
fsp = new FantasiaSubPanel(false, true, false); |
102 |
fsp.add(audioDevicesPane); |
103 |
audioDevicesTaskPane.add(fsp); |
104 |
|
105 |
taskPaneContainer.setOpaque(false); |
106 |
} |
107 |
|
108 |
public MidiDevicesPane |
109 |
getMidiDevicesPane() { return midiDevicesPane; } |
110 |
|
111 |
public AudioDevicesPane |
112 |
getAudioDevicesPane() { return audioDevicesPane; } |
113 |
} |