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 |
* |
* |
34 |
import java.awt.event.FocusAdapter; |
import java.awt.event.FocusAdapter; |
35 |
import java.awt.event.FocusEvent; |
import java.awt.event.FocusEvent; |
36 |
|
|
37 |
|
import java.io.File; |
38 |
|
|
39 |
import javax.swing.BorderFactory; |
import javax.swing.BorderFactory; |
40 |
import javax.swing.Box; |
import javax.swing.Box; |
41 |
import javax.swing.BoxLayout; |
import javax.swing.BoxLayout; |
43 |
import javax.swing.Icon; |
import javax.swing.Icon; |
44 |
import javax.swing.JButton; |
import javax.swing.JButton; |
45 |
import javax.swing.JComboBox; |
import javax.swing.JComboBox; |
|
import javax.swing.JFileChooser; |
|
46 |
import javax.swing.JLabel; |
import javax.swing.JLabel; |
|
import javax.swing.JOptionPane; |
|
47 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
48 |
import javax.swing.JRadioButton; |
import javax.swing.JRadioButton; |
49 |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
import javax.swing.event.ChangeListener; |
|
50 |
import javax.swing.event.DocumentEvent; |
import javax.swing.event.DocumentEvent; |
51 |
import javax.swing.event.DocumentListener; |
import javax.swing.event.DocumentListener; |
52 |
|
|
98 |
private final JLabel lIndex = new JLabel(i18n.getLabel("JSInstrumentChooser.lIndex")); |
private final JLabel lIndex = new JLabel(i18n.getLabel("JSInstrumentChooser.lIndex")); |
99 |
|
|
100 |
private final JComboBox cbFilename = StdUtils.createPathComboBox(); |
private final JComboBox cbFilename = StdUtils.createPathComboBox(); |
101 |
private final JComboBox cbIndex = new JComboBox(); |
private final JComboBox cbIndex = StdUtils.createEnhancedComboBox(); |
102 |
|
|
103 |
private final JButton btnBrowse; |
private final JButton btnBrowse; |
104 |
|
|
406 |
return new JSDbInstrumentChooser(owner); |
return new JSDbInstrumentChooser(owner); |
407 |
} |
} |
408 |
|
|
409 |
|
@Override |
410 |
protected void |
protected void |
411 |
onOk() { |
onOk() { |
412 |
if(!btnOk.isEnabled()) return; |
if(!btnOk.isEnabled()) return; |
476 |
private void |
private void |
477 |
onBrowse() { |
onBrowse() { |
478 |
if(!rbSelectFromFile.isSelected()) rbSelectFromFile.doClick(0); |
if(!rbSelectFromFile.isSelected()) rbSelectFromFile.doClick(0); |
479 |
String s = preferences().getStringProperty("lastInstrumentLocation"); |
File f = StdUtils.showOpenInstrumentFileChooser(this); |
480 |
JFileChooser fc = new JFileChooser(s); |
if(f == null) return; |
|
int result = fc.showOpenDialog(this); |
|
|
if(result != JFileChooser.APPROVE_OPTION) return; |
|
481 |
|
|
482 |
String path = fc.getSelectedFile().getAbsolutePath(); |
String path = f.getAbsolutePath(); |
483 |
if(java.io.File.separatorChar == '\\') { |
if(java.io.File.separatorChar == '\\') { |
484 |
path = path.replace('\\', '/'); |
path = path.replace('\\', '/'); |
485 |
} |
} |
486 |
cbFilename.setSelectedItem(toEscapedString(path)); |
cbFilename.setSelectedItem(toEscapedString(path)); |
487 |
btnOk.requestFocusInWindow(); |
btnOk.requestFocusInWindow(); |
|
|
|
|
path = fc.getCurrentDirectory().getAbsolutePath(); |
|
|
preferences().setStringProperty("lastInstrumentLocation", path); |
|
488 |
} |
} |
489 |
|
|
490 |
private void |
private void |
576 |
private class EventHandler extends FocusAdapter |
private class EventHandler extends FocusAdapter |
577 |
implements ActionListener, DocumentListener { |
implements ActionListener, DocumentListener { |
578 |
|
|
579 |
|
@Override |
580 |
public void |
public void |
581 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
582 |
updateState(); |
updateState(); |
583 |
} |
} |
584 |
|
|
585 |
// DocumentListener |
// DocumentListener |
586 |
|
@Override |
587 |
public void |
public void |
588 |
insertUpdate(DocumentEvent e) { updateState(); } |
insertUpdate(DocumentEvent e) { updateState(); } |
589 |
|
|
590 |
|
@Override |
591 |
public void |
public void |
592 |
removeUpdate(DocumentEvent e) { updateState(); } |
removeUpdate(DocumentEvent e) { updateState(); } |
593 |
|
|
594 |
|
@Override |
595 |
public void |
public void |
596 |
changedUpdate(DocumentEvent e) { updateState(); } |
changedUpdate(DocumentEvent e) { updateState(); } |
597 |
|
|
598 |
// FocusListener |
// FocusListener |
599 |
|
@Override |
600 |
public void |
public void |
601 |
focusGained(FocusEvent e) { |
focusGained(FocusEvent e) { |
602 |
Object src = e.getSource(); |
Object src = e.getSource(); |