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.JComboBox; |
31 |
import javax.swing.JPanel; |
32 |
|
33 |
import net.sf.juife.OkCancelDialog; |
34 |
|
35 |
import org.jsampler.CC; |
36 |
import org.jsampler.MidiInstrumentMap; |
37 |
|
38 |
import static org.jsampler.view.classic.ClassicI18n.i18n; |
39 |
|
40 |
|
41 |
/** |
42 |
* |
43 |
* @author Grigor Iliev |
44 |
*/ |
45 |
public class RemoveMidiInstrumentMapDlg extends OkCancelDialog { |
46 |
private final JLabel lMap = new JLabel(i18n.getLabel("RemoveMidiInstrumentMapDlg.lMap")); |
47 |
private final JComboBox cbMaps = new JComboBox(); |
48 |
|
49 |
/** Creates a new instance of <code>RemoveMidiInstrumentMapDlg</code> */ |
50 |
public |
51 |
RemoveMidiInstrumentMapDlg() { |
52 |
this(null); |
53 |
} |
54 |
|
55 |
/** |
56 |
* Creates a new instance of <code>RemoveMidiInstrumentMapDlg</code>. |
57 |
* @param map The map to be selected for removal. |
58 |
*/ |
59 |
public |
60 |
RemoveMidiInstrumentMapDlg(MidiInstrumentMap map) { |
61 |
super(CC.getMainFrame(), i18n.getLabel("RemoveMidiInstrumentMapDlg.title")); |
62 |
JPanel p = new JPanel(); |
63 |
p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS)); |
64 |
p.add(lMap); |
65 |
p.add(Box.createRigidArea(new Dimension(6, 0))); |
66 |
p.add(cbMaps); |
67 |
setMainPane(p); |
68 |
|
69 |
for(MidiInstrumentMap m : CC.getSamplerModel().getMidiInstrumentMaps()) { |
70 |
cbMaps.addItem(m); |
71 |
} |
72 |
if(map != null) cbMaps.setSelectedItem(map); |
73 |
|
74 |
pack(); |
75 |
} |
76 |
|
77 |
/** |
78 |
* Gets the selected map to be deleted. |
79 |
* @return The selected map to be deleted. |
80 |
*/ |
81 |
public MidiInstrumentMap |
82 |
getSelectedMap() { return (MidiInstrumentMap)cbMaps.getSelectedItem(); } |
83 |
|
84 |
protected void |
85 |
onOk() { |
86 |
if(!btnOk.isEnabled()) return; |
87 |
|
88 |
setVisible(false); |
89 |
setCancelled(false); |
90 |
} |
91 |
|
92 |
protected void |
93 |
onCancel() { setVisible(false); } |
94 |
} |