KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > core > mapping > ISynchronizationScope


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.core.mapping;
12
13 import org.eclipse.core.resources.IProject;
14 import org.eclipse.core.resources.IResource;
15 import org.eclipse.core.resources.mapping.*;
16
17 /**
18  * Interface which defines the protocol for translating a set of
19  * <code>ResourceMapping</code> objects representing a view selection into the
20  * complete set of resources to be operated on.
21  * <p>
22  * This interface is not intended to be implemented by clients. Instead, clients should
23  * use a {@link ISynchronizationScopeManager} to generate a resource mapping scope from
24  * a set of input resource mappings.
25  *
26  * @see org.eclipse.core.resources.mapping.ResourceMapping
27  * @see ISynchronizationScopeManager
28  *
29  * @since 3.2
30  */

31 public interface ISynchronizationScope {
32     
33     /**
34      * Return the projects that bound this scope.
35      * The projects returned will depend on the type of context used
36      * to generate this scope. If the context is a local context,
37      * all workspace projects are returned. If it is a remote context,
38      * the projects are the same as those returned from
39      * {@link RemoteResourceMappingContext#getProjects()}
40      * @return the projects that bound this scope
41      */

42     IProject[] getProjects();
43     
44     /**
45      * Return the resource mapping context that the scope
46      * uses to obtain traversals from resource mappings
47      * in order to determine what resources are in the scope.
48      *
49      * @see ResourceMapping#getTraversals(ResourceMappingContext, org.eclipse.core.runtime.IProgressMonitor)
50      *
51      * @return the resource mapping context that the scope
52      * uses to obtain traversals from resource mappings
53      */

54     ResourceMappingContext getContext();
55     
56     /**
57      * Return the array of mappings that acted as the input to the scope builder
58      * that was used to build this scope. This set usually come from a view
59      * selection but could come from another source. In most cases, clients will
60      * want to call the {@link #getMappings()} method instead of this one as it
61      * returns the complete set of mappings to be operated on.
62      *
63      * @return the set of mappings that acted as the input to the scope builder
64      * that was used to build this scope
65      */

66     public ResourceMapping[] getInputMappings();
67     
68     /**
69      * Return a scope that only contains the input mappings of this
70      * scope.
71      * @return a scope that only contains the input mappings of this
72      * scope
73      */

74     public ISynchronizationScope asInputScope();
75
76     /**
77      * Return an array of all of the mappings to be operated on. The returned
78      * mappings were included in the operation during the scope building
79      * process. The returned mappings may be the same as the input mappings but
80      * may also be a super set. Clients can call the
81      * {@link #hasAdditionalMappings()} method to determine if the two sets are
82      * the same or not.
83      *
84      * @return an array of all of the mappings to be operated on.
85      */

86     public ResourceMapping[] getMappings();
87
88     /**
89      * Return an array of traversals that cover the resource mappings to be
90      * operated on as returned by the {@link #getMappings()} method. The
91      * traversals were calculated during the scope building process and cached
92      * with the scope.
93      *
94      * @return the complete set of mappings to be operated on
95      */

96     public ResourceTraversal[] getTraversals();
97
98     /**
99      * Return the resources that are the roots of this scope.
100      * The roots are determined by collecting the roots of
101      * the traversals that define this scope.
102      * @return the resources that are the roots of this scope
103      */

104     public IResource[] getRoots();
105     
106     /**
107      * Return whether the given resource is contained in this scope.
108      * A resource is contained by the scope if it is contained in at
109      * least one of the traversals that define this scope.
110      * @param resource the resource to be tested
111      * @return whether the given resource is contained in this scope
112      */

113     public boolean contains(IResource resource);
114     
115     /**
116      * Add a scope change listener that will get invoked when a
117      * property of the receiver changes. Adding a listener that is
118      * already added has no effect.
119      *
120      * @param listener the listener to be added
121      */

122     public void addScopeChangeListener(ISynchronizationScopeChangeListener listener);
123     
124     /**
125      * Remove a scope change listener. Removing an unregistered listener
126      * has no effect.
127      *
128      * @param listener the listener to be removed
129      */

130     public void removeScopeChangeListener(ISynchronizationScopeChangeListener listener);
131     
132     /**
133      * Return an array of traversals that cover the given resource mapping to be
134      * operated on. The traversals were calculated during the scope building
135      * process and cached with the scope.
136      *
137      * @param mapping a resource mapping being operated on
138      * @return the traversals that cover the given resource mapping (or
139      * <code>null</code> if the mapping is not contained in the input)
140      */

141     public ResourceTraversal[] getTraversals(ResourceMapping mapping);
142
143     /**
144      * Return whether the scope has additional mappings added to the input
145      * mappings during the scope building process.
146      *
147      * @return whether the input has additional mappings added to the seed
148      * mappings
149      */

150     public boolean hasAdditionalMappings();
151
152     /**
153      * Return whether the scope has additional resources added due to additional
154      * resource mappings.
155      *
156      * @return whether the input has additional resources added due to
157      * additional resource mappings
158      */

159     public boolean hasAdditonalResources();
160     
161     /**
162      * Return all the model providers that have mappings in this scope.
163      *
164      * @return all the model providers that have mappings in this scope
165      */

166     public ModelProvider[] getModelProviders();
167
168     /**
169      * Return all the mappings to be operated on for the given model provider
170      * id.
171      *
172      * @param modelProviderId the id of the model provider
173      * @return all the mappings for the given model provider id
174      */

175     public ResourceMapping[] getMappings(String JavaDoc modelProviderId);
176
177     /**
178      * Return the set of traversals that cover the mappings for
179      * the given model provider.
180      * @param modelProviderId the model provider id
181      * @return the set of traversals that cover the mappings for
182      * the given model provider
183      */

184     public ResourceTraversal[] getTraversals(String JavaDoc modelProviderId);
185     
186     /**
187      * Return the resource mapping in the scope associated with the given model
188      * object or <code>null</code> if there isn't one. This method has no knowledge
189      * of hierarchical models so it only matches directly against the mappings
190      * that are contained in the scope.
191      * @param modelObject the model object
192      * @return the mapping for the model object that is contained in this scope
193      */

194     public ResourceMapping getMapping(Object JavaDoc modelObject);
195     
196     /**
197      * Refresh the given mapping asynchronously. This method
198      * is called by {@link ISynchronizationScopeParticipant}
199      * instances when they detect changes that require the scope
200      * to be adjusted.
201      * @param mappings the mappings to be refreshed.
202      */

203     void refresh(ResourceMapping[] mappings);
204
205 }
206
Popular Tags