01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 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.IFile;
13: import org.eclipse.core.resources.IResource;
14: import org.eclipse.core.runtime.content.IContentType;
15: import org.eclipse.jface.resource.ImageDescriptor;
16: import org.eclipse.ui.ISharedImages;
17: import org.eclipse.ui.PlatformUI;
18: import org.eclipse.ui.ide.IDE;
19:
20: /**
21: * An IWorkbenchAdapter that represents IFiles.
22: */
23: public class WorkbenchFile extends WorkbenchResource {
24:
25: /**
26: * Answer the appropriate base image to use for the passed resource, optionally
27: * considering the passed open status as well iff appropriate for the type of
28: * passed resource
29: */
30: protected ImageDescriptor getBaseImage(IResource resource) {
31: IContentType contentType = null;
32: // do we need to worry about checking here?
33: if (resource instanceof IFile) {
34: contentType = IDE.guessContentType((IFile) resource);
35: }
36: // @issue move IDE specific images
37: ImageDescriptor image = PlatformUI.getWorkbench()
38: .getEditorRegistry().getImageDescriptor(
39: resource.getName(), contentType);
40: if (image == null) {
41: image = PlatformUI.getWorkbench().getSharedImages()
42: .getImageDescriptor(ISharedImages.IMG_OBJ_FILE);
43: }
44: return image;
45: }
46: }
|