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 |
* |
* |
32 |
import java.awt.event.ItemEvent; |
import java.awt.event.ItemEvent; |
33 |
import java.awt.event.ItemListener; |
import java.awt.event.ItemListener; |
34 |
|
|
35 |
|
import java.io.File; |
36 |
|
|
37 |
import javax.swing.BorderFactory; |
import javax.swing.BorderFactory; |
38 |
import javax.swing.Box; |
import javax.swing.Box; |
39 |
import javax.swing.BoxLayout; |
import javax.swing.BoxLayout; |
41 |
import javax.swing.JButton; |
import javax.swing.JButton; |
42 |
import javax.swing.JCheckBox; |
import javax.swing.JCheckBox; |
43 |
import javax.swing.JComboBox; |
import javax.swing.JComboBox; |
|
import javax.swing.JFileChooser; |
|
44 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
45 |
import javax.swing.SwingUtilities; |
import javax.swing.SwingUtilities; |
46 |
|
|
223 |
|
|
224 |
private void |
private void |
225 |
onBrowse() { |
onBrowse() { |
226 |
String path = preferences().getStringProperty("lastInstrumentLocation"); |
File f = StdUtils.showOpenDirectoryChooser(this, "lastInstrumentLocation"); |
227 |
JFileChooser fc = new JFileChooser(path); |
if(f == null) return; |
228 |
fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); |
String path = f.getAbsolutePath(); |
|
int result = fc.showOpenDialog(this); |
|
|
if(result != JFileChooser.APPROVE_OPTION) return; |
|
|
|
|
|
path = fc.getSelectedFile().getAbsolutePath(); |
|
229 |
if(java.io.File.separatorChar == '\\') { |
if(java.io.File.separatorChar == '\\') { |
230 |
path = path.replace('\\', '/'); |
path = path.replace('\\', '/'); |
231 |
} |
} |
232 |
path = toEscapedString(path); |
path = toEscapedString(path); |
233 |
cbSource.setSelectedItem(path); |
cbSource.setSelectedItem(path); |
|
path = fc.getCurrentDirectory().getAbsolutePath(); |
|
|
preferences().setStringProperty("lastInstrumentLocation", path); |
|
234 |
} |
} |
235 |
|
|
236 |
private void |
private void |
253 |
btnOk.setEnabled(b); |
btnOk.setEnabled(b); |
254 |
} |
} |
255 |
|
|
256 |
|
@Override |
257 |
protected void |
protected void |
258 |
onOk() { |
onOk() { |
259 |
if(!btnOk.isEnabled()) return; |
if(!btnOk.isEnabled()) return; |
271 |
StdUtils.updateRecentElements("recentDbDirectories", dbDir); |
StdUtils.updateRecentElements("recentDbDirectories", dbDir); |
272 |
} |
} |
273 |
|
|
274 |
|
@Override |
275 |
protected void |
protected void |
276 |
onCancel() { setVisible(false); } |
onCancel() { setVisible(false); } |
277 |
|
|
306 |
|
|
307 |
private class Handler implements DocumentListener, ActionListener, ItemListener { |
private class Handler implements DocumentListener, ActionListener, ItemListener { |
308 |
// DocumentListener |
// DocumentListener |
309 |
|
@Override |
310 |
public void |
public void |
311 |
insertUpdate(DocumentEvent e) { updateState(); } |
insertUpdate(DocumentEvent e) { updateState(); } |
312 |
|
|
313 |
|
@Override |
314 |
public void |
public void |
315 |
removeUpdate(DocumentEvent e) { updateState(); } |
removeUpdate(DocumentEvent e) { updateState(); } |
316 |
|
|
317 |
|
@Override |
318 |
public void |
public void |
319 |
changedUpdate(DocumentEvent e) { updateState(); } |
changedUpdate(DocumentEvent e) { updateState(); } |
320 |
/////// |
/////// |
321 |
|
|
322 |
|
@Override |
323 |
public void |
public void |
324 |
actionPerformed(ActionEvent e) { updateState(); } |
actionPerformed(ActionEvent e) { updateState(); } |
325 |
|
|
326 |
|
@Override |
327 |
public void |
public void |
328 |
itemStateChanged(ItemEvent e) { |
itemStateChanged(ItemEvent e) { |
329 |
checkFlat.setEnabled(checkScanSubdirs.isSelected()); |
checkFlat.setEnabled(checkScanSubdirs.isSelected()); |