ElementChangeSupport Class

com.bea.ide.element
ElementChangeSupport Class

public class ElementChangeSupport

    extends Object

This class implements support for element change events. A class that wants to expose this support may embed an isntance of this object and it will insure take care of handling all of the details of firing changes.


Hierarchy
Object
  ElementChangeSupport

Constructor Summary

ElementChangeSupport(Object source)

Create a new instance of the ElementChangeSupport object.
 

Method Summary

public void
addElementChangeListener(IElementChangeListener ecl)
Adds a listener to the set that will be notified if a change occurs.
public void
finalizeRoot()
Special method to clear the root in a finalizer.
public void
fireElementChange(IElement el, String sProperty, Object oldValue, Object newValue)
Fire ElementChangeEvent.ELEMENT_CHANGE_PROPERTY element change event using the provided information.
public void
fireElementChange(IElement el, IElement elChanged, int changeType)
Fire ElementChangeEvent.ELEMENT_CHANGE_CHILDREN element change event using the provided information.
public void
fireElementChange(Collection colChanges)
Fire ElementChangeEvent.ELEMENT_CHANGE_COLLECTION element change event using the provided information.
public IElement
getRoot()
Obtain the root of the element tree
public IElement
getRoot(IElementChangeListener ecl)
Obtain the root of the element tree requesting notification if it is not available.
public boolean
hasListeners()
Return a boolean indicating whether or not this object currently has any listeners registered
public boolean
removeElementChangeListener(IElementChangeListener ecl)
Removes a listener from the list to be notified when changes occur.
public void
setRoot(IElement elRoot)
Set the root of the element tree.
public IElement
waitForRoot()
Obtain the root of the element tree, and block until it's available.
 
Methods from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
   

Constructor Detail

ElementChangeSupport

public ElementChangeSupport(Object source)
Create a new instance of the ElementChangeSupport object. The provided source object will be used as the source field of the ElementChangeEvent for events this object fires.
 

Method Detail

addElementChangeListener(IElementChangeListener) Method

public void addElementChangeListener(IElementChangeListener ecl)
Adds a listener to the set that will be notified if a change occurs. If the same listener is added twice, this shows the stack in the log, but performs the add (much like java.beans.PropertyChangeSupport).

Parameters

ecl
Instance of the listener class that will be invoked

finalizeRoot() Method

public void finalizeRoot()
Special method to clear the root in a finalizer. Should only be called from a finalizer.


fireElementChange(IElement, String, Object, Object) Method

public void fireElementChange(IElement el, 
                              String sProperty, 
                              Object oldValue, 
                              Object newValue)
Fire ElementChangeEvent.ELEMENT_CHANGE_PROPERTY element change event using the provided information.

Parameters

el
Element that changed
sProperty
Property within the element that changed
oldValue
Old value of the property
newValue
New value of the property

fireElementChange(IElement, IElement, int) Method

public void fireElementChange(IElement el, 
                              IElement elChanged, 
                              int changeType)
Fire ElementChangeEvent.ELEMENT_CHANGE_CHILDREN element change event using the provided information.

Parameters

el
The element whose children have changed
elChanged
The element that was added or removed
changeType
Either ElementChangeEvent.CHILD_CHANGE_ADDED or ElementChangeEvent.CHILD_CHANGE_REMOVED indicating whether the elChanged parameter represents an addition or removal

fireElementChange(Collection) Method

public void fireElementChange(Collection colChanges)
Fire ElementChangeEvent.ELEMENT_CHANGE_COLLECTION element change event using the provided information.

Parameters

colChanges
The collection of changes to submit

getRoot() Method

public IElement getRoot()
Obtain the root of the element tree

Returns

the stored root of the element tree

getRoot(IElementChangeListener) Method

public IElement getRoot(IElementChangeListener ecl)
Obtain the root of the element tree requesting notification if it is not available. This method will try to get the current root and also add the given listener. It is guaranteed to do so in such a way that the root cannot change until the listener has been registered. This guarantees that the user will either get the new root, or get the old root, but immediately thereafter receive notification of the new root.

Returns

the stored root of the element tree

hasListeners() Method

public boolean hasListeners()
Return a boolean indicating whether or not this object currently has any listeners registered

Returns

True if there are listeners for this object, false otherwise

removeElementChangeListener(IElementChangeListener) Method

public boolean removeElementChangeListener(IElementChangeListener ecl)
Removes a listener from the list to be notified when changes occur.

Parameters

ecl
Instance of the listener class to remove

Returns

Boolean indicating whether or not the listener was found in the list of listeners. Note: if ecl is null, this method returns false.

setRoot(IElement) Method

public void setRoot(IElement elRoot)
Set the root of the element tree. Because this can be called from other threads, the listeners are fired in an invokeLater.

Parameters

elRoot
to store as the root

waitForRoot() Method

public IElement waitForRoot()
Obtain the root of the element tree, and block until it's available. Excercise care in using this method. It's almost always preferred to use getRoot(IElementChangeListener).

Returns

the stored root of the element tree. This will never be null.