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 class
an abstract action for interacting with the history-buffer (kill-buffer)static class
action for clearing the fieldstatic class
a copy actionstatic class
a copy-all action: copying all text in a text-componentstatic class
a cut actionstatic class
a delete-next-word actionstatic class
a delete-previous-word actionstatic class
a delete-to-line-end actionstatic class
an edit in the history bufferstatic class
a history buffer (kill buffer)static class
a file loading actionstatic class
the action for opening selection as a URL in a browserstatic class
a paste actionstatic class
a paste-all action: replacing entire text with the clipboard contentsstatic class
a paste the history-buffer action (yank)static class
a file saving actionstatic class
a select-all actionstatic class
aPopupExtension.PopupMenuBuilder
which 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 int
protected static JComponent
static Charset
protected int
protected int
Fields 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 TypeMethodDescriptionvoid
addListenersTo
(JComponent pane) protected void
void
void
getEditActions
(JTextComponent textComponent) JDK has standard implementations for cut, copy and paste as DefaultEditorKit.static JComponent
getInputEditActions
(JTextComponent component) getServiceDefaultMenu
(JTextComponent component) static PopupExtensionText
installDefault
(JTextComponent textComponent) static void
putInputEditActions
(JTextComponent component) static void
putInputEditActionsToKeys
(InputMap map, JTextComponent component) static void
putInputEditActionsToMap
(ActionMap map, JTextComponent component) static void
putUnregisteredEditActions
(JTextComponent component) usually, it will register "Copy Value" and "Paste Value"void
callPopupExtension.show(Component, int, int)
with the bottom right position of the current text selection startstatic Rectangle
textComponentModelToView
(JTextComponent textComponent, int sel) static int
textComponentViewToModel
(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:
addListenersTo
in classPopupExtension
-
showByKey
callPopupExtension.show(Component, int, int)
with the bottom right position of the current text selection start- Overrides:
showByKey
in 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:
focusGained
in interfaceFocusListener
-
focusLost
- Specified by:
focusLost
in interfaceFocusListener
-
getEncodingPane
-