KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > debug > ui > StorageEditorInput


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.jdt.internal.debug.ui;
12
13  
14 import org.eclipse.core.resources.IStorage;
15 import org.eclipse.core.runtime.PlatformObject;
16 import org.eclipse.jdt.ui.ISharedImages;
17 import org.eclipse.jdt.ui.JavaUI;
18 import org.eclipse.jface.resource.ImageDescriptor;
19 import org.eclipse.ui.IPersistableElement;
20 import org.eclipse.ui.IStorageEditorInput;
21
22 public abstract class StorageEditorInput extends PlatformObject implements IStorageEditorInput {
23
24     /**
25      * Storage associated with this editor input
26      */

27     private IStorage fStorage;
28     
29     /**
30      * Constructs an editor input on the given storage
31      */

32     public StorageEditorInput(IStorage storage) {
33         fStorage = storage;
34     }
35     
36     /**
37      * @see IStorageEditorInput#getStorage()
38      */

39     public IStorage getStorage() {
40         return fStorage;
41     }
42
43     /**
44      * @see IEditorInput#getImageDescriptor()
45      */

46     public ImageDescriptor getImageDescriptor() {
47         return JavaUI.getSharedImages().getImageDescriptor(ISharedImages.IMG_OBJS_CUNIT);
48     }
49
50     /**
51      * @see IEditorInput#getName()
52      */

53     public String JavaDoc getName() {
54         return getStorage().getName();
55     }
56
57     /**
58      * @see IEditorInput#getPersistable()
59      */

60     public IPersistableElement getPersistable() {
61         return null;
62     }
63
64     /**
65      * @see IEditorInput#getToolTipText()
66      */

67     public String JavaDoc getToolTipText() {
68         return getStorage().getFullPath().toOSString();
69     }
70     
71     /**
72      * @see java.lang.Object#equals(java.lang.Object)
73      */

74     public boolean equals(Object JavaDoc object) {
75         return object instanceof StorageEditorInput &&
76          getStorage().equals(((StorageEditorInput)object).getStorage());
77     }
78     
79     /**
80      * @see java.lang.Object#hashCode()
81      */

82     public int hashCode() {
83         return getStorage().hashCode();
84     }
85
86 }
87
Popular Tags