ca.sqlpower.architect
Class SQLObjectPreEvent

java.lang.Object
  extended by ca.sqlpower.architect.SQLObjectPreEvent
All Implemented Interfaces:
java.io.Serializable

public class SQLObjectPreEvent
extends java.lang.Object
implements java.io.Serializable

Event object associated with the SQLObject pre-event system. Presently, this event class does not support property change type events; this will be added in the future if the need arises.

See Also:
Serialized Form

Constructor Summary
SQLObjectPreEvent(SQLObject source, int[] changeIndices, SQLObject[] children)
          Use this constructor for DBChildrenInserted and DBChildrenRemoved type events.
 
Method Summary
 int[] getChangeIndices()
          Returns the child indices that may be added/removed.
 SQLObject[] getChildren()
          Returns the child objects that may be added/removed.
 SQLObject getSource()
          Returns the source object of this event.
 boolean isVetoed()
          Returns whether or not this event has been vetoed yet.
 void veto()
          Sets the vetoed state of this event to true.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SQLObjectPreEvent

public SQLObjectPreEvent(SQLObject source,
                         int[] changeIndices,
                         SQLObject[] children)
Use this constructor for DBChildrenInserted and DBChildrenRemoved type events. propertyName will be set to the string "children".

Parameters:
source - The SQLObject that may undergo a change.
changeIndices - The indices of the children that might be added or removed. The indices must be in ascending order.
children - The actual SQLObject instances that might be added or removed to/from the source object.
Method Detail

getChangeIndices

public int[] getChangeIndices()
Returns the child indices that may be added/removed. Do not modify the returned array.


getChildren

public SQLObject[] getChildren()
Returns the child objects that may be added/removed. Do not modify the returned array.


getSource

public SQLObject getSource()
Returns the source object of this event. In the case of an add/remove notification, this is the parent object that is imminently gaining or losing children.


veto

public void veto()
Sets the vetoed state of this event to true. This means that, once all pre-event listeners have been notified of the impending change, the source object will abort the operation it was about to carry out. If none of the listeners veto this event, it the source object should proceed with the action (which will cause a corresponding SQLObject event to be fired announcing that the change has actually taken place).


isVetoed

public boolean isVetoed()
Returns whether or not this event has been vetoed yet. In general, it is only useful for the source SQLObject (the one firing the event) to check this, and only then after all listeners have been notified. The reason is, listeners have no way of knowing how many other listeners there are for this event, or what order those listeners will be notified in. This means that if a listener checks the vetoed state of the event, it is likely to get a false negative response.



Copyright © 2003-2007 SQL Power Group Inc. www.sqlpower.ca