| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2000, 2006 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.IContainer; |
| 14 | import org.eclipse.core.resources.IResource; |
| 15 | import org.eclipse.core.runtime.CoreException; |
| 16 | import org.eclipse.jface.resource.ImageDescriptor; |
| 17 | import org.eclipse.ui.ISharedImages; |
| 18 | import org.eclipse.ui.PlatformUI; |
| 19 | |
| 20 | /** |
| 21 | * An IWorkbenchAdapter that represents IFolders. |
| 22 | */ |
| 23 | public class WorkbenchFolder extends WorkbenchResource { |
| 24 | /** |
| 25 | * Answer the appropriate base image to use for the passed resource, optionally |
| 26 | * considering the passed open status as well iff appropriate for the type of |
| 27 | * passed resource |
| 28 | */ |
| 29 | protected ImageDescriptor getBaseImage(IResource resource) { |
| 30 | return PlatformUI.getWorkbench().getSharedImages().getImageDescriptor( |
| 31 | ISharedImages.IMG_OBJ_FOLDER); |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Returns the children of this container. |
| 36 | */ |
| 37 | public Object[] getChildren(Object o) { |
| 38 | try { |
| 39 | return ((IContainer) o).members(); |
| 40 | } catch (CoreException e) { |
| 41 | return NO_CHILDREN; |
| 42 | } |
| 43 | } |
| 44 | } |