/** * Set the subject bean to check for properties. * * @param o the subject bean */ public void setObject(Object o) { if (o != props.getObject()) { if (getTable().isEditing()) { getTable().editingStopped(new ChangeEvent(this)); } getTable().editingCanceled(new ChangeEvent(this)); props.setObject(o); getTableModel().fireTableStructureChanged(); getTable().setRowHeightToMaximumPreferredHeight(); } }
/** Create a new, empty property sheet. */ public PropertySheet() { super(new EnhancedTable()); this.getPreferredSize(); props = new ForClassPropertyList(); // Add bean change event listener props.addChangeListener( new ChangeListener() { public void stateChanged(ChangeEvent e) { // XXX Should I fire a 'stop editing' event here? refresh(); } }); // Add table JTable table = getTable(); MyTableModel tableModel = new MyTableModel(); table.setModel(tableModel); table.setDefaultRenderer(InstancePropertyDescriptor.class, new MyCellRenderer()); table.setDefaultEditor(InstancePropertyDescriptor.class, new MyCellEditor()); }
/** Refresh the properties from the bound object. */ public void refresh() { props.refresh(); getTableModel().fireTableDataChanged(); }
/** * Gets the bound subject bean. * * @return the subject */ public Object getObject() { return props.getObject(); }
/** * Sets the preference manager associated with this property sheet. This is necessary for * localization and determining extended properties. * * @param manager the preference manager */ public void setPrefs(PrefsManager manager) { props.setPrefs(manager); }
/** * Gets the preference manager associated with this property sheet. * * @return the preference manager */ public PrefsManager getPrefs() { return props.getPrefs(); }