bibliothek.gui.dock.control.relocator
Class AbstractDockRelocator

java.lang.Object
  extended by bibliothek.gui.dock.control.relocator.AbstractDockRelocator
All Implemented Interfaces:
DockRelocator
Direct Known Subclasses:
DefaultDockRelocator

public abstract class AbstractDockRelocator
extends java.lang.Object
implements DockRelocator

A manager adding MouseListener and MouseMotionListener to every DockElementRepresentatives and handling the drag and drop events.
The behaviour of a drag and drop operation can be made dependent of the keys that are pressed, using some DockRelocatorModes. These modes are added through addMode(DockRelocatorMode)

Author:
Benjamin Sigg

Constructor Summary
AbstractDockRelocator(DockController controller)
          Creates a new manager.
 
Method Summary
 void addDockRelocatorListener(DockRelocatorListener listener)
          Deprecated. 
 void addMode(DockRelocatorMode mode)
          Adds a mode to this relocator, a mode can be activated or deactivated when the user presses a button like "ctrl" or "shift" during a drag and drop operation.
 void addVetoableDockRelocatorListener(VetoableDockRelocatorListener listener)
          Adds a listener to this manager.
protected  void checkModes(int modifiers)
          Ensures that all DockRelocatorModes are in the state that fits the current set of modifiers.
protected  void disableAllModes()
          Sets all DockRelocatorModes to inactive.
protected  void fireCancel(Dockable dockable)
          Informs all listeners that a drag and drop operation has been canceled.
protected  void fireCanceled(DockRelocatorEvent event)
          Calls VetoableDockRelocatorListener.grabbing(DockRelocatorEvent) on all listeners that are currently registered.
protected  void fireDrag(Dockable dockable, DockStation station)
          Informs all listeners that dockable will be dragged.
protected  void fireDragged(DockRelocatorEvent event)
          Calls VetoableDockRelocatorListener.dragged(DockRelocatorEvent) on all listeners that are currently registered.
protected  void fireDrop(Dockable dockable, DockStation station)
          Informs all listeners that dockable was dropped on station.
protected  void fireDropped(DockRelocatorEvent event)
          Calls VetoableDockRelocatorListener.canceled(DockRelocatorEvent) on all listeners that are currently registered.
protected  void fireDropping(DockRelocatorEvent event)
          Calls VetoableDockRelocatorListener.dropping(DockRelocatorEvent) on all listeners that are currently registered.
protected  void fireGrabbed(DockRelocatorEvent event)
          Calls VetoableDockRelocatorListener.grabbed(DockRelocatorEvent) on all listeners that are currently registered.
protected  void fireGrabbing(DockRelocatorEvent event)
          Calls VetoableDockRelocatorListener.grabbing(DockRelocatorEvent) on all listeners that are currently registered.
protected  void fireInit(Dockable dockable)
          Informs all listeners that the drag-gesture has been made.
 DockController getController()
          Gets the controller for which this relocator works.
 int getDragDistance()
          Gets the distance the user must move the mouse in order to begin a drag operation.
 Merger getMerger()
          Gets an algorithm useful for merging two DockStations.
 boolean isDragOnlyTitel()
          Tells whether dockables can only be dragged through their title or not.
protected  DockRelocatorListener[] listListeners()
          Gets a list of all currently registered listeners.
 void removeDockRelocatorListener(DockRelocatorListener listener)
          Deprecated. 
 void removeMode(DockRelocatorMode mode)
          Removes a mode that has earlier been added to this relocator.
 void removeVetoableDockRelocatorListener(VetoableDockRelocatorListener listener)
          Removes a listener from this manager.
 void setDragDistance(int dragDistance)
          Sets the distance the user must move the mouse in order to begin a drag operation.
 void setDragOnlyTitel(boolean dragOnlyTitel)
          Tells whether dockables can only be dragged through their title or not.
 void setMerger(Merger merger)
          Sets an algorithm for merging two DockStations.
protected  VetoableDockRelocatorListener[] vetoableListeners()
          Gets all the VetoableDockRelocatorListener that are currently registered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface bibliothek.gui.dock.control.DockRelocator
createDirectRemote, createDirectRemote, createRemote, createRemote, isOnMove, isOnPut
 

Constructor Detail

AbstractDockRelocator

public AbstractDockRelocator(DockController controller)
Creates a new manager.

Parameters:
controller - the controller whose dockables are moved
Method Detail

getController

public DockController getController()
Gets the controller for which this relocator works.

Returns:
the controller

addDockRelocatorListener

@Deprecated
public void addDockRelocatorListener(DockRelocatorListener listener)
Deprecated. 

Description copied from interface: DockRelocator
Adds a listener to this manager. The listener will be informed whenever a Dockable is moved.

Specified by:
addDockRelocatorListener in interface DockRelocator
Parameters:
listener - the new listener

removeDockRelocatorListener

@Deprecated
public void removeDockRelocatorListener(DockRelocatorListener listener)
Deprecated. 

Description copied from interface: DockRelocator
Removes a listener from this manager.

Specified by:
removeDockRelocatorListener in interface DockRelocator
Parameters:
listener - the listener to remove

listListeners

protected DockRelocatorListener[] listListeners()
Gets a list of all currently registered listeners.

Returns:
the list of listeners

fireInit

protected void fireInit(Dockable dockable)
Informs all listeners that the drag-gesture has been made.

Parameters:
dockable - the element that will be dragged.

fireCancel

protected void fireCancel(Dockable dockable)
Informs all listeners that a drag and drop operation has been canceled.

Parameters:
dockable - the element that was grabbed

fireDrag

protected void fireDrag(Dockable dockable,
                        DockStation station)
Informs all listeners that dockable will be dragged.

Parameters:
dockable - the dragged Dockable
station - the parent of dockable

fireDrop

protected void fireDrop(Dockable dockable,
                        DockStation station)
Informs all listeners that dockable was dropped on station.

Parameters:
dockable - the dropped Dockable
station - the new owner of dockable

addVetoableDockRelocatorListener

public void addVetoableDockRelocatorListener(VetoableDockRelocatorListener listener)
Description copied from interface: DockRelocator
Adds a listener to this manager. The listener will be informed whenever a Dockable is moved.

Specified by:
addVetoableDockRelocatorListener in interface DockRelocator
Parameters:
listener - the new listener

removeVetoableDockRelocatorListener

public void removeVetoableDockRelocatorListener(VetoableDockRelocatorListener listener)
Description copied from interface: DockRelocator
Removes a listener from this manager.

Specified by:
removeVetoableDockRelocatorListener in interface DockRelocator
Parameters:
listener - the listener to remove

vetoableListeners

protected VetoableDockRelocatorListener[] vetoableListeners()
Gets all the VetoableDockRelocatorListener that are currently registered.

Returns:
all the listeners

fireGrabbing

protected void fireGrabbing(DockRelocatorEvent event)
Calls VetoableDockRelocatorListener.grabbing(DockRelocatorEvent) on all listeners that are currently registered.

Parameters:
event - the event to forward

fireGrabbed

protected void fireGrabbed(DockRelocatorEvent event)
Calls VetoableDockRelocatorListener.grabbed(DockRelocatorEvent) on all listeners that are currently registered.

Parameters:
event - the event to forward

fireDragged

protected void fireDragged(DockRelocatorEvent event)
Calls VetoableDockRelocatorListener.dragged(DockRelocatorEvent) on all listeners that are currently registered.

Parameters:
event - the event to forward

fireDropping

protected void fireDropping(DockRelocatorEvent event)
Calls VetoableDockRelocatorListener.dropping(DockRelocatorEvent) on all listeners that are currently registered.

Parameters:
event - the event to forward

fireDropped

protected void fireDropped(DockRelocatorEvent event)
Calls VetoableDockRelocatorListener.canceled(DockRelocatorEvent) on all listeners that are currently registered.

Parameters:
event - the event to forward

fireCanceled

protected void fireCanceled(DockRelocatorEvent event)
Calls VetoableDockRelocatorListener.grabbing(DockRelocatorEvent) on all listeners that are currently registered.

Parameters:
event - the event to forward

isDragOnlyTitel

public boolean isDragOnlyTitel()
Tells whether dockables can only be dragged through their title or not.

Specified by:
isDragOnlyTitel in interface DockRelocator
Returns:
true if a Dockable must be dragged through their titles, false if every part of the dockable can be grabbed by the mouse.
See Also:
setDragOnlyTitel(boolean)

setDragOnlyTitel

public void setDragOnlyTitel(boolean dragOnlyTitel)
Tells whether dockables can only be dragged through their title or not.

Specified by:
setDragOnlyTitel in interface DockRelocator
Parameters:
dragOnlyTitel - true if a Dockable must be dragged through its title, false if every part of the dockable can be grabbed by the mouse.

getDragDistance

public int getDragDistance()
Gets the distance the user must move the mouse in order to begin a drag operation.

Specified by:
getDragDistance in interface DockRelocator
Returns:
the distance in pixel

setDragDistance

public void setDragDistance(int dragDistance)
Sets the distance the user must move the mouse in order to begin a drag operation.

Specified by:
setDragDistance in interface DockRelocator
Parameters:
dragDistance - the distance in pixel

getMerger

public Merger getMerger()
Gets an algorithm useful for merging two DockStations.

Specified by:
getMerger in interface DockRelocator
Returns:
the algorithm, can be null

setMerger

public void setMerger(Merger merger)
Sets an algorithm for merging two DockStations.

Specified by:
setMerger in interface DockRelocator
Parameters:
merger - the new algorithm, can be null

addMode

public void addMode(DockRelocatorMode mode)
Adds a mode to this relocator, a mode can be activated or deactivated when the user presses a button like "ctrl" or "shift" during a drag and drop operation.

Specified by:
addMode in interface DockRelocator
Parameters:
mode - the new mode, not null

removeMode

public void removeMode(DockRelocatorMode mode)
Removes a mode that has earlier been added to this relocator.

Specified by:
removeMode in interface DockRelocator
Parameters:
mode - the mode to remove

disableAllModes

protected void disableAllModes()
Sets all DockRelocatorModes to inactive.


checkModes

protected void checkModes(int modifiers)
Ensures that all DockRelocatorModes are in the state that fits the current set of modifiers.

Parameters:
modifiers - the state of the last MouseEvent, see InputEvent.getModifiersEx()