1 /*******************************************************************************2 * Copyright (c) 2000, 2006 IBM Corporation and others.3 * All rights reserved. This program and the accompanying materials4 * are made available under the terms of the Eclipse Public License v1.05 * which accompanies this distribution, and is available at6 * http://www.eclipse.org/legal/epl-v10.html7 *8 * Contributors:9 * IBM Corporation - initial API and implementation10 *******************************************************************************/11 12 package org.eclipse.ui.views.markers.internal;13 14 import org.eclipse.core.resources.IFile;15 import org.eclipse.core.resources.IResource;16 import org.eclipse.core.runtime.IAdaptable;17 import org.eclipse.ui.views.tasklist.ITaskListResourceAdapter;18 19 /**20 * The DefaultMarkerResourceAdapter is the default21 * implementation of the IMarkerResourceAdapter used by the22 * MarkerView for resource adaption.23 */24 class DefaultMarkerResourceAdapter implements ITaskListResourceAdapter {25 26 private static ITaskListResourceAdapter singleton;27 28 /**29 * Constructor for DefaultMarkerResourceAdapter.30 */31 DefaultMarkerResourceAdapter() {32 super();33 }34 35 /**36 * Return the default instance used for MarkerView adapting.37 */38 static ITaskListResourceAdapter getDefault() {39 if (singleton == null) {40 singleton = new DefaultMarkerResourceAdapter();41 }42 return singleton;43 }44 45 /**46 * @see IMarkerResourceAdapter#getAffectedResource(IAdaptable)47 */48 public IResource getAffectedResource(IAdaptable adaptable) {49 IResource resource = (IResource) adaptable.getAdapter(IResource.class);50 51 if (resource == null) {52 return (IFile) adaptable.getAdapter(IFile.class);53 } else {54 return resource;55 }56 }57 }58