1 11 package org.eclipse.ui.wizards.datatransfer; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 import org.eclipse.jface.operation.ModalContext; 18 import org.eclipse.ui.dialogs.FileSystemElement; 19 import org.eclipse.ui.internal.wizards.datatransfer.MinimizedFileSystemElement; 20 21 25 public class PopulateRootOperation extends SelectFilesOperation { 26 31 public PopulateRootOperation(Object rootObject, 32 IImportStructureProvider structureProvider) { 33 super(rootObject, structureProvider); 34 } 35 36 44 protected FileSystemElement createElement(FileSystemElement parent, 45 Object fileSystemObject) throws InterruptedException { 46 47 return createElement(parent, fileSystemObject, 2); 49 50 } 51 52 61 protected FileSystemElement createElement(FileSystemElement parent, 62 Object fileSystemObject, int depth) throws InterruptedException { 63 ModalContext.checkCanceled(monitor); 64 boolean isContainer = provider.isFolder(fileSystemObject); 65 String elementLabel = parent == null ? provider 66 .getFullPath(fileSystemObject) : provider 67 .getLabel(fileSystemObject); 68 69 MinimizedFileSystemElement result = new MinimizedFileSystemElement( 70 elementLabel, parent, isContainer); 71 result.setFileSystemObject(fileSystemObject); 72 73 if (isContainer) { 74 if (depth > 0) { 75 List children = provider.getChildren(fileSystemObject); 76 if (children == null) { 77 children = new ArrayList (1); 78 } 79 Iterator childrenEnum = children.iterator(); 80 while (childrenEnum.hasNext()) { 81 createElement(result, childrenEnum.next(), depth - 1); 82 } 83 result.setPopulated(); 84 } 85 86 } 87 88 return result; 89 } 90 } 91 | Popular Tags |