KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > text > IDocumentExtension


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.jface.text;
13
14 /**
15  * Extension interface for {@link org.eclipse.jface.text.IDocument}.<p>
16  *
17  * It introduces the notion of sequentially rewriting a document. This is to tell a
18  * document that a sequence of non-overlapping replace operation is about to be
19  * performed. Implementers can use this knowledge for internal optimization.<p>
20  *
21  * Is also introduces the concept of post notification replaces. This is, a document
22  * listener who is informed about a document change can cause a derived document
23  * change. As the listener is not allowed to directly modify the document, it can
24  * register a replace operation that is performed directly after all document listeners
25  * have been notified.
26  *
27  * @since 2.0
28  */

29 public interface IDocumentExtension {
30
31     /**
32      * Interface for a post notification replace operation.
33      */

34     public interface IReplace {
35
36         /**
37          * Executes the replace operation on the given document.
38          *
39          * @param document the document to be changed
40          * @param owner the owner of this replace operation
41          */

42         void perform(IDocument document, IDocumentListener owner);
43     }
44
45     /**
46      * Callback for document listeners to be used inside <code>documentChanged</code>
47      * to register a post notification replace operation on the document notifying them.
48      *
49      * @param owner the owner of the replace operation
50      * @param replace the replace operation to be executed
51      * @exception UnsupportedOperationException if <code>registerPostNotificationReplace</code>
52      * is not supported by this document
53      */

54     void registerPostNotificationReplace(IDocumentListener owner, IReplace replace) throws UnsupportedOperationException JavaDoc;
55
56     /**
57      * Stops the processing of registered post notification replace operations until
58      * <code>resumePostNotificationProcessing</code> is called.
59      */

60     void stopPostNotificationProcessing();
61
62     /**
63      * Resumes the processing of post notification replace operations. If the queue of registered
64      * <code>IDocumentExtension.IReplace</code> objects is not empty, they are immediately processed if the
65      * document is not inside a replace operation. If the document is inside a replace operation,
66      * they are processed directly after the replace operation has finished.
67      */

68     void resumePostNotificationProcessing();
69
70     /**
71      * Tells the document that it is about to be sequentially rewritten. That is a
72      * sequence of non-overlapping replace operations will be performed on it. The
73      * <code>normalize</code> flag indicates whether the rewrite is performed from
74      * the start of the document to its end or from an arbitrary start offset. <p>
75      *
76      * The document is considered being in sequential rewrite mode as long as
77      * <code>stopSequentialRewrite</code> has not been called.
78      *
79      * @param normalize <code>true</code> if performed from the start to the end of the document
80      * @deprecated since 3.1. Use {@link IDocumentExtension4#startRewriteSession(DocumentRewriteSessionType)} instead.
81      */

82     void startSequentialRewrite(boolean normalize);
83
84     /**
85      * Tells the document that the sequential rewrite has been finished. This method
86      * has only any effect if <code>startSequentialRewrite</code> has been called before.
87      * @deprecated since 3.1. Use {@link IDocumentExtension4#stopRewriteSession(DocumentRewriteSession)} instead.
88      */

89     void stopSequentialRewrite();
90 }
91
Popular Tags