KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > ide > model > WorkbenchFile


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.IFile;
14 import org.eclipse.core.resources.IResource;
15 import org.eclipse.core.runtime.content.IContentType;
16 import org.eclipse.jface.resource.ImageDescriptor;
17 import org.eclipse.ui.ISharedImages;
18 import org.eclipse.ui.PlatformUI;
19 import org.eclipse.ui.ide.IDE;
20
21 /**
22  * An IWorkbenchAdapter that represents IFiles.
23  */

24 public class WorkbenchFile extends WorkbenchResource {
25
26     /**
27      * Answer the appropriate base image to use for the passed resource, optionally
28      * considering the passed open status as well iff appropriate for the type of
29      * passed resource
30      */

31     protected ImageDescriptor getBaseImage(IResource resource) {
32         IContentType contentType = null;
33         // do we need to worry about checking here?
34
if (resource instanceof IFile) {
35             contentType = IDE.guessContentType((IFile)resource);
36         }
37         // @issue move IDE specific images
38
ImageDescriptor image = PlatformUI.getWorkbench().getEditorRegistry()
39                 .getImageDescriptor(resource.getName(), contentType);
40         if (image == null) {
41             image = PlatformUI.getWorkbench().getSharedImages()
42                     .getImageDescriptor(ISharedImages.IMG_OBJ_FILE);
43         }
44         return image;
45     }
46 }
47
Popular Tags