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.jdt.internal.ui; 12 13 import org.eclipse.core.runtime.IAdaptable; 14 15 import org.eclipse.core.resources.IResource; 16 17 import org.eclipse.ui.views.tasklist.ITaskListResourceAdapter; 18 19 import org.eclipse.jdt.core.ICompilationUnit; 20 import org.eclipse.jdt.core.IJavaElement; 21 22 public class JavaTaskListAdapter implements ITaskListResourceAdapter { 23 24 /* 25 * @see ITaskListResourceAdapter#getAffectedResource(IAdaptable) 26 */ 27 public IResource getAffectedResource(IAdaptable element) { 28 IJavaElement java = (IJavaElement) element; 29 IResource resource= java.getResource(); 30 if (resource != null) 31 return resource; 32 33 ICompilationUnit cu= (ICompilationUnit) java.getAncestor(IJavaElement.COMPILATION_UNIT); 34 if (cu != null) { 35 return cu.getPrimary().getResource(); 36 } 37 return null; 38 } 39 } 40