01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor;
11:
12: import java.io.File;
13:
14: import org.eclipse.core.resources.IStorage;
15: import org.eclipse.jface.resource.ImageDescriptor;
16: import org.eclipse.pde.internal.ui.PDEPlugin;
17: import org.eclipse.ui.IMemento;
18: import org.eclipse.ui.IPersistableElement;
19: import org.eclipse.ui.IStorageEditorInput;
20:
21: public class SystemFileEditorInput implements IStorageEditorInput,
22: IPersistableElement {
23: private SystemFileStorage storage;
24: private static final String FACTORY_ID = PDEPlugin.getPluginId()
25: + ".systemFileEditorInputFactory"; //$NON-NLS-1$
26:
27: public SystemFileEditorInput(File file) {
28: storage = new SystemFileStorage(file);
29: }
30:
31: public boolean exists() {
32: return storage.getFile().exists();
33: }
34:
35: public Object getAdapter(Class adapter) {
36: if (adapter.equals(File.class))
37: return storage.getFile();
38: return null;
39: }
40:
41: public ImageDescriptor getImageDescriptor() {
42: return null;
43: }
44:
45: public String getName() {
46: return storage.getFile().getName();
47: }
48:
49: public IPersistableElement getPersistable() {
50: return this ;
51: }
52:
53: public void saveState(IMemento memento) {
54: memento.putString("path", storage.getFile().getAbsolutePath()); //$NON-NLS-1$
55: }
56:
57: public String getFactoryId() {
58: return FACTORY_ID;
59: }
60:
61: public IStorage getStorage() {
62: return storage;
63: }
64:
65: public String getToolTipText() {
66: return storage.getFile().getAbsolutePath();
67: }
68:
69: public boolean equals(Object object) {
70: return object instanceof SystemFileEditorInput
71: && getStorage().equals(
72: ((SystemFileEditorInput) object).getStorage());
73: }
74:
75: public int hashCode() {
76: return getStorage().hashCode();
77: }
78: }
|