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

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

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

revision 1784 by iliev, Mon Aug 11 22:51:24 2008 UTC revision 1785 by iliev, Tue Oct 7 00:07:14 2008 UTC
# Line 28  import java.awt.Frame; Line 28  import java.awt.Frame;
28  import java.awt.Window;  import java.awt.Window;
29    
30  import java.awt.event.ActionEvent;  import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;  
31  import java.awt.event.KeyEvent;  import java.awt.event.KeyEvent;
32  import java.awt.event.MouseAdapter;  import java.awt.event.MouseAdapter;
33  import java.awt.event.MouseEvent;  import java.awt.event.MouseEvent;
# Line 47  import javax.swing.JPanel; Line 46  import javax.swing.JPanel;
46  import javax.swing.JPopupMenu;  import javax.swing.JPopupMenu;
47  import javax.swing.JTable;  import javax.swing.JTable;
48  import javax.swing.KeyStroke;  import javax.swing.KeyStroke;
49    import javax.swing.SwingUtilities;
50    
51  import javax.swing.event.ChangeEvent;  import javax.swing.event.ChangeEvent;
52  import javax.swing.event.ChangeListener;  import javax.swing.event.ChangeListener;
# Line 70  import org.jsampler.OrchestraInstrument; Line 70  import org.jsampler.OrchestraInstrument;
70  import org.jsampler.MidiInstrumentMap;  import org.jsampler.MidiInstrumentMap;
71  import org.jsampler.OrchestraModel;  import org.jsampler.OrchestraModel;
72  import org.jsampler.SamplerChannelModel;  import org.jsampler.SamplerChannelModel;
 import org.jsampler.SamplerModel;  
73    
74  import org.jsampler.event.ListEvent;  import org.jsampler.event.ListEvent;
75  import org.jsampler.event.ListListener;  import org.jsampler.event.ListListener;
# Line 83  import org.jsampler.view.DbClipboard; Line 82  import org.jsampler.view.DbClipboard;
82  import org.jsampler.view.DbDirectoryTreeNode;  import org.jsampler.view.DbDirectoryTreeNode;
83  import org.jsampler.view.InstrumentsDbTableModel;  import org.jsampler.view.InstrumentsDbTableModel;
84    
85    import org.jsampler.view.JSChannelsPane;
86    
87  import org.linuxsampler.lscp.DbDirectoryInfo;  import org.linuxsampler.lscp.DbDirectoryInfo;
88  import org.linuxsampler.lscp.DbInstrumentInfo;  import org.linuxsampler.lscp.DbInstrumentInfo;
 import org.linuxsampler.lscp.MidiInstrumentInfo;  
89    
90  import static org.jsampler.view.InstrumentsDbTableModel.ColumnType;  import static org.jsampler.view.InstrumentsDbTableModel.ColumnType;
91  import static org.jsampler.view.std.StdI18n.i18n;  import static org.jsampler.view.std.StdI18n.i18n;
# Line 203  public class JSInstrumentsDbTable extend Line 203  public class JSInstrumentsDbTable extend
203                  CC.getOrchestras().addOrchestraListListener(getHandler());                  CC.getOrchestras().addOrchestraListListener(getHandler());
204                  CC.getSamplerModel().addSamplerChannelListListener(getHandler());                  CC.getSamplerModel().addSamplerChannelListListener(getHandler());
205                                    
206                    CC.getMainFrame().addChannelsPaneSelectionListener(new ListSelectionListener() {
207                            public void
208                            valueChanged(ListSelectionEvent e) {
209                                    updateLoadInstrumentMenus();
210                            }
211                    });
212                    
213                  ListListener<MidiInstrumentMap> l = new ListListener<MidiInstrumentMap>() {                  ListListener<MidiInstrumentMap> l = new ListListener<MidiInstrumentMap>() {
214                          public void                          public void
215                          entryAdded(ListEvent<MidiInstrumentMap> e) { updateAddToMidiMapMenus(); }                          entryAdded(ListEvent<MidiInstrumentMap> e) { updateAddToMidiMapMenus(); }
# Line 219  public class JSInstrumentsDbTable extend Line 226  public class JSInstrumentsDbTable extend
226          public static DbClipboard          public static DbClipboard
227          getDbClipboard() { return dbClipboard; }          getDbClipboard() { return dbClipboard; }
228                    
229            @Override
230          public TableCellRenderer          public TableCellRenderer
231          getCellRenderer(int row, int column) {          getCellRenderer(int row, int column) {
232                  return cellRenderer;                  return cellRenderer;
# Line 313  public class JSInstrumentsDbTable extend Line 321  public class JSInstrumentsDbTable extend
321          public void          public void
322          registerLoadInstrumentMenus(JMenu menu) {          registerLoadInstrumentMenus(JMenu menu) {
323                  loadInstrumentMenus.add(menu);                  loadInstrumentMenus.add(menu);
324                  updateLoadInstrumentMenu(menu);                  StdA4n.updateLoadInstrumentMenu(menu, loadInstrActionFactory);
325                    updateLoadInstrumentMenuState(menu);
326          }          }
327                    
328          public void          public void
# Line 330  public class JSInstrumentsDbTable extend Line 339  public class JSInstrumentsDbTable extend
339                    
340          private void          private void
341          updateLoadInstrumentMenus() {          updateLoadInstrumentMenus() {
342                  for(JMenu menu : loadInstrumentMenus) updateLoadInstrumentMenu(menu);                  for(JMenu menu : loadInstrumentMenus) {
343          }                          StdA4n.updateLoadInstrumentMenu(menu, loadInstrActionFactory);
344                                    updateLoadInstrumentMenuState(menu);
         private void  
         updateLoadInstrumentMenu(JMenu menu) {  
                 menu.removeAll();  
                 for(SamplerChannelModel m : CC.getSamplerModel().getChannels()) {  
                         menu.add(new JMenuItem(new LoadInstrumentAction(m)));  
345                  }                  }
                   
                 updateLoadInstrumentMenuState(menu);  
346          }          }
347                    
348          private void          private void
# Line 432  public class JSInstrumentsDbTable extend Line 434  public class JSInstrumentsDbTable extend
434                          setEnabled(false);                          setEnabled(false);
435                  }                  }
436                                    
437                    @Override
438                  public void                  public void
439                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
440                          DbDirectoryTreeNode n = instrumentsDbTree.getSelectedDirectoryNode();                          DbDirectoryTreeNode n = instrumentsDbTree.getSelectedDirectoryNode();
# Line 444  public class JSInstrumentsDbTable extend Line 447  public class JSInstrumentsDbTable extend
447                          });                          });
448                  }                  }
449                                    
450                    @Override
451                  public void                  public void
452                  valueChanged(TreeSelectionEvent e) {                  valueChanged(TreeSelectionEvent e) {
453                          DbDirectoryTreeNode n = instrumentsDbTree.getSelectedDirectoryNode();                          DbDirectoryTreeNode n = instrumentsDbTree.getSelectedDirectoryNode();
# Line 461  public class JSInstrumentsDbTable extend Line 465  public class JSInstrumentsDbTable extend
465                          putValue(SHORT_DESCRIPTION, s);                          putValue(SHORT_DESCRIPTION, s);
466                  }                  }
467                                    
468                    @Override
469                  public void                  public void
470                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
471                          setDirectoryName(getUniqueDirectoryName());                          setDirectoryName(getUniqueDirectoryName());
# Line 511  public class JSInstrumentsDbTable extend Line 516  public class JSInstrumentsDbTable extend
516                          setEnabled(false);                          setEnabled(false);
517                  }                  }
518                                    
519                    @Override
520                  public void                  public void
521                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
522                          final DbDirectoryInfo[] dirs = getSelectedDirectories();                          final DbDirectoryInfo[] dirs = getSelectedDirectories();
# Line 581  public class JSInstrumentsDbTable extend Line 587  public class JSInstrumentsDbTable extend
587                          putValue(SHORT_DESCRIPTION, i18n.getMenuLabel(s));                          putValue(SHORT_DESCRIPTION, i18n.getMenuLabel(s));
588                  }                  }
589                                    
590                    @Override
591                  public void                  public void
592                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
593                          String s;                          String s;
# Line 612  public class JSInstrumentsDbTable extend Line 619  public class JSInstrumentsDbTable extend
619                          putValue(SHORT_DESCRIPTION, i18n.getMenuLabel(s));                          putValue(SHORT_DESCRIPTION, i18n.getMenuLabel(s));
620                  }                  }
621                                    
622                    @Override
623                  public void                  public void
624                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
625                          String s;                          String s;
# Line 635  public class JSInstrumentsDbTable extend Line 643  public class JSInstrumentsDbTable extend
643                  }                  }
644          }          }
645                    
646          class LoadInstrumentAction extends AbstractAction {          class LoadInstrumentAction extends StdA4n.LoadInstrumentAction {
647                  private final SamplerChannelModel channelModel;                  LoadInstrumentAction(SamplerChannelModel model, boolean onPanel) {
648                                            super(model, onPanel);
                 LoadInstrumentAction(SamplerChannelModel model) {  
                         String s = "instrumentsdb.actions.loadInstrument.onChannel";  
                         int i = CC.getSamplerModel().getChannelIndex(model) + 1;  
                         putValue(Action.NAME, i18n.getMenuLabel(s, i));  
                         channelModel = model;  
649                  }                  }
650                                    
651                    @Override
652                  public void                  public void
653                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
654                          Object obj = getLeadObject();                          Object obj = getLeadObject();
# Line 656  public class JSInstrumentsDbTable extend Line 660  public class JSInstrumentsDbTable extend
660                  }                  }
661          }          }
662                    
663            private LoadInstrumentActionFactory loadInstrActionFactory = new LoadInstrumentActionFactory();
664            
665            class LoadInstrumentActionFactory implements StdA4n.LoadInstrumentActionFactory {
666                    public StdA4n.LoadInstrumentAction
667                    createLoadInstrumentAction(SamplerChannelModel model, boolean onPanel) {
668                            return new LoadInstrumentAction(model, onPanel);
669                    }
670            }
671            
672          class AddToMidiMapAction extends AbstractAction {          class AddToMidiMapAction extends AbstractAction {
673                  private final MidiInstrumentMap midiMap;                  private final MidiInstrumentMap midiMap;
674                                    
# Line 664  public class JSInstrumentsDbTable extend Line 677  public class JSInstrumentsDbTable extend
677                          midiMap = map;                          midiMap = map;
678                  }                  }
679                                    
680                    @Override
681                  public void                  public void
682                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
683                          DbInstrumentInfo[] instruments = getSelectedInstruments();                          DbInstrumentInfo[] instruments = getSelectedInstruments();
# Line 701  public class JSInstrumentsDbTable extend Line 715  public class JSInstrumentsDbTable extend
715                          orchestraModel = model;                          orchestraModel = model;
716                  }                  }
717                                    
718                    @Override
719                  public void                  public void
720                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
721                          DbInstrumentInfo[] instruments = getSelectedInstruments();                          DbInstrumentInfo[] instruments = getSelectedInstruments();
# Line 735  public class JSInstrumentsDbTable extend Line 750  public class JSInstrumentsDbTable extend
750                          setEnabled(false);                          setEnabled(false);
751                  }                  }
752                                    
753                    @Override
754                  public void                  public void
755                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
756                          Object obj = getLeadObject();                          Object obj = getLeadObject();
# Line 794  public class JSInstrumentsDbTable extend Line 810  public class JSInstrumentsDbTable extend
810                          setEnabled(false);                          setEnabled(false);
811                  }                  }
812                                    
813                    @Override
814                  public void                  public void
815                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
816                          int i = getSelectionModel().getLeadSelectionIndex();                          int i = getSelectionModel().getLeadSelectionIndex();
# Line 813  public class JSInstrumentsDbTable extend Line 830  public class JSInstrumentsDbTable extend
830                          setEnabled(false);                          setEnabled(false);
831                  }                  }
832                                    
833                    @Override
834                  public void                  public void
835                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
836                          Object obj = getLeadObject();                          Object obj = getLeadObject();
# Line 863  public class JSInstrumentsDbTable extend Line 881  public class JSInstrumentsDbTable extend
881                          setEnabled(false);                          setEnabled(false);
882                  }                  }
883                                    
884                    @Override
885                  public void                  public void
886                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
887                          getDbClipboard().setDirectories(getSelectedDirectories());                          getDbClipboard().setDirectories(getSelectedDirectories());
# Line 880  public class JSInstrumentsDbTable extend Line 899  public class JSInstrumentsDbTable extend
899                          setEnabled(false);                          setEnabled(false);
900                  }                  }
901                                    
902                    @Override
903                  public void                  public void
904                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
905                          getDbClipboard().setDirectories(getSelectedDirectories());                          getDbClipboard().setDirectories(getSelectedDirectories());
# Line 898  public class JSInstrumentsDbTable extend Line 918  public class JSInstrumentsDbTable extend
918                          getDbClipboard().addChangeListener(this);                          getDbClipboard().addChangeListener(this);
919                  }                  }
920                                    
921                    @Override
922                  public void                  public void
923                  actionPerformed(ActionEvent e) {                  actionPerformed(ActionEvent e) {
924                          DbDirectoryInfo[] dirs = getDbClipboard().getDirectories();                          DbDirectoryInfo[] dirs = getDbClipboard().getDirectories();
# Line 918  public class JSInstrumentsDbTable extend Line 939  public class JSInstrumentsDbTable extend
939                          CC.getTaskQueue().add(t);                          CC.getTaskQueue().add(t);
940                  }                  }
941                                    
942                    @Override
943                  public void                  public void
944                  valueChanged(TreeSelectionEvent e) { updateState(); }                  valueChanged(TreeSelectionEvent e) { updateState(); }
945                                    
946                    @Override
947                  public void                  public void
948                  stateChanged(ChangeEvent e) { updateState(); }                  stateChanged(ChangeEvent e) { updateState(); }
949                                    
# Line 944  public class JSInstrumentsDbTable extend Line 967  public class JSInstrumentsDbTable extend
967                          setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3));                          setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3));
968                  }                  }
969                                    
970                    @Override
971                  public Component                  public Component
972                  getTableCellRendererComponent (                  getTableCellRendererComponent (
973                          JTable table,                          JTable table,
# Line 1018  public class JSInstrumentsDbTable extend Line 1042  public class JSInstrumentsDbTable extend
1042          private class EventHandler implements ListSelectionListener, TreeSelectionListener,          private class EventHandler implements ListSelectionListener, TreeSelectionListener,
1043                                  SamplerChannelListListener, ListListener<OrchestraModel> {                                  SamplerChannelListListener, ListListener<OrchestraModel> {
1044                                    
1045                    @Override
1046                  public void                  public void
1047                  valueChanged(ListSelectionEvent e) {                  valueChanged(ListSelectionEvent e) {
1048                          boolean b = !getSelectionModel().isSelectionEmpty();                          boolean b = !getSelectionModel().isSelectionEmpty();
# Line 1032  public class JSInstrumentsDbTable extend Line 1057  public class JSInstrumentsDbTable extend
1057                          updateAddToOrchestraMenuStates();                          updateAddToOrchestraMenuStates();
1058                  }                  }
1059                                    
1060                    @Override
1061                  public void                  public void
1062                  valueChanged(TreeSelectionEvent e) {                  valueChanged(TreeSelectionEvent e) {
1063                          DbDirectoryTreeNode n = instrumentsDbTree.getSelectedDirectoryNode();                          DbDirectoryTreeNode n = instrumentsDbTree.getSelectedDirectoryNode();
# Line 1041  public class JSInstrumentsDbTable extend Line 1067  public class JSInstrumentsDbTable extend
1067                          propertiesAction.setEnabled(n != null || getLeadObject() != null);                          propertiesAction.setEnabled(n != null || getLeadObject() != null);
1068                  }                  }
1069                                    
1070                    @Override
1071                  public void                  public void
1072                  channelAdded(SamplerChannelListEvent e) {                  channelAdded(SamplerChannelListEvent e) {
1073                          if(CC.getSamplerModel().getChannelListIsAdjusting()) return;                          if(CC.getSamplerModel().getChannelListIsAdjusting()) return;
1074                          updateLoadInstrumentMenus();                          updateLoadInstrumentMenus();
1075                  }                  }
1076                                    
1077                    @Override
1078                  public void                  public void
1079                  channelRemoved(SamplerChannelListEvent e) {                  channelRemoved(SamplerChannelListEvent e) {
1080                          updateLoadInstrumentMenus();                          updateLoadInstrumentMenus();
1081                  }                  }
1082                                    
1083                    @Override
1084                  public void                  public void
1085                  entryAdded(ListEvent<OrchestraModel> e) { updateAddToOrchestraMenus(); }                  entryAdded(ListEvent<OrchestraModel> e) { updateAddToOrchestraMenus(); }
1086                                    
1087                    @Override
1088                  public void                  public void
1089                  entryRemoved(ListEvent<OrchestraModel> e) { updateAddToOrchestraMenus(); }                  entryRemoved(ListEvent<OrchestraModel> e) { updateAddToOrchestraMenus(); }
1090          }          }
# Line 1186  public class JSInstrumentsDbTable extend Line 1216  public class JSInstrumentsDbTable extend
1216                          directoryMenu.add(mi);                          directoryMenu.add(mi);
1217                  }                  }
1218                                    
1219                    @Override
1220                  public void                  public void
1221                  mousePressed(MouseEvent e) {                  mousePressed(MouseEvent e) {
1222                          if(e.isPopupTrigger()) show(e);                          if(e.isPopupTrigger()) show(e);
1223                  }                  }
1224                    
1225                    @Override
1226                  public void                  public void
1227                  mouseReleased(MouseEvent e) {                  mouseReleased(MouseEvent e) {
1228                          if(e.isPopupTrigger()) show(e);                          if(e.isPopupTrigger()) show(e);

Legend:
Removed from v.1784  
changed lines
  Added in v.1785

  ViewVC Help
Powered by ViewVC