bibliothek.gui.dock.control
Class DockRelocator

java.lang.Object
  extended by bibliothek.gui.dock.control.DockRelocator
Direct Known Subclasses:
DefaultDockRelocator

public abstract class DockRelocator
extends Object

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
DockRelocator(DockController controller)
          Creates a new manager.
 
Method Summary
 void addDockRelocatorListener(DockRelocatorListener listener)
          Adds a listener to this manager.
 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.
protected  void checkModes(int modifiers)
          Ensures that all DockRelocatorModes are in the state that fits the current set of modifiers.
abstract  DirectRemoteRelocator createDirectRemote(Dockable dockable)
          Creates a device with which drag&drop operations concerning dockable can be initiated and executed.
abstract  RemoteRelocator createRemote(Dockable dockable)
          Creates a device with which drag&drop operations concerning dockable can be initiated and executed.
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 fireDrag(Dockable dockable, DockStation station)
          Informs all listeners that dockable will be dragged.
protected  void fireDrop(Dockable dockable, DockStation station)
          Informs all listeners that dockable was dropped on station.
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.
abstract  boolean isOnMove()
          Tells whether the user has currently grabbed a dockable and moves the dockable around.
abstract  boolean isOnPut()
          Tells whether this relocator currently puts a Dockable.
protected  DockRelocatorListener[] listListeners()
          Gets a list of all currently registered listeners.
 void removeDockRelocatorListener(DockRelocatorListener listener)
          Removes a listener from this manager.
 void removeMode(DockRelocatorMode mode)
          Removes a mode that has earlier been added to this relocator.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DockRelocator

public DockRelocator(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

public void addDockRelocatorListener(DockRelocatorListener listener)
Adds a listener to this manager. The listener will be informed whenever a Dockable is moved.

Parameters:
listener - the new listener

removeDockRelocatorListener

public void removeDockRelocatorListener(DockRelocatorListener listener)
Removes a listener from this manager.

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

isDragOnlyTitel

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

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.

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.

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.

Parameters:
dragDistance - the distance in pixel

getMerger

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

Returns:
the algorithm, can be null

setMerger

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

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.

Parameters:
mode - the new mode, not null

removeMode

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

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()

isOnMove

public abstract boolean isOnMove()
Tells whether the user has currently grabbed a dockable and moves the dockable around.

Returns:
true if a Dockable is currently dragged

isOnPut

public abstract boolean isOnPut()
Tells whether this relocator currently puts a Dockable. A Dockable is put as soon as the user releases the mouse.

Returns:
true if a Dockable is moved

createDirectRemote

public abstract DirectRemoteRelocator createDirectRemote(Dockable dockable)
Creates a device with which drag&drop operations concerning dockable can be initiated and executed.

Parameters:
dockable - the dockable which might be moved
Returns:
the new remote

createRemote

public abstract RemoteRelocator createRemote(Dockable dockable)
Creates a device with which drag&drop operations concerning dockable can be initiated and executed.

Parameters:
dockable - the dockable which might be moved
Returns:
the new remote