|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bbn.openmap.MapHandlerChild
public class MapHandlerChild
MapHandlerChild shows you all the methods you need to add to an object for it be a good member of the MapHandler. The MapHandler is actually a BeanContext object, which is simply a container for a bunch of objects that may be interested in other objects. If you are using this object as a model to figure out what methods to add to other objects, there are a couple of things to notice. First, java.awt.Components already have a PropertyChangeSupport object in it, so you don't need to implement the methods that deal with property changes. For javax.swing.JComponents, they have VetoablePropertySupport build in, but that object doesn't handle certain methods needed by the BeanContextChild, most notably the (add/remove)VetoableChangeListener() methods with a specific property as an argument.
When you design a MapHandlerChild, you should make it comfortable running without references to objects it depends on. It should wait patiently for the other objects to be added to the MapHandler, and then do the work itself to hook up. It should also listen for those objects to be removed from the MapHandler, disengage gracefully, and wait patiently until it finds something else to hook up to.
An object does not have to be a MapHandlerChild to be added to the MapHandler, but it does need to be one to be able to use it. If you override and use the findAndInit(Iterator) method to look for objects, you'll find it is called on two different conditions. It's called when this MapHandlerChild is added to the MapHandler, and it then receives a list of all the objects currently contained in the MapHandler. It is also called when other objects are added to the MapHandler. The list then contains objects that have just been added. The findAndInit(Object) method has been added to allow subclassed objects to call super.findAndInit(Object) to let the super classes handles the objects they care about. You don't call the findAndInit(Object) method. You override it and implement the method so that you can look for the objects you need.
When objects are removed from the BeanContext, the childrenRemoved() method is called with a list of objects being removed. Likewise, the findAndUndo(Object) method has been added for the benefit of subclasses.
MapHandlerChild objects expect to be added to only one BeanContext. The BeanContextChildSupport object detects when it has a different BeanContext added to it, and it will fire property change notifications to get itself removed from the first BeanContext.
Field Summary | |
---|---|
protected java.beans.beancontext.BeanContextChildSupport |
beanContextChildSupport
BeanContextChildSupport object provides helper functions for BeanContextChild interface. |
protected boolean |
isolated
A boolean that prevents the BeanContextChild from looking at events from BeanContext other than the one it was originally added to. |
Constructor Summary | |
---|---|
MapHandlerChild()
|
Method Summary | |
---|---|
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener in_pcl)
Method for BeanContextChild interface. |
void |
addVetoableChangeListener(java.lang.String propertyName,
java.beans.VetoableChangeListener in_vcl)
Method for BeanContextChild interface. |
void |
childrenAdded(java.beans.beancontext.BeanContextMembershipEvent bcme)
BeanContextMembershipListener method. |
void |
childrenRemoved(java.beans.beancontext.BeanContextMembershipEvent bcme)
BeanContextMembershipListener method. |
void |
findAndInit(java.util.Iterator<?> it)
This is the method that your object can use to find other objects within the MapHandler (BeanContext). |
void |
findAndInit(java.lang.Object obj)
The findAndInit method has been made non-abstract, because it now calls this method for every object that is in the iterator it receives. |
void |
findAndUndo(java.lang.Object obj)
The childrenRemoved has been changed to go through its iterator to call this method with every object. |
void |
firePropertyChange(java.lang.String name,
java.lang.Object oldValue,
java.lang.Object newValue)
Method for BeanContextChild interface. |
void |
fireVetoableChange(java.lang.String name,
java.lang.Object oldValue,
java.lang.Object newValue)
Report a vetoable property update to any registered listeners. |
java.beans.beancontext.BeanContext |
getBeanContext()
Method for BeanContextChild interface. |
boolean |
isIsolated()
|
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener in_pcl)
Method for BeanContextChild interface. |
void |
removeVetoableChangeListener(java.lang.String propertyName,
java.beans.VetoableChangeListener in_vcl)
Method for BeanContextChild interface. |
void |
setBeanContext(java.beans.beancontext.BeanContext in_bc)
Method for BeanContextChild interface. |
void |
setIsolated(boolean isolated)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected boolean isolated
protected java.beans.beancontext.BeanContextChildSupport beanContextChildSupport
Constructor Detail |
---|
public MapHandlerChild()
Method Detail |
---|
public void findAndInit(java.util.Iterator<?> it)
it
- Iterator to use to go through a list of objects. Find the ones
you need, and hook yourself up.public void findAndInit(java.lang.Object obj)
findAndInit
in interface LightMapHandlerChild
public void childrenAdded(java.beans.beancontext.BeanContextMembershipEvent bcme)
childrenAdded
in interface java.beans.beancontext.BeanContextMembershipListener
public void childrenRemoved(java.beans.beancontext.BeanContextMembershipEvent bcme)
childrenRemoved
in interface java.beans.beancontext.BeanContextMembershipListener
public void findAndUndo(java.lang.Object obj)
findAndUndo
in interface LightMapHandlerChild
public java.beans.beancontext.BeanContext getBeanContext()
getBeanContext
in interface java.beans.beancontext.BeanContextChild
public void setBeanContext(java.beans.beancontext.BeanContext in_bc) throws java.beans.PropertyVetoException
setBeanContext
in interface java.beans.beancontext.BeanContextChild
java.beans.PropertyVetoException
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener in_pcl)
addPropertyChangeListener
in interface java.beans.beancontext.BeanContextChild
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener in_pcl)
removePropertyChangeListener
in interface java.beans.beancontext.BeanContextChild
public void addVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener in_vcl)
addVetoableChangeListener
in interface java.beans.beancontext.BeanContextChild
public void removeVetoableChangeListener(java.lang.String propertyName, java.beans.VetoableChangeListener in_vcl)
removeVetoableChangeListener
in interface java.beans.beancontext.BeanContextChild
public void firePropertyChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
public void fireVetoableChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue) throws java.beans.PropertyVetoException
No event is fired if old and new are equal and non-null.
name
- The programmatic name of the property that is about to changeoldValue
- The old value of the propertynewValue
- - The new value of the property
java.beans.PropertyVetoException
- if the recipient wishes the property change
to be rolled back.public boolean isIsolated()
public void setIsolated(boolean isolated)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |