com.developpez.ydisanto.swing.undo
Class UndoableJTextManager

java.lang.Object
  extended by com.developpez.ydisanto.swing.undo.UndoableJTextManager

public class UndoableJTextManager
extends java.lang.Object

UndoableJTextManager provides methods to implement undo and redo on JTextComponents using UndoMapping.

See Also:
UndoMapping

Field Summary
static javax.swing.KeyStroke DEFAULT_REDO_KEYSTROKE
          The Default redo KeyStroke builded with the KeyEvent.VK_Y key code and the InputEvent.CTRL_MASK modifier.
static javax.swing.KeyStroke DEFAULT_UNDO_KEYSTROKE
          The Default undo KeyStroke builded with the KeyEvent.VK_Z key code and the InputEvent.CTRL_MASK modifier.
 
Method Summary
 javax.swing.Action getRedoAction(javax.swing.text.JTextComponent component)
          Returns the redo Action associated with the specified JTextComponent.
static UndoableJTextManager getUndoableJTextManager()
          Returns the UndoableJTextManager object associated with the current Java application.
 javax.swing.Action getUndoAction(javax.swing.text.JTextComponent component)
          Returns the undo Action associated with the specified JTextComponent.
 javax.swing.undo.UndoManager getUndoManager(javax.swing.text.JTextComponent component)
          Returns the UndoManager associated with the specified JTextComponent.
 UndoMapping getUndoMapping(javax.swing.text.JTextComponent component)
          Returns the UndoMapping associated with the specified JTextComponent.
 boolean isUndoable(javax.swing.text.JTextComponent component)
          Returns true if the specified JTextComponent is undoable.
 UndoMapping makesUndoable(javax.swing.text.JTextComponent component)
          Makes the specified JTextComponent undoable.
 UndoMapping makesUndoable(javax.swing.text.JTextComponent component, javax.swing.KeyStroke undoKeyStroke, javax.swing.KeyStroke redoKeyStroke)
          Makes the specified JTextComponent undoable.
 UndoMapping makesUndoable(javax.swing.text.JTextComponent component, javax.swing.KeyStroke undoKeyStroke, javax.swing.KeyStroke redoKeyStroke, UndoListener listener)
          Makes the specified JTextComponent undoable.
 UndoMapping makesUndoable(javax.swing.text.JTextComponent component, UndoListener listener)
          Makes the specified JTextComponent undoable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_REDO_KEYSTROKE

public static final javax.swing.KeyStroke DEFAULT_REDO_KEYSTROKE
The Default redo KeyStroke builded with the KeyEvent.VK_Y key code and the InputEvent.CTRL_MASK modifier.


DEFAULT_UNDO_KEYSTROKE

public static final javax.swing.KeyStroke DEFAULT_UNDO_KEYSTROKE
The Default undo KeyStroke builded with the KeyEvent.VK_Z key code and the InputEvent.CTRL_MASK modifier.

Method Detail

getRedoAction

public javax.swing.Action getRedoAction(javax.swing.text.JTextComponent component)
Returns the redo Action associated with the specified JTextComponent.

Returns:
the redo Action associated with the specified JTextComponent. (null if the specified JTextComponent is not undoable).

getUndoableJTextManager

public static UndoableJTextManager getUndoableJTextManager()
Returns the UndoableJTextManager object associated with the current Java application.

Returns:
the UndoableJTextManager object associated with the current Java application.

getUndoAction

public javax.swing.Action getUndoAction(javax.swing.text.JTextComponent component)
Returns the undo Action associated with the specified JTextComponent.

Returns:
the undo Action associated with the specified JTextComponent. (null if the specified JTextComponent is not undoable).

getUndoManager

public javax.swing.undo.UndoManager getUndoManager(javax.swing.text.JTextComponent component)
Returns the UndoManager associated with the specified JTextComponent.

Returns:
the UndoManager associated with the specified JTextComponent. (null if the specified JTextComponent is not undoable).

getUndoMapping

public UndoMapping getUndoMapping(javax.swing.text.JTextComponent component)
Returns the UndoMapping associated with the specified JTextComponent.

Returns:
the UndoMapping associated with the specified JTextComponent. (null if the specified JTextComponent is not undoable).

isUndoable

public boolean isUndoable(javax.swing.text.JTextComponent component)
Returns true if the specified JTextComponent is undoable.

Returns:
true if the specified JTextComponent is undoable.

makesUndoable

public UndoMapping makesUndoable(javax.swing.text.JTextComponent component)
Makes the specified JTextComponent undoable. Also maps undo to CTRL + Z keystroke and redo to CTRL + Y keystroke.

Parameters:
component - the JTextComponent.
Returns:
the UndoMapping associated with the specified JTextComponent.

makesUndoable

public UndoMapping makesUndoable(javax.swing.text.JTextComponent component,
                                 UndoListener listener)
Makes the specified JTextComponent undoable. Also maps undo to CTRL + Z keystroke and redo to CTRL + Y keystroke.

Parameters:
component - the JTextComponent.
listener - a UndoListener.
Returns:
the UndoMapping associated with the specified JTextComponent.

makesUndoable

public UndoMapping makesUndoable(javax.swing.text.JTextComponent component,
                                 javax.swing.KeyStroke undoKeyStroke,
                                 javax.swing.KeyStroke redoKeyStroke)
Makes the specified JTextComponent undoable. Also maps undo and redo to the specified KeyStrokes (null can be specified for no mapping).

Parameters:
component - the JTextComponent.
undoKeyStroke - KeyStroke to maps undo on.
redoKeyStroke - KeyStroke to maps redo on.
Returns:
the UndoMapping associated with the specified JTextComponent.

makesUndoable

public UndoMapping makesUndoable(javax.swing.text.JTextComponent component,
                                 javax.swing.KeyStroke undoKeyStroke,
                                 javax.swing.KeyStroke redoKeyStroke,
                                 UndoListener listener)
Makes the specified JTextComponent undoable. Also maps undo and redo to the specified KeyStrokes (null can be specified for no undoMapping).

Parameters:
component - the JTextComponent.
undoKeyStroke - KeyStroke to maps undo on.
redoKeyStroke - KeyStroke to maps redo on.
listener - a UndoListener.
Returns:
the UndoMapping associated with the specified JTextComponent.