KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > core > mapping > ResourceMappingInputScope


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.mapping;
12
13 import org.eclipse.core.resources.IProject;
14 import org.eclipse.core.resources.mapping.*;
15 import org.eclipse.team.core.mapping.ISynchronizationScope;
16
17 /**
18  * This scope wraps another scope and treats the input mappings of
19  * that wrapped scope as the mappings of this scope.
20  */

21 public class ResourceMappingInputScope extends AbstractResourceMappingScope {
22
23     ISynchronizationScope wrappedScope;
24     
25     public ResourceMappingInputScope(ISynchronizationScope wrappedScope) {
26         
27         this.wrappedScope = wrappedScope;
28     }
29     
30     /* (non-Javadoc)
31      * @see org.eclipse.team.ui.mapping.IResourceMappingScope#getInputMappings()
32      */

33     public ResourceMapping[] getInputMappings() {
34         return wrappedScope.getInputMappings();
35     }
36
37     /* (non-Javadoc)
38      * @see org.eclipse.team.ui.mapping.IResourceMappingScope#getMappings()
39      */

40     public ResourceMapping[] getMappings() {
41         return getInputMappings();
42     }
43
44     /* (non-Javadoc)
45      * @see org.eclipse.team.ui.mapping.IResourceMappingScope#getTraversals()
46      */

47     public ResourceTraversal[] getTraversals() {
48         CompoundResourceTraversal result = new CompoundResourceTraversal();
49         ResourceMapping[] mappings = getMappings();
50         for (int i = 0; i < mappings.length; i++) {
51             ResourceMapping mapping = mappings[i];
52             ResourceTraversal[] traversals = getTraversals(mapping);
53             result.addTraversals(traversals);
54         }
55         return result.asTraversals();
56     }
57
58     /* (non-Javadoc)
59      * @see org.eclipse.team.ui.mapping.IResourceMappingScope#getTraversals(org.eclipse.core.resources.mapping.ResourceMapping)
60      */

61     public ResourceTraversal[] getTraversals(ResourceMapping mapping) {
62         if (!contains(mapping)) {
63             return null;
64         }
65         return wrappedScope.getTraversals(mapping);
66     }
67
68     private boolean contains(ResourceMapping mapping) {
69         ResourceMapping[] mappings = getMappings();
70         for (int i = 0; i < mappings.length; i++) {
71             ResourceMapping child = mappings[i];
72             if (child.equals(mapping)) {
73                 return true;
74             }
75         }
76         return false;
77     }
78
79     /* (non-Javadoc)
80      * @see org.eclipse.team.ui.mapping.IResourceMappingScope#hasAdditionalMappings()
81      */

82     public boolean hasAdditionalMappings() {
83         return false;
84     }
85     
86     /* (non-Javadoc)
87      * @see org.eclipse.team.core.mapping.IResourceMappingScope#hasAdditonalResources()
88      */

89     public boolean hasAdditonalResources() {
90         return false;
91     }
92     
93     /* (non-Javadoc)
94      * @see org.eclipse.team.core.mapping.IResourceMappingScope#asInputScope()
95      */

96     public ISynchronizationScope asInputScope() {
97         return this;
98     }
99
100     /* (non-Javadoc)
101      * @see org.eclipse.team.core.mapping.ISynchronizationScope#getProjects()
102      */

103     public IProject[] getProjects() {
104         return wrappedScope.getProjects();
105     }
106
107     /* (non-Javadoc)
108      * @see org.eclipse.team.core.mapping.ISynchronizationScope#getContext()
109      */

110     public ResourceMappingContext getContext() {
111         return wrappedScope.getContext();
112     }
113
114     /* (non-Javadoc)
115      * @see org.eclipse.team.core.mapping.ISynchronizationScope#refresh(org.eclipse.core.resources.mapping.ResourceMapping[])
116      */

117     public void refresh(ResourceMapping[] mappings) {
118         wrappedScope.refresh(mappings);
119     }
120 }
121
Popular Tags