1 11 12 package org.eclipse.ui.internal; 13 14 import java.util.ArrayList ; 15 import java.util.Iterator ; 16 import java.util.List ; 17 18 import org.eclipse.jface.viewers.IStructuredSelection; 19 import org.eclipse.jface.viewers.StructuredSelection; 20 import org.eclipse.ui.internal.util.Util; 21 22 35 public class SelectionConversionService implements ISelectionConversionService { 36 37 48 public IStructuredSelection convertToResources( 49 IStructuredSelection originalSelection) { 50 Class resourceClass = LegacyResourceSupport.getResourceClass(); 52 if (resourceClass == null) { 53 return originalSelection; 54 } 55 56 List result = new ArrayList (); 57 Iterator elements = originalSelection.iterator(); 58 59 while (elements.hasNext()) { 60 Object currentElement = elements.next(); 61 Object resource = Util.getAdapter(currentElement, resourceClass); 62 if (resource != null) { 63 result.add(resource); 64 } 65 } 66 67 if (result.isEmpty()) { 69 return StructuredSelection.EMPTY; 70 } 71 return new StructuredSelection(result.toArray()); 72 } 73 74 } 75 | Popular Tags |