1 11 package org.eclipse.ui.ide; 12 13 import java.net.URI ; 14 import java.net.URISyntaxException ; 15 16 import org.eclipse.core.filesystem.EFS; 17 18 import org.eclipse.core.runtime.CoreException; 19 import org.eclipse.core.runtime.IAdaptable; 20 21 import org.eclipse.ui.IElementFactory; 22 import org.eclipse.ui.IMemento; 23 24 25 35 public class FileStoreEditorInputFactory implements IElementFactory { 36 37 43 static final String ID = "org.eclipse.ui.ide.FileStoreEditorInputFactory"; 45 51 static void saveState(IMemento memento, FileStoreEditorInput input) { 52 URI uri = input.getURI(); 53 memento.putString(TAG_URI, uri.toString()); 54 } 55 56 59 private static final String TAG_URI = "uri"; 61 64 public IAdaptable createElement(IMemento memento) { 65 String uriString = memento.getString(TAG_URI); 67 if (uriString == null) 68 return null; 69 70 URI uri; 71 try { 72 uri = new URI (uriString); 73 } catch (URISyntaxException e) { 74 return null; 75 } 76 77 try { 78 return new FileStoreEditorInput(EFS.getStore(uri)); 79 } catch (CoreException e) { 80 return null; 81 } 82 } 83 } 84 | Popular Tags |