1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2008 Grigor Iliev <grigor@grigoriliev.com> |
* Copyright (C) 2005-2009 Grigor Iliev <grigor@grigoriliev.com> |
5 |
* |
* |
6 |
* This file is part of JSampler. |
* This file is part of JSampler. |
7 |
* |
* |
23 |
package org.jsampler.view.std; |
package org.jsampler.view.std; |
24 |
|
|
25 |
import java.awt.Dialog; |
import java.awt.Dialog; |
|
import java.awt.Dimension; |
|
26 |
import java.awt.Frame; |
import java.awt.Frame; |
27 |
import java.awt.GridBagConstraints; |
import java.awt.GridBagConstraints; |
28 |
import java.awt.GridBagLayout; |
import java.awt.GridBagLayout; |
31 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
32 |
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
33 |
|
|
34 |
|
import javax.swing.JCheckBox; |
35 |
import javax.swing.JComboBox; |
import javax.swing.JComboBox; |
36 |
import javax.swing.JLabel; |
import javax.swing.JLabel; |
37 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
78 |
private final JComboBox cbProgram = new JComboBox(); |
private final JComboBox cbProgram = new JComboBox(); |
79 |
private final JSlider slVolume = new JSlider(0, 100, 100); |
private final JSlider slVolume = new JSlider(0, 100, 100); |
80 |
private final JComboBox cbLoadMode = new JComboBox(); |
private final JComboBox cbLoadMode = new JComboBox(); |
81 |
|
|
82 |
|
private final JCheckBox checkApplyToAll = |
83 |
|
new JCheckBox(i18n.getLabel("JSAddMidiInstrumentDlg.checkApplyToAll")); |
84 |
|
|
85 |
private MidiInstrumentMap map; |
private MidiInstrumentMap map; |
86 |
private Instrument instr; |
private Instrument instr; |
87 |
|
|
88 |
private int mbBase; |
private int mbBase; |
89 |
private int mpBase; |
private int mpBase; |
90 |
|
|
91 |
|
private boolean bShowApplyToAll; |
92 |
|
|
93 |
/** |
/** |
94 |
* Creates a new instance of <code>JSAddMidiInstrumentDlg</code> |
* Creates a new instance of <code>JSAddMidiInstrumentDlg</code> |
95 |
*/ |
*/ |
96 |
public |
public |
97 |
JSAddMidiInstrumentDlg(Frame owner, MidiInstrumentMap map, Instrument instr) { |
JSAddMidiInstrumentDlg(Frame owner, MidiInstrumentMap map, Instrument instr) { |
98 |
super(owner, i18n.getLabel("JSAddMidiInstrumentDlg.title")); |
this(owner, map, instr, false); |
|
initAddMidiInstrumentDlg(map, instr); |
|
99 |
} |
} |
100 |
|
|
101 |
/** |
/** |
103 |
*/ |
*/ |
104 |
public |
public |
105 |
JSAddMidiInstrumentDlg(Dialog owner, MidiInstrumentMap map, Instrument instr) { |
JSAddMidiInstrumentDlg(Dialog owner, MidiInstrumentMap map, Instrument instr) { |
106 |
|
this(owner, map, instr, false); |
107 |
|
} |
108 |
|
|
109 |
|
/** |
110 |
|
* Creates a new instance of <code>JSAddMidiInstrumentDlg</code> |
111 |
|
* @param showApplyToAll Determines whether to show additional check box |
112 |
|
* for remembering the user decision and applying to all selected instruments |
113 |
|
*/ |
114 |
|
public |
115 |
|
JSAddMidiInstrumentDlg(Frame owner, MidiInstrumentMap map, Instrument instr, boolean showApplyToAll) { |
116 |
super(owner, i18n.getLabel("JSAddMidiInstrumentDlg.title")); |
super(owner, i18n.getLabel("JSAddMidiInstrumentDlg.title")); |
117 |
|
bShowApplyToAll = showApplyToAll; |
118 |
|
initAddMidiInstrumentDlg(map, instr); |
119 |
|
} |
120 |
|
|
121 |
|
/** |
122 |
|
* Creates a new instance of <code>JSAddMidiInstrumentDlg</code> |
123 |
|
* @param showApplyToAll Determines whether to show additional check box |
124 |
|
* for remembering the user decision and applying to all selected instruments |
125 |
|
*/ |
126 |
|
public |
127 |
|
JSAddMidiInstrumentDlg(Dialog owner, MidiInstrumentMap map, Instrument instr, boolean showApplyToAll) { |
128 |
|
super(owner, i18n.getLabel("JSAddMidiInstrumentDlg.title")); |
129 |
|
bShowApplyToAll = showApplyToAll; |
130 |
initAddMidiInstrumentDlg(map, instr); |
initAddMidiInstrumentDlg(map, instr); |
131 |
} |
} |
132 |
|
|
199 |
c.gridy = 4; |
c.gridy = 4; |
200 |
gridbag.setConstraints(cbLoadMode, c); |
gridbag.setConstraints(cbLoadMode, c); |
201 |
mainPane.add(cbLoadMode); |
mainPane.add(cbLoadMode); |
202 |
|
|
203 |
|
if(bShowApplyToAll) { |
204 |
|
c.gridx = 0; |
205 |
|
c.gridy = 5; |
206 |
|
c.gridwidth = 2; |
207 |
|
gridbag.setConstraints(checkApplyToAll, c); |
208 |
|
mainPane.add(checkApplyToAll); |
209 |
|
} |
210 |
|
|
211 |
c.gridx = 1; |
c.gridx = 1; |
212 |
c.gridy = 1; |
c.gridy = 1; |
213 |
|
c.gridwidth = 1; |
214 |
c.insets = new Insets(3, 3, 24, 3); |
c.insets = new Insets(3, 3, 24, 3); |
215 |
gridbag.setConstraints(slVolume, c); |
gridbag.setConstraints(slVolume, c); |
216 |
mainPane.add(slVolume); |
mainPane.add(slVolume); |
315 |
/** Gets the selected load mode. */ |
/** Gets the selected load mode. */ |
316 |
public MidiInstrumentInfo.LoadMode |
public MidiInstrumentInfo.LoadMode |
317 |
getLoadMode() { return (MidiInstrumentInfo.LoadMode) cbLoadMode.getSelectedItem(); } |
getLoadMode() { return (MidiInstrumentInfo.LoadMode) cbLoadMode.getSelectedItem(); } |
318 |
|
|
319 |
|
public MidiInstrumentInfo |
320 |
|
getMidiInstrumentInfo() { |
321 |
|
MidiInstrumentInfo instrInfo = new MidiInstrumentInfo(); |
322 |
|
instrInfo.setName(getInstrumentName()); |
323 |
|
instrInfo.setFilePath(instr.getFilePath()); |
324 |
|
instrInfo.setInstrumentIndex(instr.getInstrumentIndex()); |
325 |
|
instrInfo.setEngine(instr.getEngine()); |
326 |
|
instrInfo.setVolume(getVolume()); |
327 |
|
instrInfo.setLoadMode(getLoadMode()); |
328 |
|
|
329 |
|
return instrInfo; |
330 |
|
} |
331 |
|
|
332 |
|
public boolean |
333 |
|
isApplyToAllSelected() { return checkApplyToAll.isSelected(); } |
334 |
|
|
335 |
protected void |
protected void |
336 |
onOk() { |
onOk() { |
340 |
preferences().setIntProperty("lastUsedMidiBank", getMidiBank()); |
preferences().setIntProperty("lastUsedMidiBank", getMidiBank()); |
341 |
preferences().setIntProperty("lastUsedMidiProgram", getMidiProgram()); |
preferences().setIntProperty("lastUsedMidiProgram", getMidiProgram()); |
342 |
|
|
343 |
MidiInstrumentInfo instrInfo = new MidiInstrumentInfo(); |
MidiInstrumentInfo instrInfo = getMidiInstrumentInfo(); |
|
instrInfo.setName(getInstrumentName()); |
|
|
instrInfo.setFilePath(instr.getFilePath()); |
|
|
instrInfo.setInstrumentIndex(instr.getInstrumentIndex()); |
|
|
instrInfo.setEngine(instr.getEngine()); |
|
|
instrInfo.setVolume(getVolume()); |
|
|
instrInfo.setLoadMode(getLoadMode()); |
|
344 |
|
|
345 |
int id = map.getMapId(); |
int id = map.getMapId(); |
346 |
int b = getMidiBank(); |
int b = getMidiBank(); |