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

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

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

revision 787 by iliev, Mon Oct 10 16:03:12 2005 UTC revision 1327 by iliev, Fri Sep 7 12:09:59 2007 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 Grigor Kirilov Iliev   *   Copyright (C) 2005-2007 Grigor Iliev <grigor@grigoriliev.com>
5   *   *
6   *   This file is part of JSampler.   *   This file is part of JSampler.
7   *   *
# Line 64  import org.linuxsampler.lscp.StringListP Line 64  import org.linuxsampler.lscp.StringListP
64    
65    
66  /**  /**
67   *   * A tabular data model for representing LSCP parameters.
68     * @see ParameterTable
69   * @author Grigor Iliev   * @author Grigor Iliev
70   */   */
71  public class ParameterTableModel extends AbstractTableModel {  public class ParameterTableModel extends AbstractTableModel {
72          public final static int PARAMETER_NAME_COLUMN = 0;          public final static int PARAMETER_NAME_COLUMN = 0;
73          public final static int PARAMETER_VALUE_COLUMN = 1;          public final static int PARAMETER_VALUE_COLUMN = 1;
74                    
75          Parameter[] parameters;          private Parameter[] parameters;
76                    
77          private final BooleanCellRenderer booleanRenderer = new BooleanCellRenderer();          private final BooleanCellRenderer booleanRenderer = new BooleanCellRenderer();
78          private final BooleanCellEditor booleanEditor = new BooleanCellEditor();          private final BooleanCellEditor booleanEditor = new BooleanCellEditor();
# Line 151  public class ParameterTableModel extends Line 152  public class ParameterTableModel extends
152          public Parameter          public Parameter
153          getParameter(int row) { return parameters[row]; }          getParameter(int row) { return parameters[row]; }
154                    
155            /**
156             * Returns an appropriate renderer for the cell specified by
157             * <code>row</code> and <code>column</code>.
158             * @param row The row of the cell to render, where 0 is the first row.
159             * @param column The column of the cell to render, where 0 is the first column.
160             */
161          public TableCellRenderer          public TableCellRenderer
162          getCellRenderer(int row, int column) {          getCellRenderer(int row, int column) {
163                  if(column != PARAMETER_VALUE_COLUMN) return null;                  if(column != PARAMETER_VALUE_COLUMN) return null;
# Line 165  public class ParameterTableModel extends Line 172  public class ParameterTableModel extends
172                  return null;                  return null;
173          }          }
174                    
175            /**
176             * Returns an appropriate editor for the cell specified by
177             * <code>row</code> and <code>column</code>.
178             * @param row The row of the cell to edit, where 0 is the first row.
179             * @param column The column of the cell to edit, where 0 is the first column.
180             */
181          public TableCellEditor          public TableCellEditor
182          getCellEditor(int row, int column) {          getCellEditor(int row, int column) {
183                  if(column != PARAMETER_VALUE_COLUMN) return null;                  if(column != PARAMETER_VALUE_COLUMN) return null;
# Line 206  public class ParameterTableModel extends Line 219  public class ParameterTableModel extends
219                  return null;                  return null;
220          }          }
221                    
222            /** Gets the parameters that are shown in the table. */
223            public Parameter[]
224            getParameters() { return parameters; }
225            
226          /**          /**
227           * Sets the parameters to be shown in the table.           * Sets the parameters to be shown in the table.
228           * @param parameters The parameters to be shown in the table.           * @param parameters The parameters to be shown in the table.
# Line 258  public class ParameterTableModel extends Line 275  public class ParameterTableModel extends
275          }          }
276                    
277          /**          /**
278           * Sets the value in the cell at <code>columnIndex</code>           * Sets the value in the cell at <code>col</code>
279           * and <code>rowIndex</code> to <code>value</code>.           * and <code>row</code> to <code>value</code>.
280           */           */
281          public void          public void
282          setValueAt(Object value, int row, int col) {          setValueAt(Object value, int row, int col) {
# Line 272  public class ParameterTableModel extends Line 289  public class ParameterTableModel extends
289                    
290          /**          /**
291           * Returns <code>true</code> if the cell at           * Returns <code>true</code> if the cell at
292           * <code>rowIndex</code> and <code>columnIndex</code> is editable.           * <code>row</code> and <code>col</code> is editable.
293           */           */
294          public boolean          public boolean
295          isCellEditable(int row, int col) {          isCellEditable(int row, int col) {
# Line 360  public class ParameterTableModel extends Line 377  public class ParameterTableModel extends
377                  }                  }
378          }          }
379                    
380          /*class StringListCellEditor extends AbstractCellEditor implements TableCellEditor {          class StringListCellEditor extends AbstractCellEditor implements TableCellEditor {
381                  private final JButton editor = new JButton();                  private final JButton editor = new JButton();
382                  private final JPopupMenu menu = new JPopupMenu();                  private final JPopupMenu menu = new JPopupMenu();
383                  private final Vector<JCheckBoxMenuItem> menuItems = new Vector<JCheckBoxMenuItem>();                  private final Vector<JCheckBoxMenuItem> menuItems = new Vector<JCheckBoxMenuItem>();
# Line 369  public class ParameterTableModel extends Line 386  public class ParameterTableModel extends
386                          editor.setBorderPainted(false);                          editor.setBorderPainted(false);
387                          editor.setContentAreaFilled(false);                          editor.setContentAreaFilled(false);
388                          editor.setFocusPainted(false);                          editor.setFocusPainted(false);
389                            editor.setMargin(new java.awt.Insets(0, 0, 0, 0));
390                          editor.setFont(editor.getFont().deriveFont(java.awt.Font.PLAIN));                          editor.setFont(editor.getFont().deriveFont(java.awt.Font.PLAIN));
391                                                    
392                          editor.addActionListener(new ActionListener() {                          editor.addActionListener(new ActionListener() {
# Line 436  public class ParameterTableModel extends Line 454  public class ParameterTableModel extends
454                                  JCheckBoxMenuItem item = new JCheckBoxMenuItem(s);                                  JCheckBoxMenuItem item = new JCheckBoxMenuItem(s);
455                                  setListener(item);                                  setListener(item);
456                                                                    
457                                  for(String s2 : vals) if(s2.equals(s)) item.setSelected(true);                                  for(String s2 : vals) {
458                                            if(s2.equals(s)) item.setSelected(true);
459                                    }
460                                                                    
461                                  menu.add(item);                                  menu.add(item);
462                                  menuItems.add(item);                                  menuItems.add(item);
# Line 454  public class ParameterTableModel extends Line 474  public class ParameterTableModel extends
474                                  }                                  }
475                          });                          });
476                  }                  }
477          }*/          }
478                    
479          private static JComboBox comboBox = new JComboBox();          /*private static JComboBox comboBox = new JComboBox();
480          class StringListCellEditor extends DefaultCellEditor {          class StringListCellEditor extends DefaultCellEditor {
481                  StringListCellEditor() {                  StringListCellEditor() {
482                          super(comboBox);                          super(comboBox);
# Line 484  public class ParameterTableModel extends Line 504  public class ParameterTableModel extends
504                          for(String s : slp.getPossibilities()[0]) comboBox.addItem(s);                          for(String s : slp.getPossibilities()[0]) comboBox.addItem(s);
505                          return comboBox;                          return comboBox;
506                  }                  }
507          }          }*/
508                    
509          class StringListCellRenderer extends DefaultTableCellRenderer {          class StringListCellRenderer extends DefaultTableCellRenderer {
510                  private final StringBuffer sb = new StringBuffer();                  private final StringBuffer sb = new StringBuffer();

Legend:
Removed from v.787  
changed lines
  Added in v.1327

  ViewVC Help
Powered by ViewVC