bibliothek.gui.dock.control
Class MouseFocusObserver

java.lang.Object
  extended by bibliothek.gui.dock.control.MouseFocusObserver
All Implemented Interfaces:
DockRegisterListener, DockRelocatorListener, DockTitleBindingListener
Direct Known Subclasses:
DefaultMouseFocusObserver, SecureMouseFocusObserver

public abstract class MouseFocusObserver
extends Object
implements DockRegisterListener, DockRelocatorListener, DockTitleBindingListener

A FocusController listens to all AWT-events. As soon as the mouse is pressed over a Dockable, the FocusController will inform the DockController about a new front-dockable.

Author:
Benjamin Sigg

Constructor Summary
MouseFocusObserver(DockController controller, ControllerSetupCollection setup)
          Creates a new FocusController.
 
Method Summary
 void addVetoListener(FocusVetoListener listener)
          Adds a listener to this controller which can cancel a call to the DockController.
 void cancel(DockController controller, Dockable dockable)
          Invoked when a drag and drop operation was initiated, but canceld.
protected  void check(AWTEvent event)
          Lets check this controller whether the focus should change, or not.
protected  void check(Component component)
          Tries to find the Dockable which owns component and sets this Dockable to the focusedDockable.
protected  void check(Component component, boolean ensureFocus)
          Tries to find the Dockable which owns component and sets this Dockable to the focusedDockable.
 void dockableCycledRegister(DockController controller, Dockable dockable)
          Invoked when dockable was added and removed from the controller, or was removed and added again to controller.
 void dockableFocused(DockController controller, Dockable dockable)
           
 void dockableRegistered(DockController controller, Dockable dockable)
          Invoked after a Dockable was registered.
 void dockableRegistering(DockController controller, Dockable dockable)
          Invoked right before the dockable is registered in the controller.
 void dockableUnregistered(DockController controller, Dockable dockable)
          Invoked after dockable has been unregistered from controller.
 void dockStationRegistered(DockController controller, DockStation station)
          Invoked after a DockStation was registered.
 void dockStationRegistering(DockController controller, DockStation station)
          Invoked right before the station is registered in the controller.
 void dockStationUnregistered(DockController controller, DockStation station)
          Invoked after station has been unregistered from controller.
 void drag(DockController controller, Dockable dockable, DockStation station)
          Invoked when a drag and drop operation has been confirmed.
 void drop(DockController controller, Dockable dockable, DockStation station)
          Invoked after a Dockable was dropped.
protected  boolean fireVetoDockable(Dockable dockable)
          Asks all FocusVetoListener through their method FocusVetoListener.vetoFocus(MouseFocusObserver, Dockable) whether they want cancel a call to the DockController.
protected  boolean fireVetoTitle(DockTitle title)
          Asks all FocusVetoListener through their method FocusVetoListener.vetoFocus(MouseFocusObserver, DockTitle) whether they want cancel a call to the DockController.
 DockController getController()
          Gets the affected controller.
protected  Dockable getDockable(Component component)
          Gets the top-dockable which has component or parent of component as base Component.
 void init(DockController controller, Dockable dockable)
          Invoked when a drag and drop operation is initiated.
protected  boolean interact(AWTEvent event)
          Tells whether this event should change the focus.
 void kill()
          Stops this FocusController.
 void removeVetoListener(FocusVetoListener listener)
          Removes a listener from this controller
 void titleBound(DockController controller, DockTitle title, Dockable dockable)
          Called when title was bound to dockable.
 void titleUnbound(DockController controller, DockTitle title, Dockable dockable)
          Called when title was unbound from dockable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MouseFocusObserver

public MouseFocusObserver(DockController controller,
                          ControllerSetupCollection setup)
Creates a new FocusController.

Parameters:
controller - the controller which will be informed about focus-changes
setup - an observable informing this object when controller is set up.
Method Detail

kill

public void kill()
Stops this FocusController. This controller will remove all its listeners and become ready for the garbage collector.


getController

public DockController getController()
Gets the affected controller.

Returns:
the controller

addVetoListener

public void addVetoListener(FocusVetoListener listener)
Adds a listener to this controller which can cancel a call to the DockController.

Parameters:
listener - the new listener

removeVetoListener

public void removeVetoListener(FocusVetoListener listener)
Removes a listener from this controller

Parameters:
listener - the listener to remove

fireVetoTitle

protected boolean fireVetoTitle(DockTitle title)
Asks all FocusVetoListener through their method FocusVetoListener.vetoFocus(MouseFocusObserver, DockTitle) whether they want cancel a call to the DockController.

Parameters:
title - the title which was hit by the mouse
Returns:
true if at least one veto was made, false otherwise

fireVetoDockable

protected boolean fireVetoDockable(Dockable dockable)
Asks all FocusVetoListener through their method FocusVetoListener.vetoFocus(MouseFocusObserver, Dockable) whether they want cancel a call to the DockController.

Parameters:
dockable - the Dockable which was hit by the mouse
Returns:
true if at least one veto was made, false otherwise

check

protected void check(AWTEvent event)
Lets check this controller whether the focus should change, or not. Clients invoking this method should first check whether event is allowed to change the focus or not. This check can be done through the method interact(AWTEvent).

Parameters:
event - The event to react on.
See Also:
interact(AWTEvent)

interact

protected boolean interact(AWTEvent event)
Tells whether this event should change the focus.

Parameters:
event - the event
Returns:
true if the focus could be changed

check

protected void check(Component component)
Tries to find the Dockable which owns component and sets this Dockable to the focusedDockable. The method only succeeds if no veto-listener reacts.

Parameters:
component - the component whose dockable parent is to set focused

check

protected void check(Component component,
                     boolean ensureFocus)
Tries to find the Dockable which owns component and sets this Dockable to the focusedDockable. The method only succeeds if no veto-listener reacts.

Parameters:
component - the component whose dockable parent is to set focused
ensureFocus - whether the DockController should ensure that the focus is set correctly or not.

dockableRegistered

public void dockableRegistered(DockController controller,
                               Dockable dockable)
Description copied from interface: DockRegisterListener
Invoked after a Dockable was registered. Note that this method can be called while a Dockable is dragged. See the method DockController.isOnMove().

Specified by:
dockableRegistered in interface DockRegisterListener
Parameters:
controller - the controller where dockable was added
dockable - the Dockable that was added

init

public void init(DockController controller,
                 Dockable dockable)
Description copied from interface: DockRelocatorListener
Invoked when a drag and drop operation is initiated. This method is called when the user made the gesture of dragging, but not yet of dropping.

Specified by:
init in interface DockRelocatorListener
Parameters:
controller - the origin of the event
dockable - the element that has been grabbed

cancel

public void cancel(DockController controller,
                   Dockable dockable)
Description copied from interface: DockRelocatorListener
Invoked when a drag and drop operation was initiated, but canceld. This method can be called any time after DockRelocatorListener.init(DockController, Dockable). was called.

Specified by:
cancel in interface DockRelocatorListener
Parameters:
controller - the origin of the event
dockable - the element that has been grabbed

drag

public void drag(DockController controller,
                 Dockable dockable,
                 DockStation station)
Description copied from interface: DockRelocatorListener
Invoked when a drag and drop operation has been confirmed. This method is called after the user made a drop-gesture, but before dockable is dragged from its old parent.

Specified by:
drag in interface DockRelocatorListener
Parameters:
controller - the origin of the event
dockable - the Dockable which was dragged
station - the future parent of dockable
See Also:
DockRelocatorListener.drop(DockController, Dockable, DockStation)

drop

public void drop(DockController controller,
                 Dockable dockable,
                 DockStation station)
Description copied from interface: DockRelocatorListener
Invoked after a Dockable was dropped.

Specified by:
drop in interface DockRelocatorListener
Parameters:
controller - the origin of the event
dockable - the Dockable which was dragged
station - the new parent of dockable
See Also:
DockRelocatorListener.drag(DockController, Dockable, DockStation)

dockableUnregistered

public void dockableUnregistered(DockController controller,
                                 Dockable dockable)
Description copied from interface: DockRegisterListener
Invoked after dockable has been unregistered from controller. Note that this method can be invoked while a Dockable is dragged, use the method DockController.isOnMove().

Specified by:
dockableUnregistered in interface DockRegisterListener
Parameters:
controller - the controller from where dockable was removed
dockable - the removed Dockable

dockableCycledRegister

public void dockableCycledRegister(DockController controller,
                                   Dockable dockable)
Description copied from interface: DockRegisterListener
Invoked when dockable was added and removed from the controller, or was removed and added again to controller. This method is only invoked if a call to DockRegisterListener.dockableRegistered(DockController, Dockable) and DockRegisterListener.dockableUnregistered(DockController, Dockable) was suppressed. It is unknown whether dockable is now registered at controller.

Specified by:
dockableCycledRegister in interface DockRegisterListener
Parameters:
controller - the controller whose register dockable cycled
dockable - some Dockable

titleBound

public void titleBound(DockController controller,
                       DockTitle title,
                       Dockable dockable)
Description copied from interface: DockTitleBindingListener
Called when title was bound to dockable. This method is called after the DockTitle.bind()-method was invoked.

Specified by:
titleBound in interface DockTitleBindingListener
Parameters:
controller - the origin of the event
title - the DockTitle that was bound
dockable - the owner of title

titleUnbound

public void titleUnbound(DockController controller,
                         DockTitle title,
                         Dockable dockable)
Description copied from interface: DockTitleBindingListener
Called when title was unbound from dockable. This method is called after the DockTitle.bind()-method was invoked.

Specified by:
titleUnbound in interface DockTitleBindingListener
Parameters:
controller - the origin of the event
title - the DockTitle which was unbound
dockable - the old owner of title

getDockable

protected Dockable getDockable(Component component)
Gets the top-dockable which has component or parent of component as base Component.

Parameters:
component - a Component
Returns:
a Dockable or null if nothing was found or a FocusVetoListener doesn't want to inform the controller

dockStationUnregistered

public void dockStationUnregistered(DockController controller,
                                    DockStation station)
Description copied from interface: DockRegisterListener
Invoked after station has been unregistered from controller. Note that this method can be invoked while a Dockable is dragged, use the method DockController.isOnMove().

Specified by:
dockStationUnregistered in interface DockRegisterListener
Parameters:
controller - the controller from where dockable was removed
station - the removed DockStation

dockStationRegistered

public void dockStationRegistered(DockController controller,
                                  DockStation station)
Description copied from interface: DockRegisterListener
Invoked after a DockStation was registered. This method can be called while a Dockable is dragged. See the method DockController.isOnMove().

Specified by:
dockStationRegistered in interface DockRegisterListener
Parameters:
controller - the controller where station was added
station - the DockStation that was added

dockableRegistering

public void dockableRegistering(DockController controller,
                                Dockable dockable)
Description copied from interface: DockRegisterListener
Invoked right before the dockable is registered in the controller.

Specified by:
dockableRegistering in interface DockRegisterListener
Parameters:
controller - the controller who does not yet know dockable.
dockable - the dockable who does not yet know controller.

dockStationRegistering

public void dockStationRegistering(DockController controller,
                                   DockStation station)
Description copied from interface: DockRegisterListener
Invoked right before the station is registered in the controller.

Specified by:
dockStationRegistering in interface DockRegisterListener
Parameters:
controller - the controller who does not yet know station.
station - the station who does not yet know controller.

dockableFocused

public void dockableFocused(DockController controller,
                            Dockable dockable)