01: /*******************************************************************************
02: * Copyright (c) 2000, 2007 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.pde.internal.ui.views.dependencies;
11:
12: import org.eclipse.jface.viewers.ITreeContentProvider;
13: import org.eclipse.osgi.service.resolver.BundleDescription;
14: import org.eclipse.pde.core.plugin.IPluginBase;
15: import org.eclipse.pde.core.plugin.IPluginModelBase;
16:
17: public class CallersTreeContentProvider extends CallersContentProvider
18: implements ITreeContentProvider {
19:
20: /**
21: * Constructor.
22: */
23: public CallersTreeContentProvider(DependenciesView view) {
24: super (view);
25: }
26:
27: public Object[] getChildren(Object parentElement) {
28: if (parentElement instanceof IPluginBase) {
29: parentElement = ((IPluginBase) parentElement).getModel();
30: }
31: if (parentElement instanceof IPluginModelBase) {
32: parentElement = ((IPluginModelBase) parentElement)
33: .getBundleDescription();
34: }
35: if (parentElement instanceof BundleDescription) {
36: return findReferences((BundleDescription) parentElement)
37: .toArray();
38: }
39: return new Object[0];
40: }
41:
42: /**
43: * @see IStructuredContentProvider#getElements(Object)
44: * @return Object[] with 0 or 1 IPluginBase
45: */
46: public Object[] getElements(Object inputElement) {
47: if (inputElement instanceof IPluginModelBase) {
48: return new Object[] { ((IPluginModelBase) inputElement)
49: .getPluginBase() };
50: }
51: return new Object[0];
52: }
53:
54: /**
55: * @see ITreeContentProvider#getParent(Object)
56: */
57: public Object getParent(Object element) {
58: return null;
59: }
60:
61: /**
62: * @see ITreeContentProvider#hasChildren(Object)
63: */
64: public boolean hasChildren(Object element) {
65: return getChildren(element).length > 0;
66: }
67:
68: }
|