01: /*******************************************************************************
02: * Copyright (c) 2006, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.quickaccess;
11:
12: import java.util.HashMap;
13: import java.util.Map;
14:
15: import org.eclipse.jface.resource.ImageDescriptor;
16: import org.eclipse.ui.PlatformUI;
17: import org.eclipse.ui.internal.IWorkbenchGraphicConstants;
18: import org.eclipse.ui.internal.WorkbenchImages;
19: import org.eclipse.ui.views.IViewDescriptor;
20:
21: /**
22: * @since 3.3
23: *
24: */
25: public class ViewProvider extends QuickAccessProvider {
26:
27: private QuickAccessElement[] cachedElements;
28: private Map idToElement = new HashMap();
29:
30: public String getId() {
31: return "org.eclipse.ui.views"; //$NON-NLS-1$
32: }
33:
34: public QuickAccessElement getElementForId(String id) {
35: getElements();
36: return (ViewElement) idToElement.get(id);
37: }
38:
39: public QuickAccessElement[] getElements() {
40: if (cachedElements == null) {
41: IViewDescriptor[] views = PlatformUI.getWorkbench()
42: .getViewRegistry().getViews();
43: cachedElements = new QuickAccessElement[views.length];
44: for (int i = 0; i < views.length; i++) {
45: ViewElement viewElement = new ViewElement(views[i],
46: this );
47: cachedElements[i] = viewElement;
48: idToElement.put(viewElement.getId(), viewElement);
49: }
50: }
51: return cachedElements;
52: }
53:
54: public ImageDescriptor getImageDescriptor() {
55: return WorkbenchImages
56: .getImageDescriptor(IWorkbenchGraphicConstants.IMG_VIEW_DEFAULTVIEW_MISC);
57: }
58:
59: public String getName() {
60: return QuickAccessMessages.QuickAccess_Views;
61: }
62: }
|