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.views.tasklist;
11:
12: import org.eclipse.core.resources.IFile;
13: import org.eclipse.core.resources.IResource;
14: import org.eclipse.core.runtime.IAdaptable;
15:
16: /**
17: * The DefaultTaskListResourceAdapter is the default
18: * implementation of the ITaskListResourceAdapter used by the
19: * TaskList for resource adaption.
20: */
21: class DefaultTaskListResourceAdapter implements
22: ITaskListResourceAdapter {
23:
24: private static ITaskListResourceAdapter singleton;
25:
26: /**
27: * Constructor for DefaultTaskListResourceAdapter.
28: */
29: DefaultTaskListResourceAdapter() {
30: super ();
31: }
32:
33: /**
34: * Return the default instance used for TaskList adapting.
35: */
36: static ITaskListResourceAdapter getDefault() {
37: if (singleton == null) {
38: singleton = new DefaultTaskListResourceAdapter();
39: }
40: return singleton;
41: }
42:
43: /*
44: * @see ITaskListResourceAdapter#getAffectedResource(IAdaptable)
45: */
46: public IResource getAffectedResource(IAdaptable adaptable) {
47:
48: IResource resource = (IResource) adaptable
49: .getAdapter(IResource.class);
50: if (resource == null) {
51: return (IFile) adaptable.getAdapter(IFile.class);
52: } else {
53: return resource;
54: }
55:
56: }
57:
58: }
|