1 |
iliev |
1729 |
/* |
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 |
|
|
|
28 |
|
|
import java.beans.PropertyChangeEvent; |
29 |
|
|
import java.beans.PropertyChangeListener; |
30 |
|
|
|
31 |
|
|
import javax.swing.BorderFactory; |
32 |
|
|
import javax.swing.JScrollPane; |
33 |
|
|
import javax.swing.JTabbedPane; |
34 |
|
|
|
35 |
|
|
import javax.swing.event.ChangeEvent; |
36 |
|
|
import javax.swing.event.ChangeListener; |
37 |
|
|
|
38 |
iliev |
1743 |
import org.jvnet.substance.SubstanceLookAndFeel; |
39 |
|
|
|
40 |
iliev |
1729 |
import static org.jsampler.view.fantasia.FantasiaI18n.i18n; |
41 |
|
|
import static org.jsampler.view.fantasia.FantasiaPrefs.preferences; |
42 |
|
|
|
43 |
|
|
|
44 |
|
|
/** |
45 |
|
|
* |
46 |
|
|
* @author Grigor Iliev |
47 |
|
|
*/ |
48 |
|
|
public class RightSidePane extends PixmapPane { |
49 |
|
|
private JTabbedPane tabbedPane = new JTabbedPane(); |
50 |
|
|
private InstrumentsDbPane instrumentsDbPane = null; |
51 |
|
|
private final DevicesPane devicesPane = new DevicesPane(); |
52 |
|
|
private final JScrollPane spDevicesPane = new JScrollPane(); |
53 |
|
|
|
54 |
|
|
|
55 |
|
|
/** |
56 |
|
|
* Creates a new instance of <code>RightSidePane</code> |
57 |
|
|
*/ |
58 |
|
|
public |
59 |
|
|
RightSidePane() { |
60 |
|
|
super(Res.gfxRoundBg14); |
61 |
|
|
setOpaque(false); |
62 |
|
|
setPixmapInsets(new java.awt.Insets(6, 6, 6, 6)); |
63 |
|
|
setBorder(BorderFactory.createEmptyBorder(6, 6, 6, 6)); |
64 |
|
|
setLayout(new BorderLayout()); |
65 |
|
|
|
66 |
|
|
spDevicesPane.setOpaque(false); |
67 |
|
|
spDevicesPane.getViewport().setOpaque(false); |
68 |
|
|
spDevicesPane.setViewportView(devicesPane); |
69 |
|
|
spDevicesPane.setBorder(BorderFactory.createEmptyBorder()); |
70 |
|
|
int h = spDevicesPane.getMinimumSize().height; |
71 |
|
|
spDevicesPane.setMinimumSize(new Dimension(200, h)); |
72 |
|
|
|
73 |
|
|
final String s = "rightSidePane.showInstrumentsDb"; |
74 |
|
|
setTabbedView(preferences().getBoolProperty(s)); |
75 |
|
|
|
76 |
iliev |
1743 |
tabbedPane.setBackground(new java.awt.Color(0x828282)); |
77 |
|
|
tabbedPane.putClientProperty(SubstanceLookAndFeel.COLORIZATION_FACTOR, 1.0); |
78 |
|
|
|
79 |
iliev |
1729 |
preferences().addPropertyChangeListener(s, getHandler()); |
80 |
|
|
} |
81 |
|
|
|
82 |
|
|
private void |
83 |
|
|
setTabbedView(boolean b) { |
84 |
|
|
remove(spDevicesPane); |
85 |
|
|
remove(tabbedPane); |
86 |
|
|
|
87 |
|
|
tabbedPane.removeChangeListener(getHandler()); |
88 |
|
|
tabbedPane.removeAll(); |
89 |
|
|
|
90 |
|
|
if(b) { |
91 |
|
|
if(instrumentsDbPane == null) instrumentsDbPane = new InstrumentsDbPane(); |
92 |
|
|
tabbedPane.addTab(i18n.getLabel("RightSidePane.tabDevices"), spDevicesPane); |
93 |
|
|
tabbedPane.addTab(i18n.getLabel("RightSidePane.tabInstrumentsDb"), instrumentsDbPane); |
94 |
|
|
tabbedPane.addChangeListener(getHandler()); |
95 |
|
|
add(tabbedPane); |
96 |
|
|
|
97 |
|
|
int i = preferences().getIntProperty("rightSidePane.tabIndex", 0); |
98 |
|
|
if(tabbedPane.getTabCount() > i) tabbedPane.setSelectedIndex(i); |
99 |
|
|
} else { |
100 |
|
|
add(spDevicesPane); |
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
validate(); |
104 |
|
|
} |
105 |
|
|
|
106 |
|
|
protected void |
107 |
|
|
savePreferences() { |
108 |
|
|
if(instrumentsDbPane != null) instrumentsDbPane.savePreferences(); |
109 |
|
|
} |
110 |
|
|
|
111 |
|
|
private final EventHandler eventHandler = new EventHandler(); |
112 |
|
|
|
113 |
|
|
private EventHandler |
114 |
|
|
getHandler() { return eventHandler; } |
115 |
|
|
|
116 |
|
|
private class EventHandler implements ChangeListener, PropertyChangeListener { |
117 |
|
|
public void |
118 |
|
|
stateChanged(ChangeEvent e) { |
119 |
|
|
int idx = tabbedPane.getSelectedIndex(); |
120 |
|
|
if(idx == -1) return; |
121 |
|
|
preferences().setIntProperty("rightSidePane.tabIndex", idx); |
122 |
|
|
} |
123 |
|
|
|
124 |
|
|
public void |
125 |
|
|
propertyChange(PropertyChangeEvent e) { |
126 |
|
|
setTabbedView(preferences().getBoolProperty("rightSidePane.showInstrumentsDb")); |
127 |
|
|
} |
128 |
|
|
} |
129 |
|
|
} |