KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 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.pde.internal.ui.editor;
12
13
14 import java.io.File JavaDoc;
15
16 import org.eclipse.core.resources.IStorage;
17 import org.eclipse.jface.resource.ImageDescriptor;
18 import org.eclipse.ui.IEditorRegistry;
19 import org.eclipse.ui.IPersistableElement;
20 import org.eclipse.ui.IStorageEditorInput;
21 import org.eclipse.ui.PlatformUI;
22
23
24 /**
25  * An EditorInput for a JarEntryFile.
26  */

27 public class JarEntryEditorInput implements IStorageEditorInput {
28         
29     private IStorage fJarEntryFile;
30     
31     public JarEntryEditorInput(IStorage jarEntryFile) {
32         fJarEntryFile= jarEntryFile;
33     }
34     
35     /*
36      */

37     public boolean equals(Object JavaDoc obj) {
38         if (this == obj)
39             return true;
40         if (!(obj instanceof JarEntryEditorInput))
41             return false;
42         JarEntryEditorInput other= (JarEntryEditorInput) obj;
43         return fJarEntryFile.equals(other.fJarEntryFile);
44     }
45         
46     /*
47      * @see IEditorInput#getPersistable()
48      */

49     public IPersistableElement getPersistable() {
50         return null;
51     }
52     
53     /*
54      * @see IEditorInput#getName()
55      */

56     public String JavaDoc getName() {
57         return fJarEntryFile.getName();
58     }
59     
60     /*
61      * @see IEditorInput#getFullPath()
62      */

63     public String JavaDoc getFullPath() {
64         return fJarEntryFile.getFullPath().toString();
65     }
66     
67     /*
68      * @see IEditorInput#getContentType()
69      */

70     public String JavaDoc getContentType() {
71         return fJarEntryFile.getFullPath().getFileExtension();
72     }
73     
74     /*
75      * @see IEditorInput#getToolTipText()
76      */

77     public String JavaDoc getToolTipText() {
78         File JavaDoc file = (File JavaDoc) fJarEntryFile.getAdapter(File JavaDoc.class);
79         if (file != null)
80             return file.getAbsolutePath();
81         return fJarEntryFile.getFullPath().toString();
82     }
83     
84     /*
85      * @see IEditorInput#getImageDescriptor()
86      */

87     public ImageDescriptor getImageDescriptor() {
88         IEditorRegistry registry= PlatformUI.getWorkbench().getEditorRegistry();
89         return registry.getImageDescriptor(fJarEntryFile.getFullPath().getFileExtension());
90     }
91     
92     /*
93      * @see IEditorInput#exists()
94      */

95     public boolean exists() {
96         // JAR entries can't be deleted
97
return true;
98     }
99     
100     /*
101      * @see IAdaptable#getAdapter(Class)
102      */

103     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
104         if (adapter.equals(File JavaDoc.class))
105             return fJarEntryFile.getAdapter(File JavaDoc.class);
106         return null;
107     }
108         
109     /*
110      * see IStorageEditorInput#getStorage()
111      */

112      public IStorage getStorage() {
113         return fJarEntryFile;
114      }
115 }
116
117
118
Popular Tags