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 package org.eclipse.pde.internal.ui.view;12 13 import org.eclipse.jface.viewers.ITreeContentProvider;14 import org.eclipse.pde.core.plugin.IPlugin;15 import org.eclipse.pde.core.plugin.IPluginBase;16 import org.eclipse.pde.core.plugin.IPluginImport;17 import org.eclipse.pde.core.plugin.IPluginModelBase;18 import org.eclipse.pde.internal.core.PDECore;19 20 public class CalleesTreeContentProvider extends CalleesContentProvider21 implements ITreeContentProvider {22 23 /**24 * Constructor.25 */26 public CalleesTreeContentProvider(DependenciesView view) {27 super(view);28 }29 30 /**31 * @see ITreeContentProvider#getChildren(Object)32 */33 public Object [] getChildren(Object parentElement) {34 if (parentElement instanceof IPluginBase) {35 IPluginBase plugin = (IPluginBase) parentElement;36 return findCallees(plugin);37 } else if (parentElement instanceof IPluginImport) {38 IPluginImport pluginImport = (IPluginImport) parentElement;39 String id = pluginImport.getId();40 IPlugin importedPlugin = PDECore.getDefault().findPlugin(id);41 if (importedPlugin != null)42 return findCallees(importedPlugin);43 44 }45 return new Object [0];46 }47 48 /**49 * @see IStructuredContentProvider#getElements(Object)50 * @return Object[] of IPluginBase51 */52 public Object [] getElements(Object inputElement) {53 if (inputElement instanceof IPluginModelBase) {54 return new Object [] { ((IPluginModelBase) inputElement)55 .getPluginBase() };56 }57 return new Object [0];58 }59 60 /**61 * @see ITreeContentProvider#getParent(Object)62 */63 public Object getParent(Object element) {64 return null;65 }66 67 /**68 * @see ITreeContentProvider#hasChildren(Object)69 */70 public boolean hasChildren(Object element) {71 return getChildren(element).length > 0;72 }73 74 }75