/[svn]/jsampler/trunk/src/org/jsampler/view/classic/ManageOrchestrasPage.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/classic/ManageOrchestrasPage.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1540 - (show annotations) (download)
Mon Dec 3 23:22:02 2007 UTC (16 years, 4 months ago) by iliev
File size: 7301 byte(s)
* Fantasia: by default the volume values are now shown in decibels
* Implemented support for retrieving instrument information
  from instrument files
* Some bugfixes and enhancements

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.classic;
24
25 import java.awt.Dimension;
26
27 import java.awt.datatransfer.DataFlavor;
28
29 import java.awt.event.ActionEvent;
30 import java.awt.event.ActionListener;
31 import java.awt.event.MouseAdapter;
32 import java.awt.event.MouseEvent;
33
34 import java.util.logging.Level;
35
36 import javax.swing.AbstractAction;
37 import javax.swing.Action;
38 import javax.swing.Box;
39 import javax.swing.BoxLayout;
40 import javax.swing.JComponent;
41 import javax.swing.JPanel;
42 import javax.swing.JScrollPane;
43 import javax.swing.JSplitPane;
44 import javax.swing.JToolBar;
45 import javax.swing.ListSelectionModel;
46 import javax.swing.TransferHandler;
47
48 import javax.swing.event.ListSelectionEvent;
49 import javax.swing.event.ListSelectionListener;
50
51 import net.sf.juife.JuifeUtils;
52 import net.sf.juife.LinkButton;
53 import net.sf.juife.NavigationPage;
54
55 import org.jsampler.CC;
56 import org.jsampler.DOMUtils;
57 import org.jsampler.DefaultOrchestraModel;
58 import org.jsampler.HF;
59 import org.jsampler.OrchestraListModel;
60 import org.jsampler.OrchestraModel;
61
62 import org.jsampler.view.InstrumentTable;
63 import org.jsampler.view.InstrumentTableModel;
64 import org.jsampler.view.OrchestraTable;
65 import org.jsampler.view.OrchestraTableModel;
66
67 import org.jsampler.view.std.JSManageOrchestrasPane;
68 import org.jsampler.view.std.JSOrchestraPane;
69
70 import static org.jsampler.view.classic.ClassicI18n.i18n;
71 import org.jsampler.view.std.JSAddOrEditOrchestraDlg;
72
73
74 /**
75 *
76 * @author Grigor Iliev
77 */
78 public class ManageOrchestrasPage extends NavigationPage {
79 private final JComponent manageOrchestrasPane;
80 OrchestraTable orchestraTable;
81
82 private LinkButton lnkOrchestras =
83 new LinkButton(i18n.getButtonLabel("ManageOrchestrasPage.lnkOrchestras"));
84
85 private OrchestraPane orchestraPane = new OrchestraPane();
86
87
88 /** Creates a new instance of <code>ManageOrchestrasPage</code>. */
89 public ManageOrchestrasPage() {
90 setTitle(i18n.getLabel("ManageOrchestrasPage.title"));
91
92 setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
93
94 manageOrchestrasPane = createManageOrchestrasPane();
95 add(manageOrchestrasPane);
96
97 installListeneres();
98 }
99
100 class ManageOrchestrasPane extends JSManageOrchestrasPane {
101 ManageOrchestrasPane() {
102 actionAddOrchestra.putValue(Action.SMALL_ICON, Res.iconNew16);
103 actionEditOrchestra.putValue(Action.SMALL_ICON, Res.iconEdit16);
104 actionDeleteOrchestra.putValue(Action.SMALL_ICON, Res.iconDelete16);
105 actionOrchestraUp.putValue(Action.SMALL_ICON, Res.iconUp16);
106 actionOrchestraDown.putValue(Action.SMALL_ICON, Res.iconDown16);
107
108 removeAll();
109
110 JToolBar toolBar = new JToolBar();
111 toolBar.add(new ToolbarButton(actionAddOrchestra));
112 toolBar.add(new ToolbarButton(actionEditOrchestra));
113 toolBar.add(new ToolbarButton(actionDeleteOrchestra));
114
115 toolBar.addSeparator();
116
117 toolBar.add(new ToolbarButton(actionOrchestraUp));
118 toolBar.add(new ToolbarButton(actionOrchestraDown));
119
120 toolBar.setFloatable(false);
121 add(toolBar, java.awt.BorderLayout.NORTH);
122
123 JScrollPane sp = new JScrollPane(orchestraTable);
124 Dimension d;
125 d = new Dimension(sp.getMinimumSize().width, sp.getPreferredSize().height);
126 sp.setPreferredSize(d);
127
128 add(sp);
129
130 ManageOrchestrasPage.this.orchestraTable = this.orchestraTable;
131 }
132 }
133
134 class OrchestraPane extends JSOrchestraPane {
135 OrchestraPane() {
136 actionAddInstrument.putValue(Action.SMALL_ICON, Res.iconNew16);
137 actionEditInstrument.putValue(Action.SMALL_ICON, Res.iconEdit16);
138 actionDeleteInstrument.putValue(Action.SMALL_ICON, Res.iconDelete16);
139 actionInstrumentUp.putValue(Action.SMALL_ICON, Res.iconUp16);
140 actionInstrumentDown.putValue(Action.SMALL_ICON, Res.iconDown16);
141
142 removeAll();
143
144 JToolBar toolBar = new JToolBar();
145 toolBar.add(new ToolbarButton(actionAddInstrument));
146 toolBar.add(new ToolbarButton(actionEditInstrument));
147 toolBar.add(new ToolbarButton(actionDeleteInstrument));
148
149 toolBar.addSeparator();
150
151 toolBar.add(new ToolbarButton(actionInstrumentUp));
152 toolBar.add(new ToolbarButton(actionInstrumentDown));
153
154 toolBar.setFloatable(false);
155 add(toolBar, java.awt.BorderLayout.NORTH);
156
157 JScrollPane sp = new JScrollPane(instrumentTable);
158 Dimension d;
159 d = new Dimension(sp.getMinimumSize().width, sp.getPreferredSize().height);
160 sp.setPreferredSize(d);
161
162 add(sp);
163 }
164 }
165
166 private JComponent
167 createManageOrchestrasPane() {
168 JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
169 splitPane.setContinuousLayout(true);
170 splitPane.setTopComponent(new ManageOrchestrasPane());
171 splitPane.setBottomComponent(orchestraPane);
172 splitPane.setDividerSize(3);
173 splitPane.setDividerLocation(180);
174
175 return splitPane;
176 }
177
178 private void
179 installListeneres() {
180 lnkOrchestras.addActionListener(new ActionListener() {
181 public void
182 actionPerformed(ActionEvent e) {
183 LeftPane.getLeftPane().showOrchestrasPage();
184 }
185 });
186
187 OrchestraSelectionHandler l = new OrchestraSelectionHandler();
188 orchestraTable.getSelectionModel().addListSelectionListener(l);
189 }
190
191 public class DnDScrollPane extends JScrollPane {
192 private InstrumentTable instrumentTable;
193
194 private
195 DnDScrollPane(InstrumentTable table) {
196 instrumentTable = table;
197 setViewport(new DnDViewPort());
198 setViewportView(instrumentTable);
199
200 Dimension d;
201 d = new Dimension(getMinimumSize().width, getPreferredSize().height);
202 setPreferredSize(d);
203 }
204
205 public class DnDViewPort extends javax.swing.JViewport {
206 private
207 DnDViewPort() {
208 setTransferHandler(new TransferHandler("instrument") {
209 public boolean
210 canImport(JComponent comp, DataFlavor[] flavors) {
211 if(instrumentTable.isPerformingDnD()) return false;
212
213 if(orchestraPane.getSelectedInstrument() == null) {
214 return false;
215 }
216
217 return super.canImport(comp, flavors);
218 }
219 });
220
221 addMouseListener(new MouseAdapter() {
222 public void
223 mouseClicked(MouseEvent e) {
224 instrumentTable.clearSelection();
225 }
226 });
227 }
228
229 public String
230 getInstrument() { return null; }
231
232 public void
233 setInstrument(String instr) {
234 instrumentTable.setSelectedInstrument(null);
235 instrumentTable.setInstrument(instr);
236 }
237 }
238 }
239
240 private class OrchestraSelectionHandler implements ListSelectionListener {
241 public void
242 valueChanged(ListSelectionEvent e) {
243 if(e.getValueIsAdjusting()) return;
244
245 orchestraPane.setOrchestra(orchestraTable.getSelectedOrchestra());
246 }
247 }
248 }

  ViewVC Help
Powered by ViewVC