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.JButton; |
import javax.swing.JButton; |
36 |
import javax.swing.JComboBox; |
import javax.swing.JComboBox; |
|
import javax.swing.JFileChooser; |
|
37 |
import javax.swing.JLabel; |
import javax.swing.JLabel; |
38 |
import javax.swing.JPanel; |
import javax.swing.JPanel; |
39 |
import javax.swing.JTextField; |
import javax.swing.JTextField; |
185 |
updateFileInstruments(); |
updateFileInstruments(); |
186 |
} |
} |
187 |
}); |
}); |
188 |
|
|
189 |
|
cbIndex.addActionListener(new ActionListener() { |
190 |
|
public void |
191 |
|
actionPerformed(ActionEvent e) { |
192 |
|
Object o = cbIndex.getSelectedItem(); |
193 |
|
if(o == null) return; |
194 |
|
if(o.toString().length() > 5) tfName.setText(o.toString()); |
195 |
|
} |
196 |
|
}); |
197 |
|
|
198 |
updateInfo(); |
updateInfo(); |
199 |
updateState(); |
updateState(); |
258 |
CC.getTaskQueue().add(t); |
CC.getTaskQueue().add(t); |
259 |
} |
} |
260 |
|
|
261 |
|
@Override |
262 |
protected void |
protected void |
263 |
onOk() { |
onOk() { |
264 |
if(!btnOk.isEnabled()) return; |
if(!btnOk.isEnabled()) return; |
275 |
setCancelled(false); |
setCancelled(false); |
276 |
} |
} |
277 |
|
|
278 |
|
@Override |
279 |
protected void |
protected void |
280 |
onCancel() { |
onCancel() { setVisible(false); } |
|
setVisible(false); |
|
|
} |
|
281 |
|
|
282 |
/** |
/** |
283 |
* Gets the created/modified orchestra. |
* Gets the created/modified orchestra. |
294 |
|
|
295 |
private class Handler implements DocumentListener, ActionListener { |
private class Handler implements DocumentListener, ActionListener { |
296 |
// DocumentListener |
// DocumentListener |
297 |
|
@Override |
298 |
public void |
public void |
299 |
insertUpdate(DocumentEvent e) { updateState(); } |
insertUpdate(DocumentEvent e) { updateState(); } |
300 |
|
|
301 |
|
@Override |
302 |
public void |
public void |
303 |
removeUpdate(DocumentEvent e) { updateState(); } |
removeUpdate(DocumentEvent e) { updateState(); } |
304 |
|
|
305 |
|
@Override |
306 |
public void |
public void |
307 |
changedUpdate(DocumentEvent e) { updateState(); } |
changedUpdate(DocumentEvent e) { updateState(); } |
308 |
|
|
309 |
// ActionListener |
// ActionListener |
310 |
|
@Override |
311 |
public void |
public void |
312 |
actionPerformed(ActionEvent e) { |
actionPerformed(ActionEvent e) { |
313 |
String path = preferences().getStringProperty("lastInstrumentLocation"); |
File f = StdUtils.showOpenInstrumentFileChooser(JSAddOrEditInstrumentDlg.this); |
314 |
JFileChooser fc = new JFileChooser(path); |
if(f == null) return; |
|
int result = fc.showOpenDialog(JSAddOrEditInstrumentDlg.this); |
|
|
if(result != JFileChooser.APPROVE_OPTION) return; |
|
315 |
|
|
316 |
path = fc.getSelectedFile().getAbsolutePath(); |
String path = f.getAbsolutePath(); |
317 |
if(java.io.File.separatorChar == '\\') { |
if(java.io.File.separatorChar == '\\') { |
318 |
path = path.replace('\\', '/'); |
path = path.replace('\\', '/'); |
319 |
} |
} |
320 |
path = toEscapedString(path); |
path = toEscapedString(path); |
321 |
cbPath.setSelectedItem(path); |
cbPath.setSelectedItem(path); |
|
path = fc.getCurrentDirectory().getAbsolutePath(); |
|
|
preferences().setStringProperty("lastInstrumentLocation", path); |
|
322 |
} |
} |
323 |
} |
} |
324 |
} |
} |