com.javadocking.drag
Class StaticTabDragger

java.lang.Object
  extended by com.javadocking.drag.StaticTabDragger
All Implemented Interfaces:
Dragger

public class StaticTabDragger
extends java.lang.Object
implements Dragger

This is a class for dragging one dockable or all the dockables in a java.swing.JTabbedPane. One dockable can be dragged by dragging the tab. All the dockables can be dragged by dragging another part of the tabbed pane. A CompositeDockable is created with the dockables of the javax.swing.JTabbedPane.

The Docks that are used in the application should inherit from the java.awt.Component class.

With this class a tab of the javax.swing.JTabbedPane can also be dragged. This happens, when one tab is dragged, and the mouse is over the header of the JTabbedPane.

Author:
Heidi Rakels.

Constructor Summary
StaticTabDragger()
          Constructs a dragger with a default painter for painting the dragged dockables: a SwDockableDragPainter with a DefaultRectanglePainter.
StaticTabDragger(DockableDragPainter dockableDragPainter)
          Constructs a dragger with the given painter for painting the dragged dockables.
 
Method Summary
 void cancelDragging(java.awt.event.MouseEvent mouseEvent)
          Resets the cursor and other fields.
 void drag(java.awt.event.MouseEvent mouseEvent)
          Searches the dock where the dockable will be docked for the current mouse location.
 DockableDragPainter getDockableDragPainter()
          Gets the painter for painting the dragged dockables.
protected  java.awt.Cursor retrieveCanDockCursor()
          Gets the cursor that is used for dragging a dockable, when the dockable can be docked in an underlying dock.
protected  java.awt.Cursor retrieveCanNotDockCursor()
          Gets the cursor that is used for dragging a dockable, when the dockable cannot be docked in an underlying dock.
 void setDockableDragPainter(DockableDragPainter dockableDragPainter)
          Sets the painter for painting the dragged dockables.
 void showPopupMenu(java.awt.event.MouseEvent mouseEvent)
          Shows the popup menu for the selected dockable or the selected composite dockable.
 boolean startDragging(java.awt.event.MouseEvent mouseEvent)
           Tries to start the dragging of a Dockable from a source Dock to a destination dock.
 void stopDragging(java.awt.event.MouseEvent mouseEvent)
          Resets the cursor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StaticTabDragger

public StaticTabDragger()
Constructs a dragger with a default painter for painting the dragged dockables: a SwDockableDragPainter with a DefaultRectanglePainter.


StaticTabDragger

public StaticTabDragger(DockableDragPainter dockableDragPainter)
Constructs a dragger with the given painter for painting the dragged dockables.

Parameters:
dockableDragPainter - The painter for painting the dragged dockables.
Method Detail

startDragging

public boolean startDragging(java.awt.event.MouseEvent mouseEvent)
Description copied from interface: Dragger

Tries to start the dragging of a Dockable from a source Dock to a destination dock.

The dockable that should be dragged is searched for the given mouse position.

Specified by:
startDragging in interface Dragger
Parameters:
mouseEvent - The mouse event that was triggered.
Returns:
True if the dragging of a dockable could be started, false otherwise.

drag

public void drag(java.awt.event.MouseEvent mouseEvent)
Searches the dock where the dockable will be docked for the current mouse location. A rectangle is painted that shows, where the dockable will be docked. The cursor shows, if we can dock, or if we cannot dock for the current location.

Specified by:
drag in interface Dragger
Parameters:
mouseEvent - The new mouse event that was triggered.

cancelDragging

public void cancelDragging(java.awt.event.MouseEvent mouseEvent)
Resets the cursor and other fields. Cleans up what was painted before. Leaves the dragged dockable in its origin dock.

Specified by:
cancelDragging in interface Dragger
Parameters:
mouseEvent - The last mouse event that was triggered.

stopDragging

public void stopDragging(java.awt.event.MouseEvent mouseEvent)
Resets the cursor. Cleans up what was painted before. Searches a destination dock for the last mouse location and tries to dock the dragged dockable in this dock.

Specified by:
stopDragging in interface Dragger
Parameters:
mouseEvent - The last mouse event that was triggered.

showPopupMenu

public void showPopupMenu(java.awt.event.MouseEvent mouseEvent)
Description copied from interface: Dragger
Shows the popup menu for the selected dockable or the selected composite dockable.

Specified by:
showPopupMenu in interface Dragger
Parameters:
mouseEvent - The last mouse event that was triggered.

getDockableDragPainter

public DockableDragPainter getDockableDragPainter()
Gets the painter for painting the dragged dockables.

Returns:
dockableDragPainter The painter for painting the dragged dockables.

setDockableDragPainter

public void setDockableDragPainter(DockableDragPainter dockableDragPainter)
Sets the painter for painting the dragged dockables.

Parameters:
dockableDragPainter - The painter for painting the dragged dockables.

retrieveCanDockCursor

protected java.awt.Cursor retrieveCanDockCursor()
Gets the cursor that is used for dragging a dockable, when the dockable can be docked in an underlying dock.

Returns:
The cursor that is used for dragging a dockable, when the dockable can be docked in an underlying dock.

retrieveCanNotDockCursor

protected java.awt.Cursor retrieveCanNotDockCursor()
Gets the cursor that is used for dragging a dockable, when the dockable cannot be docked in an underlying dock.

Returns:
The cursor that is used for dragging a dockable, when the dockable cannot be docked in an underlying dock.