/[svn]/jsampler/trunk/src/org/jsampler/view/classic/DbSearchPage.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/classic/DbSearchPage.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1285 - (show annotations) (download)
Fri Aug 10 19:55:03 2007 UTC (16 years, 8 months ago) by iliev
File size: 4039 byte(s)
* Updated to version 0.6a. The Fantasia distribution is now
  capable of controlling all features available in LinuxSampler

1 /*
2 * JSampler - a java front-end for LinuxSampler
3 *
4 * Copyright (C) 2005-2007 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.classic;
24
25 import java.awt.BorderLayout;
26 import java.awt.Cursor;
27 import java.awt.Dimension;
28 import java.awt.Frame;
29 import java.awt.Insets;
30
31 import java.awt.event.ActionEvent;
32 import java.awt.event.ActionListener;
33 import java.awt.event.MouseAdapter;
34 import java.awt.event.MouseEvent;
35
36 import javax.swing.BoxLayout;
37 import javax.swing.JComponent;
38 import javax.swing.JLabel;
39 import javax.swing.JPanel;
40 import javax.swing.JToggleButton;
41
42 import javax.swing.event.ChangeEvent;
43 import javax.swing.event.ChangeListener;
44
45 import net.sf.juife.NavigationPage;
46
47 import org.jsampler.view.std.JSDbSearchPane;
48
49 import static org.jsampler.view.classic.ClassicI18n.i18n;
50
51 /**
52 *
53 * @author Grigor Iliev
54 */
55 public class DbSearchPage extends NavigationPage {
56 private final DbSearchPane dbSearchPane;
57
58 /** Creates a new instance of <code>DbSearchPage</code> */
59 public
60 DbSearchPage(final InstrumentsDbFrame frame) {
61 setTitle(i18n.getLabel("DbSearchPage.title"));
62 setLayout(new BorderLayout());
63
64 dbSearchPane = new DbSearchPane(frame);
65 dbSearchPane.setBackgroundColor(java.awt.Color.WHITE);
66 add(dbSearchPane);
67
68 dbSearchPane.addChangeListener(new ChangeListener() {
69 public void
70 stateChanged(ChangeEvent e) {
71 frame.setSearchResults (
72 dbSearchPane.getDirectoryResults(),
73 dbSearchPane.getInstrumentResults()
74 );
75 }
76 });
77 }
78
79 class DbSearchPane extends JSDbSearchPane {
80 DbSearchPane(Frame owner) {
81 super(owner);
82
83
84 }
85
86 protected JComponent
87 createCriteriaPane(String title, JComponent mainPane) {
88 return new CriteriaPane(title, mainPane);
89 }
90 }
91
92 class CriteriaPane extends JPanel {
93
94 CriteriaPane(String title, final JComponent mainPane) {
95 setOpaque(false);
96
97 final JToggleButton btn = new JToggleButton();
98 btn.setBorderPainted(false);
99 btn.setContentAreaFilled(false);
100 btn.setFocusPainted(false);
101 btn.setIcon(Res.iconBack16);
102 btn.setSelectedIcon(Res.iconDown16);
103 btn.setMargin(new Insets(0, 0, 0, 0));
104 btn.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
105 btn.setOpaque(false);
106
107 final JLabel l = new JLabel(title);
108 l.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
109 int h = l.getMaximumSize().height;
110 Dimension d = new Dimension(Short.MAX_VALUE, h);
111 l.setMaximumSize(d);
112 l.setOpaque(false);
113
114 setLayout(new BorderLayout());
115 JPanel p = new JPanel();
116 p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
117 p.add(l);
118 p.add(btn);
119 add(p, BorderLayout.NORTH);
120 p.setOpaque(false);
121
122 mainPane.setVisible(false);
123 add(mainPane);
124
125 h = getMaximumSize().height;
126 d = new Dimension(Short.MAX_VALUE, h);
127 setMaximumSize(d);
128
129 btn.addActionListener(new ActionListener() {
130 public void
131 actionPerformed(ActionEvent e) {
132 mainPane.setVisible(btn.isSelected());
133 }
134 });
135
136 l.addMouseListener(new MouseAdapter() {
137 public void
138 mouseClicked(MouseEvent e) {
139 if(e.getButton() != e.BUTTON1) return;
140 if(e.getClickCount() != 1) return;
141
142 btn.doClick();
143 }
144 });
145
146 h = getPreferredSize().height;
147 setMaximumSize(new Dimension(Short.MAX_VALUE, h));
148
149 setAlignmentX(LEFT_ALIGNMENT);
150 }
151 }
152 }

  ViewVC Help
Powered by ViewVC