KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > resources > IResourceChangeEvent


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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 package org.eclipse.core.resources;
12
13 import org.eclipse.core.runtime.IProgressMonitor;
14
15 /**
16  * Resource change events describe changes to resources.
17  * <p>
18  * There are currently five different types of resource change events:
19  * <ul>
20  * <li>
21  * After-the-fact batch reports of arbitrary creations,
22  * deletions and modifications to one or more resources expressed
23  * as a hierarchical resource delta. Event type is
24  * <code>PRE_BUILD</code>, and <code>getDelta</code> returns
25  * the hierarchical delta. The resource delta is rooted at the
26  * workspace root. The <code>getBuildKind</code> method returns
27  * the kind of build that is about to occur, and the <code>getSource</code>
28  * method returns the scope of the build (either the workspace or a single project).
29  * These events are broadcast to interested parties immediately
30  * before each build operation. If autobuilding is not enabled, these events still
31  * occur at times when autobuild would have occurred. The workspace is open
32  * for change during notification of these events. The delta reported in this event
33  * cycle is identical across all listeners registered for this type of event.
34  * Resource changes attempted during a <code>PRE_BUILD</code> callback
35  * <b>must</b> be done in the thread doing the notification.
36  * </li>
37  * <li>
38  * After-the-fact batch reports of arbitrary creations,
39  * deletions and modifications to one or more resources expressed
40  * as a hierarchical resource delta. Event type is
41  * <code>POST_BUILD</code>, and <code>getDelta</code> returns
42  * the hierarchical delta. The resource delta is rooted at the
43  * workspace root. The <code>getBuildKind</code> method returns
44  * the kind of build that occurred, and the <code>getSource</code>
45  * method returns the scope of the build (either the workspace or a single project).
46  * These events are broadcast to interested parties at the end of every build operation.
47  * If autobuilding is not enabled, these events still occur at times when autobuild
48  * would have occurred. The workspace is open for change during notification of
49  * these events. The delta reported in this event cycle is identical across
50  * all listeners registered for this type of event.
51  * Resource changes attempted during a <code>POST_BUILD</code> callback
52  * <b>must</b> be done in the thread doing the notification.
53  * </li>
54  * <li>
55  * After-the-fact batch reports of arbitrary creations,
56  * deletions and modifications to one or more resources expressed
57  * as a hierarchical resource delta. Event type is
58  * <code>POST_CHANGE</code>, and <code>getDelta</code> returns
59  * the hierarchical delta. The resource delta is rooted at the
60  * workspace root. These events are broadcast to interested parties after
61  * a set of resource changes and happen whether or not autobuilding is enabled.
62  * The workspace is closed for change during notification of these events.
63  * The delta reported in this event cycle is identical across all listeners registered for
64  * this type of event.
65  * </li>
66  * <li>
67  * Before-the-fact reports of the impending closure of a single
68  * project. Event type is <code>PRE_CLOSE</code>,
69  * and <code>getResource</code> returns the project being closed.
70  * The workspace is closed for change during notification of these events.
71  * </li>
72  * <li>
73  * Before-the-fact reports of the impending deletion of a single
74  * project. Event type is <code>PRE_DELETE</code>,
75  * and <code>getResource</code> returns the project being deleted.
76  * The workspace is closed for change during notification of these events.
77  * </li>
78  * </ul>
79  * <p>
80  * In order to handle additional event types that may be introduced
81  * in future releases of the platform, clients should do not write code
82  * that presumes the set of event types is closed.
83  * </p>
84  * <p>
85  * This interface is not intended to be implemented by clients.
86  * </p>
87  */

88 public interface IResourceChangeEvent {
89     /**
90      * Event type constant (bit mask) indicating an after-the-fact
91      * report of creations, deletions, and modifications
92      * to one or more resources expressed as a hierarchical
93      * resource delta as returned by <code>getDelta</code>.
94      * See class comments for further details.
95      *
96      * @see #getType()
97      * @see #getDelta()
98      */

99     public static final int POST_CHANGE = 1;
100
101     /**
102      * Event type constant (bit mask) indicating a before-the-fact
103      * report of the impending closure of a single
104      * project as returned by <code>getResource</code>.
105      * See class comments for further details.
106      *
107      * @see #getType()
108      * @see #getResource()
109      */

110     public static final int PRE_CLOSE = 2;
111
112     /**
113      * Event type constant (bit mask) indicating a before-the-fact
114      * report of the impending deletion of a single
115      * project as returned by <code>getResource</code>.
116      * See class comments for further details.
117      *
118      * @see #getType()
119      * @see #getResource()
120      */

121     public static final int PRE_DELETE = 4;
122
123     /**
124      * @deprecated This event type has been renamed to
125      * <code>PRE_BUILD</code>
126      */

127     public static final int PRE_AUTO_BUILD = 8;
128
129     /**
130      * Event type constant (bit mask) indicating an after-the-fact
131      * report of creations, deletions, and modifications
132      * to one or more resources expressed as a hierarchical
133      * resource delta as returned by <code>getDelta</code>.
134      * See class comments for further details.
135      *
136      * @see #getType()
137      * @see #getResource()
138      * @since 3.0
139      */

140     public static final int PRE_BUILD = 8;
141
142     /**
143      * @deprecated This event type has been renamed to
144      * <code>POST_BUILD</code>
145      */

146     public static final int POST_AUTO_BUILD = 16;
147
148     /**
149      * Event type constant (bit mask) indicating an after-the-fact
150      * report of creations, deletions, and modifications
151      * to one or more resources expressed as a hierarchical
152      * resource delta as returned by <code>getDelta</code>.
153      * See class comments for further details.
154      *
155      * @see #getType()
156      * @see #getResource()
157      * @since 3.0
158      */

159     public static final int POST_BUILD = 16;
160
161     /**
162      * Returns all marker deltas of the specified type that are associated
163      * with resource deltas for this event. If <code>includeSubtypes</code>
164      * is <code>false</code>, only marker deltas whose type exactly matches
165      * the given type are returned. Returns an empty array if there
166      * are no matching marker deltas.
167      * <p>
168      * Calling this method is equivalent to walking the entire resource
169      * delta for this event, and collecting all marker deltas of a given type.
170      * The speed of this method will be proportional to the number of changed
171      * markers, regardless of the size of the resource delta tree.
172      * </p>
173      * @param type the type of marker to consider, or <code>null</code> to indicate all types
174      * @param includeSubtypes whether or not to consider sub-types of the given type
175      * @return an array of marker deltas
176      * @since 2.0
177      */

178     public IMarkerDelta[] findMarkerDeltas(String JavaDoc type, boolean includeSubtypes);
179
180     /**
181      * Returns the kind of build that caused this event,
182      * or <code>0</code> if not applicable to this type of event.
183      * <p>
184      * If the event is a <code>PRE_BUILD</code> or <code>POST_BUILD</code>
185      * then this will be the kind of build that occurred to cause the event.
186      * </p>
187      *
188      * @see IProject#build(int, IProgressMonitor)
189      * @see IWorkspace#build(int, IProgressMonitor)
190      * @see IncrementalProjectBuilder#AUTO_BUILD
191      * @see IncrementalProjectBuilder#FULL_BUILD
192      * @see IncrementalProjectBuilder#INCREMENTAL_BUILD
193      * @see IncrementalProjectBuilder#CLEAN_BUILD
194      * @return the kind of build, or <code>0</code> if not applicable
195      * @since 3.1
196      */

197     public int getBuildKind();
198
199     /**
200      * Returns a resource delta, rooted at the workspace, describing the set
201      * of changes that happened to resources in the workspace.
202      * Returns <code>null</code> if not applicable to this type of event.
203      *
204      * @return the resource delta, or <code>null</code> if not
205      * applicable
206      */

207     public IResourceDelta getDelta();
208
209     /**
210      * Returns the resource in question or <code>null</code>
211      * if not applicable to this type of event.
212      * <p>
213      * If the event is a <code>PRE_CLOSE</code> or
214      * <code>PRE_DELETE</code> event then the resource
215      * will be the affected project. Otherwise the resource will
216      * be <code>null</code>.
217      * </p>
218      * @return the resource, or <code>null</code> if not applicable
219      */

220     public IResource getResource();
221
222     /**
223      * Returns an object identifying the source of this event.
224      * <p>
225      * If the event is a <code>PRE_BUILD</code> or <code>POST_BUILD</code>
226      * then this will be the scope of the build (either the {@link IWorkspace} or a single {@link IProject}).
227      * </p>
228      *
229      * @return an object identifying the source of this event
230      * @see java.util.EventObject
231      */

232     public Object JavaDoc getSource();
233     
234     /**
235      * Returns the type of event being reported.
236      *
237      * @return one of the event type constants
238      * @see #POST_CHANGE
239      * @see #POST_BUILD
240      * @see #PRE_BUILD
241      * @see #PRE_CLOSE
242      * @see #PRE_DELETE
243      */

244     public int getType();
245 }
246
Popular Tags