1 11 package org.eclipse.pde.internal.ui.editor; 12 13 import java.io.File ; 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 FACTORY_ID = PDEPlugin.getPluginId()+".systemFileEditorInputFactory"; 26 public SystemFileEditorInput(File file) { 27 storage = new SystemFileStorage(file); 28 } 29 public boolean exists() { 30 return storage.getFile().exists(); 31 } 32 public Object getAdapter(Class adapter) { 33 if (adapter.equals(File .class)) 34 return storage.getFile(); 35 return null; 36 } 37 public ImageDescriptor getImageDescriptor() { 38 return null; 39 } 40 public String 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()); } 49 public String getFactoryId() { 50 return FACTORY_ID; 51 } 52 public IStorage getStorage() { 53 return storage; 54 } 55 public String getToolTipText() { 56 return storage.getFile().getAbsolutePath(); 57 } 58 public boolean equals(Object 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 |