当前位置: 首页>>代码示例>>Java>>正文


Java DocumentListenerPriority类代码示例

本文整理汇总了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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ViewUpdates.java

示例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});
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:AnnotationHolder.java

示例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();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:AnnotationHolder.java

示例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);
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:BaseDocument.java

示例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);
   }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:BaseDocument.java

示例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);
            }
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:GsfSemanticLayer.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:ConsoleModel.java

示例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();
                }
            }
        );
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:BaseCaret.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:7,代码来源:DocumentInput.java


注:本文中的org.netbeans.lib.editor.util.swing.DocumentListenerPriority类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。