java.lang.Object
org.autogui.swing.util.PopupExtension
org.autogui.swing.util.PopupExtensionText
- All Implemented Interfaces:
ActionListener,FocusListener,KeyListener,MouseListener,EventListener
default popup menu support for text components.
The default impl. can be set by
installDefault(JTextComponent)
which supplies PopupExtension.getDefaultKeyMatcher() and getServiceDefaultMenu(JTextComponent).
The method calls putInputEditActions(JTextComponent) which instruments additional key-actions regarding deleting.
the default items flow:
PopupExtensionText.TextServiceDefaultMenu.initEditActions(JTextComponent)->-
PopupExtensionText.TextServiceDefaultMenu.getActionsInInitEditActions(JTextComponent)-> -
getEditActions(JTextComponent)
Note putUnregisteredEditActions(JTextComponent) is not called automatically.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classan abstract action for interacting with the history-buffer (kill-buffer)static classaction for clearing the fieldstatic classa copy actionstatic classa copy-all action: copying all text in a text-componentstatic classa cut actionstatic classa delete-next-word actionstatic classa delete-previous-word actionstatic classa delete-to-line-end actionstatic classan edit in the history bufferstatic classa history buffer (kill buffer)static classa file loading actionstatic classthe action for opening selection as a URL in a browserstatic classa paste actionstatic classa paste-all action: replacing entire text with the clipboard contentsstatic classa paste the history-buffer action (yank)static classa file saving actionstatic classa select-all actionstatic classaPopupExtension.PopupMenuBuilderwhich has typical actions for the text componentNested classes/interfaces inherited from class org.autogui.swing.util.PopupExtension
PopupExtension.DefaultPopupGetter, PopupExtension.DefaultPopupMenu, PopupExtension.MenuKeySelector, PopupExtension.PopupCancelChecker, PopupExtension.PopupExtensionDisplayAction, PopupExtension.PopupMenuBuilder, PopupExtension.PopupMenuBuilderEmpty, PopupExtension.PopupMenuFilter, PopupExtension.PopupMenuFilterAsIs, PopupExtension.PopupMenuHidingFix, PopupExtension.PopupMenuListenerForSetup, PopupExtension.PredicateKeyMatcher -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected intprotected static JComponentstatic Charsetprotected intprotected intFields inherited from class org.autogui.swing.util.PopupExtension
action, cancelChecker, filter, keyMatcher, menu, MENU_CATEGORY_EDIT, MENU_CATEGORY_JUMP, MENU_CATEGORY_PREFS, MENU_CATEGORY_SELECT, MENU_CATEGORY_SET, MENU_CATEGORY_TRANSFER, MENU_CATEGORY_UNDO, MENU_CATEGORY_VIEW, MENU_CATEGORY_WINDOW, MENU_FILTER_IDENTITY, MENU_SUB_CATEGORY_COPY, MENU_SUB_CATEGORY_CUT, MENU_SUB_CATEGORY_DELETE, MENU_SUB_CATEGORY_EXPORT, MENU_SUB_CATEGORY_IMPORT, MENU_SUB_CATEGORY_NEW, MENU_SUB_CATEGORY_PASTE, MENU_SUB_CATEGORY_PREFS_CHANGE, MENU_SUB_CATEGORY_PREFS_WINDOW, MENU_SUB_CATEGORY_REDO, MENU_SUB_CATEGORY_SELECT, MENU_SUB_CATEGORY_UNDO, MENU_SUB_CATEGORY_WINDOW_SELECT, MENU_SUB_CATEGORY_WINDOW_VIEW, menuBuilder, pane -
Constructor Summary
ConstructorsConstructorDescriptionPopupExtensionText(JTextComponent textComponent, Predicate<KeyEvent> keyMatcher, PopupExtension.PopupMenuBuilder builder) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListenersTo(JComponent pane) protected voidvoidvoidgetEditActions(JTextComponent textComponent) JDK has standard implementations for cut, copy and paste as DefaultEditorKit.static JComponentgetInputEditActions(JTextComponent component) getServiceDefaultMenu(JTextComponent component) static PopupExtensionTextinstallDefault(JTextComponent textComponent) static voidputInputEditActions(JTextComponent component) static voidputInputEditActionsToKeys(InputMap map, JTextComponent component) static voidputInputEditActionsToMap(ActionMap map, JTextComponent component) static voidputUnregisteredEditActions(JTextComponent component) usually, it will register "Copy Value" and "Paste Value"voidcallPopupExtension.show(Component, int, int)with the bottom right position of the current text selection startstatic RectangletextComponentModelToView(JTextComponent textComponent, int sel) static inttextComponentViewToModel(JTextComponent textComponent, Point p) Methods inherited from class org.autogui.swing.util.PopupExtension
actionPerformed, addListenersToAsPopupMenuListener, addListenersToPane, getAction, getDefaultKeyMatcher, getDefaultKeyStroke, getFilter, getKeyCode, getKeyMatcher, getKeyStroke, getMenu, getMenuBuilder, getMenuShortcutKeyMask, getPane, keyPressed, keyReleased, keyTyped, mouseClicked, mouseEntered, mouseExited, mousePressed, mouseReleased, setFilter, setMenuBuilder, setupCancelChecker, setupMenu, show, show
-
Field Details
-
selectionStart
protected int selectionStart -
selectionEnd
protected int selectionEnd -
documentLength
protected int documentLength -
defaultHistory
-
selectedCharset
-
encodingPane
-
-
Constructor Details
-
PopupExtensionText
public PopupExtensionText(JTextComponent textComponent, Predicate<KeyEvent> keyMatcher, PopupExtension.PopupMenuBuilder builder)
-
-
Method Details
-
installDefault
-
getTextComponent
-
addListenersTo
- Overrides:
addListenersToin classPopupExtension
-
showByKey
callPopupExtension.show(Component, int, int)with the bottom right position of the current text selection start- Overrides:
showByKeyin classPopupExtension- Parameters:
e- the key-eventcomp- the target component
-
textComponentModelToView
public static Rectangle textComponentModelToView(JTextComponent textComponent, int sel) throws BadLocationException - Throws:
BadLocationException
-
textComponentViewToModel
-
error
-
getServiceDefaultMenu
public static PopupExtensionText.TextServiceDefaultMenu getServiceDefaultMenu(JTextComponent component) -
getEditActions
JDK has standard implementations for cut, copy and paste as DefaultEditorKit. However, those actions take the target from event source, and do not have user-friendly name- Parameters:
textComponent- the target component- Returns:
- list of actions for the component: cut, copy, copy-all, paste, paste-all, select-all, load, save, and open-browser
-
getInputEditActions
- Parameters:
component- optional component- Returns:
- list of actions of additional edit-actions: delete-next-word, delete-previous-word, delete-to-line-end, and paste-history
-
putInputEditActions
-
putInputEditActionsToMap
-
putInputEditActionsToKeys
-
putUnregisteredEditActions
usually, it will register "Copy Value" and "Paste Value"- Parameters:
component- the host of action- and input-map
-
focusGained
- Specified by:
focusGainedin interfaceFocusListener
-
focusLost
- Specified by:
focusLostin interfaceFocusListener
-
getEncodingPane
-