1 |
iliev |
1767 |
/* |
2 |
|
|
* JSampler - a java front-end for LinuxSampler |
3 |
|
|
* |
4 |
iliev |
2288 |
* Copyright (C) 2005-2011 Grigor Iliev <grigor@grigoriliev.com> |
5 |
iliev |
1767 |
* |
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.Dialog; |
26 |
|
|
import java.awt.Dimension; |
27 |
|
|
import java.awt.GridBagConstraints; |
28 |
|
|
import java.awt.GridBagLayout; |
29 |
|
|
import java.awt.Insets; |
30 |
|
|
|
31 |
|
|
import javax.swing.BorderFactory; |
32 |
|
|
import javax.swing.Box; |
33 |
|
|
import javax.swing.BoxLayout; |
34 |
|
|
import javax.swing.JCheckBox; |
35 |
|
|
import javax.swing.JComboBox; |
36 |
|
|
import javax.swing.JLabel; |
37 |
|
|
import javax.swing.JPanel; |
38 |
|
|
|
39 |
iliev |
2288 |
import net.sf.juife.swing.OkCancelDialog; |
40 |
iliev |
1767 |
|
41 |
|
|
import org.jsampler.CC; |
42 |
|
|
|
43 |
|
|
import static org.jsampler.JSPrefs.*; |
44 |
|
|
import static org.jsampler.view.std.StdI18n.i18n; |
45 |
|
|
|
46 |
|
|
|
47 |
|
|
/** |
48 |
|
|
* |
49 |
|
|
* @author Grigor Iliev |
50 |
|
|
*/ |
51 |
|
|
public class JSAdvancedGeneralPropsDlg extends OkCancelDialog { |
52 |
|
|
private final MainPane mainPane = new MainPane(); |
53 |
|
|
|
54 |
|
|
/** Creates a new instance of <code>JSAdvancedGeneralPropsDlg</code> */ |
55 |
|
|
public |
56 |
|
|
JSAdvancedGeneralPropsDlg(Dialog owner) { |
57 |
|
|
super(owner, i18n.getLabel("JSAdvancedGeneralPropsDlg.title")); |
58 |
|
|
btnOk.setText(i18n.getButtonLabel("apply")); |
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
setMainPane(mainPane); |
63 |
|
|
btnOk.requestFocus(); |
64 |
|
|
} |
65 |
|
|
|
66 |
|
|
protected void |
67 |
|
|
onOk() { |
68 |
|
|
if(!btnOk.isEnabled()) return; |
69 |
|
|
|
70 |
|
|
mainPane.apply(); |
71 |
|
|
|
72 |
|
|
setVisible(false); |
73 |
|
|
setCancelled(false); |
74 |
|
|
} |
75 |
|
|
|
76 |
|
|
protected void |
77 |
|
|
onCancel() { setVisible(false); } |
78 |
|
|
|
79 |
|
|
public static class MainPane extends JPanel { |
80 |
iliev |
1818 |
private final JSGeneralProps.MaxVolumePane maxVolumePane = new JSGeneralProps.MaxVolumePane(); |
81 |
iliev |
1767 |
private final MidiBankProgramNumberingPane numberingPane = new MidiBankProgramNumberingPane(); |
82 |
|
|
private final ExportSettingsPane exportSettingsPane = new ExportSettingsPane(); |
83 |
|
|
|
84 |
|
|
public |
85 |
|
|
MainPane() { |
86 |
|
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
87 |
iliev |
1818 |
add(maxVolumePane); |
88 |
|
|
add(Box.createRigidArea(new Dimension(0, 6))); |
89 |
iliev |
1767 |
add(numberingPane); |
90 |
|
|
add(Box.createRigidArea(new Dimension(0, 6))); |
91 |
|
|
add(exportSettingsPane); |
92 |
|
|
} |
93 |
|
|
|
94 |
|
|
public void |
95 |
|
|
apply() { |
96 |
iliev |
1818 |
maxVolumePane.apply(); |
97 |
iliev |
1767 |
numberingPane.apply(); |
98 |
|
|
exportSettingsPane.apply(); |
99 |
|
|
} |
100 |
|
|
} |
101 |
|
|
|
102 |
|
|
public static class MidiBankProgramNumberingPane extends JPanel { |
103 |
|
|
private final JLabel lFirstBank = |
104 |
iliev |
1776 |
new JLabel(i18n.getLabel("JSAdvancedGeneralPropsDlg.lFirstBank")); |
105 |
iliev |
1767 |
|
106 |
|
|
private final JLabel lFirstProgram = |
107 |
|
|
new JLabel(i18n.getLabel("JSAdvancedGeneralPropsDlg.lFirstProgram")); |
108 |
|
|
|
109 |
|
|
private final JComboBox cbFirstBank = new JComboBox(); |
110 |
|
|
private final JComboBox cbFirstProgram = new JComboBox(); |
111 |
|
|
|
112 |
|
|
public |
113 |
|
|
MidiBankProgramNumberingPane() { |
114 |
|
|
GridBagLayout gridbag = new GridBagLayout(); |
115 |
|
|
GridBagConstraints c = new GridBagConstraints(); |
116 |
|
|
|
117 |
|
|
setLayout(gridbag); |
118 |
|
|
|
119 |
|
|
c.fill = GridBagConstraints.NONE; |
120 |
|
|
|
121 |
|
|
c.gridx = 0; |
122 |
|
|
c.gridy = 0; |
123 |
|
|
c.anchor = GridBagConstraints.EAST; |
124 |
|
|
c.insets = new Insets(3, 3, 3, 3); |
125 |
|
|
gridbag.setConstraints(lFirstBank, c); |
126 |
|
|
add(lFirstBank); |
127 |
|
|
|
128 |
|
|
c.gridx = 0; |
129 |
|
|
c.gridy = 1; |
130 |
|
|
gridbag.setConstraints(lFirstProgram, c); |
131 |
|
|
add(lFirstProgram); |
132 |
|
|
|
133 |
|
|
c.fill = GridBagConstraints.HORIZONTAL; |
134 |
|
|
c.gridx = 1; |
135 |
|
|
c.gridy = 0; |
136 |
|
|
c.weightx = 1.0; |
137 |
|
|
c.insets = new Insets(3, 3, 3, 3); |
138 |
|
|
c.anchor = GridBagConstraints.WEST; |
139 |
|
|
gridbag.setConstraints(cbFirstBank, c); |
140 |
|
|
add(cbFirstBank); |
141 |
|
|
|
142 |
|
|
c.gridx = 1; |
143 |
|
|
c.gridy = 1; |
144 |
|
|
gridbag.setConstraints(cbFirstProgram, c); |
145 |
|
|
add(cbFirstProgram); |
146 |
|
|
|
147 |
|
|
String s = i18n.getLabel("MidiBankProgramNumberingPane.title"); |
148 |
|
|
setBorder(BorderFactory.createTitledBorder(s)); |
149 |
|
|
|
150 |
|
|
cbFirstBank.addItem("0"); |
151 |
|
|
cbFirstBank.addItem("1"); |
152 |
|
|
|
153 |
|
|
cbFirstProgram.addItem("0"); |
154 |
|
|
cbFirstProgram.addItem("1"); |
155 |
|
|
|
156 |
|
|
int i = CC.preferences().getIntProperty(FIRST_MIDI_BANK_NUMBER); |
157 |
|
|
if(i < 0 || i > 1) i = 1; |
158 |
|
|
cbFirstBank.setSelectedIndex(i); |
159 |
|
|
|
160 |
|
|
i = CC.preferences().getIntProperty(FIRST_MIDI_PROGRAM_NUMBER); |
161 |
|
|
if(i < 0 || i > 1) i = 1; |
162 |
|
|
cbFirstProgram.setSelectedIndex(i); |
163 |
|
|
|
164 |
|
|
setAlignmentX(LEFT_ALIGNMENT); |
165 |
|
|
} |
166 |
|
|
|
167 |
|
|
public void |
168 |
|
|
apply() { |
169 |
|
|
int i = cbFirstBank.getSelectedIndex(); |
170 |
|
|
if(i < 0) i = 1; |
171 |
|
|
CC.preferences().setIntProperty(FIRST_MIDI_BANK_NUMBER, i); |
172 |
|
|
|
173 |
|
|
i = cbFirstProgram.getSelectedIndex(); |
174 |
|
|
if(i < 0) i = 1; |
175 |
|
|
CC.preferences().setIntProperty(FIRST_MIDI_PROGRAM_NUMBER, i); |
176 |
|
|
} |
177 |
|
|
} |
178 |
|
|
|
179 |
|
|
public static class ExportSettingsPane extends JPanel { |
180 |
|
|
private final JCheckBox checkExportMidiMapsToSession = |
181 |
|
|
new JCheckBox(i18n.getLabel("ExportSettingsPane.checkExportMidiMapsToSession")); |
182 |
|
|
|
183 |
|
|
private final JCheckBox checkLoadInstrInBackground = |
184 |
|
|
new JCheckBox(i18n.getLabel("ExportSettingsPane.checkLoadInstrInBackground")); |
185 |
|
|
|
186 |
|
|
public |
187 |
|
|
ExportSettingsPane() { |
188 |
|
|
setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); |
189 |
|
|
|
190 |
|
|
boolean b; |
191 |
|
|
b = CC.preferences().getBoolProperty(EXPORT_MIDI_MAPS_TO_SESSION_SCRIPT); |
192 |
|
|
checkExportMidiMapsToSession.setSelected(b); |
193 |
|
|
checkExportMidiMapsToSession.setAlignmentX(LEFT_ALIGNMENT); |
194 |
|
|
add(checkExportMidiMapsToSession); |
195 |
|
|
|
196 |
|
|
b = CC.preferences().getBoolProperty(LOAD_MIDI_INSTRUMENTS_IN_BACKGROUND); |
197 |
|
|
checkLoadInstrInBackground.setSelected(b); |
198 |
|
|
checkLoadInstrInBackground.setAlignmentX(LEFT_ALIGNMENT); |
199 |
|
|
add(checkLoadInstrInBackground); |
200 |
|
|
|
201 |
|
|
String s = i18n.getLabel("ExportSettingsPane.title"); |
202 |
|
|
setBorder(BorderFactory.createTitledBorder(s)); |
203 |
|
|
setAlignmentX(LEFT_ALIGNMENT); |
204 |
|
|
} |
205 |
|
|
|
206 |
|
|
protected void |
207 |
|
|
apply() { |
208 |
|
|
boolean b = checkExportMidiMapsToSession.isSelected(); |
209 |
|
|
CC.preferences().setBoolProperty(EXPORT_MIDI_MAPS_TO_SESSION_SCRIPT, b); |
210 |
|
|
|
211 |
|
|
b = checkLoadInstrInBackground.isSelected(); |
212 |
|
|
CC.preferences().setBoolProperty(LOAD_MIDI_INSTRUMENTS_IN_BACKGROUND, b); |
213 |
|
|
} |
214 |
|
|
} |
215 |
|
|
} |