KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > resources > team > IMoveDeleteHook


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.team;
12
13 import org.eclipse.core.resources.*;
14 import org.eclipse.core.runtime.IProgressMonitor;
15 import org.eclipse.core.runtime.OperationCanceledException;
16
17 /**
18  * Primary interface for hooking the implementation of
19  * <code>IResource.move</code> and <code>IResource.delete</code>.
20  * <p>
21  * This interface is intended to be implemented by the team component in
22  * conjunction with the <code>org.eclipse.core.resources.moveDeleteHook</code>
23  * standard extension point. Individual team providers may also implement this
24  * interface. It is not intended to be implemented by other clients. The methods
25  * defined on this interface are called from within the implementations of
26  * <code>IResource.move</code> and <code>IResource.delete</code>. They are not
27  * intended to be called from anywhere else.
28  * </p>
29  *
30  * @since 2.0
31  */

32 public interface IMoveDeleteHook {
33
34     /**
35      * Implements <code>IResource.delete(int,IProgressMonitor)</code> where the
36      * receiver is a file. Returns <code>true</code> to accept responsibility
37      * for implementing this operation as per the API contract.
38      * <p>
39      * In broad terms, a full re-implementation should delete the file in the
40      * local file system and then call <code>tree.deletedFile</code> to complete
41      * the updating of the workspace resource tree to reflect this fact. If
42      * unsuccessful in deleting the file from the local file system, it
43      * should instead call <code>tree.failed</code> to report the reason for
44      * the failure. In either case, it should return <code>true</code> to
45      * indicate that the operation was attempted. The <code>FORCE</code> update
46      * flag needs to be honored: unless <code>FORCE</code> is specified, the
47      * implementation must use <code>tree.isSynchronized</code> to determine
48      * whether the file is in sync before attempting to delete it.
49      * The <code>KEEP_HISTORY</code> update flag needs to be honored as well;
50      * use <code>tree.addToLocalHistory</code> to capture the contents of the
51      * file before deleting it from the local file system.
52      * </p><p>
53      * An extending implementation should perform whatever pre-processing it
54      * needs to do and then call <code>tree.standardDeleteFile</code> to
55      * explicitly invoke the standard file deletion behavior, which deletes
56      * both the file from the local file system and updates the workspace
57      * resource tree. It should return <code>true</code> to indicate that the
58      * operation was attempted.
59      * </p><p>
60      * Returning <code>false</code> is the easy way for the implementation to
61      * say "pass". It is equivalent to calling
62      * <code>tree.standardDeleteFile</code> and returning <code>true</code>.
63      * </p><p>
64      * The implementation of this method runs "below" the resources API and is
65      * therefore very restricted in what resource API method it can call. The
66      * list of useable methods includes most resource operations that read but
67      * do not update the resource tree; resource operations that modify
68      * resources and trigger deltas must not be called from within the dynamic
69      * scope of the invocation of this method.
70      * </p>
71      *
72      * @param tree the workspace resource tree; this object is only valid
73      * for the duration of the invocation of this method, and must not be
74      * used after this method has completed
75      * @param file the handle of the file to delete; the receiver of
76      * <code>IResource.delete(int,IProgressMonitor)</code>
77      * @param updateFlags bit-wise or of update flag constants as per
78      * <code>IResource.delete(int,IProgressMonitor)</code>
79      * @param monitor the progress monitor, or <code>null</code> as per
80      * <code>IResource.delete(int,IProgressMonitor)</code>
81      * @return <code>false</code> if this method declined to assume
82      * responsibility for this operation, and <code>true</code> if this method
83      * attempted to carry out the operation
84      * @exception OperationCanceledException if the operation is canceled.
85      * Cancelation can occur even if no progress monitor is provided.
86      * @see IResource#delete(int,IProgressMonitor)
87      */

88     public boolean deleteFile(IResourceTree tree, IFile file, int updateFlags, IProgressMonitor monitor);
89
90     /**
91      * Implements <code>IResource.delete(int,IProgressMonitor)</code> where the
92      * receiver is a folder. Returns <code>true</code> to accept responsibility
93      * for implementing this operation as per the API contract.
94      * <p>
95      * In broad terms, a full re-implementation should delete the directory tree
96      * in the local file system and then call <code>tree.deletedFolder</code> to
97      * complete the updating of the workspace resource tree to reflect this fact.
98      * If unsuccessful in deleting the directory or any of its descendents from
99      * the local file system, it should instead call <code>tree.failed</code> to
100      * report each reason for failure. In either case it should return
101      * <code>true</code> to indicate that the operation was attempted.
102      * The <code>FORCE</code> update flag needs to be honored: unless
103      * <code>FORCE</code> is specified, the implementation must use
104      * <code>tree.isSynchronized</code> to determine whether the folder
105      * subtree is in sync before attempting to delete it.
106      * The <code>KEEP_HISTORY</code> update flag needs to be honored as well;
107      * use <code>tree.addToLocalHistory</code> to capture the contents of any
108      * files being deleted.
109      * </p><p>
110      * A partial re-implementation should perform whatever pre-processing it
111      * needs to do and then call <code>tree.standardDeleteFolder</code> to
112      * explicitly invoke the standard folder deletion behavior, which deletes
113      * both the folder and its descendents from the local file system and
114      * updates the workspace resource tree. It should return <code>true</code>
115      * to indicate that the operation was attempted.
116      * </p><p>
117      * Returning <code>false</code> is the easy way for the implementation to
118      * say "pass". It is equivalent to calling
119      * <code>tree.standardDeleteFolder</code> and returning <code>true</code>.
120      * </p><p>
121      * The implementation of this method runs "below" the resources API and is
122      * therefore very restricted in what resource API method it can call. The
123      * list of useable methods includes most resource operations that read but
124      * do not update the resource tree; resource operations that modify
125      * resources and trigger deltas must not be called from within the dynamic
126      * scope of the invocation of this method.
127      * </p>
128      *
129      * @param tree the workspace resource tree; this object is only valid
130      * for the duration of the invocation of this method, and must not be
131      * used after this method has completed
132      * @param folder the handle of the folder to delete; the receiver of
133      * <code>IResource.delete(int,IProgressMonitor)</code>
134      * @param updateFlags bit-wise or of update flag constants as per
135      * <code>IResource.delete(int,IProgressMonitor)</code>
136      * @param monitor the progress monitor, or <code>null</code> as per
137      * <code>IResource.delete(int,IProgressMonitor)</code>
138      * @return <code>false</code> if this method declined to assume
139      * responsibility for this operation, and <code>true</code> if this
140      * method attempted to carry out the operation
141      * @exception OperationCanceledException if the operation is canceled.
142      * Cancelation can occur even if no progress monitor is provided.
143      * @see IResource#delete(int,IProgressMonitor)
144      */

145     public boolean deleteFolder(IResourceTree tree, IFolder folder, int updateFlags, IProgressMonitor monitor);
146
147     /**
148      * Implements <code>IResource.delete(int,IProgressMonitor)</code> where the
149      * receiver is a project. Returns <code>true</code> to accept responsibility
150      * for implementing this operation as per the API contract.
151      * <p>
152      * In broad terms, a full re-implementation should delete the project content area in
153      * the local file system if required (the files of a closed project should be deleted
154      * only if the <code>IResource.ALWAYS_DELETE_PROJECT_CONTENTS</code> update
155      * flag is specified; the files of an open project should be deleted unless the
156      * the <code>IResource.NEVER_DELETE_PROJECT_CONTENTS</code> update flag is
157      * specified). It should then call <code>tree.deletedProject</code> to complete
158      * the updating of the workspace resource tree to reflect this fact. If unsuccessful
159      * in deleting the project's files from the local file system, it should instead call
160      * <code>tree.failed</code> to report the reason for the failure. In either case, it
161      * should return <code>true</code> to indicate that the operation was attempted.
162      * The <code>FORCE</code> update flag may need to be honored if the project is open:
163      * unless <code>FORCE</code> is specified, the implementation must use
164      * <code>tree.isSynchronized</code> to determine whether the project subtree is in
165      * sync before attempting to delete it.
166      * Note that local history is not maintained when a project is deleted,
167      * regardless of the setting of the <code>KEEP_HISTORY</code> update flag.
168      * </p><p>
169      * A partial re-implementation should perform whatever pre-processing it needs
170      * to do and then call <code>tree.standardDeleteProject</code> to explicitly
171      * invoke the standard project deletion behavior. It should return <code>true</code>
172      * to indicate that the operation was attempted.
173      * </p><p>
174      * Returning <code>false</code> is the easy way for the implementation to
175      * say "pass". It is equivalent to calling
176      * <code>tree.standardDeleteProject</code> and returning <code>true</code>.
177      * </p><p>
178      * The implementation of this method runs "below" the resources API and is
179      * therefore very restricted in what resource API method it can call. The
180      * list of useable methods includes most resource operations that read but
181      * do not update the resource tree; resource operations that modify
182      * resources and trigger deltas must not be called from within the dynamic
183      * scope of the invocation of this method.
184      * </p>
185      *
186      * @param tree the workspace resource tree; this object is only valid
187      * for the duration of the invocation of this method, and must not be
188      * used after this method has completed
189      * @param project the handle of the project to delete; the receiver of
190      * <code>IResource.delete(int,IProgressMonitor)</code>
191      * @param updateFlags bit-wise or of update flag constants as per
192      * <code>IResource.delete(int,IProgressMonitor)</code>
193      * @param monitor the progress monitor, or <code>null</code> as per
194      * <code>IResource.delete(int,IProgressMonitor)</code>
195      * @return <code>false</code> if this method declined to assume
196      * responsibility for this operation, and <code>true</code> if this
197      * method attempted to carry out the operation
198      * @exception OperationCanceledException if the operation is canceled.
199      * Cancelation can occur even if no progress monitor is provided.
200      * @see IResource#delete(int,IProgressMonitor)
201      */

202     public boolean deleteProject(IResourceTree tree, IProject project, int updateFlags, IProgressMonitor monitor);
203
204     /**
205      * Implements <code>IResource.move(IPath,int,IProgressMonitor)</code> where
206      * the receiver is a file. Returns <code>true</code> to accept
207      * responsibility for implementing this operation as per the API contract.
208      * <p>
209      * On entry to this hook method, the following is guaranteed about the
210      * workspace resource tree: the source file exists; the destination file
211      * does not exist; the container of the destination file exists and is
212      * accessible. In broad terms, a full re-implementation should move the file
213      * in the local file system and then call <code>tree.moveFile</code> to
214      * complete the updating of the workspace resource tree to reflect this
215      * fact. If unsuccessful in moving the file in the local file system,
216      * it should instead call <code>tree.failed</code> to report the reason for
217      * the failure. In either case, it should return <code>true</code> to
218      * indicate that the operation was attempted.
219      * The <code>FORCE</code> update flag needs to be honored: unless
220      * <code>FORCE</code> is specified, the implementation must use
221      * <code>tree.isSynchronized</code> to determine whether the file is in sync before
222      * attempting to move it.
223      * The <code>KEEP_HISTORY</code> update flag needs to be honored as well; use
224      * <code>tree.addToLocalHistory</code> to capture the contents of the file
225      * (naturally, this must be before moving the file from the local file system).
226      * </p><p>
227      * An extending implementation should perform whatever pre-processing it needs
228      * to do and then call <code>tree.standardMoveFile</code> to explicitly
229      * invoke the standard file moving behavior, which moves both the file in the
230      * local file system and updates the workspace resource tree. It should return
231      * <code>true</code> to indicate that the operation was attempted.
232      * </p><p>
233      * Returning <code>false</code> is the easy way for the implementation to
234      * say "pass". It is equivalent to calling
235      * <code>tree.standardMoveFile</code> and returning <code>true</code>.
236      * </p><p>
237      * The implementation of this method runs "below" the resources API and is
238      * therefore very restricted in what resource API method it can call. The
239      * list of useable methods includes most resource operations that read but
240      * do not update the resource tree; resource operations that modify
241      * resources and trigger deltas must not be called from within the dynamic
242      * scope of the invocation of this method.
243      * </p>
244      *
245      * @param tree the workspace resource tree; this object is only valid
246      * for the duration of the invocation of this method, and must not be
247      * used after this method has completed
248      * @param source the handle of the file to move; the receiver of
249      * <code>IResource.move(IPath,int,IProgressMonitor)</code>
250      * @param destination the handle of where the file will move to; the handle
251      * equivalent of the first parameter to
252      * <code>IResource.move(IPath,int,IProgressMonitor)</code>
253      * @param updateFlags bit-wise or of update flag constants as per
254      * <code>IResource.move(IPath,int,IProgressMonitor)</code>
255      * @param monitor the progress monitor, or <code>null</code> as per
256      * <code>IResource.move(IPath,int,IProgressMonitor)</code>
257      * @return <code>false</code> if this method declined to assume
258      * responsibility for this operation, and <code>true</code> if this
259      * method attempted to carry out the operation
260      * @exception OperationCanceledException if the operation is canceled.
261      * Cancelation can occur even if no progress monitor is provided.
262      * @see IResource#move(org.eclipse.core.runtime.IPath,int,IProgressMonitor)
263      */

264     public boolean moveFile(IResourceTree tree, IFile source, IFile destination, int updateFlags, IProgressMonitor monitor);
265
266     /**
267      * Implements <code>IResource.move(IPath,int,IProgressMonitor)</code> where
268      * the receiver is a project. Returns <code>true</code> to accept
269      * responsibility for implementing this operation as per the API contract.
270      * <p>
271      * On entry to this hook method, the following is guaranteed about the
272      * workspace resource tree: the source folder exists; the destination folder
273      * does not exist; the container of the destination folder exists and is
274      * accessible. In broad terms, a full re-implementation should move the
275      * directory tree in the local file system and then call
276      * <code>tree.movedFolder</code> to complete the updating of the workspace
277      * resource tree to reflect this fact. If unsuccessful in moving the
278      * directory or any of its descendents in the local file system,
279      * call <code>tree.failed</code> to report each reason for failure.
280      * In either case, return <code>true</code> to indicate that the operation
281      * was attempted.
282      * The <code>FORCE</code> update flag needs to be honored: unless
283      * <code>FORCE</code> is specified, the implementation must use
284      * <code>tree.isSynchronized</code> to determine whether the folder subtree is in sync
285      * before attempting to move it.
286      * The <code>KEEP_HISTORY</code> update flag needs to be honored as well; use
287      * <code>tree.addToLocalHistory</code> to capture the contents of any files being
288      * moved.
289      * </p><p>
290      * A partial re-implementation should perform whatever pre-processing it needs
291      * to do and then call <code>tree.standardMoveFolder</code> to explicitly
292      * invoke the standard folder move behavior, which move both the folder
293      * and its descendents in the local file system and updates the workspace resource
294      * tree. Return <code>true</code> to indicate that the operation was attempted.
295      * </p><p>
296      * Returning <code>false</code> is the easy way for the implementation to
297      * say "pass". It is equivalent to calling
298      * <code>tree.standardDeleteFolder</code> and returning <code>true</code>.
299      * </p><p>
300      * The implementation of this method runs "below" the resources API and is
301      * therefore very restricted in what resource API method it can call. The
302      * list of useable methods includes most resource operations that read but
303      * do not update the resource tree; resource operations that modify
304      * resources and trigger deltas must not be called from within the dynamic
305      * scope of the invocation of this method.
306      * </p>
307      *
308      * @param tree the workspace resource tree; this object is only valid
309      * for the duration of the invocation of this method, and must not be
310      * used after this method has completed
311      * @param source the handle of the folder to move; the receiver of
312      * <code>IResource.move(IPath,int,IProgressMonitor)</code>
313      * @param destination the handle of where the folder will move to; the
314      * handle equivalent of the first parameter to
315      * <code>IResource.move(IPath,int,IProgressMonitor)</code>
316      * @param updateFlags bit-wise or of update flag constants as per
317      * <code>IResource.move(IPath,int,IProgressMonitor)</code>
318      * @param monitor the progress monitor, or <code>null</code> as per
319      * <code>IResource.move(IPath,int,IProgressMonitor)</code>
320      * @return <code>false</code> if this method declined to assume
321      * responsibility for this operation, and <code>true</code> if this
322      * method attempted to carry out the operation
323      * @exception OperationCanceledException if the operation is canceled.
324      * Cancelation can occur even if no progress monitor is provided.
325      * @see IResource#move(org.eclipse.core.runtime.IPath,int,IProgressMonitor)
326      */

327     public boolean moveFolder(IResourceTree tree, IFolder source, IFolder destination, int updateFlags, IProgressMonitor monitor);
328
329     /**
330      * Implements <code>IResource.move(IPath,int,IProgressMonitor)</code> and
331      * <code>IResource.move(IProjectDescription,int,IProgressMonitor)</code>
332      * where the receiver is a project. Returns <code>true</code> to accept
333      * responsibility for implementing this operation as per the API contracts.
334      * <p>
335      * On entry to this hook method, the source project is guaranteed to exist
336      * and be open in the workspace resource tree. If the given description
337      * contains a different name from that of the given project, then the
338      * project is being renamed (and its content possibly relocated). If the
339      * given description contains the same name as the given project, then the
340      * project is being relocated but not renamed. When the project is being
341      * renamed, the destination project is guaranteed not to exist in the
342      * workspace resource tree.
343      * </p><p>
344      * Returning <code>false</code> is the easy way for the implementation to
345      * say "pass". It is equivalent to calling
346      * <code>tree.standardMoveProject</code> and returning <code>true</code>.
347      * </p><p>
348      * The implementation of this method runs "below" the resources API and is
349      * therefore very restricted in what resource API method it can call. The
350      * list of useable methods includes most resource operations that read but
351      * do not update the resource tree; resource operations that modify
352      * resources and trigger deltas must not be called from within the dynamic
353      * scope of the invocation of this method.
354      * </p>
355      *
356      * @param tree the workspace resource tree; this object is only valid
357      * for the duration of the invocation of this method, and must not be
358      * used after this method has completed
359      * @param source the handle of the open project to move; the receiver of
360      * <code>IResource.move(IProjectDescription,int,IProgressMonitor)</code>
361      * or <code>IResource.move(IPath,int,IProgressMonitor)</code>
362      * @param description the new description of the project; the first
363      * parameter to
364      * <code>IResource.move(IProjectDescription,int,IProgressMonitor)</code>, or
365      * a copy of the project's description with the location changed to the
366      * path given in the first parameter to
367      * <code>IResource.move(IPath,int,IProgressMonitor)</code>
368      * @param updateFlags bit-wise or of update flag constants as per
369      * <code>IResource.move(IProjectDescription,int,IProgressMonitor)</code>
370      * or <code>IResource.move(IPath,int,IProgressMonitor)</code>
371      * @param monitor the progress monitor, or <code>null</code> as per
372      * <code>IResource.move(IProjectDescription,int,IProgressMonitor)</code>
373      * or <code>IResource.move(IPath,int,IProgressMonitor)</code>
374      * @return <code>false</code> if this method declined to assume
375      * responsibility for this operation, and <code>true</code> if this method
376      * attempted to carry out the operation
377      * @exception OperationCanceledException if the operation is canceled.
378      * Cancelation can occur even if no progress monitor is provided.
379      * @see IResource#move(org.eclipse.core.runtime.IPath,int,IProgressMonitor)
380      * @see IResource#move(IProjectDescription,int,IProgressMonitor)
381      */

382     public boolean moveProject(IResourceTree tree, IProject source, IProjectDescription description, int updateFlags, IProgressMonitor monitor);
383 }
384
Popular Tags