當前位置: 首頁>>代碼示例>>Java>>正文


Java Document.removeDocumentListener方法代碼示例

本文整理匯總了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();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:SpringXMLConfigCompletionProvider.java

示例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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:18,代碼來源:LWTextAreaPeer.java

示例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();
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:20,代碼來源:LWTextComponentPeer.java

示例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);
    }
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:20,代碼來源:ElementTreePanel.java

示例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();
        }
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:36,代碼來源:CustomCodeView.java

示例6: run

import javax.swing.text.Document; //導入方法依賴的package包/類
@Override
public void run() {
    Document d = document;
    if (d != null) {
        d.removeDocumentListener(this);
        document = null;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:OffsetsBag.java

示例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);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:EditHistoryTest.java

示例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);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:EditHistoryTest.java

示例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();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:XmlMultiViewEditorSupport.java

示例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);
    }
}
 
開發者ID:AdoptOpenJDK,項目名稱:openjdk-jdk10,代碼行數:31,代碼來源:ElementTreePanel.java

示例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();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:16,代碼來源:OutputPane.java

示例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 );
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:Editor.java

示例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());

}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:52,代碼來源:TextEditorPane.java

示例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);
}
 
開發者ID:Thecarisma,項目名稱:powertext,代碼行數:15,代碼來源:TextEditorPane.java

示例15: onDispose

import javax.swing.text.Document; //導入方法依賴的package包/類
@Override
protected void onDispose(Document w) {
    w.removeDocumentListener(this);
}
 
開發者ID:akarnokd,項目名稱:RxJava2Swing,代碼行數:5,代碼來源:DocumentEventObservable.java


注:本文中的javax.swing.text.Document.removeDocumentListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。