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

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

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

revision 1301 by iliev, Fri Aug 10 20:24:23 2007 UTC revision 1302 by iliev, Sat Aug 25 15:32:54 2007 UTC
# Line 62  import net.sf.juife.event.TaskListener; Line 62  import net.sf.juife.event.TaskListener;
62    
63  import org.jsampler.CC;  import org.jsampler.CC;
64  import org.jsampler.Instrument;  import org.jsampler.Instrument;
65    import org.jsampler.JSPrefs;
66  import org.jsampler.OrchestraModel;  import org.jsampler.OrchestraModel;
67    
68  import org.jsampler.task.InstrumentsDb;  import org.jsampler.task.InstrumentsDb;
# Line 176  public class JSInstrumentChooser extends Line 177  public class JSInstrumentChooser extends
177                  } else {                  } else {
178                          btnBrowseDb.requestFocusInWindow();                          btnBrowseDb.requestFocusInWindow();
179                  }                  }
180                    
181                    int i = preferences().getIntProperty("lastUsedOrchestraIndex", 0);
182                    if(CC.getOrchestras().getOrchestraCount() > i) {
183                            cbOrchestras.setSelectedIndex(i);
184                            i = preferences().getIntProperty("lastUsedOrchestraInstrumentIndex", 0);
185                            if(cbInstruments.getItemCount() > i) cbInstruments.setSelectedIndex(i);
186                    }
187          }          }
188                    
189          private JPanel          private JPanel
# Line 235  public class JSInstrumentChooser extends Line 243  public class JSInstrumentChooser extends
243                  return p;                  return p;
244          }          }
245                    
246            protected JSPrefs
247            preferences() { return CC.getViewConfig().preferences(); }
248            
249          private void          private void
250          orchestraChanged() {          orchestraChanged() {
251                  OrchestraModel om = (OrchestraModel)cbOrchestras.getSelectedItem();                  OrchestraModel om = (OrchestraModel)cbOrchestras.getSelectedItem();
# Line 279  public class JSInstrumentChooser extends Line 290  public class JSInstrumentChooser extends
290                                    
291                  btnBrowseDb.addActionListener(new ActionListener() {                  btnBrowseDb.addActionListener(new ActionListener() {
292                          public void                          public void
293                          actionPerformed(ActionEvent e) {                          actionPerformed(ActionEvent e) { onBrowseDb(); }
                                 if(!rbSelectFromDb.isSelected()) rbSelectFromDb.doClick(0);  
                                 JSDbInstrumentChooser dlg;  
                                 dlg = new JSDbInstrumentChooser(JSInstrumentChooser.this);  
                                 String s = tfDbInstrument.getText();  
                                 if(s.length() > 0) dlg.setSelectedInstrument(s);  
                                 else dlg.setSelectedDirectory("/");  
                                 dlg.setVisible(true);  
                                 if(dlg.isCancelled()) return;  
                                 tfDbInstrument.setText(dlg.getSelectedInstrument());  
                                 tfDbInstrument.requestFocus();  
                         }  
294                  });                  });
295                                    
296                  p.setAlignmentX(LEFT_ALIGNMENT);                  p.setAlignmentX(LEFT_ALIGNMENT);
# Line 357  public class JSInstrumentChooser extends Line 357  public class JSInstrumentChooser extends
357          protected void          protected void
358          onOk() {          onOk() {
359                  if(!btnOk.isEnabled()) return;                  if(!btnOk.isEnabled()) return;
360                    
361                  if(rbSelectFromOrchestra.isSelected()) {                  if(rbSelectFromOrchestra.isSelected()) {
362                          Instrument instr = (Instrument)cbInstruments.getSelectedItem();                          Instrument instr = (Instrument)cbInstruments.getSelectedItem();
363                          instrumentFile = instr.getPath();                          instrumentFile = instr.getPath();
364                          instrumentIndex = instr.getInstrumentIndex();                          instrumentIndex = instr.getInstrumentIndex();
365                          engine = instr.getEngine();                          engine = instr.getEngine();
366                          setVisible(false);                          setVisible(false);
367                            
368                            int i = cbOrchestras.getSelectedIndex();
369                            if(i >= 0) preferences().setIntProperty("lastUsedOrchestraIndex", i);
370                            
371                            i = cbInstruments.getSelectedIndex();
372                            if(i >= 0) {
373                                    preferences().setIntProperty("lastUsedOrchestraInstrumentIndex", i);
374                            }
375                            
376                          return;                          return;
377                  }                  }
378                                    
# Line 376  public class JSInstrumentChooser extends Line 386  public class JSInstrumentChooser extends
386                  if(!rbSelectFromDb.isSelected()) return;                  if(!rbSelectFromDb.isSelected()) return;
387                                    
388                  String instr = tfDbInstrument.getText();                  String instr = tfDbInstrument.getText();
389                    preferences().setStringProperty("lastUsedDbInstrument", instr);
390                  final InstrumentsDb.GetInstrument t = new InstrumentsDb.GetInstrument(instr);                  final InstrumentsDb.GetInstrument t = new InstrumentsDb.GetInstrument(instr);
391                                    
392                  t.addTaskListener(new TaskListener() {                  t.addTaskListener(new TaskListener() {
# Line 401  public class JSInstrumentChooser extends Line 412  public class JSInstrumentChooser extends
412          private void          private void
413          onBrowse() {          onBrowse() {
414                  if(!rbSelectFromFile.isSelected()) rbSelectFromFile.doClick(0);                  if(!rbSelectFromFile.isSelected()) rbSelectFromFile.doClick(0);
415                  JFileChooser fc = new JFileChooser();                  String s = preferences().getStringProperty("lastInstrumentLocation");
416                    JFileChooser fc = new JFileChooser(s);
417                  int result = fc.showOpenDialog(this);                  int result = fc.showOpenDialog(this);
418                  if(result == JFileChooser.APPROVE_OPTION) {                  if(result == JFileChooser.APPROVE_OPTION) {
419                          tfFilename.setText(fc.getSelectedFile().getPath());                          tfFilename.setText(fc.getSelectedFile().getPath());
420                          btnOk.requestFocusInWindow();                          btnOk.requestFocusInWindow();
421                            
422                            String path = fc.getCurrentDirectory().getAbsolutePath();
423                            preferences().setStringProperty("lastInstrumentLocation", path);
424                    }
425            }
426            
427            private void
428            onBrowseDb() {
429                    if(!rbSelectFromDb.isSelected()) rbSelectFromDb.doClick(0);
430                    JSDbInstrumentChooser dlg;
431                    dlg = new JSDbInstrumentChooser(JSInstrumentChooser.this);
432                    String s = tfDbInstrument.getText();
433                    if(s.length() > 0) dlg.setSelectedInstrument(s);
434                    else {
435                            s = preferences().getStringProperty("lastUsedDbInstrument", "");
436                            if(s.length() > 0) dlg.setSelectedInstrument(s);
437                            else dlg.setSelectedDirectory("/");
438                  }                  }
439                    dlg.setVisible(true);
440                    if(dlg.isCancelled()) return;
441                    tfDbInstrument.setText(dlg.getSelectedInstrument());
442                    tfDbInstrument.requestFocus();
443          }          }
444                    
445          /**          /**

Legend:
Removed from v.1301  
changed lines
  Added in v.1302

  ViewVC Help
Powered by ViewVC