KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > core > MoveDeleteManager


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.team.internal.core;
12
13  
14 import org.eclipse.core.resources.IFile;
15 import org.eclipse.core.resources.IFolder;
16 import org.eclipse.core.resources.IProject;
17 import org.eclipse.core.resources.IProjectDescription;
18 import org.eclipse.core.resources.IResource;
19 import org.eclipse.core.resources.team.IMoveDeleteHook;
20 import org.eclipse.core.resources.team.IResourceTree;
21 import org.eclipse.core.runtime.IProgressMonitor;
22 import org.eclipse.team.core.RepositoryProvider;
23
24 public class MoveDeleteManager implements IMoveDeleteHook {
25
26     private static final IMoveDeleteHook DEFAULT_HOOK = new DefaultMoveDeleteHook();
27     
28     private IMoveDeleteHook getHookFor(IResource resource) {
29         IProject project = resource.getProject();
30         RepositoryProvider provider = RepositoryProvider.getProvider(project);
31         if(provider==null) {
32             return DEFAULT_HOOK;
33         }
34         IMoveDeleteHook hook = provider.getMoveDeleteHook();
35         if (hook == null) {
36             return DEFAULT_HOOK;
37         }
38         return hook;
39     }
40     
41     /*
42      * @see IMoveDeleteHook#deleteFile(IResourceTree, IFile, int, IProgressMonitor)
43      */

44     public boolean deleteFile(
45         IResourceTree tree,
46         IFile file,
47         int updateFlags,
48         IProgressMonitor monitor) {
49         
50         return getHookFor(file).deleteFile(tree, file, updateFlags, monitor);
51     }
52
53     /*
54      * @see IMoveDeleteHook#deleteFolder(IResourceTree, IFolder, int, IProgressMonitor)
55      */

56     public boolean deleteFolder(
57         IResourceTree tree,
58         IFolder folder,
59         int updateFlags,
60         IProgressMonitor monitor) {
61         
62         return getHookFor(folder).deleteFolder(tree, folder, updateFlags, monitor);
63     }
64
65     /*
66      * @see IMoveDeleteHook#deleteProject(IResourceTree, IProject, int, IProgressMonitor)
67      */

68     public boolean deleteProject(
69         IResourceTree tree,
70         IProject project,
71         int updateFlags,
72         IProgressMonitor monitor) {
73             
74         return getHookFor(project).deleteProject(tree, project, updateFlags, monitor);
75     }
76
77     /*
78      * @see IMoveDeleteHook#moveFile(IResourceTree, IFile, IFile, int, IProgressMonitor)
79      */

80     public boolean moveFile(
81         IResourceTree tree,
82         IFile source,
83         IFile destination,
84         int updateFlags,
85         IProgressMonitor monitor) {
86         
87         return getHookFor(source).moveFile(tree, source, destination, updateFlags, monitor);
88     }
89
90     /*
91      * @see IMoveDeleteHook#moveFolder(IResourceTree, IFolder, IFolder, int, IProgressMonitor)
92      */

93     public boolean moveFolder(
94         IResourceTree tree,
95         IFolder source,
96         IFolder destination,
97         int updateFlags,
98         IProgressMonitor monitor) {
99             
100         return getHookFor(source).moveFolder(tree, source, destination, updateFlags, monitor);
101     }
102
103     /*
104      * @see IMoveDeleteHook#moveProject(IResourceTree, IProject, IProjectDescription, int, IProgressMonitor)
105      */

106     public boolean moveProject(
107         IResourceTree tree,
108         IProject source,
109         IProjectDescription description,
110         int updateFlags,
111         IProgressMonitor monitor) {
112             
113         return getHookFor(source).moveProject(tree, source, description, updateFlags, monitor);
114     }
115
116 }
117
Popular Tags