KickJava   Java API By Example, From Geeks To Geeks.

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


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.pde.internal.ui.editor;
12
13 import java.io.File JavaDoc;
14
15 import org.eclipse.core.resources.IStorage;
16 import org.eclipse.jface.resource.ImageDescriptor;
17 import org.eclipse.pde.internal.ui.PDEPlugin;
18 import org.eclipse.ui.IMemento;
19 import org.eclipse.ui.IPersistableElement;
20 import org.eclipse.ui.IStorageEditorInput;
21
22 public class SystemFileEditorInput implements IStorageEditorInput, IPersistableElement {
23     private SystemFileStorage storage;
24     private static final String JavaDoc FACTORY_ID = PDEPlugin.getPluginId()+".systemFileEditorInputFactory"; //$NON-NLS-1$
25

26     public SystemFileEditorInput(File JavaDoc file) {
27         storage = new SystemFileStorage(file);
28     }
29     public boolean exists() {
30         return storage.getFile().exists();
31     }
32     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
33         if (adapter.equals(File JavaDoc.class))
34             return storage.getFile();
35         return null;
36     }
37     public ImageDescriptor getImageDescriptor() {
38         return null;
39     }
40     public String JavaDoc getName() {
41         return storage.getFile().getName();
42     }
43     public IPersistableElement getPersistable() {
44         return this;
45     }
46     public void saveState(IMemento memento) {
47         memento.putString("path", storage.getFile().getAbsolutePath()); //$NON-NLS-1$
48
}
49     public String JavaDoc getFactoryId() {
50         return FACTORY_ID;
51     }
52     public IStorage getStorage() {
53         return storage;
54     }
55     public String JavaDoc getToolTipText() {
56         return storage.getFile().getAbsolutePath();
57     }
58     public boolean equals(Object JavaDoc object) {
59         return object instanceof SystemFileEditorInput &&
60          getStorage().equals(((SystemFileEditorInput)object).getStorage());
61     }
62     
63     public int hashCode() {
64         return getStorage().hashCode();
65     }
66 }
67
Popular Tags