1 11 package org.eclipse.ui.wizards.datatransfer; 12 13 import java.io.InputStream ; 14 import java.util.ArrayList ; 15 import java.util.Arrays ; 16 import java.util.List ; 17 18 import org.eclipse.core.filesystem.EFS; 19 import org.eclipse.core.filesystem.IFileStore; 20 import org.eclipse.core.runtime.CoreException; 21 import org.eclipse.core.runtime.NullProgressMonitor; 22 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; 23 24 31 public class FileStoreStructureProvider implements IImportStructureProvider { 32 33 36 public final static FileStoreStructureProvider INSTANCE = new FileStoreStructureProvider(); 37 38 43 public List getChildren(Object element) { 44 try { 45 return Arrays.asList(((IFileStore) element).childStores(EFS.NONE, 46 new NullProgressMonitor())); 47 } catch (CoreException exception) { 48 logException(exception); 49 return new ArrayList (); 50 } 51 } 52 53 58 private void logException(CoreException exception) { 59 IDEWorkbenchPlugin.log(exception.getLocalizedMessage(), exception); 60 61 } 62 63 68 public InputStream getContents(Object element) { 69 try { 70 return ((IFileStore) element).openInputStream(EFS.NONE, 71 new NullProgressMonitor()); 72 } catch (CoreException exception) { 73 logException(exception); 74 return null; 75 } 76 } 77 78 83 public String getFullPath(Object element) { 84 return ((IFileStore) element).toURI().getSchemeSpecificPart(); 85 } 86 87 92 public String getLabel(Object element) { 93 return ((IFileStore) element).getName(); 94 } 95 96 101 public boolean isFolder(Object element) { 102 return ((IFileStore) element).fetchInfo().isDirectory(); 103 } 104 105 } 106 | Popular Tags |