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 |
* |
* |
23 |
package org.jsampler.view.std; |
package org.jsampler.view.std; |
24 |
|
|
25 |
import java.awt.BorderLayout; |
import java.awt.BorderLayout; |
|
import java.awt.Dimension; |
|
26 |
import java.awt.GridBagConstraints; |
import java.awt.GridBagConstraints; |
27 |
import java.awt.GridBagLayout; |
import java.awt.GridBagLayout; |
28 |
import java.awt.Insets; |
import java.awt.Insets; |
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 javax.swing.Box; |
import java.io.File; |
34 |
|
|
35 |
import javax.swing.BoxLayout; |
import javax.swing.BoxLayout; |
36 |
import javax.swing.ButtonGroup; |
import javax.swing.ButtonGroup; |
37 |
import javax.swing.ImageIcon; |
import javax.swing.ImageIcon; |
38 |
import javax.swing.JButton; |
import javax.swing.JButton; |
39 |
import javax.swing.JCheckBox; |
import javax.swing.JCheckBox; |
40 |
import javax.swing.JComboBox; |
import javax.swing.JComboBox; |
|
import javax.swing.JFileChooser; |
|
41 |
import javax.swing.JLabel; |
import javax.swing.JLabel; |
42 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
43 |
import javax.swing.JRadioButton; |
import javax.swing.JRadioButton; |
139 |
* Moves to the next page in the wizard. |
* Moves to the next page in the wizard. |
140 |
* @return The next page in the wizard. |
* @return The next page in the wizard. |
141 |
*/ |
*/ |
142 |
|
@Override |
143 |
public WizardPage |
public WizardPage |
144 |
next() { |
next() { |
145 |
InstrLocationMethodWizardPage p1 = instrLocationMethodWizardPage; |
InstrLocationMethodWizardPage p1 = instrLocationMethodWizardPage; |
159 |
* @return The previous page in the wizard. |
* @return The previous page in the wizard. |
160 |
* @see #hasPrevious |
* @see #hasPrevious |
161 |
*/ |
*/ |
162 |
|
@Override |
163 |
public WizardPage |
public WizardPage |
164 |
previous() { |
previous() { |
165 |
InstrLocationMethodWizardPage p1 = instrLocationMethodWizardPage; |
InstrLocationMethodWizardPage p1 = instrLocationMethodWizardPage; |
443 |
getWizard().enableNextButton(instr != null); |
getWizard().enableNextButton(instr != null); |
444 |
} |
} |
445 |
|
|
446 |
|
@Override |
447 |
public void |
public void |
448 |
postinitPage() { |
postinitPage() { |
449 |
getWizard().enableNextButton(cbInstruments.getSelectedItem() != null); |
getWizard().enableNextButton(cbInstruments.getSelectedItem() != null); |
608 |
|
|
609 |
private void |
private void |
610 |
onBrowse() { |
onBrowse() { |
611 |
String s = preferences().getStringProperty("lastInstrumentLocation"); |
File f = StdUtils.showOpenInstrumentFileChooser(getWizardDialog()); |
612 |
JFileChooser fc = new JFileChooser(s); |
if(f == null) return; |
|
int result = fc.showOpenDialog(this); |
|
|
if(result != JFileChooser.APPROVE_OPTION) return; |
|
613 |
|
|
614 |
String path = fc.getSelectedFile().getAbsolutePath(); |
String path = f.getAbsolutePath(); |
615 |
if(java.io.File.separatorChar == '\\') { |
if(java.io.File.separatorChar == '\\') { |
616 |
path = path.replace('\\', '/'); |
path = path.replace('\\', '/'); |
617 |
} |
} |
618 |
cbFilename.setSelectedItem(toEscapedString(path)); |
cbFilename.setSelectedItem(toEscapedString(path)); |
|
path = fc.getCurrentDirectory().getAbsolutePath(); |
|
|
preferences().setStringProperty("lastInstrumentLocation", path); |
|
619 |
} |
} |
620 |
|
|
621 |
private void |
private void |
668 |
return s.substring(i + 3); |
return s.substring(i + 3); |
669 |
} |
} |
670 |
|
|
671 |
|
@Override |
672 |
public void |
public void |
673 |
postinitPage() { |
postinitPage() { updateState(); } |
|
updateState(); |
|
|
} |
|
674 |
|
|
675 |
/** |
/** |
676 |
* Gets the name of the instrument file. |
* Gets the name of the instrument file. |
705 |
|
|
706 |
private class Handler implements DocumentListener { |
private class Handler implements DocumentListener { |
707 |
// DocumentListener |
// DocumentListener |
708 |
|
@Override |
709 |
public void |
public void |
710 |
insertUpdate(DocumentEvent e) { updateState(); } |
insertUpdate(DocumentEvent e) { updateState(); } |
711 |
|
|
712 |
|
@Override |
713 |
public void |
public void |
714 |
removeUpdate(DocumentEvent e) { updateState(); } |
removeUpdate(DocumentEvent e) { updateState(); } |
715 |
|
|
716 |
|
@Override |
717 |
public void |
public void |
718 |
changedUpdate(DocumentEvent e) { updateState(); } |
changedUpdate(DocumentEvent e) { updateState(); } |
719 |
} |
} |
878 |
cbProgram.setSelectedIndex(entry.getMidiProgram()); |
cbProgram.setSelectedIndex(entry.getMidiProgram()); |
879 |
} |
} |
880 |
|
|
881 |
|
@Override |
882 |
public void |
public void |
883 |
postinitPage() { |
postinitPage() { |
884 |
String s = wizardModel.getInstrumentName(); |
String s = wizardModel.getInstrumentName(); |
895 |
* while this page is the current page of the wizard. |
* while this page is the current page of the wizard. |
896 |
* @return <code>true</code> |
* @return <code>true</code> |
897 |
*/ |
*/ |
898 |
|
@Override |
899 |
public boolean |
public boolean |
900 |
mayFinish() { |
mayFinish() { |
901 |
((NewMidiInstrumentWizardModel)getWizardModel()).mapInstrument(); |
((NewMidiInstrumentWizardModel)getWizardModel()).mapInstrument(); |
953 |
|
|
954 |
private class Handler implements DocumentListener { |
private class Handler implements DocumentListener { |
955 |
// DocumentListener |
// DocumentListener |
956 |
|
@Override |
957 |
public void |
public void |
958 |
insertUpdate(DocumentEvent e) { updateState(); } |
insertUpdate(DocumentEvent e) { updateState(); } |
959 |
|
|
960 |
|
@Override |
961 |
public void |
public void |
962 |
removeUpdate(DocumentEvent e) { updateState(); } |
removeUpdate(DocumentEvent e) { updateState(); } |
963 |
|
|
964 |
|
@Override |
965 |
public void |
public void |
966 |
changedUpdate(DocumentEvent e) { updateState(); } |
changedUpdate(DocumentEvent e) { updateState(); } |
967 |
} |
} |