1 |
/* |
/* |
2 |
* JSampler - a java front-end for LinuxSampler |
* JSampler - a java front-end for LinuxSampler |
3 |
* |
* |
4 |
* Copyright (C) 2005-2007 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 |
* |
* |
30 |
import java.awt.event.ActionEvent; |
import java.awt.event.ActionEvent; |
31 |
import java.awt.event.ActionListener; |
import java.awt.event.ActionListener; |
32 |
|
|
33 |
|
import java.io.File; |
34 |
|
|
35 |
import javax.swing.BorderFactory; |
import javax.swing.BorderFactory; |
36 |
import javax.swing.Box; |
import javax.swing.Box; |
37 |
import javax.swing.BoxLayout; |
import javax.swing.BoxLayout; |
39 |
import javax.swing.Icon; |
import javax.swing.Icon; |
40 |
import javax.swing.JButton; |
import javax.swing.JButton; |
41 |
import javax.swing.JComboBox; |
import javax.swing.JComboBox; |
|
import javax.swing.JFileChooser; |
|
42 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
43 |
import javax.swing.JRadioButton; |
import javax.swing.JRadioButton; |
44 |
import javax.swing.JSpinner; |
import javax.swing.JSpinner; |
234 |
|
|
235 |
private void |
private void |
236 |
onBrowse() { |
onBrowse() { |
237 |
String path = preferences().getStringProperty("lastInstrumentLocation"); |
File f = StdUtils.showOpenInstrumentFileChooser(this); |
238 |
JFileChooser fc = new JFileChooser(path); |
if(f == null) return; |
|
fc.setFileSelectionMode(JFileChooser.FILES_ONLY); |
|
|
int result = fc.showOpenDialog(this); |
|
|
if(result != JFileChooser.APPROVE_OPTION) return; |
|
239 |
|
|
240 |
path = fc.getSelectedFile().getAbsolutePath(); |
String path = f.getAbsolutePath(); |
241 |
if(java.io.File.separatorChar == '\\') { |
if(java.io.File.separatorChar == '\\') { |
242 |
path = path.replace('\\', '/'); |
path = path.replace('\\', '/'); |
243 |
} |
} |
244 |
path = toEscapedString(path); |
path = toEscapedString(path); |
245 |
cbSource.setSelectedItem(path); |
cbSource.setSelectedItem(path); |
|
path = fc.getCurrentDirectory().getAbsolutePath(); |
|
|
preferences().setStringProperty("lastInstrumentLocation", path); |
|
246 |
} |
} |
247 |
|
|
248 |
private void |
private void |
265 |
btnOk.setEnabled(b); |
btnOk.setEnabled(b); |
266 |
} |
} |
267 |
|
|
268 |
|
@Override |
269 |
protected void |
protected void |
270 |
onOk() { |
onOk() { |
271 |
if(!btnOk.isEnabled()) return; |
if(!btnOk.isEnabled()) return; |
302 |
}); |
}); |
303 |
} |
} |
304 |
|
|
305 |
|
@Override |
306 |
protected void |
protected void |
307 |
onCancel() { setVisible(false); } |
onCancel() { setVisible(false); } |
308 |
|
|
313 |
|
|
314 |
private class Handler implements DocumentListener, ActionListener { |
private class Handler implements DocumentListener, ActionListener { |
315 |
// DocumentListener |
// DocumentListener |
316 |
|
@Override |
317 |
public void |
public void |
318 |
insertUpdate(DocumentEvent e) { updateState(); } |
insertUpdate(DocumentEvent e) { updateState(); } |
319 |
|
|
320 |
|
@Override |
321 |
public void |
public void |
322 |
removeUpdate(DocumentEvent e) { updateState(); } |
removeUpdate(DocumentEvent e) { updateState(); } |
323 |
|
|
324 |
|
@Override |
325 |
public void |
public void |
326 |
changedUpdate(DocumentEvent e) { updateState(); } |
changedUpdate(DocumentEvent e) { updateState(); } |
327 |
/////// |
/////// |
328 |
|
|
329 |
|
@Override |
330 |
public void |
public void |
331 |
actionPerformed(ActionEvent e) { updateState(); } |
actionPerformed(ActionEvent e) { updateState(); } |
332 |
} |
} |