KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > wizards > datatransfer > PopulateElementOperation


1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.ui.wizards.datatransfer;
12
13 import java.util.*;
14
15 import org.eclipse.core.runtime.IProgressMonitor;
16 import org.eclipse.jface.operation.ModalContext;
17
18 /**
19  * The PopulateElementOperation has a MinimizedFileSystemElement as an object as this is
20  * just filled in.
21  */

22 class PopulateElementOperation extends PopulateRootOperation {
23 /**
24  * Create a new <code>PopulateElementsOperation</code>.
25  * @param rootObject the object to be populated
26  * @param structureProvider the object that defines how we are to populate it.
27  */

28 public PopulateElementOperation(
29     MinimizedFileSystemElement rootObject,
30     IImportStructureProvider structureProvider) {
31     super(rootObject, structureProvider);
32 }
33 /**
34  * Populates the children of element down to level depth
35  */

36 private void populateElement(
37     MinimizedFileSystemElement element,
38     IProgressMonitor monitor)
39     throws InterruptedException JavaDoc {
40
41     Object JavaDoc fileSystemObject = element.getFileSystemObject();
42     ModalContext.checkCanceled(monitor);
43
44     
45     List children = provider.getChildren(fileSystemObject);
46     if (children == null)
47         children = new ArrayList(1);
48     Iterator childrenEnum = children.iterator();
49     while (childrenEnum.hasNext()) {
50         //Create one level below
51
createElement(element, childrenEnum.next(), 1);
52     }
53     element.setPopulated();
54 }
55 /**
56  * Runs the operation. The result of this operation is always the elemen provided.
57  */

58 public void run(IProgressMonitor monitor) throws InterruptedException JavaDoc {
59     try {
60         this.monitor = monitor;
61         monitor.beginTask(DataTransferMessages.getString("DataTransfer.scanningChildren"),IProgressMonitor.UNKNOWN); //$NON-NLS-1$
62
MinimizedFileSystemElement element = (MinimizedFileSystemElement) root;
63         populateElement(element,monitor);
64         
65     } finally {
66         monitor.done();
67     }
68 }
69 }
70
Popular Tags