KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > core > mapping > ChangeSetResourceMapping


1 /*******************************************************************************
2  * Copyright (c) 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.ccvs.core.mapping;
12
13 import java.util.HashSet JavaDoc;
14 import java.util.Set JavaDoc;
15
16 import org.eclipse.core.resources.IProject;
17 import org.eclipse.core.resources.IResource;
18 import org.eclipse.core.resources.mapping.*;
19 import org.eclipse.core.runtime.CoreException;
20 import org.eclipse.core.runtime.IProgressMonitor;
21 import org.eclipse.team.internal.core.subscribers.DiffChangeSet;
22
23 public class ChangeSetResourceMapping extends ResourceMapping {
24
25     private final DiffChangeSet changeSet;
26
27     public ChangeSetResourceMapping(DiffChangeSet changeSet) {
28         this.changeSet = changeSet;
29     }
30
31     public Object JavaDoc getModelObject() {
32         return changeSet;
33     }
34
35     public String JavaDoc getModelProviderId() {
36         return ChangeSetModelProvider.ID;
37     }
38
39     public IProject[] getProjects() {
40         Set JavaDoc result = new HashSet JavaDoc();
41         IResource[] resources = changeSet.getResources();
42         for (int i = 0; i < resources.length; i++) {
43             IResource resource = resources[i];
44             result.add(resource.getProject());
45         }
46         return (IProject[]) result.toArray(new IProject[result.size()]);
47     }
48
49     public ResourceTraversal[] getTraversals(ResourceMappingContext context,
50             IProgressMonitor monitor) throws CoreException {
51         IResource[] resources = changeSet.getResources();
52         if (resources.length == 0) {
53             return new ResourceTraversal[0];
54         }
55         return new ResourceTraversal[] {
56                 new ResourceTraversal(resources, IResource.DEPTH_ZERO, IResource.NONE)
57         };
58     }
59
60 }
61
Popular Tags