edu.princeton.swing
Class ClipboardTargetManager

java.lang.Object
  extended by edu.princeton.swing.ClipboardTargetManager

public class ClipboardTargetManager
extends Object

ClipboardTargetManager is kept informed of all


Nested Class Summary
protected static class ClipboardTargetManager.CopyAction
          CopyAction is an action which calls the copy() method of the ClipboardTargetManager.
protected static class ClipboardTargetManager.CutAction
          CutAction is an action which calls the cut() method of the ClipboardTargetManager.
protected static class ClipboardTargetManager.PasteAction
          PasteAction is an action which calls the paste() method of the ClipboardTargetManager.
protected static class ClipboardTargetManager.SelectAllAction
          SelectAllAction is an action which calls the selectAll() method of the ClipboardTargetManager.
 
Field Summary
static AbstractAction2 COPY_ACTION
          An implementation of Action to use for the copy operation.
static Icon COPY_ICON
          The copy icon.
static byte[] COPY_ICON_BYTES
          The bytes for the copy icon.
static KeyStroke COPY_KEYSTROKE
          The keystroke generally associated with the copy action.
static AbstractAction2 CUT_ACTION
          An implementation of Action to use for the cut operation.
static Icon CUT_ICON
          The cut icon.
static byte[] CUT_ICON_BYTES
          The bytes for the cut icon.
static KeyStroke CUT_KEYSTROKE
          The keystroke generally associated with the cut action.
static AbstractAction2 PASTE_ACTION
          An implementation of Action to use for the paste operation.
static Icon PASTE_ICON
          The paste icon.
static byte[] PASTE_ICON_BYTES
          The bytes for the paste icon.
static KeyStroke PASTE_KEYSTROKE
          The keystroke generally associated with the paste action.
static AbstractAction2 SELECT_ALL_ACTION
          An implementation of Action to use for the selectAll operation.
static Icon SELECT_ALL_ICON
          The paste icon.
static byte[] SELECT_ALL_ICON_BYTES
          The bytes for the select all icon.
static KeyStroke SELECT_ALL_KEYSTROKE
          The keystroke generally associated with the select all action.
 
Method Summary
static void copy()
          Executes the copy() method of the ClipboardTarget which most recently owned the focus.
static JPopupMenu createDefaultPopupMenu()
          Creates a basic JPopupMenu which contains MenuItems for all the clipboard actions.
static void cut()
          Executes the cut() method of the ClipboardTarget which most recently owned the focus.
static ClipboardTarget getRecentTarget()
          Returns the ClipboardTarget which most recently owned the focus.
static void installMappings(JComponent component)
          Installs the InputMap and ActionMap mappings necessary to get the JComponent to behave correctly when the keyboard trigger for a clipboard action is fired.
static void paste()
          Executes the paste() method of the ClipboardTarget which most recently owned the focus.
static void selectAll()
          Executes the selectAll() method of the ClipboardTarget which most recently owned the focus.
static void targetAbilityChanged(ClipboardTarget target)
          The function by which a ClipboardTarget registers itself with the Manager when its canX() method changes.
static void targetGainedFocus(ClipboardTarget target)
          The function by which a ClipboardTarget registers itself with the Manager when it gains the focus.
static void targetLostFocus(ClipboardTarget target)
          The function by which a ClipboardTarget unregisters itself with the Manager when it loses the focus.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CUT_ICON_BYTES

public static final byte[] CUT_ICON_BYTES
The bytes for the cut icon.


CUT_ICON

public static final Icon CUT_ICON
The cut icon.


COPY_ICON_BYTES

public static final byte[] COPY_ICON_BYTES
The bytes for the copy icon.


COPY_ICON

public static final Icon COPY_ICON
The copy icon.


PASTE_ICON_BYTES

public static final byte[] PASTE_ICON_BYTES
The bytes for the paste icon.


PASTE_ICON

public static final Icon PASTE_ICON
The paste icon.


SELECT_ALL_ICON_BYTES

public static final byte[] SELECT_ALL_ICON_BYTES
The bytes for the select all icon.


SELECT_ALL_ICON

public static final Icon SELECT_ALL_ICON
The paste icon.


CUT_KEYSTROKE

public static final KeyStroke CUT_KEYSTROKE
The keystroke generally associated with the cut action.


COPY_KEYSTROKE

public static final KeyStroke COPY_KEYSTROKE
The keystroke generally associated with the copy action.


PASTE_KEYSTROKE

public static final KeyStroke PASTE_KEYSTROKE
The keystroke generally associated with the paste action.


SELECT_ALL_KEYSTROKE

public static final KeyStroke SELECT_ALL_KEYSTROKE
The keystroke generally associated with the select all action.


CUT_ACTION

public static final AbstractAction2 CUT_ACTION
An implementation of Action to use for the cut operation. The ClipboardTargetManager will manage the enabled status of this Action.


COPY_ACTION

public static final AbstractAction2 COPY_ACTION
An implementation of Action to use for the copy operation. The ClipboardTargetManager will manage the enabled status of this Action.


PASTE_ACTION

public static final AbstractAction2 PASTE_ACTION
An implementation of Action to use for the paste operation. The ClipboardTargetManager will manage the enabled status of this Action.


SELECT_ALL_ACTION

public static final AbstractAction2 SELECT_ALL_ACTION
An implementation of Action to use for the selectAll operation. The ClipboardTargetManager will manage the enabled status of this Action.

Method Detail

installMappings

public static void installMappings(JComponent component)
Installs the InputMap and ActionMap mappings necessary to get the JComponent to behave correctly when the keyboard trigger for a clipboard action is fired.

Parameters:
component - The component for which we should install the mappings. A NullPointerException will be thrown if this is null.

createDefaultPopupMenu

public static JPopupMenu createDefaultPopupMenu()
Creates a basic JPopupMenu which contains MenuItems for all the clipboard actions.

Returns:
A basic JPopupMenu which contains MenuItems for all the clipboard actions.

targetGainedFocus

public static void targetGainedFocus(ClipboardTarget target)
The function by which a ClipboardTarget registers itself with the Manager when it gains the focus.

Parameters:
target - The ClipboardTarget which just gained the focus.

targetLostFocus

public static void targetLostFocus(ClipboardTarget target)
The function by which a ClipboardTarget unregisters itself with the Manager when it loses the focus.

Parameters:
target - The ClipboardTarget which just lost the focus.

targetAbilityChanged

public static void targetAbilityChanged(ClipboardTarget target)
The function by which a ClipboardTarget registers itself with the Manager when its canX() method changes.

Parameters:
target - The ClipboardTarget which just lost the focus.

getRecentTarget

public static ClipboardTarget getRecentTarget()
Returns the ClipboardTarget which most recently owned the focus. If no such ClipboardTarget exists, null is returned. If that target (or one of its parents) is not currently showing, then null will be returned.

Returns:
The ClipboardTarget which most recently owned the focus.

cut

public static void cut()
Executes the cut() method of the ClipboardTarget which most recently owned the focus. If no such ClipboardTarget exists or if that target is not showing, nothing will happen.


copy

public static void copy()
Executes the copy() method of the ClipboardTarget which most recently owned the focus. If no such ClipboardTarget exists or if that target is not showing, nothing will happen.


paste

public static void paste()
Executes the paste() method of the ClipboardTarget which most recently owned the focus. If no such ClipboardTarget exists or if that target is not showing, nothing will happen.


selectAll

public static void selectAll()
Executes the selectAll() method of the ClipboardTarget which most recently owned the focus. If no such ClipboardTarget exists or if that target is not showing, nothing will happen.