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

Diff of /jsampler/trunk/src/org/jsampler/view/MidiMapTableModel.java

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

revision 1865 by iliev, Fri Aug 10 20:24:23 2007 UTC revision 1866 by iliev, Sun Mar 15 19:40:29 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 26  import javax.swing.table.AbstractTableMo Line 26  import javax.swing.table.AbstractTableMo
26    
27  import org.jsampler.CC;  import org.jsampler.CC;
28  import org.jsampler.MidiInstrumentMap;  import org.jsampler.MidiInstrumentMap;
 import org.jsampler.MidiInstrumentMapList;  
29  import org.jsampler.SamplerModel;  import org.jsampler.SamplerModel;
30    
31  import org.jsampler.event.ListEvent;  import org.jsampler.event.ListEvent;
# Line 41  import static org.jsampler.JSI18n.i18n; Line 40  import static org.jsampler.JSI18n.i18n;
40   * @author Grigor Iliev   * @author Grigor Iliev
41   */   */
42  public class MidiMapTableModel extends AbstractTableModel {  public class MidiMapTableModel extends AbstractTableModel {
43                    private final MidiMapTable table;
44          /**          /**
45           * Creates a new instance of <code>MidiMapTableModel</code>.           * Creates a new instance of <code>MidiMapTableModel</code>.
46           */           */
47          public          public
48          MidiMapTableModel() {          MidiMapTableModel(MidiMapTable table) {
49                    this.table = table;
50                  SamplerModel sm = CC.getSamplerModel();                  SamplerModel sm = CC.getSamplerModel();
51                                    
52                  for(int i = 0; i < sm.getMidiInstrumentMapCount(); i++) {                  for(int i = 0; i < sm.getMidiInstrumentMapCount(); i++) {
# Line 61  public class MidiMapTableModel extends A Line 61  public class MidiMapTableModel extends A
61           * Gets the number of columns in the model.           * Gets the number of columns in the model.
62           * @return The number of columns in the model.           * @return The number of columns in the model.
63           */           */
64            @Override
65          public int          public int
66          getColumnCount() { return 1; }          getColumnCount() { return 1; }
67                    
# Line 68  public class MidiMapTableModel extends A Line 69  public class MidiMapTableModel extends A
69           * Gets the number of rows in the model.           * Gets the number of rows in the model.
70           * @return The number of rows in the model.           * @return The number of rows in the model.
71           */           */
72            @Override
73          public int          public int
74          getRowCount() { return CC.getSamplerModel().getMidiInstrumentMapCount(); }          getRowCount() { return CC.getSamplerModel().getMidiInstrumentMapCount(); }
75                    
# Line 75  public class MidiMapTableModel extends A Line 77  public class MidiMapTableModel extends A
77           * Gets the name of the column at <code>columnIndex</code>.           * Gets the name of the column at <code>columnIndex</code>.
78           * @return The name of the column at <code>columnIndex</code>.           * @return The name of the column at <code>columnIndex</code>.
79           */           */
80            @Override
81          public String          public String
82          getColumnName(int col) { return i18n.getLabel("MidiMapTableModel.title"); }          getColumnName(int col) { return i18n.getLabel("MidiMapTableModel.title"); }
83                    
# Line 86  public class MidiMapTableModel extends A Line 89  public class MidiMapTableModel extends A
89           * @return The value for the cell at <code>columnIndex</code> and           * @return The value for the cell at <code>columnIndex</code> and
90           * <code>rowIndex</code>.           * <code>rowIndex</code>.
91           */           */
92            @Override
93          public Object          public Object
94          getValueAt(int row, int col) {          getValueAt(int row, int col) {
95                  return CC.getSamplerModel().getMidiInstrumentMap(row);                  return CC.getSamplerModel().getMidiInstrumentMap(row);
# Line 95  public class MidiMapTableModel extends A Line 99  public class MidiMapTableModel extends A
99           * Sets the value in the cell at <code>col</code>           * Sets the value in the cell at <code>col</code>
100           * and <code>row</code> to <code>value</code>.           * and <code>row</code> to <code>value</code>.
101           */           */
102            @Override
103          public void          public void
104          setValueAt(Object value, int row, int col) {          setValueAt(Object value, int row, int col) {
105                                    
# Line 105  public class MidiMapTableModel extends A Line 110  public class MidiMapTableModel extends A
110           * Returns <code>true</code> if the cell at           * Returns <code>true</code> if the cell at
111           * <code>row</code> and <code>col</code> is editable.           * <code>row</code> and <code>col</code> is editable.
112           */           */
113            @Override
114          public boolean          public boolean
115          isCellEditable(int row, int col) { return false; }          isCellEditable(int row, int col) { return false; }
116                    
# Line 116  public class MidiMapTableModel extends A Line 122  public class MidiMapTableModel extends A
122                    
123          private class Handler implements ListListener<MidiInstrumentMap>, MidiInstrumentMapListener {          private class Handler implements ListListener<MidiInstrumentMap>, MidiInstrumentMapListener {
124                  /** Invoked when an orchestra is added to the orchestra list. */                  /** Invoked when an orchestra is added to the orchestra list. */
125                    @Override
126                  public void                  public void
127                  entryAdded(ListEvent<MidiInstrumentMap> e) {                  entryAdded(ListEvent<MidiInstrumentMap> e) {
128                          e.getEntry().addMidiInstrumentMapListener(getHandler());                          e.getEntry().addMidiInstrumentMapListener(getHandler());
129                          fireTableDataChanged();                          fireTableDataChanged();
130                            table.setSelectedMidiInstrumentMap(e.getEntry());
131                  }                  }
132                    
133                  /** Invoked when an orchestra is removed from the orchestra list. */                  /** Invoked when an orchestra is removed from the orchestra list. */
134                    @Override
135                  public void                  public void
136                  entryRemoved(ListEvent<MidiInstrumentMap> e) {                  entryRemoved(ListEvent<MidiInstrumentMap> e) {
137                          e.getEntry().removeMidiInstrumentMapListener(getHandler());                          e.getEntry().removeMidiInstrumentMapListener(getHandler());
138                          fireTableDataChanged();                          fireTableDataChanged();
139                  }                  }
140                                    
141                    @Override
142                  public void                  public void
143                  nameChanged(MidiInstrumentMapEvent e) {                  nameChanged(MidiInstrumentMapEvent e) {
144                          MidiInstrumentMap m = (MidiInstrumentMap)e.getSource();                          MidiInstrumentMap m = (MidiInstrumentMap)e.getSource();
# Line 136  public class MidiMapTableModel extends A Line 146  public class MidiMapTableModel extends A
146                          fireTableRowsUpdated(idx, idx);                          fireTableRowsUpdated(idx, idx);
147                  }                  }
148                                    
149                    @Override
150                  public void                  public void
151                  instrumentAdded(MidiInstrumentMapEvent e) { }                  instrumentAdded(MidiInstrumentMapEvent e) { }
152                                    
153                    @Override
154                  public void                  public void
155                  instrumentRemoved(MidiInstrumentMapEvent e) { }                  instrumentRemoved(MidiInstrumentMapEvent e) { }
156          }          }

Legend:
Removed from v.1865  
changed lines
  Added in v.1866

  ViewVC Help
Powered by ViewVC