/[svn]/jsampler/trunk/src/org/jsampler/view/fantasia/RightSidePane.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/fantasia/RightSidePane.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1785 - (show annotations) (download)
Tue Oct 7 00:07:14 2008 UTC (15 years, 6 months ago) by iliev
File size: 4289 byte(s)
* Fantasia: Implemented multiple channels panels
* Fantasia: Refactoring - all basic UI components moved to
  org.jsampler.view.fantasia.basic package

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

  ViewVC Help
Powered by ViewVC