palmed.edit.selection
Class AbstractAction

java.lang.Object
  extended by palmed.edit.selection.AbstractAction
All Implemented Interfaces:
IAction
Direct Known Subclasses:
CharacterDeletion, CharacterInsertion, Cut, NewLineInsertion, Paste, SelectionDeletion, SelectionReplacement

public abstract class AbstractAction
extends java.lang.Object
implements IAction

This class factorizes behaviours common to all actions.

Version:
$Revision$ $Date$
Author:
Mathieu Champlon

Constructor Summary
protected AbstractAction(ISelection selection)
          Create an abstract action.
 
Method Summary
protected  void backupData()
          Backup the selected text.
protected abstract  void onPerform()
          Perform the action.
protected abstract  boolean onRedo()
          Redo the action.
protected abstract  boolean onUndo()
          Undo the action.
protected  void overwriteFinalState(AbstractAction action)
          Overwrite the current final state with the one of another action.
 void perform()
          Perform the operation.
protected  void prependData(AbstractAction action)
          Prepend the current backup data with the data from another action.
 void redo()
          Redo the operation.
protected  void restoreData()
          Remove the selected text and restore backup.
 void undo()
          Undo the operation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface palmed.edit.selection.IAction
merge
 

Constructor Detail

AbstractAction

protected AbstractAction(ISelection selection)
Create an abstract action.

Parameters:
selection - the selection
Method Detail

perform

public final void perform()
Perform the operation.

Specified by:
perform in interface IAction

undo

public final void undo()
Undo the operation.

Specified by:
undo in interface IAction

redo

public final void redo()
Redo the operation.

Specified by:
redo in interface IAction

onPerform

protected abstract void onPerform()
Perform the action.


onUndo

protected abstract boolean onUndo()
Undo the action.

Returns:
Whether the initial state must be restored or not

onRedo

protected abstract boolean onRedo()
Redo the action.

Returns:
Whether the final state must be restored or not

overwriteFinalState

protected final void overwriteFinalState(AbstractAction action)
Overwrite the current final state with the one of another action.

Parameters:
action - the action

prependData

protected final void prependData(AbstractAction action)
Prepend the current backup data with the data from another action.

Parameters:
action - the action

backupData

protected final void backupData()
Backup the selected text.


restoreData

protected final void restoreData()
Remove the selected text and restore backup.



Copyright © 2004-2006 PalmEd. All Rights Reserved.