01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 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.ide.model;
11:
12: import org.eclipse.core.resources.IWorkspaceRoot;
13: import org.eclipse.jface.resource.ImageDescriptor;
14: import org.eclipse.ui.ISharedImages;
15: import org.eclipse.ui.PlatformUI;
16: import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
17: import org.eclipse.ui.model.WorkbenchAdapter;
18:
19: /**
20: * An IWorkbenchAdapter implementation for IWorkspaceRoot objects.
21: */
22: public class WorkbenchRootResource extends WorkbenchAdapter {
23: /**
24: * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(Object)
25: * Returns the children of the root resource.
26: */
27: public Object[] getChildren(Object o) {
28: IWorkspaceRoot root = (IWorkspaceRoot) o;
29: return root.getProjects();
30: }
31:
32: /**
33: * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(Object)
34: */
35: public ImageDescriptor getImageDescriptor(Object object) {
36: return PlatformUI.getWorkbench().getSharedImages()
37: .getImageDescriptor(ISharedImages.IMG_OBJ_ELEMENT);
38: }
39:
40: /**
41: * Returns the name of this element. This will typically
42: * be used to assign a label to this object when displayed
43: * in the UI.
44: */
45: public String getLabel(Object o) {
46: //root resource has no name
47: return IDEWorkbenchMessages.Workspace;
48: }
49: }
|