/[svn]/jsampler/trunk/src/org/jsampler/view/std/JSAddOrEditInstrumentDlg.java
ViewVC logotype

Diff of /jsampler/trunk/src/org/jsampler/view/std/JSAddOrEditInstrumentDlg.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1870 by iliev, Mon Dec 3 23:22:02 2007 UTC revision 1871 by iliev, Sun Mar 22 18:11:39 2009 UTC
# Line 1  Line 1 
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   *   *
# Line 30  import java.awt.Insets; Line 30  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 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;
# Line 184  public class JSAddOrEditInstrumentDlg ex Line 185  public class JSAddOrEditInstrumentDlg ex
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();
# Line 248  public class JSAddOrEditInstrumentDlg ex Line 258  public class JSAddOrEditInstrumentDlg ex
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;
# Line 264  public class JSAddOrEditInstrumentDlg ex Line 275  public class JSAddOrEditInstrumentDlg ex
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.
# Line 284  public class JSAddOrEditInstrumentDlg ex Line 294  public class JSAddOrEditInstrumentDlg ex
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  }  }

Legend:
Removed from v.1870  
changed lines
  Added in v.1871

  ViewVC Help
Powered by ViewVC