/[svn]/jsampler/trunk/src/org/jsampler/view/std/JSAddMidiInstrumentMapDlg.java
ViewVC logotype

Contents of /jsampler/trunk/src/org/jsampler/view/std/JSAddMidiInstrumentMapDlg.java

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1286 - (show annotations) (download)
Fri Aug 10 20:24:23 2007 UTC (16 years, 9 months ago) by iliev
File size: 2945 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.std;
24
25 import java.awt.Dimension;
26
27 import javax.swing.Box;
28 import javax.swing.BoxLayout;
29 import javax.swing.JLabel;
30 import javax.swing.JPanel;
31 import javax.swing.JTextField;
32
33 import javax.swing.event.DocumentEvent;
34 import javax.swing.event.DocumentListener;
35
36 import net.sf.juife.OkCancelDialog;
37
38 import org.jsampler.CC;
39
40 import static org.jsampler.view.std.StdI18n.i18n;
41
42
43 /**
44 *
45 * @author Grigor Iliev
46 */
47 public class JSAddMidiInstrumentMapDlg extends OkCancelDialog {
48 private final JLabel lName = new JLabel(i18n.getLabel("JSAddMidiInstrumentMapDlg.lName"));
49 private final JTextField tfName = new JTextField();
50
51 /**
52 * Creates a new instance of <code>JSAddMidiInstrumentMapDlg</code>
53 */
54 public
55 JSAddMidiInstrumentMapDlg() {
56 super(CC.getMainFrame(), i18n.getLabel("JSAddMidiInstrumentMapDlg.title"));
57 JPanel p = new JPanel();
58 p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
59 p.add(lName);
60 p.add(Box.createRigidArea(new Dimension(6, 0)));
61 p.add(tfName);
62 p.setPreferredSize(new Dimension(250, p.getPreferredSize().height));
63 setMainPane(p);
64 updateState();
65 tfName.getDocument().addDocumentListener(getHandler());
66 }
67
68 /**
69 * Gets the chosen name for the new MIDI instrument map.
70 * @return The chosen name for the new MIDI instrument map.
71 */
72 public String
73 getMapName() { return tfName.getText(); }
74
75 /**
76 * Sets the text name text field.
77 */
78 public void
79 setMapName(String name) { tfName.setText(name); }
80
81 protected void
82 onOk() {
83 if(!btnOk.isEnabled()) return;
84
85 setVisible(false);
86 setCancelled(false);
87 }
88
89 protected void
90 onCancel() { setVisible(false); }
91
92 private void
93 updateState() { btnOk.setEnabled(tfName.getText().length() != 0); }
94
95 private final Handler eventHandler = new Handler();
96
97 private Handler
98 getHandler() { return eventHandler; }
99
100 private class Handler implements DocumentListener {
101 // DocumentListener
102 public void
103 insertUpdate(DocumentEvent e) { updateState(); }
104
105 public void
106 removeUpdate(DocumentEvent e) { updateState(); }
107
108 public void
109 changedUpdate(DocumentEvent e) { updateState(); }
110 }
111 }

  ViewVC Help
Powered by ViewVC