KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > editor > structure > api > DocumentElementEvent


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.modules.editor.structure.api;
21
22 import java.util.EventObject JavaDoc;
23
24
25 /**
26  * This is an implementation of EventObject class holding an information
27  * about a change in an DocumentElement. It is fired by DocumentElement-s and
28  * received via DocumentElementListener-s.
29  * <br/>
30  * The event object holds an information about the type of the change which can be one
31  * of the following:
32  * <ul>
33  * <li>A child has been added into the element
34  * <li>A child has been removed into the element
35  * <li>Children of the element have been reordered
36  * <li>Text content of the element has changed
37  * <li>Attributes of the element has changed
38  * </ul>
39  *
40  * @author Marek Fukala
41  * @version 1.0
42  */

43 public final class DocumentElementEvent extends EventObject JavaDoc {
44
45     //it can be either an added or a deleted component or null
46
private DocumentElement changedChild;
47     private int type;
48     
49     /** Event type indicating that the element's text content has been changed. */
50     public static final int CONTENT_CHANGED = 1;
51     
52     /** Event type indicating that a child has been added into the element. */
53     public static final int CHILD_ADDED = 2;
54     
55     /** Event type indicating that a child has been removed from the element. */
56     public static final int CHILD_REMOVED = 3;
57     
58     /** Event type indicating that children of the element have been reordered. */
59     public static final int CHILDREN_REORDERED = 4;
60     
61     /** Event type indicating that attributes of the element have changed.*/
62     public static final int ATTRIBUTES_CHANGED = 5;
63     
64     DocumentElementEvent(int type, DocumentElement source, DocumentElement changedChild) {
65         super(source);
66         this.type = type;
67         this.changedChild = changedChild;
68     }
69     
70     /** Returns the source element which fired this event. */
71     public DocumentElement getSourceDocumentElement() {
72         return (DocumentElement)getSource();
73     }
74     
75     /** Returns the added or removed child when the event is one of the CHILD_ADDED or CHILD_REMOVED type.*/
76     public DocumentElement getChangedChild() {
77         return this.changedChild;
78     }
79
80     /** Returns the type of the event. */
81     public int getType() {
82         return type;
83     }
84 }
85
86
Popular Tags