本文整理汇总了Java中org.netbeans.lib.editor.util.swing.DocumentListenerPriority类的典型用法代码示例。如果您正苦于以下问题:Java DocumentListenerPriority类的具体用法?Java DocumentListenerPriority怎么用?Java DocumentListenerPriority使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DocumentListenerPriority类属于org.netbeans.lib.editor.util.swing包,在下文中一共展示了DocumentListenerPriority类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: ViewUpdates
import org.netbeans.lib.editor.util.swing.DocumentListenerPriority; //导入依赖的package包/类
public ViewUpdates(DocumentView docView) {
this.docView = docView;
incomingModificationListener = new IncomingModificationListener();
Document doc = docView.getDocument();
// View hierarchy uses a pair of its own document listeners and DocumentView ignores
// document change notifications sent from BasicTextUI.RootView.
// First listener - incomingModificationListener at DocumentListenerPriority.FIRST notifies the hierarchy
// about incoming document modification.
// Second listener is "this" at DocumentListenerPriority.VIEW updates the view hierarchy structure
// according to the document modification.
// These two listeners avoid situation when a document modification modifies line structure
// and so the view hierarchy (which uses swing Positions for line view statrts) is inconsistent
// since e.g. with insert there may be gaps between views and with removal there may be overlapping views
// but the document listeners that are just being notified include a highlighting layer's document listener
// BEFORE the BasicTextUI.RootView listener. At that point the highlighting layer would fire a highlighting
// change and the view hierarchy would attempt to rebuild itself but that would fail.
listenerPriorityAwareDoc = DocumentUtilities.addPriorityDocumentListener(doc,
WeakListeners.create(DocumentListener.class, incomingModificationListener, null),
DocumentListenerPriority.FIRST);
// Add the second listener in all cases.
DocumentUtilities.addDocumentListener(doc,
WeakListeners.create(DocumentListener.class, this, doc),
DocumentListenerPriority.VIEW);
}
示例2: AnnotationHolder
import org.netbeans.lib.editor.util.swing.DocumentListenerPriority; //导入依赖的package包/类
@SuppressWarnings("LeakingThisInConstructor")
private AnnotationHolder(FileObject file, DataObject od, BaseDocument doc) {
openedComponents = new HashSet<>();
this.doc = doc;
if (file == null)
return ;
init();
this.file = file;
this.od = od;
getBag(doc);
DocumentUtilities.addPriorityDocumentListener(this.doc, this, DocumentListenerPriority.AFTER_CARET_UPDATE);
SwingUtilities.invokeLater(new Runnable() {
@Override public void run() {
resolveAllComponents();
}
});
// LOG.log(Level.FINE, null, new Throwable("Creating AnnotationHolder for " + file.getPath()));
Logger.getLogger("TIMER").log(Level.FINE, "Annotation Holder", //NOI18N
new Object[] {file, this});
}
示例3: clearAll
import org.netbeans.lib.editor.util.swing.DocumentListenerPriority; //导入依赖的package包/类
private synchronized void clearAll() {
//remove all annotations:
for (ParseErrorAnnotation a : line2Annotations.values()) {
detachAnnotation(a, false);
}
line2Annotations.clear();
file2Holder.remove(od);
DocumentUtilities.removePriorityDocumentListener(this.doc, this, DocumentListenerPriority.AFTER_CARET_UPDATE);
getBag(doc).clear();
}
示例4: addDocumentListener
import org.netbeans.lib.editor.util.swing.DocumentListenerPriority; //导入依赖的package包/类
@Override
public void addDocumentListener(DocumentListener listener) {
if (LOG_LISTENER.isLoggable(Level.FINE)) {
LOG_LISTENER.fine("ADD DocumentListener of class " + listener.getClass() + " to existing " +
org.netbeans.lib.editor.util.swing.DocumentUtilities.getDocumentListenerCount(this) +
" listeners. Listener: " + listener + '\n'
);
if (LOG_LISTENER.isLoggable(Level.FINER)) {
LOG_LISTENER.log(Level.FINER, " StackTrace:\n", new Exception());
}
}
if (!org.netbeans.lib.editor.util.swing.DocumentUtilities.addPriorityDocumentListener(
this, listener, DocumentListenerPriority.DEFAULT))
super.addDocumentListener(listener);
}
示例5: removeDocumentListener
import org.netbeans.lib.editor.util.swing.DocumentListenerPriority; //导入依赖的package包/类
@Override
public void removeDocumentListener(DocumentListener listener) {
if (LOG_LISTENER.isLoggable(Level.FINE)) {
LOG_LISTENER.fine("REMOVE DocumentListener of class " + listener.getClass() + " from existing " +
org.netbeans.lib.editor.util.swing.DocumentUtilities.getDocumentListenerCount(this) +
" listeners. Listener: " + listener + '\n'
);
if (LOG_LISTENER.isLoggable(Level.FINER)) {
LOG_LISTENER.log(Level.FINER, " StackTrace:\n", new Exception());
}
}
if (!org.netbeans.lib.editor.util.swing.DocumentUtilities.removePriorityDocumentListener(
this, listener, DocumentListenerPriority.DEFAULT))
super.removeDocumentListener(listener);
}
示例6: setColorings
import org.netbeans.lib.editor.util.swing.DocumentListenerPriority; //导入依赖的package包/类
void setColorings(final SortedSet<SequenceElement> colorings, final int version /*, final Set<OffsetRange> addedTokens, final Set<OffsetRange> removedTokens*/) {
doc.render(new Runnable() {
public @Override void run() {
synchronized (GsfSemanticLayer.this) {
GsfSemanticLayer.this.colorings = colorings;
GsfSemanticLayer.this.edits = new ArrayList<Edit>();
GsfSemanticLayer.this.version = version;
// I am not accurately computing it here
//if (addedTokens.isEmpty()) {
// //need to fire anything here?
//} else {
// if (addedTokens.size() == 1) {
// OffsetRange t = addedTokens.iterator().next();
//
// //fireHighlightsChange(t.offset(null), t.offset(null) + t.length()); //XXX: locking
// fireHighlightsChange(t.getStart(), t.getEnd()); //XXX: locking
// } else {
fireHighlightsChange(0, doc.getLength()); //XXX: locking
// }
//}
DocumentUtilities.removeDocumentListener(doc, GsfSemanticLayer.this, DocumentListenerPriority.LEXER);
DocumentUtilities.addDocumentListener(doc, GsfSemanticLayer.this, DocumentListenerPriority.LEXER);
}
}
});
}
示例7: init
import org.netbeans.lib.editor.util.swing.DocumentListenerPriority; //导入依赖的package包/类
private void init() {
AbstractDocument ad = LineDocumentUtils.asRequired(document, AbstractDocument.class);
this.valid = true;
ad.setDocumentFilter(new DocFilter());
try {
// initialize the bypass:
ad.replace(0, 0, "", null);
} catch (BadLocationException ex) {
}
org.netbeans.lib.editor.util.swing.DocumentUtilities.addPriorityDocumentListener(document,
l = new DocL(), DocumentListenerPriority.CARET_UPDATE);
}
示例8: modelChanged
import org.netbeans.lib.editor.util.swing.DocumentListenerPriority; //导入依赖的package包/类
protected void modelChanged(BaseDocument oldDoc, BaseDocument newDoc) {
if (oldDoc != null) {
// ideally the oldDoc param shouldn't exist and only listenDoc should be used
assert (oldDoc == listenDoc);
DocumentUtilities.removeDocumentListener(
oldDoc, this, DocumentListenerPriority.CARET_UPDATE);
oldDoc.removeAtomicLockListener(this);
caretPos = null;
markPos = null;
listenDoc = null;
if (prefs != null && weakPrefsListener != null) {
prefs.removePreferenceChangeListener(weakPrefsListener);
}
}
if (newDoc != null) {
DocumentUtilities.addDocumentListener(
newDoc, this, DocumentListenerPriority.CARET_UPDATE);
listenDoc = newDoc;
newDoc.addAtomicLockListener(this);
// Leave caretPos and markPos null => offset==0
prefs = MimeLookup.getLookup(DocumentUtilities.getMimeType(newDoc)).lookup(Preferences.class);
if (prefs != null) {
weakPrefsListener = WeakListeners.create(PreferenceChangeListener.class, prefsListener, prefs);
prefs.addPreferenceChangeListener(weakPrefsListener);
}
Utilities.runInEventDispatchThread(
new Runnable() {
public @Override void run() {
updateType();
}
}
);
}
}
示例9: DocumentInput
import org.netbeans.lib.editor.util.swing.DocumentListenerPriority; //导入依赖的package包/类
public DocumentInput(D doc) {
this.doc = doc;
this.text = DocumentUtilities.getText(doc);
// Add document listener with the appropriate priority (if priority listening is supported)
DocumentUtilities.addDocumentListener(doc, this, DocumentListenerPriority.LEXER);
}