net.refractions.udig.catalog.util
Class HandleListener

java.lang.Object
  extended by net.refractions.udig.catalog.util.HandleListener
All Implemented Interfaces:
java.util.EventListener, IResolveChangeListener

public abstract class HandleListener
extends java.lang.Object
implements IResolveChangeListener

Easy example that listens to a specific IResolve.

Will do its best to reduce the IResolveChangeEvent to:

Note 1: The IResolveDelta does not always include information about *your* handle. If your parent is being replaced - your direct replacement may not be available until you ask for it.

Translation repalce with a null newResolve = reset. This indicates you need to find your handle again from first principles.

Note 2: HandleListener only holds onto a IResolve with a weak reference. Although this protects you a little bit, you still need to remove zombie listeners from the catalog (they cannot do it themselves).

However when the weak reference is cleaned up, we will notice and call dispose for you.

Since:
0.9.0
Author:
jgarnett

Constructor Summary
HandleListener(IResolve handle)
           
 
Method Summary
 void changed(IResolveChangeEvent event)
          Actual listener implemtnation
abstract  void dispose()
          Called after remove while handle is invalid
 IResolve getHandle()
          Resolve the handle - will call dispose if handle has passed out of scope.
abstract  void refresh(IResolve handle)
          Called when handle has changed
abstract  void replace(IResolve handle, IResolve newHandle)
          Handle is being replaced with newHandle.
abstract  void reset(IResolve handle, IResolveChangeEvent event)
          This is a replace where the replacement is unknown.
 void setHandle(IResolve newHandle)
          Can be called during a repalce, or reset to switch this listener over to the new handle.
abstract  void start(IResolve handle)
          Called after create with valid handle
abstract  void stop(IResolve handle)
          Called before remove while handle is still valid
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HandleListener

public HandleListener(IResolve handle)
Method Detail

getHandle

public IResolve getHandle()
Resolve the handle - will call dispose if handle has passed out of scope.


setHandle

public void setHandle(IResolve newHandle)
Can be called during a repalce, or reset to switch this listener over to the new handle.

Parameters:
handle -

start

public abstract void start(IResolve handle)
Called after create with valid handle


stop

public abstract void stop(IResolve handle)
Called before remove while handle is still valid


dispose

public abstract void dispose()
Called after remove while handle is invalid


refresh

public abstract void refresh(IResolve handle)
Called when handle has changed


replace

public abstract void replace(IResolve handle,
                             IResolve newHandle)
Handle is being replaced with newHandle.

Note: This method is called post change, the newHandle already exists in the catalog.

You have two options:


reset

public abstract void reset(IResolve handle,
                           IResolveChangeEvent event)
This is a replace where the replacement is unknown.

This occurs when:

In both cases you have two options:

Parameters:
handle -

changed

public final void changed(IResolveChangeEvent event)
Actual listener implemtnation

Specified by:
changed in interface IResolveChangeListener
Parameters:
event - the resource change event
See Also:
IResourceDelta