public class BaseKit extends DefaultEditorKit
Modifier and Type | Class and Description |
---|---|
static class |
BaseKit.BackwardAction |
static class |
BaseKit.BeepAction |
static class |
BaseKit.BeginAction |
static class |
BaseKit.BeginLineAction |
static class |
BaseKit.BeginWordAction |
static class |
BaseKit.CompoundAction
Deprecated.
this action is no longer used.
|
static class |
BaseKit.CopyAction |
static class |
BaseKit.CutAction |
static class |
BaseKit.DefaultKeyTypedAction
Deprecated.
Please do not subclass this class. Use Typing Hooks instead, for details see
Editor Library 2.
|
static class |
BaseKit.DeleteCharAction
Deprecated.
Please do not subclass this class. Use Typing Hooks instead, for details see
Editor Library 2.
|
static class |
BaseKit.DownAction |
static class |
BaseKit.EndAction |
static class |
BaseKit.EndLineAction |
static class |
BaseKit.EndWordAction |
static class |
BaseKit.ForwardAction |
static class |
BaseKit.InsertBreakAction
Deprecated.
Please do not subclass this class. Use Typing Hooks instead, for details see
Editor Library 2.
|
static class |
BaseKit.InsertContentAction
Deprecated.
this action is no longer used. It is reimplemented in editor.actions module.
|
static class |
BaseKit.InsertStringAction
Insert text specified in constructor
|
static class |
BaseKit.InsertTabAction |
static class |
BaseKit.KitCompoundAction
Deprecated.
this action is no longer used. It is reimplemented in editor.actions module.
|
static class |
BaseKit.NextWordAction
Deprecated.
use
CamelCaseInterceptor instead |
static class |
BaseKit.PageDownAction
Go one page down
|
static class |
BaseKit.PageUpAction
Go one page up
|
static class |
BaseKit.PasteAction |
static class |
BaseKit.PreviousWordAction
Deprecated.
use
CamelCaseInterceptor instead |
static class |
BaseKit.ReadOnlyAction
Deprecated.
this action is no longer used. It is reimplemented in editor.actions module.
|
static class |
BaseKit.RemoveTrailingSpacesAction |
static class |
BaseKit.SelectAllAction
Select text of whole document
|
static class |
BaseKit.SelectLineAction
Select line around caret
|
static class |
BaseKit.SelectWordAction
Select word around caret
|
static class |
BaseKit.SplitLineAction |
static class |
BaseKit.UpAction |
static class |
BaseKit.WritableAction
Deprecated.
this action is no longer used. It is reimplemented in editor.actions module.
|
Modifier and Type | Field and Description |
---|---|
static String |
abbrevExpandAction
Expand the abbreviation
|
static String |
abbrevResetAction
Reset the abbreviation accounting string
|
static String |
adjustCaretBottomAction
Action that moves the caret so that caret is at the bottom of the window
|
static String |
adjustCaretCenterAction
Action that moves the caret so that caret is at the center of the window
|
static String |
adjustCaretTopAction
Action that moves the caret so that caret is at the top of the window
|
static String |
adjustWindowBottomAction
Action that scrolls the window so that caret is at the bottom of the window
|
static String |
adjustWindowCenterAction
Action that scrolls the window so that caret is at the center of the window
|
static String |
adjustWindowTopAction
Action that scrolls the window so that caret is at the top of the window
|
static String |
annotationsCyclingAction
Cycle through annotations on the current line
|
static String |
collapseAllFoldsAction
Collapse all existing folds in the document.
|
static String |
collapseFoldAction
Collapse a fold.
|
static String |
copySelectionElseLineDownAction |
static String |
copySelectionElseLineUpAction |
static String |
cutToLineBeginAction
Cut text from caret position to line begining action.
|
static String |
cutToLineEndAction
Cut text from caret position to line end action.
|
static String |
DOC_REPLACE_SELECTION_PROPERTY |
static String |
expandAllFoldsAction
Expand all existing folds in the document.
|
static String |
expandFoldAction
Expand a fold.
|
static String |
findNextAction
Find next occurence action
|
static String |
findPreviousAction
Find previous occurence action
|
static String |
findSelectionAction
Find current word
|
static String |
firstNonWhiteAction
First non-white character on the line
|
static String |
formatAction
Format part of the document text using Indent
|
static String |
generateGutterPopupAction
Name of the action for generating of Glyph Gutter popup menu
|
static String |
indentAction
Indent part of the document text using Indent
|
static String |
insertDateTimeAction
Insert the current Date and Time
|
static String |
jumpListNextAction
Go to the previous position stored in the jump-list
|
static String |
jumpListNextComponentAction
Go to the last position in the previous component stored in the jump-list
|
static String |
jumpListPrevAction
Go to the next position stored in the jump-list
|
static String |
jumpListPrevComponentAction
Go to the next position in the previous component stored in the jump-list
|
static String |
lastNonWhiteAction
Last non-white character on the line
|
static String |
lineFirstColumnAction
Name of the action moving caret to the first column on the line
|
static String |
macroActionPrefix
Prefix of all macro-based actions
|
static int |
MAGIC_POSITION_MAX |
static String |
moveSelectionElseLineDownAction |
static String |
moveSelectionElseLineUpAction |
static String |
pasteFormatedAction
Paste and reformat code
|
static String |
redoAction
Redo action
|
static String |
reformatLineAction
Reformat Line action
|
static String |
reindentLineAction
Reindent Line action
|
static String |
removeLineAction
Remove line
|
static String |
removeLineBeginAction
Remove to the begining of the line
|
static String |
removeNextWordAction
Remove characters to the end of the word or
the next word if caret is not directly at word
|
static String |
removePreviousWordAction
Remove characters to the begining of the word or
the previous word if caret is not directly at word
|
static String |
removeSelectionAction
Remove selected block or do nothing - useful for popup menu
|
static String |
removeTabAction
Remove indentation
|
static String |
removeTrailingSpacesAction
Remove all trailing spaces in the document.
|
static String |
scrollDownAction
Scroll window one line down
|
static String |
scrollUpAction
Scroll window one line up
|
static String |
selectIdentifierAction
Select the nearest identifier around caret
|
static String |
selectionFirstNonWhiteAction
First non-white character on the line
|
static String |
selectionLastNonWhiteAction
Last non-white character on the line
|
static String |
selectionLineFirstColumnAction
Name of the action moving caret to the first
column on the line and extending the selection
|
static String |
selectionPageDownAction
Move one page down and make or extend selection
|
static String |
selectionPageUpAction
Move one page up and make or extend selection
|
static String |
selectNextParameterAction
Select the next parameter (after the comma) in the given context
|
static String |
shiftLineLeftAction
Shift line left action
|
static String |
shiftLineRightAction
Shift line right action
|
static String |
splitLineAction
split the current line at cursor position
|
static String |
startMacroRecordingAction
Start recording of macro.
|
static String |
startNewLineAction
Starts a new line in code
|
static String |
stopMacroRecordingAction
Stop the active recording
|
static String |
switchCaseAction
Switch the case of the selected text or current character
|
static String |
toggleHighlightSearchAction
Toggle highlight search action
|
static String |
toggleLineNumbersAction
Toggle visibility of line numbers
|
static String |
toggleTypingModeAction
Toggle the typing mode to overwrite mode or back to insert mode
|
static String |
toLowerCaseAction
Change the selected text or current character to lowercase
|
static String |
toUpperCaseAction
Change the selected text or current character to uppercase
|
static String |
undoAction
Undo action
|
static String |
wordMatchNextAction
Word match next
|
static String |
wordMatchPrevAction
Word match prev
|
backwardAction, beepAction, beginAction, beginLineAction, beginLineUpAction, beginParagraphAction, beginWordAction, copyAction, cutAction, defaultKeyTypedAction, deleteNextCharAction, deleteNextWordAction, deletePrevCharAction, deletePrevWordAction, downAction, endAction, endLineAction, endLineDownAction, EndOfLineStringProperty, endParagraphAction, endWordAction, forwardAction, insertBreakAction, insertContentAction, insertTabAction, nextWordAction, pageDownAction, pageUpAction, pasteAction, previousWordAction, readOnlyAction, selectAllAction, selectionBackwardAction, selectionBeginAction, selectionBeginLineAction, selectionBeginParagraphAction, selectionBeginWordAction, selectionDownAction, selectionEndAction, selectionEndLineAction, selectionEndParagraphAction, selectionEndWordAction, selectionForwardAction, selectionNextWordAction, selectionPreviousWordAction, selectionUpAction, selectLineAction, selectParagraphAction, selectWordAction, upAction, writableAction
Constructor and Description |
---|
BaseKit()
Creates a new instance of
BaseKit . |
Modifier and Type | Method and Description |
---|---|
static void |
addActionsToMap(Map<String,Action> map,
Action[] actions,
String logActionsType)
Creates map with [name, action] pairs from the given
array of actions.
|
Object |
clone()
Clone this editor kit
|
protected Action[] |
createActions()
Create actions that this kit supports.
|
Caret |
createCaret()
Create caret to navigate through document
|
Document |
createDefaultDocument()
Create empty document
|
protected EditorUI |
createEditorUI()
Create extended UI
|
Syntax |
createFormatSyntax(Document doc)
Deprecated.
Please use Editor Indentation API instead, for details see
Editor Indentation.
|
protected EditorUI |
createPrintEditorUI(BaseDocument doc)
Deprecated.
this method is no longer being called by
EditorUI .
BaseKit.createPrintEditorUI(BaseDocument, boolean, boolean) is being
called instead. |
protected EditorUI |
createPrintEditorUI(BaseDocument doc,
boolean usePrintColoringMap,
boolean lineNumberEnabled)
Create extended UI for printing a document.
|
Syntax |
createSyntax(Document doc)
Deprecated.
Please use Lexer instead, for details see
Lexer.
|
SyntaxSupport |
createSyntaxSupport(BaseDocument doc)
Deprecated.
Please use Lexer instead, for details see
Lexer.
|
protected BaseTextUI |
createTextUI()
Create text UI
|
void |
deinstall(JEditorPane c) |
protected void |
executeDeinstallActions(JEditorPane c) |
protected void |
executeInstallActions(JEditorPane c) |
Action |
getActionByName(String name)
Get action from its name.
|
Action[] |
getActions()
Get actions associated with this kit.
|
protected Action[] |
getCustomActions() |
protected Action[] |
getDeclaredActions()
Get actions declared in the xml layer.
|
MultiKeymap |
getKeymap() |
static BaseKit |
getKit(Class kitClass)
Deprecated.
Use
CloneableEditorSupport.getEditorKit or
MimeLookup instead to find EditorKit for a mime
type. |
protected Action[] |
getMacroActions()
Deprecated.
Without any replacement.
|
ViewFactory |
getViewFactory()
Fetches a factory that is suitable for producing
views of any models that are produced by this
kit.
|
protected void |
initDocument(BaseDocument doc)
Initialize document by adding the draw-layers for example.
|
void |
install(JEditorPane c)
Called after the kit is installed into JEditorPane
|
static Action[] |
mapToActions(Map map)
Converts map with [name, action] back
to array of actions.
|
void |
read(Reader in,
Document doc,
int pos)
Inserts content from the given stream.
|
List<Action> |
translateActionNameList(List<String> actionNameList) |
protected void |
updateActions()
Update the actions right after their creation was finished.
|
void |
write(Writer out,
Document doc,
int pos,
int len)
Writes content from a document to the given stream
|
getContentType, read, write
public static final String splitLineAction
public static final String annotationsCyclingAction
public static final String collapseFoldAction
public static final String expandFoldAction
public static final String collapseAllFoldsAction
public static final String expandAllFoldsAction
public static final String selectionPageUpAction
public static final String selectionPageDownAction
public static final String removeTabAction
public static final String removeSelectionAction
public static final String abbrevExpandAction
public static final String abbrevResetAction
public static final String removePreviousWordAction
public static final String removeNextWordAction
public static final String removeLineBeginAction
public static final String removeLineAction
public static final String moveSelectionElseLineUpAction
public static final String moveSelectionElseLineDownAction
public static final String copySelectionElseLineUpAction
public static final String copySelectionElseLineDownAction
public static final String toggleTypingModeAction
public static final String toUpperCaseAction
public static final String toLowerCaseAction
public static final String switchCaseAction
public static final String findNextAction
public static final String findPreviousAction
public static final String toggleHighlightSearchAction
public static final String findSelectionAction
public static final String undoAction
public static final String redoAction
public static final String wordMatchNextAction
public static final String wordMatchPrevAction
public static final String reindentLineAction
public static final String reformatLineAction
public static final String shiftLineRightAction
public static final String shiftLineLeftAction
public static final String adjustWindowCenterAction
public static final String adjustWindowTopAction
public static final String adjustWindowBottomAction
public static final String adjustCaretCenterAction
public static final String adjustCaretTopAction
public static final String adjustCaretBottomAction
public static final String formatAction
public static final String indentAction
public static final String firstNonWhiteAction
public static final String lastNonWhiteAction
public static final String selectionFirstNonWhiteAction
public static final String selectionLastNonWhiteAction
public static final String selectIdentifierAction
public static final String selectNextParameterAction
public static final String jumpListNextAction
public static final String jumpListPrevAction
public static final String jumpListNextComponentAction
public static final String jumpListPrevComponentAction
public static final String scrollUpAction
public static final String scrollDownAction
public static final String macroActionPrefix
public static final String startMacroRecordingAction
public static final String stopMacroRecordingAction
public static final String lineFirstColumnAction
public static final String insertDateTimeAction
public static final String selectionLineFirstColumnAction
public static final String generateGutterPopupAction
public static final String toggleLineNumbersAction
public static final String pasteFormatedAction
public static final String startNewLineAction
public static final String cutToLineBeginAction
public static final String cutToLineEndAction
public static final String removeTrailingSpacesAction
public static final String DOC_REPLACE_SELECTION_PROPERTY
public static final int MAGIC_POSITION_MAX
public BaseKit()
BaseKit
.
You should not need to instantiate editor kits
directly under normal circumstances. There is a few ways how you can get
instance of EditorKit
depending on what you already have
available:
CloneableEditorSupport.getEditorKit(yourMimeType)
to get the EditorKit
registered for your mime type or use
the following code MimeLookup.getLookup(MimePath.parse(yourMimeType)).lookup(EditorKit.class)
and check for null
.
JTextComponent.getUI().getEditorKit(JTextComponent)
passing
in the same component.
@Deprecated public static BaseKit getKit(Class kitClass)
CloneableEditorSupport.getEditorKit
or
MimeLookup
instead to find EditorKit
for a mime
type.Please be careful when using this method and make sure that you understand
how it works and what the deference is from using MimeLookup
.
This method simply creates an instance of BaseKit
from
its implementation class passed in as a parameter. It completely ignores
the registry of editor kits in MimeLookup
, which has severe
consequences.
The usuall pattern for using editor kits is to start with a mime type
of a document (ie. file) that you want to edit, then use some registry
for editor kits to look up the kit for your mime type and finally set the
kit in a JTextComponent
, let it create a Document
and load it with data. The registry can generally be anything, but in Netbeans
we use MimeLookup
(JDK for example uses
JEditorPane.createEditorKitForContentType
).
The editor kits are registered in MimeLookup
for each
particular mime type and the registry itself does not impose any rules on
the editor kit implementations other than extending the EditorKit
class. This for example means that the same implemantation of EditorKit
can be used for multiple mime types. This is exactly how XML editor kit
is reused for various flavors of XML documents (e.g. ant build scripts,
web app descriptors, etc).
Netbeans did not always have MimeLookup
and it also used a different approach for registering and retrieving
editor kits. This old approach was based on implemetation classes rather than on mime
types and while it is still more or less functional for the old kit
implementations, it is fundamentally broken and should not be used any more.
The code below demonstrates probably the biggest mistake when thinking
in the old ways.
// WARNING: The code below is a demonstration of a common mistake that
// people do when using BaseKit.getKit
.
JTextComponent component = ...; // Let's say we have a component
Class kitClass = Utilities.getKitClass(component);
String mimeType = BaseKit.getKit(kitClass).getContentType();
The problem with the above code is that it blindely assumes that each kit class can be uniquely mapped to a mime type. This is not true! The same can be achieved in much easier way, which always works.
JTextComponent component = ...; // Let's say we have a component String mimeType = component.getUI().getEditorKit(component).getContentType();
kitClass
- An implementation class of the editor kit that should
be returned. If the kitClass
is not BaseKit
or
its subclass the instance of bare BaseKit
will be returned.kitClass
or BaseKit
.public ViewFactory getViewFactory()
getViewFactory
in class DefaultEditorKit
public Caret createCaret()
createCaret
in class DefaultEditorKit
public Document createDefaultDocument()
createDefaultDocument
in class DefaultEditorKit
@Deprecated public Syntax createSyntax(Document doc)
doc
- document to operate on. It can be null in the cases the syntax
creation is not related to the particular document@Deprecated public Syntax createFormatSyntax(Document doc)
@Deprecated public SyntaxSupport createSyntaxSupport(BaseDocument doc)
protected BaseTextUI createTextUI()
protected EditorUI createEditorUI()
@Deprecated protected EditorUI createPrintEditorUI(BaseDocument doc)
EditorUI
.
BaseKit.createPrintEditorUI(BaseDocument, boolean, boolean)
is being
called instead.protected EditorUI createPrintEditorUI(BaseDocument doc, boolean usePrintColoringMap, boolean lineNumberEnabled)
doc
- document for which the extended UI is being created.usePrintColoringMap
- use printing coloring settings instead
of the regular ones.lineNumberEnabled
- if set to false the line numbers will not be printed.
If set to true the visibility of line numbers depends on the settings
for the line number visibility.public MultiKeymap getKeymap()
public void read(Reader in, Document doc, int pos) throws IOException, BadLocationException
read
in class DefaultEditorKit
IOException
BadLocationException
public void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException
write
in class DefaultEditorKit
IOException
BadLocationException
public static void addActionsToMap(Map<String,Action> map, Action[] actions, String logActionsType)
public static Action[] mapToActions(Map map)
public void install(JEditorPane c)
protected void executeInstallActions(JEditorPane c)
public void deinstall(JEditorPane c)
protected void executeDeinstallActions(JEditorPane c)
protected void initDocument(BaseDocument doc)
protected Action[] createActions()
protected Action[] getCustomActions()
@Deprecated protected Action[] getMacroActions()
public final Action[] getActions()
getActions
in class DefaultEditorKit
protected Action[] getDeclaredActions()
createActions()
and finally by result of getCustomActions()
.protected void updateActions()
getActions()
and getActionByName()
can be used safely in this method.
The implementation must call super.updateActions()
so that
the updating in parent is performed too.