/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License.
*/
/** * Editor kit implementation for base document * * @author Miloslav Metelka * @version 1.00
*/
publicclass BaseKit extends DefaultEditorKit {
/** * Flag indicating that the JTextComponent.paste() is in progress. * Checked in BaseDocument.read() to ignore clearing of the regions * for trailing-whitespace-removal.
*/ static ThreadLocal<Boolean> IN_PASTE = new ThreadLocal<Boolean>();
/** Remove characters to the begining of the word or
* the previous word if caret is not directly at word */ publicstaticfinal String removePreviousWordAction = "remove-word-previous"; // NOI18N
/** Remove characters to the end of the word or
* the next word if caret is not directly at word */ publicstaticfinal String removeNextWordAction = "remove-word-next"; // NOI18N
/** Remove to the begining of the line */ publicstaticfinal String removeLineBeginAction = "remove-line-begin"; // NOI18N
/** Toggle the typing mode to overwrite mode or back to insert mode */ publicstaticfinal String toggleTypingModeAction = "toggle-typing-mode"; // NOI18N
/** Change the selected text or current character to uppercase */ publicstaticfinal String toUpperCaseAction = "to-upper-case"; // NOI18N
/** Change the selected text or current character to lowercase */ publicstaticfinal String toLowerCaseAction = "to-lower-case"; // NOI18N
/** Switch the case of the selected text or current character */ publicstaticfinal String switchCaseAction = "switch-case"; // NOI18N
/** Shift line right action */ publicstaticfinal String shiftLineRightAction = "shift-line-right"; // NOI18N
/** Shift line left action */ publicstaticfinal String shiftLineLeftAction = "shift-line-left"; // NOI18N
/** Action that scrolls the window so that caret is at the center of the window */ publicstaticfinal String adjustWindowCenterAction = "adjust-window-center"; // NOI18N
/** Action that scrolls the window so that caret is at the top of the window */ publicstaticfinal String adjustWindowTopAction = "adjust-window-top"; // NOI18N
/** Action that scrolls the window so that caret is at the bottom of the window */ publicstaticfinal String adjustWindowBottomAction = "adjust-window-bottom"; // NOI18N
/** Action that moves the caret so that caret is at the center of the window */ publicstaticfinal String adjustCaretCenterAction = "adjust-caret-center"; // NOI18N
/** Action that moves the caret so that caret is at the top of the window */ publicstaticfinal String adjustCaretTopAction = "adjust-caret-top"; // NOI18N
/** Action that moves the caret so that caret is at the bottom of the window */ publicstaticfinal String adjustCaretBottomAction = "adjust-caret-bottom"; // NOI18N
/** Format part of the document text using Indent */ publicstaticfinal String formatAction = "format"; // NOI18N
/** Indent part of the document text using Indent */ publicstaticfinal String indentAction = "indent"; // NOI18N
/** First non-white character on the line */ publicstaticfinal String firstNonWhiteAction = "first-non-white"; // NOI18N
/** Last non-white character on the line */ publicstaticfinal String lastNonWhiteAction = "last-non-white"; // NOI18N
/** First non-white character on the line */ publicstaticfinal String selectionFirstNonWhiteAction = "selection-first-non-white"; // NOI18N
/** Last non-white character on the line */ publicstaticfinal String selectionLastNonWhiteAction = "selection-last-non-white"; // NOI18N
/** Select the nearest identifier around caret */ publicstaticfinal String selectIdentifierAction = "select-identifier"; // NOI18N
/** Select the next parameter (after the comma) in the given context */ publicstaticfinal String selectNextParameterAction = "select-next-parameter"; // NOI18N
/** Go to the previous position stored in the jump-list */ publicstaticfinal String jumpListNextAction = "jump-list-next"; // NOI18N
/** Go to the next position stored in the jump-list */ publicstaticfinal String jumpListPrevAction = "jump-list-prev"; // NOI18N
/** Go to the last position in the previous component stored in the jump-list */ publicstaticfinal String jumpListNextComponentAction = "jump-list-next-component"; // NOI18N
/** Go to the next position in the previous component stored in the jump-list */ publicstaticfinal String jumpListPrevComponentAction = "jump-list-prev-component"; // NOI18N
/** Scroll window one line up */ publicstaticfinal String scrollUpAction = "scroll-up"; // NOI18N
/** Scroll window one line down */ publicstaticfinal String scrollDownAction = "scroll-down"; // NOI18N
/** Prefix of all macro-based actions */ publicstaticfinal String macroActionPrefix = "macro-"; // NOI18N
/** Start recording of macro. Only one macro recording can be active at the time */ publicstaticfinal String startMacroRecordingAction = "start-macro-recording"; //NOI18N
/** Stop the active recording */ publicstaticfinal String stopMacroRecordingAction = "stop-macro-recording"; //NOI18N
/** Name of the action moving caret to the first column on the line */ publicstaticfinal String lineFirstColumnAction = "caret-line-first-column"; // NOI18N
/** Insert the current Date and Time */ publicstaticfinal String insertDateTimeAction = "insert-date-time"; // NOI18N
/** Name of the action moving caret to the first * column on the line and extending the selection
*/ publicstaticfinal String selectionLineFirstColumnAction = "selection-line-first-column"; // NOI18N
/** Name of the action for generating of Glyph Gutter popup menu*/ publicstaticfinal String generateGutterPopupAction = "generate-gutter-popup"; // NOI18N
/** Toggle visibility of line numbers*/ publicstaticfinal String toggleLineNumbersAction = "toggle-line-numbers"; // NOI18N
/** * Navigational boundaries for "home" and "end" actions. If defined on the target component, * home/end will move the caret first to the boundary, and only after that proceeds as usual (to the start/end of line). * The property must contain {@link PositionRegion} instance
*/ privatestaticfinal String PROP_NAVIGATE_BOUNDARIES = "NetBeansEditor.navigateBoundaries"; // NOI18N
/** * Gets an editor kit from its implemetation class. * * <p>Please be careful when using this method and make sure that you understand * how it works and what the deference is from using <code>MimeLookup</code>. * This method simply creates an instance of <code>BaseKit</code> from * its implementation class passed in as a parameter. It completely ignores * the registry of editor kits in <code>MimeLookup</code>, which has severe * consequences. * * <div class="nonnormative"> * <p>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 <code>JTextComponent</code>, let it create a <code>Document</code> * and load it with data. The registry can generally be anything, but in Netbeans * we use <code>MimeLookup</code> (JDK for example uses * <code>JEditorPane.createEditorKitForContentType</code>). * * <p>The editor kits are registered in <code>MimeLookup</code> for each * particular mime type and the registry itself does not impose any rules on * the editor kit implementations other than extending the <code>EditorKit</code> * class. This for example means that the same implemantation of <code>EditorKit</code> * 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). * * <p>Netbeans did not always have <code>MimeLookup</code> * 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. * * <pre> * // WARNING: The code below is a demonstration of a common mistake that * // people do when using <code>BaseKit.getKit</code>. * * JTextComponent component = ...; // Let's say we have a component * Class kitClass = Utilities.getKitClass(component); * String mimeType = BaseKit.getKit(kitClass).getContentType(); * </pre> * * <p>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. * * <pre> * JTextComponent component = ...; // Let's say we have a component * String mimeType = component.getUI().getEditorKit(component).getContentType(); * </pre> * </div> * * @param kitClass An implementation class of the editor kit that should * be returned. If the <code>kitClass</code> is not <code>BaseKit</code> or * its subclass the instance of bare <code>BaseKit</code> will be returned. * * @return An instance of the <code>kitClass</code> or <code>BaseKit</code>. * @deprecated Use <code>CloneableEditorSupport.getEditorKit</code> or * <code>MimeLookup</code> instead to find <code>EditorKit</code> for a mime * type.
*/
@Deprecated publicstatic BaseKit getKit(Class kitClass) { if (kitClass != null && BaseKit.class.isAssignableFrom(kitClass) && BaseKit.class != kitClass) {
String mimeType = KitsTracker.getInstance().findMimeType(kitClass); if (mimeType != null) {
EditorKit kit = MimeLookup.getLookup(MimePath.parse(mimeType)).lookup(EditorKit.class); if (kit instanceof BaseKit) { return (BaseKit) kit;
}
}
} else {
kitClass = BaseKit.class;
}
/** * Creates a new instance of <code>BaseKit</code>. * * <div class="nonnormative"> * <p>You should not need to instantiate editor kits * directly under normal circumstances. There is a few ways how you can get * instance of <code>EditorKit</code> depending on what you already have * available: * * <ul> * <li><b>mime type</b> - Use <code>CloneableEditorSupport.getEditorKit(yourMimeType)</code> * to get the <code>EditorKit</code> registered for your mime type or use * the following code <code>MimeLookup.getLookup(MimePath.parse(yourMimeType)).lookup(EditorKit.class)</code> * and check for <code>null</code>. * <li><b>JTextComponent</b> - Simply call * <code>JTextComponent.getUI().getEditorKit(JTextComponent)</code> passing * in the same component. * </ul> * </div>
*/ public BaseKit() { // possibly register synchronized (kits) { if (kits.get(this.getClass()) == null) {
kits.put(this.getClass(), this); // register itself
}
} // Directly implementing searchable editor kit would require module dependency changes // of any modules using BaseKit reference so make a wrapper instead
org.netbeans.modules.editor.lib2.actions.EditorActionUtilities.registerSearchableKit(this,
searchableKit = new SearchableKit(this));
}
/** Clone this editor kit */ public @Override Object clone() { returnthis; // no need to create another instance
}
/** Fetches a factory that is suitable for producing * views of any models that are produced by this * kit. The default is to have the UI produce the * factory, so this method has no implementation. * * @return the view factory
*/ public @Override ViewFactory getViewFactory() { return org.netbeans.modules.editor.lib2.view.ViewFactoryImpl.INSTANCE;
}
/** Create caret to navigate through document */ public @Override Caret createCaret() { returnnew EditorCaret();
}
/** * Create new instance of syntax coloring scanner * @param doc document to operate on. It can be null in the cases the syntax * creation is not related to the particular document * * @deprecated Please use Lexer instead, for details see * <a href="@org-netbeans-modules-lexer@/index.html">Lexer</a>.
*/
@Deprecated public Syntax createSyntax(Document doc) { returnnew DefaultSyntax();
}
/** * Create the syntax used for formatting. * * @deprecated Please use Editor Indentation API instead, for details see * <a href="@org-netbeans-modules-editor-indent@/index.html">Editor Indentation</a>.
*/
@Deprecated public Syntax createFormatSyntax(Document doc) { return createSyntax(doc);
}
/** * Create syntax support * * @deprecated Please use Lexer instead, for details see * <a href="@org-netbeans-modules-lexer@/index.html">Lexer</a>.
*/
@Deprecated public SyntaxSupport createSyntaxSupport(BaseDocument doc) { returnnew SyntaxSupport(doc);
}
// XXX: formatting cleanup // /** // * Create the formatter appropriate for this kit // * @deprecated Please use Editor Indentation API instead, for details see // * <a href="@org-netbeans-modules-editor-indent@/index.html">Editor Indentation</a>. // */ // public Formatter createFormatter() { // return new Formatter(this.getClass()); // }
/** * Create extended UI for printing a document. * @deprecated this method is no longer being called by {@link EditorUI}. * {@link #createPrintEditorUI(BaseDocument, boolean, boolean)} is being * called instead.
*/
@Deprecated protected EditorUI createPrintEditorUI(BaseDocument doc) { returnnew EditorUI(doc);
}
/** * Create extended UI for printing a document. * * @param doc document for which the extended UI is being created. * @param usePrintColoringMap use printing coloring settings instead * of the regular ones. * @param 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.
*/ protected EditorUI createPrintEditorUI(BaseDocument doc, boolean usePrintColoringMap, boolean lineNumberEnabled) {
public MultiKeymap getKeymap() { synchronized (KEYMAPS_AND_ACTIONS_LOCK) {
MimePath mimePath = MimePath.parse(getContentType());
MultiKeymap km = (MultiKeymap)kitKeymaps.get(mimePath);
if (km == null) { // keymap not yet constructed // construct new keymap
km = new MultiKeymap("Keymap for " + mimePath.getPath()); // NOI18N
// retrieve key bindings for this kit and super kits
KeyBindingSettings kbs = MimeLookup.getLookup(mimePath).lookup(KeyBindingSettings.class);
List<org.netbeans.api.editor.settings.MultiKeyBinding> mkbList = kbs.getKeyBindings();
List<JTextComponent.KeyBinding> editorMkbList = new ArrayList<JTextComponent.KeyBinding>();
// go through all levels and collect key bindings
km.load(editorMkbList.toArray(new JTextComponent.KeyBinding[0]), getActionMap());
km.setDefaultAction(getActionMap().get(defaultKeyTypedAction));
kitKeymaps.put(mimePath, km);
}
return km;
}
}
/** Inserts content from the given stream. */ public @Override void read(Reader in, Document doc, int pos) throws IOException, BadLocationException { if (doc instanceof BaseDocument) {
((BaseDocument)doc).read(in, pos); // delegate it to document
} else { super.read(in, doc, pos);
}
}
/** Writes content from a document to the given stream */ public @Override void write(Writer out, Document doc, int pos, int len) throws IOException, BadLocationException { if (doc instanceof BaseDocument) {
((BaseDocument)doc).write(out, pos, len);
} else { super.write(out, doc, pos, len);
}
}
/** Creates map with [name, action] pairs from the given * array of actions.
*/ publicstaticvoid addActionsToMap(Map<String, Action> map, Action[] actions, String logActionsType) { boolean fineLoggable = LOG.isLoggable(Level.FINE); if (fineLoggable) {
LOG.fine(logActionsType + " start --------------------\n");
} for (int i = 0; i < actions.length; i++) {
Action a = actions[i]; if (a == null) {
LOG.info("actions[] contains null at index " + i +
((i > 0) ? ". Preceding action is " + actions[i - 1] : ".")); continue;
}
String name = (String) a.getValue(Action.NAME); if (name == null) {
LOG.info("Null Action.NAME property of action " + a); continue;
}
if (fineLoggable) {
String overriding = map.containsKey(name) ? " OVERRIDING\n" : "\n"; // NOI18N
LOG.fine(" " + name + ": " + a + overriding); // NOI18N
}
map.put(name, a); // NOI18N
} if (fineLoggable) {
LOG.fine(logActionsType + " end ----------------------\n");
}
}
/** Converts map with [name, action] back * to array of actions.
*/ publicstatic Action[] mapToActions(Map map) {
Action[] actions = new Action[map.size()]; int i = 0; for (Iterator iter = map.values().iterator() ; iter.hasNext() ;) {
actions[i++] = (Action)iter.next();
} return actions;
}
/** Called after the kit is installed into JEditorPane */ public @Override void install(JEditorPane c) {
assert (SwingUtilities.isEventDispatchThread()) // expected in AWT only
: "BaseKit.install() incorrectly called from non-AWT thread."; // NOI18N
// Mark that the editor's multi keymap adheres to context API in status displayer
c.putClientProperty("context-api-aware", Boolean.TRUE); // NOI18N
// Add default help IDs derived from the kit's mime type, #61618. // If the kit itself is HelpCtx.Provider it will be called from CloneableEditor.getHelpCtx() if (!(thisinstanceof HelpCtx.Provider)) {
HelpCtx.setHelpIDString(c, getContentType().replace('/', '.').replace('+', '.')); //NOI18N
}
// setup the keymap tracker and initialize the keymap
MultiKeymap keymap; synchronized (KEYMAPS_AND_ACTIONS_LOCK) {
MimePath mimePath = MimePath.get(getContentType());
KeybindingsAndPreferencesTracker tracker = keymapTrackers.get(mimePath); if (tracker == null) {
tracker = new KeybindingsAndPreferencesTracker(mimePath.getPath());
keymapTrackers.put(mimePath, tracker);
}
tracker.addComponent(c);
keymap = getKeymap();
}
List<Action> actionsList = translateActionNameList(actionNamesList); // translate names to actions for (Action a : actionsList) {
a.actionPerformed(new ActionEvent(c, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
}
}
public @Override void deinstall(JEditorPane c) { assert (SwingUtilities.isEventDispatchThread()) // expected in AWT only
: "BaseKit.deinstall() incorrectly called from non-AWT thread."; // NOI18N
executeDeinstallActions(c);
// reset the keymap and remove the component from the tracker
c.setKeymap(null); synchronized (KEYMAPS_AND_ACTIONS_LOCK) {
MimePath mimePath = MimePath.get(getContentType());
KeybindingsAndPreferencesTracker tracker = keymapTrackers.get(mimePath); if (tracker != null) {
tracker.removeComponent(c);
}
}
BaseTextUI.uninstallUIWatcher(c);
// #41209: reset ancestor override flag if previously set if (c.getClientProperty("ancestorOverride") != null) { // NOI18N
c.putClientProperty("ancestorOverride", Boolean.FALSE); // NOI18N
}
}
List<Action> actionsList = translateActionNameList(actionNamesList); // translate names to actions for (Action a : actionsList) {
a.actionPerformed(new ActionEvent(c, ActionEvent.ACTION_PERFORMED, "")); // NOI18N
}
}
/** Initialize document by adding the draw-layers for example. */ protectedvoid initDocument(BaseDocument doc) {
}
/** Create actions that this kit supports. To use the actions of the parent kit * it's better instead of using super.createActions() to use * getKit(super.getClass()).getActions() because it can reuse existing * parent actions.
*/ protected Action[] createActions() { returnnew Action[] { // new DefaultKeyTypedAction() - overriden in ExtKit
insertBreakActionDef,
insertTabActionDef,
deletePrevCharActionDef,
deleteNextCharActionDef,
cutActionDef,
copyActionDef,
pasteActionDef, new PasteAction(true),
removeTabActionDef, //new ActionFactory.RemoveWordAction(), #47709
removeSelectionActionDef,
undoActionDef,
redoActionDef, //new ActionFactory.ToggleLineNumbersAction(), new ActionFactory.ToggleRectangularSelectionAction(),
// Self test actions // new EditorDebug.SelfTestAction(), // new EditorDebug.DumpPlanesAction(), // new EditorDebug.DumpSyntaxMarksAction()
};
}
/** * @deprecated Without any replacement.
*/
@Deprecated protected Action[] getMacroActions() { returnnew Action[0];
}
/** Get actions associated with this kit. createActions() is called * to get basic list and then customActions are added.
*/ public @Override final Action[] getActions() {
Action[] actions = (Action []) addActionsToMap()[0];
if (!keyBindingsUpdaterInited) {
keyBindingsUpdaterInited = true;
KeyBindingsUpdater.get(getContentType()).addKit(this); // Update key bindings in actions
}
if (actions == null || actionMap == null) { // Initialize actions - use the following actions: // 1. Declared "global" actions (declared in the xml layer under "Editors/Actions") // 2. Declared "mime-type" actions (declared in the xml layer under "Editors/mime-type/Actions") // 3. Result of createActions() // 4. Custom actions (EditorPreferencesKeys.CUSTOM_ACTION_LIST) // Higher levels override actions with same Action.NAME
actions = getDeclaredActions(); // non-null
actionMap = new HashMap<String, Action>(actions.length << 1);
addActionsToMap(actionMap, actions, "Declared actions"); // NOI18N
Action[] createActionsMethodResult = createActions(); if (createActionsMethodResult != null) {
addActionsToMap(actionMap, createActionsMethodResult, "Actions from createActions()"); // NOI18N
}
// At this moment the actions are constructed completely // The actions will be updated now if necessary
updateActions();
}
returnnew Object [] { actions, actionMap };
}
}
/** * Get actions declared in the xml layer. They may be overriden by result * of <code>createActions()</code> and finally by result of <code>getCustomActions()</code>. * * @return non-null list of declared actions.
*/ protected Action[] getDeclaredActions() { returnnew Action[0];
}
/** Update the actions right after their creation was finished. * The <code>getActions()</code> and <code>getActionByName()</code> * can be used safely in this method. * The implementation must call <code>super.updateActions()</code> so that * the updating in parent is performed too.
*/ protectedvoid updateActions() {
}
/** Get action from its name. */ public Action getActionByName(String name) { return (name != null) ? (Action)getActionMap().get(name) : null;
}
public List<Action> translateActionNameList(List<String> actionNameList) {
List<Action> ret = new ArrayList<Action>(); if (actionNameList != null) { for(String actionName : actionNameList) {
Action a = getActionByName(actionName); if (a != null) {
ret.add(a);
}
}
} return ret;
}
/** * Checks that the action will result in an insertion into document. * Returns true for readonly docs as well. * * @param evt action event * @return true, if the action event will result in insertion; readonly doc status is not * checked.
*/ staticboolean isValidDefaultTypedAction(ActionEvent evt) { // Check whether the modifiers are OK int mod = evt.getModifiers(); boolean ctrl = ((mod & ActionEvent.CTRL_MASK) != 0); boolean alt = org.openide.util.Utilities.isMac() ? ((mod & ActionEvent.META_MASK) != 0) :
((mod & ActionEvent.ALT_MASK) != 0); return !(alt || ctrl);
}
public DefaultKeyTypedAction() { // Construct with defaultKeyTypedAction name to retain full compatibility for extending actions super(defaultKeyTypedAction, CLEAR_STATUS_TEXT);
putValue(BaseAction.NO_KEYBINDING, Boolean.TRUE);
LOG.fine("DefaultKeyTypedAction with enhanced logging, see issue #145306"); //NOI18N
}
publicvoid actionPerformed (final ActionEvent evt, final JTextComponent target) { if ((target != null) && (evt != null)) {
if (!isValidDefaultTypedAction(evt)) { return;
}
// Check whether the target is enabled and editable if (!target.isEditable() || !target.isEnabled()) {
target.getToolkit().beep(); return;
}
// reset magic caret position if (target.getCaret() != null) {
target.getCaret().setMagicCaretPosition(null);
}
// determine if typed char is valid final String cmd = evt.getActionCommand(); if (isValidDefaultTypedCommand(evt)) { if (LOG.isLoggable(Level.FINE)) {
LOG.log(Level.FINE, "Processing command char: {0}", Integer.toHexString(cmd.charAt(0))); //NOI18N
}
if (((Boolean) result[0]).booleanValue()) {
transaction.afterInsertion();
// XXX: this is potentially wrong and we may need to call this with // the original cmd; or maybe only if insertionText == cmd; but maybe // it does not matter, because nobody seems to be overwriting this method anyway
checkIndent(target, (String) result[1]);
} // else text insertion failed
}
} finally {
transaction.close();
}
} catch (BadLocationException ble) {
LOG.log(Level.FINE, null, ble);
target.getToolkit().beep();
}
} else { if (LOG.isLoggable(Level.FINE)) {
StringBuilder sb = new StringBuilder(); for(int i = 0; i < cmd.length(); i++) {
String hex = Integer.toHexString(cmd.charAt(i));
sb.append(hex); if (i + 1 < cmd.length()) {
sb.append(" ");
}
}
LOG.log(Level.FINE, "Invalid command: {0}", sb); //NOI18N
}
}
}
}
/** * Hook to insert the given string at the given position into * the given document in insert-mode, no selection, writeable * document. Designed to be overridden by subclasses that want * to intercept inserted characters. * * @deprecated Please use Typing Hooks instead, for details see * <a href="@org-netbeans-modules-editor-lib2@/index.html">Editor Library 2</a>.
*/ protectedvoid insertString(BaseDocument doc, int dotPos,
Caret caret,
String str, boolean overwrite) throws BadLocationException
{ if (overwrite) {
doc.remove(dotPos, 1);
}
doc.insertString(dotPos, str, null);
}
/** * Hook to insert the given string at the given position into * the given document in insert-mode with selection visible * Designed to be overridden by subclasses that want * to intercept inserted characters. * * @deprecated Please use Typing Hooks instead, for details see * <a href="@org-netbeans-modules-editor-lib2@/index.html">Editor Library 2</a>.
*/ protectedvoid replaceSelection(
JTextComponent target, int dotPos,
Caret caret,
String str, boolean overwrite) throws BadLocationException
{
target.replaceSelection(str);
}
/** * Check whether there was any important character typed * so that the line should be possibly reformatted. * * @deprecated Please use <a href="@org-netbeans-modules-editor-indent-support@/org/netbeans/modules/editor/indent/spi/support/AutomatedIndenting.html">AutomatedIndentig</a> * or Typing Hooks instead, for details see * <a href="@org-netbeans-modules-editor-lib2@/index.html">Editor Library 2</a>.
*/ protectedvoid checkIndent(JTextComponent target, String typedText) {
}
privatevoid performTextInsertion(JTextComponent target, int insertionOffset, String insertionText, int caretPosition, boolean formatNewLines) throws BadLocationException { final BaseDocument doc = (BaseDocument)target.getDocument();
try {
NavigationHistory.getEdits().markWaypoint(target, insertionOffset, false, true);
} catch (BadLocationException e) {
LOG.log(Level.WARNING, "Can't add position to the history of edits.", e); //NOI18N
}
editorUI.getWordMatch().clear(); // reset word matching Boolean overwriteMode = (Boolean)editorUI.getProperty(EditorUI.OVERWRITE_MODE_PROPERTY); boolean ovr = (overwriteMode != null && overwriteMode.booleanValue()); int currentInsertOffset = insertionOffset; int targetCaretOffset = caretPosition; for (int i = 0; i < insertionText.length();) { int end = insertionText.indexOf('\n', i); if (end == (-1) || !formatNewLines) end = insertionText.length();
--> --------------------
--> maximum size reached
--> --------------------
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.25Angebot
Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.