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