1 11 package org.eclipse.pde.internal.ui.views.dependencies; 12 13 import java.util.HashSet ; 14 import java.util.Iterator ; 15 import java.util.Set ; 16 17 import org.eclipse.jface.viewers.IStructuredContentProvider; 18 import org.eclipse.osgi.service.resolver.BundleDescription; 19 import org.eclipse.pde.core.plugin.IPluginModelBase; 20 21 public class CallersListContentProvider extends CallersContentProvider 22 implements IStructuredContentProvider { 23 24 public CallersListContentProvider(DependenciesView view) { 25 super(view); 26 } 27 28 31 public Object [] getElements(Object inputElement) { 32 BundleDescription desc = null; 34 if (inputElement instanceof IPluginModelBase) { 35 desc = ((IPluginModelBase) inputElement) 36 .getBundleDescription(); 37 } else if (inputElement instanceof BundleDescription) { 38 desc = (BundleDescription)inputElement; 39 } 40 if (desc != null) { 41 Set callers = new HashSet (); 42 Set candidates = new HashSet (); 43 candidates.addAll(findReferences(desc)); 44 while (!candidates.isEmpty()) { 45 Set newCandidates = new HashSet (); 46 for (Iterator it = candidates.iterator(); it.hasNext();) { 47 Object o = it.next(); 48 it.remove(); 49 BundleDescription caller = (BundleDescription) o; 50 if (!callers.contains(caller)) { 51 callers.add(caller); 52 newCandidates.addAll(findReferences(caller)); 53 } 54 } 55 candidates = newCandidates; 56 57 } 58 59 return callers.toArray(); 60 } 61 return new Object [0]; 62 } 63 } 64 | Popular Tags |