edu.umd.cfar.lamp.apploader.undo
Class ActionHistoryPane

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Container
          extended byjavax.swing.JComponent
              extended byjavax.swing.JScrollPane
                  extended byedu.umd.cfar.lamp.apploader.undo.ActionHistoryPane
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.image.ImageObserver, java.awt.MenuContainer, javax.swing.ScrollPaneConstants, java.io.Serializable

public class ActionHistoryPane
extends javax.swing.JScrollPane

A javabean/Swing widget that provides a view into the user's undo history. It is designed to work with the AppLoader framework.

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class javax.swing.JScrollPane
javax.swing.JScrollPane.AccessibleJScrollPane, javax.swing.JScrollPane.ScrollBar
 
Nested classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Nested classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class javax.swing.JScrollPane
columnHeader, horizontalScrollBar, horizontalScrollBarPolicy, lowerLeft, lowerRight, rowHeader, upperLeft, upperRight, verticalScrollBar, verticalScrollBarPolicy, viewport
 
Fields inherited from class javax.swing.JComponent
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface javax.swing.ScrollPaneConstants
COLUMN_HEADER, HORIZONTAL_SCROLLBAR, HORIZONTAL_SCROLLBAR_ALWAYS, HORIZONTAL_SCROLLBAR_AS_NEEDED, HORIZONTAL_SCROLLBAR_NEVER, HORIZONTAL_SCROLLBAR_POLICY, LOWER_LEADING_CORNER, LOWER_LEFT_CORNER, LOWER_RIGHT_CORNER, LOWER_TRAILING_CORNER, ROW_HEADER, UPPER_LEADING_CORNER, UPPER_LEFT_CORNER, UPPER_RIGHT_CORNER, UPPER_TRAILING_CORNER, VERTICAL_SCROLLBAR, VERTICAL_SCROLLBAR_ALWAYS, VERTICAL_SCROLLBAR_AS_NEEDED, VERTICAL_SCROLLBAR_NEVER, VERTICAL_SCROLLBAR_POLICY, VIEWPORT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
ActionHistoryPane()
          Creates a new history pane without any undo objects.
 
Method Summary
 void addAction(javax.swing.undo.UndoableEdit e)
          Add a new action after the cursor.
 void addHistoryChangeListener(javax.swing.event.ChangeListener cl)
          Add a listener for history change events.
 boolean canRedo()
          Tests to see if any redo events are available above the stack.
 boolean canUndo()
          Tests to see if any undo events are available on the stack.
 void fireHistoryChangeEvent()
          Fire a history change event to all attached listeners.
 int getBufferLength()
          Gets how many items will be kept before the last save point.
 AppLoader getCore()
          Get the associated application launcher.
 javax.swing.event.ChangeListener[] getHistoryChangeListeners()
          Gets a list of all current listeners.
 int getHistoryCursor()
          Get the location of the history cursor.
 int getHistorySize()
          Get the number of events currently stored in the history archive.
 boolean hasChanged()
          Tests to see if the cursor is not at the last save point.
 void markSavedNow()
          Mark the cursor location as the last saved point and clear the undo buffer.
 void moveCursorTo(int i)
          Undo/redo until the cursor is as close to the given index as possible.
 void redo()
          Redo one action.
 void removeHistoryChangeListener(javax.swing.event.ChangeListener cl)
          Remove the given change listener, if it is currently attached.
 void setBufferLength(int i)
          Sets the number of items that should be saved before the last save point.
 void setCore(AppLoader loader)
          Sets the associated application loader.
 void setHistorySize(int size)
          Reduce the number of events currently stored in the history archive.
 void undo()
          Undo one action.
 
Methods inherited from class javax.swing.JScrollPane
createHorizontalScrollBar, createVerticalScrollBar, createViewport, getAccessibleContext, getColumnHeader, getCorner, getHorizontalScrollBar, getHorizontalScrollBarPolicy, getRowHeader, getUI, getUIClassID, getVerticalScrollBar, getVerticalScrollBarPolicy, getViewport, getViewportBorder, getViewportBorderBounds, isValidateRoot, isWheelScrollingEnabled, paramString, setColumnHeader, setColumnHeaderView, setComponentOrientation, setCorner, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setLayout, setRowHeader, setRowHeaderView, setUI, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportBorder, setViewportView, setWheelScrollingEnabled, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, transferFocusBackward, transferFocusDownCycle, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ActionHistoryPane

public ActionHistoryPane()
Creates a new history pane without any undo objects.

Method Detail

addAction

public void addAction(javax.swing.undo.UndoableEdit e)
Add a new action after the cursor. Currently, this deletes all existing events after the cursor.

Parameters:
e - The new edit.

getCore

public AppLoader getCore()
Get the associated application launcher.

Returns:
the AppLoader

setCore

public void setCore(AppLoader loader)
Sets the associated application loader. This is needed for user preferences, such as the undo limit and key controls.

Parameters:
loader - The application loader for the app that holds this widget.

moveCursorTo

public void moveCursorTo(int i)
Undo/redo until the cursor is as close to the given index as possible.

Parameters:
i - Where to move the cursor

undo

public void undo()
Undo one action. Moves the cursor back one.


canUndo

public boolean canUndo()
Tests to see if any undo events are available on the stack.

Returns:
if undo will do anything

redo

public void redo()
Redo one action. Moves the cursor ahead one.


canRedo

public boolean canRedo()
Tests to see if any redo events are available above the stack.

Returns:
if redo will do anything

getHistoryCursor

public int getHistoryCursor()
Get the location of the history cursor. It is equal to the number of actions in the history that have been applied.

Returns:
The action cursor location.

getHistorySize

public int getHistorySize()
Get the number of events currently stored in the history archive.

Returns:
The available number of events.

setHistorySize

public void setHistorySize(int size)
Reduce the number of events currently stored in the history archive.

Parameters:
size - the maximum number of recent events to keep around. It keeps a window of min(size, this.size()), which goes between 0 and size in either direction, with the preference of being size/2 in either direction. This assures that multiple calls to setHistorySize(C) for some constant C don't reduce the size of the stack when mixed with undos and redos.

hasChanged

public boolean hasChanged()
Tests to see if the cursor is not at the last save point. This allows the user to undo so that the 'file changed' status can be updated properly.

Returns:
true when the cursor is not at the last save point

markSavedNow

public void markSavedNow()
Mark the cursor location as the last saved point and clear the undo buffer.


addHistoryChangeListener

public void addHistoryChangeListener(javax.swing.event.ChangeListener cl)
Add a listener for history change events. These events occur when an event is added to the history list.

Parameters:
cl - The listener to add

getHistoryChangeListeners

public javax.swing.event.ChangeListener[] getHistoryChangeListeners()
Gets a list of all current listeners.

Returns:
All listeners attached for history change events.

removeHistoryChangeListener

public void removeHistoryChangeListener(javax.swing.event.ChangeListener cl)
Remove the given change listener, if it is currently attached.

Parameters:
cl - the listener to remove

fireHistoryChangeEvent

public void fireHistoryChangeEvent()
Fire a history change event to all attached listeners.


getBufferLength

public int getBufferLength()
Gets how many items will be kept before the last save point.

Returns:

setBufferLength

public void setBufferLength(int i)
Sets the number of items that should be saved before the last save point.

Parameters:
i -