public class Document3
extends javax.swing.text.DefaultStyledDocument
Modifier and Type | Class and Description |
---|---|
static class |
Document3.ORIENTATION |
javax.swing.text.DefaultStyledDocument.AttributeUndoableEdit, javax.swing.text.DefaultStyledDocument.ElementBuffer, javax.swing.text.DefaultStyledDocument.ElementSpec, javax.swing.text.DefaultStyledDocument.SectionElement
javax.swing.text.AbstractDocument.AbstractElement, javax.swing.text.AbstractDocument.AttributeContext, javax.swing.text.AbstractDocument.BranchElement, javax.swing.text.AbstractDocument.Content, javax.swing.text.AbstractDocument.DefaultDocumentEvent, javax.swing.text.AbstractDocument.ElementEdit, javax.swing.text.AbstractDocument.LeafElement
Modifier and Type | Field and Description |
---|---|
protected EditorController |
controller |
protected boolean |
textBeingComposed
Flag to indicate that text is currently being composed (should
not be considered to have been input yet) by an IME.
|
protected boolean |
trustedChangesInProgress
Flag for check internal changes of content, which should be always acceptable.
|
Constructor and Description |
---|
Document3(EditorController controller) |
Modifier and Type | Method and Description |
---|---|
protected int |
getTranslationEnd()
Calculate the position of the end of the current translation
|
int |
getTranslationStart()
Calculate the position of the start of the current translation
|
protected void |
setAlignment(int beginOffset,
int endOffset,
boolean isRightAlignment)
Set alignment for specified part of text.
|
addDocumentListener, addStyle, create, createDefaultRoot, getBackground, getCharacterElement, getDefaultRootElement, getFont, getForeground, getLogicalStyle, getParagraphElement, getStyle, getStyleNames, insert, insertUpdate, removeDocumentListener, removeElement, removeStyle, removeUpdate, setCharacterAttributes, setLogicalStyle, setParagraphAttributes, styleChanged
addUndoableEditListener, createBranchElement, createLeafElement, createPosition, dump, fireChangedUpdate, fireInsertUpdate, fireRemoveUpdate, fireUndoableEditUpdate, getAsynchronousLoadPriority, getAttributeContext, getBidiRootElement, getContent, getCurrentWriter, getDocumentFilter, getDocumentListeners, getDocumentProperties, getEndPosition, getLength, getListeners, getProperty, getRootElements, getStartPosition, getText, getText, getUndoableEditListeners, insertString, postRemoveUpdate, putProperty, readLock, readUnlock, remove, removeUndoableEditListener, render, replace, setAsynchronousLoadPriority, setDocumentFilter, setDocumentProperties, writeLock, writeUnlock
protected final EditorController controller
protected boolean trustedChangesInProgress
Note that there is a concurrency bug with the AquaCaret class (part of the OS X native LAF) whereby insertion into the Document while the doc is visible can cause the caret to try to update itself while the doc internals are inconsistent, leading to exceptions whenever any visual update of the Editor is performed (the Editor becomes unusable).
This bug is very old (reported as early as February 2006) and appears to not have been addressed even in December 2015 in Java 1.8.0_66), though it is very hard to reproduce (it appears to be a concurrency issue that only manifests itself under certain circumstances).
There is a chance that the "real" bug is in the way we are manipulating the JEditorPane and/or the underlying document, but it is unclear what the correct solution would be.
As a workaround, when setting this flag to true, if the changes are to include insertions or deletions of text in
the document, you must also disable the editor's caret updates temporarily (e.g. with
StaticUIUtils#setCaretUpdateEnabled()
). After the document changes are complete and you have set this
flag back to false, caret update can be re-enabled.
protected boolean textBeingComposed
public Document3(EditorController controller)
public int getTranslationStart()
protected int getTranslationEnd()
protected void setAlignment(int beginOffset, int endOffset, boolean isRightAlignment)
beginOffset
- begin offsetendOffset
- end offsetisRightAlignment
- false - left alignment, true - right alignment