本文整理汇总了Java中javax.swing.text.Document.removeDocumentListener方法的典型用法代码示例。如果您正苦于以下问题:Java Document.removeDocumentListener方法的具体用法?Java Document.removeDocumentListener怎么用?Java Document.removeDocumentListener使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.text.Document
的用法示例。
在下文中一共展示了Document.removeDocumentListener方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: query
import javax.swing.text.Document; //导入方法依赖的package包/类
@Override
protected void query(CompletionResultSet resultSet, Document doc, int caretOffset) {
CompletionContext context = new CompletionContext(doc, caretOffset, queryType);
if (context.getCompletionType() == CompletionType.NONE) {
resultSet.finish();
return;
}
SpringXMLConfigDocumentListener listener = SpringXMLConfigDocumentListener.getListener(context.getDocumentContext());
doc.removeDocumentListener(listener);
doc.addDocumentListener(listener);
completor = CompletorRegistry.getDefault().getCompletor(context);
if(completor != null) {
SpringCompletionResult springCompletionResult = completor.complete(context);
populateResultSet(resultSet, springCompletionResult);
}
resultSet.finish();
}
示例2: replaceRange
import javax.swing.text.Document; //导入方法依赖的package包/类
@Override
public void replaceRange(final String text, final int start,
final int end) {
synchronized (getDelegateLock()) {
// JTextArea.replaceRange() posts two different events.
// Since we make no differences between text events,
// the document listener has to be disabled while
// JTextArea.replaceRange() is called.
final Document document = getTextComponent().getDocument();
document.removeDocumentListener(this);
getTextComponent().replaceRange(text, start, end);
revalidate();
postEvent(new TextEvent(getTarget(), TextEvent.TEXT_VALUE_CHANGED));
document.addDocumentListener(this);
}
repaintPeer();
}
示例3: setText
import javax.swing.text.Document; //导入方法依赖的package包/类
@Override
public final void setText(final String text) {
synchronized (getDelegateLock()) {
// JTextArea.setText() posts two different events (remove & insert).
// Since we make no differences between text events,
// the document listener has to be disabled while
// JTextArea.setText() is called.
final Document document = getTextComponent().getDocument();
document.removeDocumentListener(this);
getTextComponent().setText(text);
revalidate();
if (firstChangeSkipped) {
postEvent(new TextEvent(getTarget(),
TextEvent.TEXT_VALUE_CHANGED));
}
document.addDocumentListener(this);
}
repaintPeer();
}
示例4: propertyChange
import javax.swing.text.Document; //导入方法依赖的package包/类
/**
* Invoked when a property changes. We are only interested in when the
* Document changes to reset the DocumentListener.
*/
public void propertyChange(PropertyChangeEvent e) {
if (e.getSource() == getEditor() && e.getPropertyName().equals(
"document")) {
Document oldDoc = (Document) e.getOldValue();
Document newDoc = (Document) e.getNewValue();
// Reset the DocumentListener
oldDoc.removeDocumentListener(this);
newDoc.addDocumentListener(this);
// Recreate the TreeModel.
treeModel = new ElementTreeModel(newDoc);
tree.setModel(treeModel);
}
}
示例5: contentChange
import javax.swing.text.Document; //导入方法依赖的package包/类
private void contentChange(DocumentEvent e) {
changed = true;
Document doc = e.getDocument();
CodeCategory category = getCategoryForDocument(doc);
int eBlockIndex = getEditBlockIndex(category, e.getOffset());
if (eBlockIndex < 0) {
return;
}
List<EditableLine> lines = getEditInfos(category)[eBlockIndex].lines;
int[] blockBounds = getEditBlockBounds(category, eBlockIndex);
boolean repaint = false;
Integer lastLineCount = lastDocLineCounts.get(doc);
int lineCount = getLineCount(doc);
if (lastLineCount == null || lastLineCount.intValue() != lineCount) {
lastDocLineCounts.put(doc, Integer.valueOf(lineCount));
updateLines(doc, blockBounds[0], blockBounds[1], lines,
codeData.getEditableBlock(category, eBlockIndex));
repaint = true;
// make sure our listener is invoked after position listeners update
doc.removeDocumentListener(this);
doc.addDocumentListener(this);
}
repaint |= updateGutterComponents(lines, doc, blockBounds[0], blockBounds[1]);
if (repaint) {
JPanel gutter = getGutter(doc);
gutter.revalidate();
gutter.repaint();
}
// ((BaseDocument)doc).resetUndoMerge();
}
示例6: run
import javax.swing.text.Document; //导入方法依赖的package包/类
@Override
public void run() {
Document d = document;
if (d != null) {
d.removeDocumentListener(this);
document = null;
}
}
示例7: insert
import javax.swing.text.Document; //导入方法依赖的package包/类
private void insert(Document document, EditHistory history, int offset, String string) throws Exception {
try {
document.addDocumentListener(history);
document.insertString(offset, string, null);
} finally {
document.removeDocumentListener(history);
}
}
示例8: remove
import javax.swing.text.Document; //导入方法依赖的package包/类
private void remove(Document document, EditHistory history, int offset, int length) throws Exception {
try {
document.addDocumentListener(history);
document.remove(offset, length);
} finally {
document.removeDocumentListener(history);
}
}
示例9: notifyClosed
import javax.swing.text.Document; //导入方法依赖的package包/类
/** Resolving problems when editor was modified and closed
* (issue 57483)
*/
protected void notifyClosed() {
mvtc = null;
if (topComponentsListener != null) {
TopComponent.getRegistry().removePropertyChangeListener(topComponentsListener);
topComponentsListener = null;
}
Document document = getDocument();
if (document!=null) document.removeDocumentListener(docListener);
super.notifyClosed();
}
示例10: setEditor
import javax.swing.text.Document; //导入方法依赖的package包/类
/**
* Resets the JTextComponent to <code>editor</code>. This will update
* the tree accordingly.
*/
public void setEditor(JTextComponent editor) {
if (this.editor == editor) {
return;
}
if (this.editor != null) {
Document oldDoc = this.editor.getDocument();
oldDoc.removeDocumentListener(this);
this.editor.removePropertyChangeListener(this);
this.editor.removeCaretListener(this);
}
this.editor = editor;
if (editor == null) {
treeModel = null;
tree.setModel(null);
} else {
Document newDoc = editor.getDocument();
newDoc.addDocumentListener(this);
editor.addPropertyChangeListener(this);
editor.addCaretListener(this);
treeModel = new ElementTreeModel(newDoc);
tree.setModel(treeModel);
}
}
示例11: setDocument
import javax.swing.text.Document; //导入方法依赖的package包/类
@Override
protected void setDocument (Document doc) {
if (doc == null) {
Document d = getDocument();
if (d != null) {
d.removeDocumentListener(this);
}
textView.setDocument (new PlainDocument());
return;
}
textView.setEditorKit(new OutputEditorKit(isWrapped(), textView,
editorKitListener));
super.setDocument(doc);
updateKeyBindings();
}
示例12: markChanged
import javax.swing.text.Document; //导入方法依赖的package包/类
private void markChanged( DocumentEvent evt ) {
Document doc = evt.getDocument();
doc.putProperty( MODIFIED, Boolean.TRUE );
File file = (File)doc.getProperty( FILE );
int index = tabPane.indexOfComponent( comp );
tabPane.setTitleAt( index, file.getName() + '*' );
doc.removeDocumentListener( this );
}
示例13: load
import javax.swing.text.Document; //导入方法依赖的package包/类
/**
* Loads the specified file in this editor. This method fires a property
* change event of type {@link #FULL_PATH_PROPERTY}.
*
* @param loc The location of the file to load. This cannot be
* <code>null</code>.
* @param defaultEnc The encoding to use when loading/saving the file.
* This encoding will only be used if the file is not Unicode.
* If this value is <code>null</code>, the system default encoding
* is used.
* @throws IOException If an IO error occurs.
* @see #save()
* @see #saveAs(FileLocation)
*/
public void load(FileLocation loc, String defaultEnc) throws IOException {
// For new local files, just go with it.
if (loc.isLocal() && !loc.isLocalAndExists()) {
this.charSet = defaultEnc!=null ? defaultEnc : getDefaultEncoding();
this.loc = loc;
setText(null);
discardAllEdits();
setDirty(false);
return;
}
// Old local files and remote files, load 'em up. UnicodeReader will
// check for BOMs and handle them correctly in all cases, then pass
// rest of stream down to InputStreamReader.
UnicodeReader ur = new UnicodeReader(loc.getInputStream(), defaultEnc);
// Remove listener so dirty flag doesn't get set when loading a file.
Document doc = getDocument();
doc.removeDocumentListener(this);
BufferedReader r = new BufferedReader(ur);
try {
read(r, null);
} finally {
doc.addDocumentListener(this);
r.close();
}
// No IOException thrown, so we can finally change the location.
charSet = ur.getEncoding();
String old = getFileFullPath();
this.loc = loc;
setDirty(false);
setCaretPosition(0);
firePropertyChange(FULL_PATH_PROPERTY, old, getFileFullPath());
}
示例14: setDocument
import javax.swing.text.Document; //导入方法依赖的package包/类
/**
* Sets the document for this editor.
*
* @param doc The new document.
*/
@Override
public void setDocument(Document doc) {
Document old = getDocument();
if (old!=null) {
old.removeDocumentListener(this);
}
super.setDocument(doc);
doc.addDocumentListener(this);
}
示例15: onDispose
import javax.swing.text.Document; //导入方法依赖的package包/类
@Override
protected void onDispose(Document w) {
w.removeDocumentListener(this);
}