/[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 1743 - (show annotations) (download)
Sat May 31 23:04:01 2008 UTC (15 years, 10 months ago) by iliev
File size: 3685 byte(s)
* Renamed the column labels in the Channel Routing dialog: The column
  representing the sampler channel's audio channels is "Audio In" and
  the column representing the audio device's channels is "Audio Out"
* Remember the last used tab in the Preferences dialog
* Fantasia: The sampler channels are now referenced by their position
  in the list, not by their ID
* Fantasia: Implemented options to show the channel number and/or the MIDI
  input port/channel on the sampler channel screen when using Small View
  (choose Edit/Preferences, then click the `Channels' tab)
* Fantasia: Migrated to substance 5

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.util.List;
29
30 import javax.swing.JComponent;
31 import javax.swing.JPanel;
32 import javax.swing.JScrollPane;
33 import javax.swing.JSplitPane;
34 import javax.swing.RowSorter.SortKey;
35 import javax.swing.SortOrder;
36
37 import javax.swing.event.ChangeEvent;
38 import javax.swing.event.ChangeListener;
39
40 import org.jsampler.CC;
41
42 import org.jsampler.view.InstrumentsDbTreeModel;
43 import org.jsampler.view.std.JSInstrumentsDbTable;
44
45 import org.jvnet.substance.SubstanceLookAndFeel;
46
47 import static org.jsampler.view.fantasia.FantasiaPrefs.preferences;
48
49
50 /**
51 *
52 * @author Grigor Iliev
53 */
54 public class InstrumentsDbPane extends JPanel {
55 private final FantasiaInstrumentsDbTree instrumentsDbTree;
56 private final JSInstrumentsDbTable instrumentsTable;
57 private final JSplitPane splitPane;
58
59 /** Creates a new instance of <code>InstrumentsDbPane</code> */
60 public
61 InstrumentsDbPane() {
62 setLayout(new BorderLayout());
63 if(CC.getInstrumentsDbTreeModel() != null) {
64 instrumentsDbTree = new FantasiaInstrumentsDbTree(CC.getInstrumentsDbTreeModel());
65 } else {
66 instrumentsDbTree = new FantasiaInstrumentsDbTree(new InstrumentsDbTreeModel(true));
67 }
68
69 instrumentsTable = new JSInstrumentsDbTable(instrumentsDbTree);
70 instrumentsTable.getModel().showNameColumnOnly();
71 instrumentsTable.getModel().setShowDummyColumn(true);
72 instrumentsTable.loadColumnWidths("InstrumentsDbPane.");
73 instrumentsTable.getRowSorter().toggleSortOrder(0);
74 boolean b = preferences().getBoolProperty("InstrumentsDbPane.reverseSortOrder");
75 if(b) instrumentsTable.getRowSorter().toggleSortOrder(0);
76
77 CC.addInstrumentsDbChangeListener(new ChangeListener() {
78 public void
79 stateChanged(ChangeEvent e) {
80 instrumentsDbTree.setModel(CC.getInstrumentsDbTreeModel());
81
82 CC.scheduleInTaskQueue(new Runnable() {
83 public void
84 run() { instrumentsDbTree.setSelectedDirectory("/"); }
85 });
86 }
87 });
88
89 instrumentsDbTree.setSelectedDirectory("/");
90
91 JScrollPane sp1 = new JScrollPane(instrumentsDbTree);
92 sp1.setPreferredSize(new Dimension(200, 200));
93 JScrollPane sp2 = new JScrollPane(instrumentsTable);
94 sp2.setPreferredSize(new Dimension(200, 200));
95 sp2.setOpaque(false);
96 sp2.getViewport().setOpaque(false);
97
98 splitPane = new JSplitPane (
99 JSplitPane.VERTICAL_SPLIT,
100 true, // continuousLayout
101 sp1,
102 sp2
103 );
104
105 add(splitPane);
106 }
107
108 protected void
109 savePreferences() {
110 instrumentsTable.saveColumnWidths("InstrumentsDbPane.");
111
112 List<? extends SortKey> list = instrumentsTable.getRowSorter().getSortKeys();
113 if(list.isEmpty()) return;
114 SortKey k = list.get(0);
115 if(k.getColumn() != 0) return;
116 boolean b = k.getSortOrder() == SortOrder.DESCENDING;
117 preferences().setBoolProperty("InstrumentsDbPane.reverseSortOrder", b);
118 }
119 }

  ViewVC Help
Powered by ViewVC