本文整理匯總了Java中javax.swing.text.Document.removeUndoableEditListener方法的典型用法代碼示例。如果您正苦於以下問題:Java Document.removeUndoableEditListener方法的具體用法?Java Document.removeUndoableEditListener怎麽用?Java Document.removeUndoableEditListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.swing.text.Document
的用法示例。
在下文中一共展示了Document.removeUndoableEditListener方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setDocument
import javax.swing.text.Document; //導入方法依賴的package包/類
/**
* Sets the document used by this text area.
*
* @param document The new document to use.
* @throws IllegalArgumentException If the document is not an instance of
* {@link RDocument}.
*/
@Override
public void setDocument(Document document) {
if (!(document instanceof RDocument)) {
throw new IllegalArgumentException("RTextArea requires " +
"instances of RDocument for its document");
}
if (undoManager!=null) { // First time through, undoManager==null
Document old = getDocument();
if (old!=null) {
old.removeUndoableEditListener(undoManager);
}
}
super.setDocument(document);
if (undoManager!=null) {
document.addUndoableEditListener(undoManager);
discardAllEdits();
}
}
示例2: testSourceEditSyncUndo
import javax.swing.text.Document; //導入方法依賴的package包/類
public void testSourceEditSyncUndo() throws Exception {
defaultSetup();
UndoManager urListener = new UndoManager();
Document doc = mModel.getBaseDocument();
mModel.addUndoableEditListener(urListener);
mModel.startTransaction();
B b2 = new B(mModel, 2);
mModel.getRootComponent().addAfter(b2.getName(), b2, TestComponent3._A);
mModel.endTransaction();
assertEquals("first edit setup", 2, mModel.getRootComponent().getChildren(B.class).size());
// see fix for issue 83963, with this fix we need coordinate edits from
// on XDM model and on document buffer. This reduce XDM undo/redo efficiency,
// but is the best we can have to satisfy fine-grained text edit undo requirements.
mModel.removeUndoableEditListener(urListener);
doc.addUndoableEditListener(urListener);
Util.setDocumentContentTo(doc, "resources/test2.xml");
assertEquals("undo sync", 1, mModel.getRootComponent().getChildren(C.class).size());
mModel.sync();
doc.removeUndoableEditListener(urListener);
assertEquals("sync setup", 1, mModel.getRootComponent().getChildren(B.class).size());
assertEquals("sync setup", 0, mModel.getRootComponent().getChildren(C.class).size());
// setDocumentContentTo did delete all, then insert, hence 2 undo's'
urListener.undo(); urListener.undo();
mModel.sync(); // the above undo's are just on document buffer, needs sync (inefficient).
assertEquals("undo sync", 1, mModel.getRootComponent().getChildren(C.class).size());
assertEquals("undo sync", 2, mModel.getRootComponent().getChildren(B.class).size());
urListener.undo();
assertEquals("undo first edit before sync", 1, mModel.getRootComponent().getChildren(B.class).size());
urListener.redo();
assertEquals("redo first edit", 1, mModel.getRootComponent().getChildren(C.class).size());
assertEquals("redo first edit", 2, mModel.getRootComponent().getChildren(B.class).size());
// needs to back track the undo's, still needs sync'
urListener.redo(); urListener.redo();
mModel.sync();
assertEquals("redo to sync", 1, mModel.getRootComponent().getChildren(B.class).size());
assertEquals("redo to sync", 0, mModel.getRootComponent().getChildren(C.class).size());
}
示例3: onDispose
import javax.swing.text.Document; //導入方法依賴的package包/類
@Override
protected void onDispose(Document w) {
w.removeUndoableEditListener(this);
}