1 /******************************************************************************* 2 * Copyright (c) 2000, 2005 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11 package org.eclipse.ui.internal.ide.model; 12 13 import org.eclipse.core.resources.IWorkspaceRoot; 14 import org.eclipse.jface.resource.ImageDescriptor; 15 import org.eclipse.ui.ISharedImages; 16 import org.eclipse.ui.PlatformUI; 17 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; 18 import org.eclipse.ui.model.WorkbenchAdapter; 19 20 /** 21 * An IWorkbenchAdapter implementation for IWorkspaceRoot objects. 22 */ 23 public class WorkbenchRootResource extends WorkbenchAdapter { 24 /** 25 * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(Object) 26 * Returns the children of the root resource. 27 */ 28 public Object[] getChildren(Object o) { 29 IWorkspaceRoot root = (IWorkspaceRoot) o; 30 return root.getProjects(); 31 } 32 33 /** 34 * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(Object) 35 */ 36 public ImageDescriptor getImageDescriptor(Object object) { 37 return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( 38 ISharedImages.IMG_OBJ_ELEMENT); 39 } 40 41 /** 42 * Returns the name of this element. This will typically 43 * be used to assign a label to this object when displayed 44 * in the UI. 45 */ 46 public String getLabel(Object o) { 47 //root resource has no name 48 return IDEWorkbenchMessages.Workspace; 49 } 50 } 51