/[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 1729 - (show annotations) (download)
Tue Apr 29 22:22:40 2008 UTC (16 years ago) by iliev
File size: 3574 byte(s)
* Added support for handling lost files in the Instruments Database
  (In the Instruments Database window choose Actions/Check For Lost Files)
* Fantasia: Added option to show the Instruments Database
  on the Right-Side Pane of the Fantasia's main window
  (choose Edit/Preferences, then click the `View' tab)
* Added new menu item in the Instruments Database window: Edit/Find
* Some minor bugfixes and enhancements

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

  ViewVC Help
Powered by ViewVC