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.PlatformUI; 19 import org.eclipse.ui.internal.IWorkbenchGraphicConstants; 20 import org.eclipse.ui.internal.WorkbenchImages; 21 import org.eclipse.ui.views.IViewDescriptor; 22 23 27 public class ViewProvider extends QuickAccessProvider { 28 29 private QuickAccessElement[] cachedElements; 30 private Map idToElement = new HashMap (); 31 32 public String getId() { 33 return "org.eclipse.ui.views"; } 35 36 public QuickAccessElement getElementForId(String id) { 37 getElements(); 38 return (ViewElement) idToElement.get(id); 39 } 40 41 public QuickAccessElement[] getElements() { 42 if (cachedElements == null) { 43 IViewDescriptor[] views = PlatformUI.getWorkbench() 44 .getViewRegistry().getViews(); 45 cachedElements = new QuickAccessElement[views.length]; 46 for (int i = 0; i < views.length; i++) { 47 ViewElement viewElement = new ViewElement(views[i], this); 48 cachedElements[i] = viewElement; 49 idToElement.put(viewElement.getId(), viewElement); 50 } 51 } 52 return cachedElements; 53 } 54 55 public ImageDescriptor getImageDescriptor() { 56 return WorkbenchImages 57 .getImageDescriptor(IWorkbenchGraphicConstants.IMG_VIEW_DEFAULTVIEW_MISC); 58 } 59 60 public String getName() { 61 return QuickAccessMessages.QuickAccess_Views; 62 } 63 } 64 | Popular Tags |