KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > lib > editor > util > swing > DocumentListenerPriority


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.lib.editor.util.swing;
21
22 /**
23 * Priorities of firing of document listeners being added to a document.
24 *
25 * @author Miloslav Metelka
26 * @since 1.4
27 */

28
29 public final class DocumentListenerPriority {
30
31     /**
32      * Lexer gets notified early to allow other levels to use the udpated
33      * token list.
34      */

35     public static final DocumentListenerPriority LEXER
36             = new DocumentListenerPriority(5, "lexer"); // NOI18N
37

38     /**
39      * Fold update gets notified prior default level.
40      */

41     public static final DocumentListenerPriority FOLD_UPDATE
42             = new DocumentListenerPriority(4, "fold-update"); // NOI18N
43

44     /**
45      * Default level is used for all listeners added
46      * by regular {@link javax.swing.text.Document#addDocumentListener(
47      * javax.swing.event.DocumentListener)} method.
48      */

49     public static final DocumentListenerPriority DEFAULT
50             = new DocumentListenerPriority(3, "default"); // NOI18N
51

52     /**
53      * Views are updated after default level and prior caret gets updated.
54      * @since 1.11
55      */

56     public static final DocumentListenerPriority VIEW
57             = new DocumentListenerPriority(2, "view"); // NOI18N
58

59     /**
60      * Caret udpate gets notified as last.
61      */

62     public static final DocumentListenerPriority CARET_UPDATE
63             = new DocumentListenerPriority(1, "caret-update"); // NOI18N
64

65     /**
66      * Udpate that follows caret update.
67      * @since 1.6
68      */

69     public static final DocumentListenerPriority AFTER_CARET_UPDATE
70             = new DocumentListenerPriority(0, "after-caret-update"); // NOI18N
71

72     
73     private int priority;
74     
75     private String JavaDoc description;
76
77     /**
78      * Construct new DocumentListenerPriority.
79      *
80      * @param priority higher priority means sooner firing.
81      * @param description textual description of the priority.
82      */

83     private DocumentListenerPriority(int priority, String JavaDoc description) {
84         this.priority = priority;
85         this.description = description;
86     }
87     
88     public String JavaDoc getDescription() {
89         return description;
90     }
91
92     public String JavaDoc toString() {
93         return getDescription();
94     }
95
96     /**
97      * Get the integer priority for the purpose of adding/removing
98      * of the listener with this priority.
99      */

100     int getPriority() {
101         return priority;
102     }
103
104 }
105
Popular Tags