butler.swing.record
Class RecordController

java.lang.Object
  extended by butler.swing.record.RecordController
All Implemented Interfaces:
RecordSelectionListener, java.awt.event.ActionListener, java.util.EventListener, javax.swing.event.ListSelectionListener

public class RecordController
extends java.lang.Object
implements java.awt.event.ActionListener, javax.swing.event.ListSelectionListener, RecordSelectionListener

Controls editing of one record. This class keeps tracks of the column editors and does the right thing at save and new operations.

Author:
Fredrik Bertilsson

Field Summary
static java.lang.String DELETE_ACTION_COMMAND
           
static java.lang.String NEW_ACTION_COMMAND
           
static java.lang.String SAVE_ACTION_COMMAND
           
 
Constructor Summary
RecordController(Record rec)
           
RecordController(Table tab)
           
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent e)
           
 void addChangeListener(javax.swing.event.ChangeListener listener)
           
 void addRecordSelectionListener(RecordSelectionListener listener)
           
 ValueEditor createEditor(Column col)
          Creates and registers a appropiate editor for given column.
 void deleteRecord()
           
 java.awt.event.ActionListener getDeleteListener()
           
 java.awt.event.ActionListener getNewListener()
           
 Record getRecord()
           
 SaveAction getSaveAction()
           
 java.awt.event.ActionListener getSaveListener()
          Deprecated. Use getSaveAction
 Table getTable()
           
 boolean isDirty()
           
 boolean isRecordEdited()
           
 void newRecord()
           
 void recordListSelected(RecordList recList)
           
 void recordSelected(Record rec)
           
 void register(Column col, RecordSelector selector)
          Registers an record selector for a pk or fk column.
 void register(Column col, ValueEditor editor)
          Registers an editor for a column.
 void register(ForeignKey fk, RecordSelector selector)
          Registers an editor for a foreign key.
 void register(ManyToManyRelation relation, RecordSelector selector)
           
 void save()
           
 void setListModel(RecordListModel model)
          Sets the RecordListModel from which records are picked, if such exists.
 void setRecord(Record rec)
           
 void valueChanged(javax.swing.event.ListSelectionEvent e)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SAVE_ACTION_COMMAND

public static final java.lang.String SAVE_ACTION_COMMAND
See Also:
Constant Field Values

NEW_ACTION_COMMAND

public static final java.lang.String NEW_ACTION_COMMAND
See Also:
Constant Field Values

DELETE_ACTION_COMMAND

public static final java.lang.String DELETE_ACTION_COMMAND
See Also:
Constant Field Values
Constructor Detail

RecordController

public RecordController(Table tab)
                 throws java.lang.Exception
Throws:
java.lang.Exception

RecordController

public RecordController(Record rec)
                 throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

register

public void register(Column col,
                     ValueEditor editor)
Registers an editor for a column.

Parameters:
col - Column
editor - Editor

register

public void register(Column col,
                     RecordSelector selector)
Registers an record selector for a pk or fk column. This is only possible if the primary or foreign key contains only one column.

Parameters:
col - Column
selector - RecordSelector

register

public void register(ForeignKey fk,
                     RecordSelector selector)
Registers an editor for a foreign key.

Parameters:
fk - Foreign key
selector - Record selector

register

public void register(ManyToManyRelation relation,
                     RecordSelector selector)

createEditor

public ValueEditor createEditor(Column col)
                         throws java.lang.Exception
Creates and registers a appropiate editor for given column.

Throws:
java.lang.Exception

setListModel

public void setListModel(RecordListModel model)
Sets the RecordListModel from which records are picked, if such exists. At new operation this RecordListModel will be updated.


getTable

public Table getTable()

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent e)
Specified by:
actionPerformed in interface java.awt.event.ActionListener

save

public void save()
          throws java.lang.Exception
Throws:
java.lang.Exception

newRecord

public void newRecord()
               throws java.lang.Exception
Throws:
java.lang.Exception

deleteRecord

public void deleteRecord()
                  throws java.lang.Exception
Throws:
java.lang.Exception

setRecord

public void setRecord(Record rec)
               throws java.lang.Exception
Throws:
java.lang.Exception

getRecord

public Record getRecord()

valueChanged

public void valueChanged(javax.swing.event.ListSelectionEvent e)
Specified by:
valueChanged in interface javax.swing.event.ListSelectionListener

recordSelected

public void recordSelected(Record rec)
                    throws java.lang.Exception
Specified by:
recordSelected in interface RecordSelectionListener
Throws:
java.lang.Exception

recordListSelected

public void recordListSelected(RecordList recList)
Specified by:
recordListSelected in interface RecordSelectionListener

addChangeListener

public void addChangeListener(javax.swing.event.ChangeListener listener)

getSaveListener

public java.awt.event.ActionListener getSaveListener()
Deprecated. Use getSaveAction


getNewListener

public java.awt.event.ActionListener getNewListener()

getDeleteListener

public java.awt.event.ActionListener getDeleteListener()

addRecordSelectionListener

public void addRecordSelectionListener(RecordSelectionListener listener)

isDirty

public boolean isDirty()

getSaveAction

public SaveAction getSaveAction()

isRecordEdited

public boolean isRecordEdited()