/[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 1752 - (show annotations) (download)
Mon Aug 11 22:51:24 2008 UTC (15 years, 8 months ago) by iliev
File size: 4158 byte(s)
* Added toolbar to the Database Instrument Chooser dialog
* Instrument Chooser and Database Instrument Chooser dialogs
  are now resizable
* Fantasia: Added toolbar to the Right-Side Pane's Instruments Database

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

  ViewVC Help
Powered by ViewVC