dsto.dfc.swing.undo
Class EditListView

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by javax.swing.JComponent
              extended by javax.swing.JList
                  extended by dsto.dfc.swing.undo.EditListView
All Implemented Interfaces:
DragComponent, DropComponent, ImageObserver, MenuContainer, PropertyChangeListener, Serializable, EventListener, Accessible, ListDataListener, Scrollable

public class EditListView
extends JList
implements ListDataListener, PropertyChangeListener, DragComponent, DropComponent

List view of an EditListModel, with a custom renderer which highlights not only the UndoableEdit in the list, but also the undo cursor of the MonitoredUndoManager using the edit list. Supports drop'n'drag of MonitoredEdits.

Version:
$Revision$
Author:
Peter J Smet, Derek Weber
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class javax.swing.JList
JList.AccessibleJList, JList.DropLocation
 
Nested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponent
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
protected  boolean dragNDropEnabled
           
protected  MonitoredUndoManager undoManager
           
 
Fields inherited from class javax.swing.JList
HORIZONTAL_WRAP, VERTICAL, VERTICAL_WRAP
 
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 java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
EditListView()
          For bean serialisation.
EditListView(ListModel listModel, MonitoredUndoManager undoManager)
          Constructs an EditListView using the edits managed by the MonitoredUndoManager undoManager.
EditListView(MonitoredUndoManager undoManager)
           
 
Method Summary
 List cloneSelectedEdits()
          Returns a list of clones of the selected edits.
 void contentsChanged(ListDataEvent e)
           
 void endDrag(DragSourceDropEvent e, boolean moveData)
           
 void executeDrop(DropTargetDropEvent dtde)
          Execute a drop action.
 UndoableEdit getSelectedEdit()
          Returns the currently selected edit or the MonitoredUndoManager.NULL_EDIT.
 List getSelectedEdits()
          Returns an array of the currently selected edits.
 int getSupportedDragActions()
          Return a mask of possible drag actions supported by this component eg DnDConstants.ACTION_COPY_OR_MOVE.
 int getSupportedDropActions()
          Return a mask of actions supported by this component eg DnDConstants.ACTION_COPY_OR_MOVE.
 void hideDragUnderFeedback()
          Remove any drag under feedback displayed by showDragUnderFeedback ().
 void intervalAdded(ListDataEvent e)
           
 void intervalRemoved(ListDataEvent e)
           
 boolean isDragNDropEnabled()
           
 boolean isDragOK(DragGestureEvent e)
          Return true if starting a drag in the given context is possible.
 boolean isDropOK(DropTargetDragEvent e)
          Return true if a drop in the context in a DropTargetDragEvent is possible.
 void propertyChange(PropertyChangeEvent evt)
           
 void setDragNDropEnabled(boolean enabled)
           
 void setModel(ListModel listModel)
          Changes the ListModel that the EditListView uses.
 void setSelectedEdit(UndoableEdit edit)
          For programmatically setting an edit as selected.
 void showDragUnderFeedback(boolean dropOK, DropTargetDragEvent e)
          Display any drag under (ie displayed under the mouse in the component) feedback.
 Transferable startDrag(DragGestureEvent e)
          Start a drag operation.
 
Methods inherited from class javax.swing.JList
addListSelectionListener, addSelectionInterval, clearSelection, createSelectionModel, ensureIndexIsVisible, fireSelectionValueChanged, getAccessibleContext, getAnchorSelectionIndex, getCellBounds, getCellRenderer, getDragEnabled, getDropLocation, getDropMode, getFirstVisibleIndex, getFixedCellHeight, getFixedCellWidth, getLastVisibleIndex, getLayoutOrientation, getLeadSelectionIndex, getListSelectionListeners, getMaxSelectionIndex, getMinSelectionIndex, getModel, getNextMatch, getPreferredScrollableViewportSize, getPrototypeCellValue, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedIndex, getSelectedIndices, getSelectedValue, getSelectedValues, getSelectionBackground, getSelectionForeground, getSelectionMode, getSelectionModel, getToolTipText, getUI, getUIClassID, getValueIsAdjusting, getVisibleRowCount, indexToLocation, isSelectedIndex, isSelectionEmpty, locationToIndex, paramString, removeListSelectionListener, removeSelectionInterval, setCellRenderer, setDragEnabled, setDropMode, setFixedCellHeight, setFixedCellWidth, setLayoutOrientation, setListData, setListData, setPrototypeCellValue, setSelectedIndex, setSelectedIndices, setSelectedValue, setSelectionBackground, setSelectionForeground, setSelectionInterval, setSelectionMode, setSelectionModel, setUI, setValueIsAdjusting, setVisibleRowCount, updateUI
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, 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, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, 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, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, 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
 

Field Detail

undoManager

protected MonitoredUndoManager undoManager

dragNDropEnabled

protected boolean dragNDropEnabled
Constructor Detail

EditListView

public EditListView()
For bean serialisation.


EditListView

public EditListView(MonitoredUndoManager undoManager)

EditListView

public EditListView(ListModel listModel,
                    MonitoredUndoManager undoManager)
Constructs an EditListView using the edits managed by the MonitoredUndoManager undoManager.

Method Detail

setModel

public void setModel(ListModel listModel)
Changes the ListModel that the EditListView uses.

Overrides:
setModel in class JList

getSelectedEdit

public UndoableEdit getSelectedEdit()
Returns the currently selected edit or the MonitoredUndoManager.NULL_EDIT.


getSelectedEdits

public List getSelectedEdits()
Returns an array of the currently selected edits.


setSelectedEdit

public void setSelectedEdit(UndoableEdit edit)
For programmatically setting an edit as selected.


cloneSelectedEdits

public List cloneSelectedEdits()
Returns a list of clones of the selected edits.


propertyChange

public void propertyChange(PropertyChangeEvent evt)
Specified by:
propertyChange in interface PropertyChangeListener

intervalAdded

public void intervalAdded(ListDataEvent e)
Specified by:
intervalAdded in interface ListDataListener

intervalRemoved

public void intervalRemoved(ListDataEvent e)
Specified by:
intervalRemoved in interface ListDataListener

contentsChanged

public void contentsChanged(ListDataEvent e)
Specified by:
contentsChanged in interface ListDataListener

setDragNDropEnabled

public void setDragNDropEnabled(boolean enabled)

isDragNDropEnabled

public boolean isDragNDropEnabled()

getSupportedDragActions

public int getSupportedDragActions()
Description copied from interface: DragComponent
Return a mask of possible drag actions supported by this component eg DnDConstants.ACTION_COPY_OR_MOVE. Note that the component may veto any particular drag attempt from DragComponent.isDragOK(java.awt.dnd.DragGestureEvent).

Specified by:
getSupportedDragActions in interface DragComponent

isDragOK

public boolean isDragOK(DragGestureEvent e)
Description copied from interface: DragComponent
Return true if starting a drag in the given context is possible.

Specified by:
isDragOK in interface DragComponent
Parameters:
e - The drag context.

startDrag

public Transferable startDrag(DragGestureEvent e)
Description copied from interface: DragComponent
Start a drag operation.

Specified by:
startDrag in interface DragComponent
Parameters:
e - The gesture that started the drag.
Returns:
The transferable data, or null if no data available.

endDrag

public void endDrag(DragSourceDropEvent e,
                    boolean moveData)
Specified by:
endDrag in interface DragComponent

getSupportedDropActions

public int getSupportedDropActions()
Description copied from interface: DropComponent
Return a mask of actions supported by this component eg DnDConstants.ACTION_COPY_OR_MOVE. Note that the component may veto any particular drop attempt from DropComponent.isDropOK(java.awt.dnd.DropTargetDragEvent).

Specified by:
getSupportedDropActions in interface DropComponent

isDropOK

public boolean isDropOK(DropTargetDragEvent e)
Description copied from interface: DropComponent
Return true if a drop in the context in a DropTargetDragEvent is possible.

Specified by:
isDropOK in interface DropComponent
Parameters:
e - The drop context.

showDragUnderFeedback

public void showDragUnderFeedback(boolean dropOK,
                                  DropTargetDragEvent e)
Description copied from interface: DropComponent
Display any drag under (ie displayed under the mouse in the component) feedback.

Specified by:
showDragUnderFeedback in interface DropComponent
Parameters:
dropOK - The value of isDropOK () when the mouse first entered the component.
e - The drop context.

hideDragUnderFeedback

public void hideDragUnderFeedback()
Description copied from interface: DropComponent
Remove any drag under feedback displayed by showDragUnderFeedback ().

Specified by:
hideDragUnderFeedback in interface DropComponent

executeDrop

public void executeDrop(DropTargetDropEvent dtde)
Description copied from interface: DropComponent
Execute a drop action.

Specified by:
executeDrop in interface DropComponent


Copyright © 2008 Commonwealth of Australia