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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1144 - (show annotations) (download)
Mon Apr 2 21:39:15 2007 UTC (16 years, 11 months ago) by iliev
File size: 2870 byte(s)
- upgrading to version 0.4a

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.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.classic.ClassicI18n.i18n;
41
42
43 /**
44 *
45 * @author Grigor Iliev
46 */
47 public class AddMidiInstrumentMapDlg extends OkCancelDialog {
48 private final JLabel lName = new JLabel(i18n.getLabel("AddMidiInstrumentMapDlg.lName"));
49 private final JTextField tfName = new JTextField();
50
51 /** Creates a new instance of <code>AddMidiInstrumentMapDlg</code> */
52 public
53 AddMidiInstrumentMapDlg() {
54 super(CC.getMainFrame(), i18n.getLabel("AddMidiInstrumentMapDlg.title"));
55 JPanel p = new JPanel();
56 p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
57 p.add(lName);
58 p.add(Box.createRigidArea(new Dimension(6, 0)));
59 p.add(tfName);
60 setMainPane(p);
61 updateState();
62 tfName.getDocument().addDocumentListener(getHandler());
63 }
64
65 /**
66 * Gets the chosen name for the new MIDI instrument map.
67 * @return The chosen name for the new MIDI instrument map.
68 */
69 public String
70 getMapName() { return tfName.getText(); }
71
72 /**
73 * Sets the text name text field.
74 */
75 public void
76 setMapName(String name) { tfName.setText(name); }
77
78 protected void
79 onOk() {
80 if(!btnOk.isEnabled()) return;
81
82 setVisible(false);
83 setCancelled(false);
84 }
85
86 protected void
87 onCancel() { setVisible(false); }
88
89 private void
90 updateState() { btnOk.setEnabled(tfName.getText().length() != 0); }
91
92 private final Handler eventHandler = new Handler();
93
94 private Handler
95 getHandler() { return eventHandler; }
96
97 private class Handler implements DocumentListener {
98 // DocumentListener
99 public void
100 insertUpdate(DocumentEvent e) { updateState(); }
101
102 public void
103 removeUpdate(DocumentEvent e) { updateState(); }
104
105 public void
106 changedUpdate(DocumentEvent e) { updateState(); }
107 }
108 }

  ViewVC Help
Powered by ViewVC