001: /*
002: *
003: * JMoney - A Personal Finance Manager
004: * Copyright (c) 2004 Nigel Westbury <westbury@users.sourceforge.net>
005: *
006: *
007: * This program is free software; you can redistribute it and/or modify
008: * it under the terms of the GNU General Public License as published by
009: * the Free Software Foundation; either version 2 of the License, or
010: * (at your option) any later version.
011: *
012: * This program is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
015: * GNU General Public License for more details.
016: *
017: * You should have received a copy of the GNU General Public License
018: * along with this program; if not, write to the Free Software
019: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
020: *
021: */
022:
023: package net.sf.jmoney.model2;
024:
025: import java.util.EventListener;
026:
027: /**
028: * Listener interface for changes to the accounting data.
029: *
030: * @author Nigel Westbury
031: */
032: public interface SessionChangeListener extends EventListener {
033: /**
034: * An extendable object has been added to the datastore.
035: * <P>
036: * If an object with child objects is added to the datastore as a single
037: * transaction then this method is called only for the object itself and not
038: * for the child objects. For example, if a Transaction object and its list
039: * of Entry objects is added then this method will be called only for the
040: * Transaction object, but if another Entry object is added in a later
041: * transaction then this method will be called for that Entry object.
042: *
043: * All the descendents of the inserted object will already be created when
044: * this method is called.
045: *
046: * If the newly inserted object contains a reference to another object that
047: * is also created in this transaction, and if that object has not already been
048: * created (i.e. objectInserted has not yet been fired for the referenced object)
049: * then the value of the reference when this method is called will be null.
050: * A later objectChanged event will be fired after the referenced object has been
051: * created and the correct reference being set in this object. This makes things
052: * a little easier for some listeners because the listener does not have to worry about seeing
053: * a reference to an object that has not been processed in the objectInserted or
054: * objectCreated methods. It does mean the listener must be able to deal with the case
055: * where a reference is null even though a null reference is not valid, but that is
056: * an easier case with which to deal.
057: *
058: * Listeners should put code in this method to avoid complications that can
059: * arise if objects and their children are added piecemeal.
060: *
061: * @param newObject
062: */
063: void objectInserted(ExtendableObject newObject);
064:
065: /**
066: * An extendable object has been added to the datastore.
067: * <P>
068: * If an object with child objects is added to the datastore then this
069: * method is called for the inserted object and all its descendent objects.
070: * For example, if a Transaction object and its list
071: * of Entry objects is added then this method will be called for the Transaction
072: * object and for each Entry object.
073: *
074: * Listeners should put code in this method if it needs to process new objects in
075: * the same way regardless of how the object was added.
076: *
077: * @param extendableObject
078: */
079: void objectCreated(ExtendableObject newObject);
080:
081: /**
082: * An extendable object has been deleted.
083: *
084: * If an object with child objects is deleted from the datastore as a single
085: * transaction then this method is called only for the object itself and not
086: * for the child objects. For example, if a Transaction object is deleted
087: * then this method will be called only for the Transaction object and not
088: * for the Entry objects in the Transaction object. If, however, an entry is
089: * deleted from a transaction with split entries then this method will be
090: * called for that Entry object.
091: *
092: * Listeners should put code in this method to avoid complications that can
093: * arise if objects and there children are removed piecemeal.
094: *
095: * @param extendableObject
096: */
097: void objectRemoved(ExtendableObject deletedObject);
098:
099: /**
100: * An extendable object has been deleted.
101: *
102: * If an object with child objects is deleted from the datastore then this method is called for the object itself and
103: * for all the descendent objects. For example, if a Transaction object is deleted
104: * then this method will be called for the Transaction object and
105: * for the Entry objects in the Transaction object.
106: *
107: * Listeners should put code in this method if it needs to process deleted objects in
108: * the same way regardless of how the object was deleted.
109: *
110: * @param extendableObject
111: */
112: void objectDestroyed(ExtendableObject deletedObject);
113:
114: /**
115: * A scalar property in an extendable object has been changed.
116: */
117: void objectChanged(ExtendableObject changedObject,
118: ScalarPropertyAccessor changedProperty, Object oldValue,
119: Object newValue);
120:
121: /**
122: * An extendable object has been moved from one list property to another list property.
123: * The contents of the object, including the contents of any list properties in it, remain
124: * intact. References to the object also remain intact.
125: */
126: void objectMoved(ExtendableObject movedObject,
127: ExtendableObject originalParent,
128: ExtendableObject newParent,
129: ListPropertyAccessor originalParentListProperty,
130: ListPropertyAccessor newParentListProperty);
131:
132: /**
133: * This method is called after a transaction has completed firing notifications
134: * during the committing of a transaction.
135: *
136: * A listener may 'batch up' changes in the other methods and then update the view and/or data
137: * in a single pass in this method. Listeners could make all updates in the other methods and provide
138: * an empty implementation of this method, or listeners could even ignore all the other methods and
139: * do a complete refresh of a view and/or data when this method is called.
140: *
141: * If changes are made by other plug-ins outside a transaction then this method is called after each change.
142: * Listeners can thus rely on this method being called in a timely manner.
143: */
144: void performRefresh();
145:
146: }
|