KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > model > JavaResourceMapping


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.jdt.internal.ui.model;
12
13 import org.eclipse.core.runtime.Assert;
14 import org.eclipse.core.runtime.IProgressMonitor;
15
16 import org.eclipse.core.resources.IProject;
17 import org.eclipse.core.resources.IResource;
18 import org.eclipse.core.resources.mapping.ResourceMapping;
19 import org.eclipse.core.resources.mapping.ResourceMappingContext;
20 import org.eclipse.core.resources.mapping.ResourceTraversal;
21
22 /**
23  * Resource mapping for the java model provider.
24  *
25  * @since 3.2
26  */

27 public final class JavaResourceMapping extends ResourceMapping {
28
29     /** The resource to map */
30     private final IResource fResource;
31
32     /**
33      * Creates a new java resource mapping.
34      *
35      * @param resource
36      * the resource to map
37      */

38     public JavaResourceMapping(final IResource resource) {
39         Assert.isNotNull(resource);
40         fResource= resource;
41     }
42
43     /**
44      * {@inheritDoc}
45      */

46     public Object JavaDoc getModelObject() {
47         return fResource;
48     }
49
50     /**
51      * {@inheritDoc}
52      */

53     public String JavaDoc getModelProviderId() {
54         return JavaModelProvider.JAVA_MODEL_PROVIDER_ID;
55     }
56
57     /**
58      * {@inheritDoc}
59      */

60     public IProject[] getProjects() {
61         return new IProject[] { fResource.getProject() };
62     }
63
64     /**
65      * {@inheritDoc}
66      */

67     public ResourceTraversal[] getTraversals(final ResourceMappingContext context, final IProgressMonitor monitor) {
68         return new ResourceTraversal[] { new ResourceTraversal(new IResource[] { fResource }, IResource.DEPTH_INFINITE, IResource.NONE) };
69     }
70 }
71
Popular Tags