1 11 12 package org.eclipse.ui.internal.quickaccess; 13 14 import java.util.HashMap ; 15 import java.util.Map ; 16 17 import org.eclipse.jface.resource.ImageDescriptor; 18 import org.eclipse.ui.IEditorReference; 19 import org.eclipse.ui.IWorkbenchPage; 20 import org.eclipse.ui.PlatformUI; 21 import org.eclipse.ui.internal.IWorkbenchGraphicConstants; 22 import org.eclipse.ui.internal.WorkbenchImages; 23 24 28 public class EditorProvider extends QuickAccessProvider { 29 30 private Map idToElement; 31 32 public QuickAccessElement getElementForId(String id) { 33 getElements(); 34 return (EditorElement) idToElement.get(id); 35 } 36 37 public QuickAccessElement[] getElements() { 38 if (idToElement == null) { 39 idToElement = new HashMap (); 40 IWorkbenchPage activePage = PlatformUI.getWorkbench() 41 .getActiveWorkbenchWindow().getActivePage(); 42 IEditorReference[] editors = activePage.getEditorReferences(); 43 for (int i = 0; i < editors.length; i++) { 44 EditorElement editorElement = new EditorElement(editors[i], 45 this); 46 idToElement.put(editorElement.getId(), editorElement); 47 } 48 } 49 return (QuickAccessElement[]) idToElement.values().toArray( 50 new QuickAccessElement[idToElement.values().size()]); 51 } 52 53 public String getId() { 54 return "org.eclipse.ui.editors"; } 56 57 public ImageDescriptor getImageDescriptor() { 58 return WorkbenchImages 59 .getImageDescriptor(IWorkbenchGraphicConstants.IMG_OBJ_NODE); 60 } 61 62 public String getName() { 63 return QuickAccessMessages.QuickAccess_Editors; 64 } 65 } 66 | Popular Tags |