01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.ide;
11:
12: import org.eclipse.core.resources.IResource;
13: import org.eclipse.core.resources.mapping.ResourceMapping;
14: import org.eclipse.core.runtime.IAdaptable;
15: import org.eclipse.ui.IContributorResourceAdapter;
16: import org.eclipse.ui.ide.IContributorResourceAdapter2;
17:
18: /**
19: * The DefaultContributorResourceAdapter is the default
20: * implementation of the IContributorResourceAdapter used for
21: * one to one resource adaption.
22: */
23: public class DefaultContributorResourceAdapter implements
24: IContributorResourceAdapter2 {
25:
26: private static IContributorResourceAdapter singleton;
27:
28: /**
29: * Constructor for DefaultContributorResourceAdapter.
30: */
31: public DefaultContributorResourceAdapter() {
32: super ();
33: }
34:
35: /**
36: * Return the default instance used for TaskList adapting.
37: * @return the default instance used for TaskList adapting
38: */
39: public static IContributorResourceAdapter getDefault() {
40: if (singleton == null) {
41: singleton = new DefaultContributorResourceAdapter();
42: }
43: return singleton;
44: }
45:
46: /*
47: * @see IContributorResourceAdapter#getAdaptedResource(IAdaptable)
48: */
49: public IResource getAdaptedResource(IAdaptable adaptable) {
50: return (IResource) adaptable.getAdapter(IResource.class);
51: }
52:
53: public ResourceMapping getAdaptedResourceMapping(
54: IAdaptable adaptable) {
55: return (ResourceMapping) adaptable
56: .getAdapter(ResourceMapping.class);
57: }
58: }
|