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

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

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

revision 1539 by iliev, Sat Sep 8 18:33:05 2007 UTC revision 1540 by iliev, Mon Dec 3 23:22:02 2007 UTC
# Line 47  import net.sf.juife.JuifeUtils; Line 47  import net.sf.juife.JuifeUtils;
47    
48  import org.jsampler.CC;  import org.jsampler.CC;
49  import org.jsampler.DefaultOrchestraModel;  import org.jsampler.DefaultOrchestraModel;
50  import org.jsampler.Instrument;  import org.jsampler.OrchestraInstrument;
51  import org.jsampler.MidiInstrumentMap;  import org.jsampler.MidiInstrumentMap;
52  import org.jsampler.OrchestraModel;  import org.jsampler.OrchestraModel;
53  import org.jsampler.SamplerChannelModel;  import org.jsampler.SamplerChannelModel;
# Line 141  public class JSOrchestraPane extends JPa Line 141  public class JSOrchestraPane extends JPa
141                  instrumentTable.getModel().setOrchestraModel(orchestra);                  instrumentTable.getModel().setOrchestraModel(orchestra);
142          }          }
143                    
144          public Instrument          public OrchestraInstrument
145          getSelectedInstrument() { return instrumentTable.getSelectedInstrument(); }          getSelectedInstrument() { return instrumentTable.getSelectedInstrument(); }
146                    
147          /**          /**
# Line 149  public class JSOrchestraPane extends JPa Line 149  public class JSOrchestraPane extends JPa
149           * @return The instrument to add           * @return The instrument to add
150           * or <code>null</code> if the user cancelled the task.           * or <code>null</code> if the user cancelled the task.
151           */           */
152          public Instrument          public OrchestraInstrument
153          createInstrument() {          createInstrument() {
154                  JSAddOrEditInstrumentDlg dlg = new JSAddOrEditInstrumentDlg();                  JSAddOrEditInstrumentDlg dlg = new JSAddOrEditInstrumentDlg();
155                  dlg.setVisible(true);                  dlg.setVisible(true);
# Line 159  public class JSOrchestraPane extends JPa Line 159  public class JSOrchestraPane extends JPa
159          }          }
160                    
161          public void          public void
162          editInstrument(Instrument instr) {          editInstrument(OrchestraInstrument instr) {
163                  JSAddOrEditInstrumentDlg dlg = new JSAddOrEditInstrumentDlg(instr);                  JSAddOrEditInstrumentDlg dlg = new JSAddOrEditInstrumentDlg(instr);
164                  dlg.setVisible(true);                  dlg.setVisible(true);
165          }          }
# Line 196  public class JSOrchestraPane extends JPa Line 196  public class JSOrchestraPane extends JPa
196                                    
197                  public void                  public void
198                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
199                          Instrument instr = createInstrument();                          OrchestraInstrument instr = createInstrument();
200                          if(instr == null) return;                          if(instr == null) return;
201                          orchestra.addInstrument(instr);                          orchestra.addInstrument(instr);
202                  }                  }
# Line 230  public class JSOrchestraPane extends JPa Line 230  public class JSOrchestraPane extends JPa
230                                    
231                  public void                  public void
232                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
233                          Instrument instr = instrumentTable.getSelectedInstrument();                          OrchestraInstrument instr = instrumentTable.getSelectedInstrument();
234                          if(instr == null) return;                          if(instr == null) return;
235                            int i = instrumentTable.getSelectedRow();
236                          orchestra.removeInstrument(instr);                          orchestra.removeInstrument(instr);
237                            
238                            if(instrumentTable.getRowCount() > i) {
239                                    instrumentTable.getSelectionModel().setSelectionInterval(i, i);
240                            }
241                  }                  }
242          }          }
243                    
# Line 248  public class JSOrchestraPane extends JPa Line 253  public class JSOrchestraPane extends JPa
253                                    
254                  public void                  public void
255                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
256                          Instrument instr = instrumentTable.getSelectedInstrument();                          OrchestraInstrument instr = instrumentTable.getSelectedInstrument();
257                          instrumentTable.getModel().getOrchestraModel().moveInstrumentUp(instr);                          instrumentTable.getModel().getOrchestraModel().moveInstrumentUp(instr);
258                          instrumentTable.setSelectedInstrument(instr);                          instrumentTable.setSelectedInstrument(instr);
259                  }                  }
# Line 266  public class JSOrchestraPane extends JPa Line 271  public class JSOrchestraPane extends JPa
271                                    
272                  public void                  public void
273                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
274                          Instrument instr = instrumentTable.getSelectedInstrument();                          OrchestraInstrument instr = instrumentTable.getSelectedInstrument();
275                          instrumentTable.getModel().getOrchestraModel().moveInstrumentDown(instr);                          instrumentTable.getModel().getOrchestraModel().moveInstrumentDown(instr);
276                          instrumentTable.setSelectedInstrument(instr);                          instrumentTable.setSelectedInstrument(instr);
277                  }                  }
# Line 285  public class JSOrchestraPane extends JPa Line 290  public class JSOrchestraPane extends JPa
290                                    
291                  public void                  public void
292                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
293                          Instrument instr = instrumentTable.getSelectedInstrument();                          OrchestraInstrument instr = instrumentTable.getSelectedInstrument();
294                          if(instr == null) return;                          if(instr == null) return;
295                                                    
296                          int idx = instr.getInstrumentIndex();                          int idx = instr.getInstrumentIndex();
297                          channelModel.setBackendEngineType(instr.getEngine());                          channelModel.setBackendEngineType(instr.getEngine());
298                          channelModel.loadBackendInstrument(instr.getPath(), idx);                          channelModel.loadBackendInstrument(instr.getFilePath(), idx);
299                  }                  }
300          }          }
301                    
# Line 304  public class JSOrchestraPane extends JPa Line 309  public class JSOrchestraPane extends JPa
309                                    
310                  public void                  public void
311                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
312                          Instrument instr = instrumentTable.getSelectedInstrument();                          OrchestraInstrument instr = instrumentTable.getSelectedInstrument();
313                          if(instr == null) return;                          if(instr == null) return;
314                                                    
315                          JSAddMidiInstrumentDlg dlg;                          JSAddMidiInstrumentDlg dlg;
316                          Window w = JuifeUtils.getWindow(JSOrchestraPane.this);                          Window w = JuifeUtils.getWindow(JSOrchestraPane.this);
317                          if(w instanceof Dialog) {                          if(w instanceof Dialog) {
318                                  dlg = new JSAddMidiInstrumentDlg((Dialog)w);                                  dlg = new JSAddMidiInstrumentDlg((Dialog)w, midiMap, instr);
319                          } else if(w instanceof Frame) {                          } else if(w instanceof Frame) {
320                                  dlg = new JSAddMidiInstrumentDlg((Frame)w);                                  dlg = new JSAddMidiInstrumentDlg((Frame)w, midiMap, instr);
321                          } else {                          } else {
322                                  dlg = new JSAddMidiInstrumentDlg((Frame)null);                                  dlg = new JSAddMidiInstrumentDlg((Frame)null, midiMap, instr);
323                          }                          }
324                                                    
                         dlg.setInstrumentName(instr.getName());  
                         MidiInstrumentEntry entry = midiMap.getAvailableEntry();  
                         if(entry != null) {  
                                 dlg.setMidiBank(entry.getMidiBank());  
                                 dlg.setMidiProgram(entry.getMidiProgram());  
                         }  
325                          dlg.setVisible(true);                          dlg.setVisible(true);
                         if(dlg.isCancelled()) return;  
                           
                         MidiInstrumentInfo instrInfo = new MidiInstrumentInfo();  
                         instrInfo.setName(dlg.getInstrumentName());  
                         instrInfo.setFilePath(instr.getPath());  
                         instrInfo.setInstrumentIndex(instr.getInstrumentIndex());  
                         instrInfo.setEngine(instr.getEngine());  
                         instrInfo.setVolume(dlg.getVolume());  
                         instrInfo.setLoadMode(dlg.getLoadMode());  
                           
                         int id = midiMap.getMapId();  
                         int b = dlg.getMidiBank();  
                         int p = dlg.getMidiProgram();  
                         CC.getSamplerModel().mapBackendMidiInstrument(id, b, p, instrInfo);  
326                  }                  }
327          }          }
328                    
# Line 407  public class JSOrchestraPane extends JPa Line 392  public class JSOrchestraPane extends JPa
392                                    
393                  private void                  private void
394                  updateLoadInstrumentMenuState(JMenu menu) {                  updateLoadInstrumentMenuState(JMenu menu) {
395                          Instrument instr = instrumentTable.getSelectedInstrument();                          OrchestraInstrument instr = instrumentTable.getSelectedInstrument();
396                          boolean b = instr == null;                          boolean b = instr == null;
397                          b = b || CC.getSamplerModel().getChannelCount() == 0;                          b = b || CC.getSamplerModel().getChannelCount() == 0;
398                          menu.setEnabled(!b);                          menu.setEnabled(!b);
# Line 426  public class JSOrchestraPane extends JPa Line 411  public class JSOrchestraPane extends JPa
411                                    
412                  private void                  private void
413                  updateAddToMidiMapMenuState(JMenu menu) {                  updateAddToMidiMapMenuState(JMenu menu) {
414                          Instrument instr = instrumentTable.getSelectedInstrument();                          OrchestraInstrument instr = instrumentTable.getSelectedInstrument();
415                          boolean b = instr == null;                          boolean b = instr == null;
416                          b = b || CC.getSamplerModel().getMidiInstrumentMapCount() == 0;                          b = b || CC.getSamplerModel().getMidiInstrumentMapCount() == 0;
417                          menu.setEnabled(!b);                          menu.setEnabled(!b);

Legend:
Removed from v.1539  
changed lines
  Added in v.1540

  ViewVC Help
Powered by ViewVC