1 11 package org.eclipse.ui.internal.wizards.datatransfer; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 import java.util.List ; 16 17 import org.eclipse.ui.dialogs.FileSystemElement; 18 import org.eclipse.ui.model.AdaptableList; 19 import org.eclipse.ui.wizards.datatransfer.IImportStructureProvider; 20 21 25 public class MinimizedFileSystemElement extends FileSystemElement { 26 private boolean populated = false; 27 28 34 public MinimizedFileSystemElement(String name, FileSystemElement parent, 35 boolean isDirectory) { 36 super(name, parent, isDirectory); 37 } 38 39 44 public AdaptableList getFiles(IImportStructureProvider provider) { 45 if (!populated) { 46 populate(provider); 47 } 48 return super.getFiles(); 49 } 50 51 56 public AdaptableList getFolders(IImportStructureProvider provider) { 57 if (!populated) { 58 populate(provider); 59 } 60 return super.getFolders(); 61 } 62 63 66 boolean isPopulated() { 67 return this.populated; 68 } 69 70 74 private void populate(IImportStructureProvider provider) { 75 76 Object fileSystemObject = getFileSystemObject(); 77 78 List children = provider.getChildren(fileSystemObject); 79 if (children == null) { 80 children = new ArrayList (1); 81 } 82 Iterator childrenEnum = children.iterator(); 83 while (childrenEnum.hasNext()) { 84 Object child = childrenEnum.next(); 85 86 String elementLabel = provider.getLabel(child); 87 MinimizedFileSystemElement result = new MinimizedFileSystemElement( 89 elementLabel, this, provider.isFolder(child)); 90 result.setFileSystemObject(child); 91 } 92 setPopulated(); 93 } 94 95 98 public void setPopulated() { 99 this.populated = true; 100 } 101 } 102 | Popular Tags |