KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > view > JarEntryEditorInput


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.internal.ui.view;
12
13
14 import org.eclipse.core.resources.IStorage;
15 import org.eclipse.jface.resource.ImageDescriptor;
16 import org.eclipse.ui.*;
17
18
19 /**
20  * An EditorInput for a JarEntryFile.
21  */

22 public class JarEntryEditorInput implements IStorageEditorInput {
23         
24     private IStorage fJarEntryFile;
25     
26     public JarEntryEditorInput(IStorage jarEntryFile) {
27         fJarEntryFile= jarEntryFile;
28     }
29     
30     /*
31      */

32     public boolean equals(Object JavaDoc obj) {
33         if (this == obj)
34             return true;
35         if (!(obj instanceof JarEntryEditorInput))
36             return false;
37         JarEntryEditorInput other= (JarEntryEditorInput) obj;
38         return fJarEntryFile.equals(other.fJarEntryFile);
39     }
40         
41     /*
42      * @see IEditorInput#getPersistable()
43      */

44     public IPersistableElement getPersistable() {
45         return null;
46     }
47     
48     /*
49      * @see IEditorInput#getName()
50      */

51     public String JavaDoc getName() {
52         return fJarEntryFile.getName();
53     }
54     
55     /*
56      * @see IEditorInput#getFullPath()
57      */

58     public String JavaDoc getFullPath() {
59         return fJarEntryFile.getFullPath().toString();
60     }
61     
62     /*
63      * @see IEditorInput#getContentType()
64      */

65     public String JavaDoc getContentType() {
66         return fJarEntryFile.getFullPath().getFileExtension();
67     }
68     
69     /*
70      * @see IEditorInput#getToolTipText()
71      */

72     public String JavaDoc getToolTipText() {
73         return fJarEntryFile.getFullPath().toString();
74     }
75     
76     /*
77      * @see IEditorInput#getImageDescriptor()
78      */

79     public ImageDescriptor getImageDescriptor() {
80         IEditorRegistry registry= PlatformUI.getWorkbench().getEditorRegistry();
81         return registry.getImageDescriptor(fJarEntryFile.getFullPath().getFileExtension());
82     }
83     
84     /*
85      * @see IEditorInput#exists()
86      */

87     public boolean exists() {
88         // JAR entries can't be deleted
89
return true;
90     }
91     
92     /*
93      * @see IAdaptable#getAdapter(Class)
94      */

95     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
96         return null;
97     }
98         
99     /*
100      * see IStorageEditorInput#getStorage()
101      */

102      public IStorage getStorage() {
103         return fJarEntryFile;
104      }
105 }
106
107
108
Popular Tags