1 11 package org.eclipse.pde.internal.ui.view; 12 13 import java.util.Arrays ; 14 import java.util.HashSet ; 15 import java.util.Hashtable ; 16 import java.util.Iterator ; 17 import java.util.Map ; 18 import java.util.Set ; 19 20 import org.eclipse.jface.viewers.IStructuredContentProvider; 21 import org.eclipse.pde.core.plugin.IPlugin; 22 import org.eclipse.pde.core.plugin.IPluginBase; 23 import org.eclipse.pde.core.plugin.IPluginImport; 24 import org.eclipse.pde.core.plugin.IPluginModelBase; 25 import org.eclipse.pde.internal.core.PDECore; 26 27 public class CalleesListContentProvider extends CalleesContentProvider 28 implements IStructuredContentProvider { 29 30 public CalleesListContentProvider(DependenciesView view) { 31 super(view); 32 } 33 34 37 public Object [] getElements(Object inputElement) { 38 if (inputElement instanceof IPluginModelBase) { 40 IPluginBase pluginBase = ((IPluginModelBase) inputElement) 41 .getPluginBase(); 42 Map elements = new Hashtable (); 43 Set candidates = new HashSet (); 44 candidates.addAll(Arrays.asList(findCallees(pluginBase))); 45 46 while (!candidates.isEmpty()) { 47 Set newCandidates = new HashSet (); 48 for (Iterator it = candidates.iterator(); it.hasNext();) { 49 Object candidate = it.next(); 50 String id; 51 if(candidate instanceof IPluginImport){ 52 id = ((IPluginImport)candidate).getId(); 53 }else { 54 id = ((IPluginBase)candidate).getId(); 55 } 56 IPlugin callee = PDECore.getDefault() 57 .findPlugin(id); 58 it.remove(); 59 if (!elements.containsKey(id)) { 60 elements.put(id, candidate); 61 if (callee != null) { 62 newCandidates.addAll(Arrays 63 .asList(findCallees(callee))); 64 } 65 } 66 } 67 candidates = newCandidates; 68 69 } 70 return elements.values().toArray(); 71 } 72 return new Object [0]; 73 } 74 } 75 | Popular Tags |