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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1778 - (show annotations) (download)
Sun Sep 28 20:38:36 2008 UTC (15 years, 6 months ago) by iliev
File size: 4336 byte(s)
* Fantasia: Improved look and feel
* Fantasia: Added buttons for increasing/decreasing the key number
  of the MIDI keyboard (Ctrl+Up Arrow/Ctrl+Down Arrow)
* Fantasia: Added buttons for scrolling left/right on the MIDI keyboard
  (Ctrl+Left Arrow/Ctrl+Right Arrow)
* Added key bindings for triggering MIDI notes using the computer keyboard
  (from a to ' for the white keys and from 0 to 7 for changing the octaves)
* Notes are now triggered when dragging the mouse over the MIDI keyboard

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.awt.event.ActionEvent;
29 import java.awt.event.ActionListener;
30
31 import javax.swing.Action;
32 import javax.swing.JButton;
33 import javax.swing.JPanel;
34 import javax.swing.JScrollPane;
35 import javax.swing.JSplitPane;
36 import javax.swing.JToolBar;
37
38 import org.jsampler.CC;
39
40 import org.jsampler.view.InstrumentsDbTreeModel;
41
42 import static org.jsampler.view.fantasia.FantasiaPrefs.preferences;
43 import org.jsampler.view.std.JSInstrumentsDbColumnPreferencesDlg;
44 import org.jsampler.view.std.JSInstrumentsDbTable;
45
46
47 /**
48 *
49 * @author Grigor Iliev
50 */
51 public class InstrumentsDbPane extends JPanel {
52 private final FantasiaInstrumentsDbTree instrumentsDbTree;
53 private final JSInstrumentsDbTable instrumentsTable;
54 private final JSplitPane splitPane;
55
56 /** Creates a new instance of <code>InstrumentsDbPane</code> */
57 public
58 InstrumentsDbPane() {
59 setLayout(new BorderLayout());
60 if(CC.getInstrumentsDbTreeModel() != null) {
61 instrumentsDbTree = new FantasiaInstrumentsDbTree(CC.getInstrumentsDbTreeModel());
62 } else {
63 instrumentsDbTree = new FantasiaInstrumentsDbTree(new InstrumentsDbTreeModel(true));
64 }
65
66 instrumentsTable = new JSInstrumentsDbTable(instrumentsDbTree, "InstrumentsDbPane.");
67 instrumentsTable.getModel().setShowDummyColumn(true);
68 instrumentsTable.loadColumnsVisibleState();
69 instrumentsTable.loadColumnWidths();
70 instrumentsTable.loadSortOrder();
71
72 instrumentsDbTree.setSelectedDirectory("/");
73
74 JScrollPane sp1 = new JScrollPane(instrumentsDbTree);
75 sp1.setPreferredSize(new Dimension(200, 200));
76 JScrollPane sp2 = new JScrollPane(instrumentsTable);
77 sp2.setPreferredSize(new Dimension(200, 200));
78 sp2.setOpaque(false);
79 sp2.getViewport().setOpaque(false);
80
81 splitPane = new JSplitPane (
82 JSplitPane.VERTICAL_SPLIT,
83 true, // continuousLayout
84 sp1,
85 sp2
86 );
87
88 splitPane.setResizeWeight(0.4);
89
90 add(splitPane);
91 add(new ToolBar(), BorderLayout.NORTH);
92
93 int i = preferences().getIntProperty("InstrumentsDbPane.splitDividerLocation", 160);
94 splitPane.setDividerLocation(i);
95 }
96
97 protected void
98 savePreferences() {
99 instrumentsTable.saveColumnsVisibleState();
100 instrumentsTable.saveColumnWidths();
101
102 int i = splitPane.getDividerLocation();
103 preferences().setIntProperty("InstrumentsDbPane.splitDividerLocation", i);
104 }
105
106 class ToolBar extends JToolBar {
107 protected final JButton btnGoUp = new ToolbarButton(instrumentsDbTree.actionGoUp);
108 protected final JButton btnGoBack = new ToolbarButton(instrumentsDbTree.actionGoBack);
109 protected final JButton btnGoForward = new ToolbarButton(instrumentsDbTree.actionGoForward);
110 protected final JButton btnReload = new ToolbarButton(instrumentsTable.reloadAction);
111 protected final JButton btnPreferences = new ToolbarButton(null);
112
113 public ToolBar() {
114 super("");
115 setFloatable(false);
116
117 add(btnGoBack);
118 add(btnGoForward);
119 add(btnGoUp);
120
121 instrumentsTable.reloadAction.putValue(Action.SMALL_ICON, Res.iconReload16);
122 add(btnReload);
123
124 addSeparator();
125
126 btnPreferences.setIcon(Res.iconPreferences16);
127 add(btnPreferences);
128
129 btnPreferences.addActionListener(new ActionListener() {
130 public void
131 actionPerformed(ActionEvent e) {
132 new PreferencesDlg().setVisible(true);
133 }
134 });
135 }
136 }
137
138 class PreferencesDlg extends JSInstrumentsDbColumnPreferencesDlg {
139 PreferencesDlg() {
140 super(CC.getMainFrame(), instrumentsTable);
141 }
142 }
143 }

  ViewVC Help
Powered by ViewVC