KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > ide > DefaultContributorResourceAdapter


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.ui.internal.ide;
12
13 import org.eclipse.core.resources.IResource;
14 import org.eclipse.core.resources.mapping.ResourceMapping;
15 import org.eclipse.core.runtime.IAdaptable;
16 import org.eclipse.ui.IContributorResourceAdapter;
17 import org.eclipse.ui.ide.IContributorResourceAdapter2;
18
19 /**
20  * The DefaultContributorResourceAdapter is the default
21  * implementation of the IContributorResourceAdapter used for
22  * one to one resource adaption.
23  */

24 public class DefaultContributorResourceAdapter implements
25         IContributorResourceAdapter2 {
26
27     private static IContributorResourceAdapter singleton;
28
29     /**
30      * Constructor for DefaultContributorResourceAdapter.
31      */

32     public DefaultContributorResourceAdapter() {
33         super();
34     }
35
36     /**
37      * Return the default instance used for TaskList adapting.
38      * @return the default instance used for TaskList adapting
39      */

40     public static IContributorResourceAdapter getDefault() {
41         if (singleton == null) {
42             singleton = new DefaultContributorResourceAdapter();
43         }
44         return singleton;
45     }
46
47     /*
48      * @see IContributorResourceAdapter#getAdaptedResource(IAdaptable)
49      */

50     public IResource getAdaptedResource(IAdaptable adaptable) {
51         return (IResource) adaptable.getAdapter(IResource.class);
52     }
53
54     public ResourceMapping getAdaptedResourceMapping(IAdaptable adaptable) {
55         return (ResourceMapping) adaptable.getAdapter(ResourceMapping.class);
56     }
57 }
58
59
Popular Tags