Class CommandStackDialog
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- org.openstreetmap.josm.gui.dialogs.ToggleDialog
-
- org.openstreetmap.josm.gui.dialogs.CommandStackDialog
-
- All Implemented Interfaces:
java.awt.event.AWTEventListener,java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,java.util.EventListener,javax.accessibility.Accessible,UndoRedoHandler.CommandQueuePreciseListener,Helpful,ShowHideButtonListener,PreferenceChangedListener,Destroyable
public class CommandStackDialog extends ToggleDialog implements UndoRedoHandler.CommandQueuePreciseListener
Dialog displaying list of all executed commands (undo/redo buffer).- Since:
- 94
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classCommandStackDialog.CommandCellRendererprivate classCommandStackDialog.CommandStackPopup(package private) classCommandStackDialog.MouseEventHandlerclassCommandStackDialog.SelectActionAction that selects the objects that take part in a command.classCommandStackDialog.SelectAndZoomActionAction that selects the objects that take part in a command, then zoom to them.protected classCommandStackDialog.UndoRedoActionAction to undo or redo all commands up to (and including) the selected item.private classCommandStackDialog.UndoRedoSelectionListenerSelection listener for undo and redo area.protected static classCommandStackDialog.UndoRedoTypeundo / redo switch to reduce duplicate code-
Nested classes/interfaces inherited from class org.openstreetmap.josm.gui.dialogs.ToggleDialog
ToggleDialog.ButtonHidingType, ToggleDialog.TitleBar, ToggleDialog.ToggleDialogAction
-
Nested classes/interfaces inherited from class javax.swing.JPanel
javax.swing.JPanel.AccessibleJPanel
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description private CommandStackDialog.UndoRedoTypelastOperationprivate javax.swing.tree.DefaultMutableTreeNoderedoRootprivate CommandStackDialog.UndoRedoSelectionListenerredoSelectionListenerprivate javax.swing.JTreeredoTreeprivate javax.swing.tree.DefaultTreeModelredoTreeModelprivate javax.swing.JScrollPanescrollPaneprivate CommandStackDialog.SelectActionselectActionprivate CommandStackDialog.SelectAndZoomActionselectAndZoomActionprivate javax.swing.JSeparatorseparatorprivate java.util.Set<IEnabledStateUpdating>showNotifyListenerSimple listener setup to update the button enabled state when the side dialog shows.private java.awt.Componentspacerprivate javax.swing.tree.DefaultMutableTreeNodeundoRootprivate CommandStackDialog.UndoRedoSelectionListenerundoSelectionListenerprivate javax.swing.JTreeundoTreeprivate javax.swing.tree.DefaultTreeModelundoTreeModel-
Fields inherited from class org.openstreetmap.josm.gui.dialogs.ToggleDialog
button, buttonHiding, detachedDialog, dialogsPanel, isCollapsed, isDocked, isShowing, name, preferenceClass, preferencePrefix, PROP_DYNAMIC_BUTTONS, titleBar, toggleAction, windowMenuItem
-
Fields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor Description CommandStackDialog()Constructs a newCommandStackDialog.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddShowNotifyListener(IEnabledStateUpdating listener)private voidbuildRedoTree()private voidbuildTrees()Build the trees of undo and redo commands (initially or when they have changed).private voidbuildUndoTree()voidcleaned(UndoRedoHandler.CommandQueueCleanedEvent e)Notifies the listener about commands being cleaned.voidcommandAdded(UndoRedoHandler.CommandAddedEvent e)Notifies the listener about a new command added to the queue.voidcommandRedone(UndoRedoHandler.CommandRedoneEvent e)Notifies the listener about a command that has been redone.voidcommandUndone(UndoRedoHandler.CommandUndoneEvent e)Notifies the listener about a command that has been undone.private voidensureTreesConsistency()protected static java.util.Collection<? extends OsmPrimitive>getAffectedPrimitives(PseudoCommand c)Return primitives that are affected by some commandprotected CommandListMutableTreeNodegetNodeForCommand(PseudoCommand c)Wraps a command in a CommandListMutableTreeNode.PseudoCommandgetSelectedCommand()Returns the selected undo/redo commandvoidhideNotify()Called when toggle dialog is hidden (collapsed, removed, MapFrame is removed, ...).protected booleanredoTreeIsEmpty()voidshowNotify()Called when toggle dialog is shown (after it was created or expanded).private voidswapNode(javax.swing.tree.DefaultTreeModel srcModel, javax.swing.tree.DefaultMutableTreeNode srcRoot, int srcIndex, javax.swing.tree.DefaultTreeModel dstModel, javax.swing.tree.DefaultMutableTreeNode dstRoot, int dstIndex)private voidupdateTitle()protected voidwireUpdateEnabledStateUpdater(IEnabledStateUpdating updater, javax.swing.JTree tree)Wires updater for enabled state to the events.-
Methods inherited from class org.openstreetmap.josm.gui.dialogs.ToggleDialog
buttonHidden, buttonShown, clearButtonActions, closeDetachedDialog, collapse, createLayout, createLayout, destroy, detach, dock, dockWhenClosingDetachedDlg, eventDispatched, expand, getButton, getDefaultDetachedSize, getLastHeight, getName, getPreferencePrefix, getPreferredHeight, getToggleAction, helpTopic, hideDialog, isDialogInCollapsedView, isDialogInDefaultView, isDialogShowing, preferenceChanged, registerInWindowMenu, rememberHeight, setButton, setContentVisible, setDialogsPanel, setIsButtonHiding, setIsCollapsed, setIsDocked, setIsShowing, setTitle, showDialog, stateChanged, toggleButtonHook, toString, unfurlDialog
-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, paramString, setUI, 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, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, 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, 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, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, 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, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
undoTreeModel
private final javax.swing.tree.DefaultTreeModel undoTreeModel
-
redoTreeModel
private final javax.swing.tree.DefaultTreeModel redoTreeModel
-
undoTree
private final javax.swing.JTree undoTree
-
redoTree
private final javax.swing.JTree redoTree
-
undoRoot
private javax.swing.tree.DefaultMutableTreeNode undoRoot
-
redoRoot
private javax.swing.tree.DefaultMutableTreeNode redoRoot
-
undoSelectionListener
private final transient CommandStackDialog.UndoRedoSelectionListener undoSelectionListener
-
redoSelectionListener
private final transient CommandStackDialog.UndoRedoSelectionListener redoSelectionListener
-
scrollPane
private final javax.swing.JScrollPane scrollPane
-
separator
private final javax.swing.JSeparator separator
-
spacer
private final java.awt.Component spacer
-
lastOperation
private CommandStackDialog.UndoRedoType lastOperation
-
selectAction
private final CommandStackDialog.SelectAction selectAction
-
selectAndZoomAction
private final CommandStackDialog.SelectAndZoomAction selectAndZoomAction
-
showNotifyListener
private final transient java.util.Set<IEnabledStateUpdating> showNotifyListener
Simple listener setup to update the button enabled state when the side dialog shows.
-
-
Constructor Detail
-
CommandStackDialog
public CommandStackDialog()
Constructs a newCommandStackDialog.
-
-
Method Detail
-
updateTitle
private void updateTitle()
-
wireUpdateEnabledStateUpdater
protected void wireUpdateEnabledStateUpdater(IEnabledStateUpdating updater, javax.swing.JTree tree)
Wires updater for enabled state to the events. Also updates dialog title if needed.- Parameters:
updater- updatertree- tree on which wire updater
-
showNotify
public void showNotify()
Description copied from class:ToggleDialogCalled when toggle dialog is shown (after it was created or expanded). Descendants may overwrite this method, it's a good place to register listeners needed to keep dialog updated- Overrides:
showNotifyin classToggleDialog
-
addShowNotifyListener
private void addShowNotifyListener(IEnabledStateUpdating listener)
-
hideNotify
public void hideNotify()
Description copied from class:ToggleDialogCalled when toggle dialog is hidden (collapsed, removed, MapFrame is removed, ...). Good place to unregister listeners- Overrides:
hideNotifyin classToggleDialog
-
buildTrees
private void buildTrees()
Build the trees of undo and redo commands (initially or when they have changed).
-
buildUndoTree
private void buildUndoTree()
-
buildRedoTree
private void buildRedoTree()
-
ensureTreesConsistency
private void ensureTreesConsistency()
-
getNodeForCommand
protected CommandListMutableTreeNode getNodeForCommand(PseudoCommand c)
Wraps a command in a CommandListMutableTreeNode. Recursively adds child commands.- Parameters:
c- the command- Returns:
- the resulting node
-
getAffectedPrimitives
protected static java.util.Collection<? extends OsmPrimitive> getAffectedPrimitives(PseudoCommand c)
Return primitives that are affected by some command- Parameters:
c- the command- Returns:
- collection of affected primitives, only usable ones
-
redoTreeIsEmpty
protected boolean redoTreeIsEmpty()
-
cleaned
public void cleaned(UndoRedoHandler.CommandQueueCleanedEvent e)
Description copied from interface:UndoRedoHandler.CommandQueuePreciseListenerNotifies the listener about commands being cleaned.- Specified by:
cleanedin interfaceUndoRedoHandler.CommandQueuePreciseListener- Parameters:
e- event
-
commandAdded
public void commandAdded(UndoRedoHandler.CommandAddedEvent e)
Description copied from interface:UndoRedoHandler.CommandQueuePreciseListenerNotifies the listener about a new command added to the queue.- Specified by:
commandAddedin interfaceUndoRedoHandler.CommandQueuePreciseListener- Parameters:
e- event
-
commandUndone
public void commandUndone(UndoRedoHandler.CommandUndoneEvent e)
Description copied from interface:UndoRedoHandler.CommandQueuePreciseListenerNotifies the listener about a command that has been undone.- Specified by:
commandUndonein interfaceUndoRedoHandler.CommandQueuePreciseListener- Parameters:
e- event
-
commandRedone
public void commandRedone(UndoRedoHandler.CommandRedoneEvent e)
Description copied from interface:UndoRedoHandler.CommandQueuePreciseListenerNotifies the listener about a command that has been redone.- Specified by:
commandRedonein interfaceUndoRedoHandler.CommandQueuePreciseListener- Parameters:
e- event
-
swapNode
private void swapNode(javax.swing.tree.DefaultTreeModel srcModel, javax.swing.tree.DefaultMutableTreeNode srcRoot, int srcIndex, javax.swing.tree.DefaultTreeModel dstModel, javax.swing.tree.DefaultMutableTreeNode dstRoot, int dstIndex)
-
getSelectedCommand
public PseudoCommand getSelectedCommand()
Returns the selected undo/redo command- Returns:
- the selected undo/redo command or
null
-
-