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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2308 - (show annotations) (download)
Mon Jan 30 09:02:24 2012 UTC (12 years, 2 months ago) by iliev
File size: 3434 byte(s)
* fixed bug #160

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2011 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 package org.jsampler.view.fantasia;
23
24 import java.awt.BorderLayout;
25
26 import javax.swing.JMenuBar;
27 import javax.swing.JPanel;
28 import javax.swing.JScrollPane;
29 import javax.swing.JSplitPane;
30 import javax.swing.event.TreeSelectionEvent;
31 import javax.swing.event.TreeSelectionListener;
32 import javax.swing.tree.TreePath;
33
34 import org.jsampler.CC;
35 import org.jsampler.view.std.JSFrame;
36 import org.jsampler.view.std.JSSamplerTable;
37 import org.jsampler.view.swing.SamplerTreeModel;
38 import org.jsampler.view.swing.SamplerTreeModel.TreeNodeBase;
39
40 import static org.jsampler.view.fantasia.FantasiaI18n.i18n;
41
42 /**
43 *
44 * @author Grigor Iliev
45 */
46 public class SamplerBrowserFrame extends JSFrame {
47 private final JMenuBar menuBar = new JMenuBar();
48
49 private final SidePane sidePane;
50 private final JSplitPane splitPane;
51 private final MainPane mainPane;
52
53 private final FantasiaSamplerTree samplerTree = new FantasiaSamplerTree(new SamplerTreeModel());
54 private final JSSamplerTable samplerTable = new JSSamplerTable(samplerTree);
55
56 /**
57 * Creates a new instance of <code>InstrumentsDbFrame</code>
58 */
59 public
60 SamplerBrowserFrame() {
61 super(i18n.getLabel("SamplerBrowserFrame.title"), "SamplerBrowserFrame");
62 if(Res.iconAppIcon != null) setIconImage(Res.iconAppIcon.getImage());
63
64 ((ViewConfig)CC.getViewConfig()).restoreMenuProperties();
65
66 sidePane = new SidePane();
67 mainPane = new MainPane();
68
69 splitPane = new JSplitPane (
70 JSplitPane.HORIZONTAL_SPLIT,
71 true, // continuousLayout
72 sidePane,
73 mainPane
74 );
75
76 splitPane.setDividerSize(3);
77 splitPane.setDividerLocation(200);
78
79 // fix for moving the menu bar on top of the screen
80 // when running on Mac OS and third party plugin is used
81 ((ViewConfig)CC.getViewConfig()).setNativeMenuProperties();
82
83 addMenu();
84
85 getContentPane().add(splitPane);
86 }
87
88
89
90 private void
91 addMenu() { }
92
93 class MainPane extends JPanel implements TreeSelectionListener {
94 MainPane() {
95 setLayout(new BorderLayout());
96 add(new JScrollPane(samplerTable));
97
98 samplerTree.getSelectionModel().addTreeSelectionListener(this);
99 TreePath path = samplerTree.getSelectionPath();
100 if(path != null) samplerTable.setNode((TreeNodeBase)path.getLastPathComponent());
101 }
102
103 public void
104 valueChanged(TreeSelectionEvent e) {
105 if(e.getNewLeadSelectionPath() == null) {
106 samplerTable.setNode(null);
107 return;
108 }
109
110 samplerTable.setNode((TreeNodeBase)e.getNewLeadSelectionPath().getLastPathComponent());
111 }
112 }
113
114
115 class SidePane extends JPanel {
116 SidePane() {
117 setLayout(new BorderLayout());
118 add(new JScrollPane(samplerTree));
119 }
120 }
121 }

  ViewVC Help
Powered by ViewVC