1 11 package org.eclipse.pde.internal.ui.util; 12 import java.util.HashSet ; 13 14 import org.eclipse.core.resources.IProject; 15 import org.eclipse.core.resources.IResource; 16 import org.eclipse.core.runtime.IAdaptable; 17 import org.eclipse.osgi.service.resolver.BundleDescription; 18 import org.eclipse.pde.core.plugin.IPluginModelBase; 19 import org.eclipse.pde.core.plugin.PluginRegistry; 20 import org.eclipse.ui.IWorkingSet; 21 import org.eclipse.ui.IWorkingSetElementAdapter; 22 23 public class PluginAdapter implements IWorkingSetElementAdapter { 24 25 28 public IAdaptable[] adaptElements(IWorkingSet ws, IAdaptable[] elements) { 29 HashSet set = new HashSet (); 30 for (int i = 0; i < elements.length; i++) { 31 IResource res = (IResource)elements[i].getAdapter(IResource.class); 32 if (res == null) 33 continue; 34 IProject proj = res.getProject(); 35 IPluginModelBase base = PluginRegistry.findModel(proj); 36 if (base == null) 38 continue; 39 BundleDescription desc = base.getBundleDescription(); 40 String id = (desc != null) ? desc.getSymbolicName() : base.getPluginBase().getId(); 41 set.add(new PersistablePluginObject(id)); 42 } 43 return (IAdaptable[]) set.toArray(new IAdaptable[set.size()]); 44 } 45 46 49 public void dispose() { 50 } 51 52 } 53 | Popular Tags |