示例#1
0
 /**
  * Sets the appropriate property value, if possible. Otherwise, this silently fails.
  *
  * @param value the new value for the appropriate property
  * @param rowIndex the row corresponding to a property
  * @param columnIndex only the value column (column one) works
  */
 public void setValueAt(Object value, int rowIndex, int columnIndex) {
   if (columnIndex == 1) {
     InstancePropertyDescriptor row = getRow(rowIndex);
     if (row.isSettable(props.getObject())) {
       row.applySetter(props.getObject(), value);
     }
   }
 }
示例#2
0
 /**
  * Gets the appropriate property name or property value.
  *
  * @param rowIndex the row corresponding to a property
  * @param columnIndex either the name column (zero) or value column (one)
  * @return the name or value of the appropriate property
  */
 public Object getValueAt(int rowIndex, int columnIndex) {
   InstancePropertyDescriptor row = getRow(rowIndex);
   if (columnIndex == 0) {
     return row.getName();
   } else if (columnIndex == 1) {
     return row;
   } else {
     throw new IndexOutOfBoundsException("Not a valid cell: " + rowIndex + "x" + columnIndex);
   }
 }
示例#3
0
 /**
  * Determines if the value at a cell is editable
  *
  * @param rowIndex the property
  * @param columnIndex whether the property name (column zero) or property value (column one)
  * @return true, if the corresponding property is settable and the column index is 1
  */
 public boolean isCellEditable(int rowIndex, int columnIndex) {
   InstancePropertyDescriptor row = getRow(rowIndex);
   if (columnIndex == 0) {
     return false;
   } else if (columnIndex == 1) {
     return row.isSettable(props.getObject());
   } else {
     throw new IndexOutOfBoundsException("Not a valid cell: " + rowIndex + "x" + columnIndex);
   }
 }
示例#4
0
 /**
  * @see javax.swing.table.TableCellRenderer#getTableCellRendererComponent(javax.swing.JTable,
  *     java.lang.Object, boolean, boolean, int, int)
  */
 public Component getTableCellRendererComponent(
     JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
   InstancePropertyDescriptor v = (InstancePropertyDescriptor) value;
   try {
     lastEditor = v.getRenderer(props.getObject(), props.getPrefs().getCore());
     return lastEditor;
   } catch (PreferenceException e) {
     e.printStackTrace();
     return null;
   }
 }
示例#5
0
 /**
  * @see javax.swing.table.TableCellEditor#getTableCellEditorComponent(javax.swing.JTable,
  *     java.lang.Object, boolean, int, int)
  */
 public Component getTableCellEditorComponent(
     JTable table, Object value, boolean isSelected, int row, int column) {
   InstancePropertyDescriptor v = (InstancePropertyDescriptor) value;
   JComponent c;
   try {
     c = v.getEditor(props.getObject(), props.getPrefs().getCore());
     lastEditor = (CellEditor) c;
     return c;
   } catch (PreferenceException e) {
     e.printStackTrace();
     return null;
   }
 }
示例#6
0
    /**
     * Sort the descriptors by their display name using the current lexicographical ordering
     *
     * @param a a property descriptor
     * @param b the other ObjectPropertyDescriptor
     * @return <code>getName().compareto(b.getName())</code>
     */
    public int compare(Object a, Object b) {
      InstancePropertyDescriptor A = (InstancePropertyDescriptor) a;
      InstancePropertyDescriptor B = (InstancePropertyDescriptor) b;

      return A.getName().compareTo(B.getName());
    }