Class TextContextualPopupMenu
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPopupMenu
-
- org.openstreetmap.josm.gui.widgets.TextContextualPopupMenu
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,java.awt.MenuContainer,java.io.Serializable,javax.accessibility.Accessible,javax.swing.MenuElement
public class TextContextualPopupMenu extends javax.swing.JPopupMenu
A popup menu designed for text components. It displays the following actions:- Undo
- Redo
- Cut
- Copy
- Paste
- Delete
- Select All
- Since:
- 5886
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classTextContextualPopupMenu.RedoActionprotected classTextContextualPopupMenu.UndoAction-
Nested classes/interfaces inherited from class javax.swing.JPopupMenu
javax.swing.JPopupMenu.AccessibleJPopupMenu, javax.swing.JPopupMenu.Separator
-
Nested classes/interfaces inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.swing.text.JTextComponentcomponentprivate static java.lang.StringEDITABLEprotected java.beans.PropertyChangeListenerpropertyChangeListenerprotected TextContextualPopupMenu.RedoActionredoActionprotected javax.swing.undo.UndoManagerundoprotected TextContextualPopupMenu.UndoActionundoActionprotected javax.swing.event.UndoableEditListenerundoEditListenerprotected booleanundoRedo-
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 Modifier Constructor Description protectedTextContextualPopupMenu()Creates a newTextContextualPopupMenu.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private voidaddMenuEntries()protected voidaddMenuEntry(javax.swing.JMenuItem mi, java.lang.String iconName)protected voidaddMenuEntry(javax.swing.text.JTextComponent component, java.lang.String label, java.lang.String actionName, java.lang.String iconName)protected TextContextualPopupMenuattach(javax.swing.text.JTextComponent component, boolean undoRedo)Attaches this contextual menu to the given text component.protected TextContextualPopupMenudetach()Detaches this contextual menu from its text component.static voiddisableMenuFor(javax.swing.text.JTextComponent component, PopupMenuLauncher launcher)Disables theTextContextualPopupMenuattached to the given popup menu launcher and text component.private voiddisableUndoRedo()voiddiscardAllUndoableEdits()Empties the internal undo manager.static PopupMenuLauncherenableMenuFor(javax.swing.text.JTextComponent component, boolean undoRedo)Creates a newTextContextualPopupMenuand enables it for the given text component.private voidenableUndoRedo()booleanisAttached()Determines if this popup is currently attached to a component.private voidupdateUndoRedoState()-
Methods inherited from class javax.swing.JPopupMenu
add, add, add, addMenuKeyListener, addPopupMenuListener, addSeparator, createActionChangeListener, createActionComponent, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getComponent, getComponentAtIndex, getComponentIndex, getDefaultLightWeightPopupEnabled, getInvoker, getLabel, getMargin, getMenuKeyListeners, getPopupMenuListeners, getSelectionModel, getSubElements, getUI, getUIClassID, insert, insert, isBorderPainted, isLightWeightPopupEnabled, isPopupTrigger, isVisible, menuSelectionChanged, pack, paintBorder, paramString, processFocusEvent, processKeyEvent, processKeyEvent, processMouseEvent, remove, removeMenuKeyListener, removePopupMenuListener, setBorderPainted, setDefaultLightWeightPopupEnabled, setInvoker, setLabel, setLightWeightPopupEnabled, setLocation, setPopupSize, setPopupSize, setSelected, setSelectionModel, setUI, setVisible, show, 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, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, 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, 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, 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, getName, 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, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, 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, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
-
-
-
Field Detail
-
EDITABLE
private static final java.lang.String EDITABLE
- See Also:
- Constant Field Values
-
component
protected javax.swing.text.JTextComponent component
-
undoRedo
protected boolean undoRedo
-
undoAction
protected final TextContextualPopupMenu.UndoAction undoAction
-
redoAction
protected final TextContextualPopupMenu.RedoAction redoAction
-
undo
protected final javax.swing.undo.UndoManager undo
-
undoEditListener
protected final transient javax.swing.event.UndoableEditListener undoEditListener
-
propertyChangeListener
protected final transient java.beans.PropertyChangeListener propertyChangeListener
-
-
Constructor Detail
-
TextContextualPopupMenu
protected TextContextualPopupMenu()
Creates a newTextContextualPopupMenu.
-
-
Method Detail
-
updateUndoRedoState
private void updateUndoRedoState()
-
attach
protected TextContextualPopupMenu attach(javax.swing.text.JTextComponent component, boolean undoRedo)
Attaches this contextual menu to the given text component. A menu can only be attached to a single component.- Parameters:
component- The text component that will display the menu and handle its actions.undoRedo-trueif undo/redo must be supported- Returns:
this- See Also:
detach()
-
enableUndoRedo
private void enableUndoRedo()
-
disableUndoRedo
private void disableUndoRedo()
-
addMenuEntries
private void addMenuEntries()
-
detach
protected TextContextualPopupMenu detach()
Detaches this contextual menu from its text component.- Returns:
this- See Also:
attach(JTextComponent, boolean)
-
enableMenuFor
public static PopupMenuLauncher enableMenuFor(javax.swing.text.JTextComponent component, boolean undoRedo)
Creates a newTextContextualPopupMenuand enables it for the given text component.- Parameters:
component- The component that will display the menu and handle its actions.undoRedo- Enables or not Undo/Redo feature. Not recommended for table cell editors, unless each cell provides its own editor- Returns:
- The
PopupMenuLauncherresponsible of displaying the popup menu. CalldisableMenuFor(javax.swing.text.JTextComponent, org.openstreetmap.josm.gui.widgets.PopupMenuLauncher)with this object if you want to disable the menu later. - See Also:
disableMenuFor(javax.swing.text.JTextComponent, org.openstreetmap.josm.gui.widgets.PopupMenuLauncher)
-
disableMenuFor
public static void disableMenuFor(javax.swing.text.JTextComponent component, PopupMenuLauncher launcher)
Disables theTextContextualPopupMenuattached to the given popup menu launcher and text component.- Parameters:
component- The component that currently displays the menu and handles its actions.launcher- ThePopupMenuLauncherobtained viaenableMenuFor(javax.swing.text.JTextComponent, boolean).- See Also:
enableMenuFor(javax.swing.text.JTextComponent, boolean)
-
discardAllUndoableEdits
public void discardAllUndoableEdits()
Empties the internal undo manager.- Since:
- 14977
-
isAttached
public final boolean isAttached()
Determines if this popup is currently attached to a component.- Returns:
trueif this popup is currently attached to a component,falseotherwise.
-
addMenuEntry
protected void addMenuEntry(javax.swing.text.JTextComponent component, java.lang.String label, java.lang.String actionName, java.lang.String iconName)
-
addMenuEntry
protected void addMenuEntry(javax.swing.JMenuItem mi, java.lang.String iconName)
-
-