KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > xml > xam > Model


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.xml.xam;
21
22 import java.beans.PropertyChangeListener JavaDoc;
23 import javax.swing.event.UndoableEditListener JavaDoc;
24
25 /**
26  * Interface describing an abstract model. The model is based on a
27  * document representation that represents the persistent form.
28  * @author Chris Webster
29  * @author Nam Nguyen
30  * @author Rico Cruz
31  */

32 public interface Model<C extends Component<C>> extends Referenceable {
33     public static final String JavaDoc STATE_PROPERTY = "state";
34     
35     /**
36      * Add coarse-grained change listener for events on model components.
37      */

38     public void removeComponentListener(ComponentListener cl);
39
40     /**
41      * Remove component event listener.
42      */

43     public void addComponentListener(ComponentListener cl);
44
45     /**
46      * Add fine-grained property change listener for events on model components.
47      */

48     public void addPropertyChangeListener(PropertyChangeListener JavaDoc pcl);
49
50     /**
51      * Remove property change listener.
52      */

53     public void removePropertyChangeListener(PropertyChangeListener JavaDoc pcl);
54
55     /**
56      * Removes undoable edit listener.
57      */

58     void removeUndoableEditListener(UndoableEditListener JavaDoc uel);
59
60     /**
61      * Adds undoable edit listener.
62      */

63     void addUndoableEditListener(UndoableEditListener JavaDoc uel);
64
65     /**
66      * Removes undoable refactoring edit listener. This will also restored
67      * the existing undoable edit listeners to the set before the start of
68      * refactoring. Note, if these listeners are UndoManager instances
69      * their queues are cleared of existing edits.
70      */

71     void removeUndoableRefactorListener(UndoableEditListener JavaDoc uel);
72
73     /**
74      * Adds undoable refactoring edit listener. This is typically called by a
75      * refactoring manager before start refactoring changes. This
76      * will also save existing undoable edit listeners. Note, if these listeners
77      * are UndoManager instances, their queues will be cleared of existing edits.
78      */

79     void addUndoableRefactorListener(UndoableEditListener JavaDoc uel);
80
81     /**
82      * make the current memory model consistent with the underlying
83      * representation, typically a swing document.
84      */

85     void sync() throws java.io.IOException JavaDoc;
86     
87     /**
88      * return true if sync is being performed.
89      */

90     boolean inSync();
91     
92     /**
93      * State of the model.
94      * VALID - Source is well-formed and model is in-sync.
95      * NOT_WELL_FORMED - Source is not well-formed, model is not synced.
96      * NOT_SYNCED - Source is well-formed, but there was error from last sync.
97      */

98     enum State {
99         VALID,
100         NOT_WELL_FORMED,
101         NOT_SYNCED
102     }
103     /**
104      * @return the last known state of the document. This method is affected
105      * by invocations of #sync().
106      */

107     State getState();
108     
109     /**
110      * @return true if model is in middle of transformation tranasction.
111      */

112     boolean isIntransaction();
113     
114     /**
115      * This method will block until a transaction can be started. A transaction
116      * in this context will fire events (such as property change) when
117      * #endTransaction() has been invoked. A transaction must be
118      * be acquired during a mutation, reading can be performed without
119      * a transaction. Only a single transaction at a time is supported. Mutations
120      * which occur based on events will not be reflected until the transaction
121      * has completed.
122      * @return true if transaction is acquired successfully, else false, for example
123      * if model has transitioned into invalid state.
124      */

125     boolean startTransaction();
126     
127     /**
128      * This method stops the transaction and causes all events to be fired.
129      * After all events have been fired, the document representation will be
130      * modified to reflect the current value of the model (flush).
131      */

132     void endTransaction();
133     
134     /**
135      * Add child component at specified index.
136      * @param target the parent component.
137      * @param child the child component to be added.
138      * @param index position among same type of child components, or -1 if not relevant.
139      */

140     void addChildComponent(Component target, Component child, int index);
141     
142     /**
143      * Remove specified component from model.
144      */

145     void removeChildComponent(Component child);
146
147     /**
148      * @return the source of this model or null if this model does associate
149      * with any model source.
150      */

151     ModelSource getModelSource();
152
153 }
154
Popular Tags