Search in sources :

Example 6 with ILeveledImportStructureProvider

use of org.eclipse.ui.internal.wizards.datatransfer.ILeveledImportStructureProvider in project knime-core by knime.

the class WorkflowImportSelectionPage method collectWorkflowsFromProvider.

/**
 * @param parent the archive element to collect the workflows from
 * @param monitor progress monitor
 */
public void collectWorkflowsFromProvider(final WorkflowImportElementFromArchive parent, final IProgressMonitor monitor) {
    if (monitor.isCanceled()) {
        m_importRoot = null;
        Display.getDefault().syncExec(new Runnable() {

            @Override
            public void run() {
                m_fromZipTextUI.setText("");
            }
        });
        return;
    }
    if (parent == null || parent.isWorkflow()) {
        // abort recursion
        return;
    }
    // public in order to make it possible to import from a given zip entry
    ILeveledImportStructureProvider provider = parent.getProvider();
    Object entry = parent.getEntry();
    List children = provider.getChildren(entry);
    if (children == null) {
        return;
    }
    monitor.subTask(provider.getLabel(entry));
    Iterator childrenEnum = children.iterator();
    while (childrenEnum.hasNext()) {
        Object child = childrenEnum.next();
        if (provider.isFolder(child)) {
            WorkflowImportElementFromArchive childElement = new WorkflowImportElementFromArchive(provider, child, parent.getLevel() + 1);
            collectWorkflowsFromProvider(childElement, monitor);
            // either it's a workflow
            if (childElement.isWorkflow() || // or it is a workflow group
            childElement.isWorkflowGroup()) {
                // because only workflows and workflow groups  are added
                parent.addChild(childElement);
            }
        }
    }
}
Also used : Iterator(java.util.Iterator) List(java.util.List) ArrayList(java.util.ArrayList) ILeveledImportStructureProvider(org.eclipse.ui.internal.wizards.datatransfer.ILeveledImportStructureProvider)

Aggregations

ILeveledImportStructureProvider (org.eclipse.ui.internal.wizards.datatransfer.ILeveledImportStructureProvider)6 List (java.util.List)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IResource (org.eclipse.core.resources.IResource)2 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 ZipFile (java.util.zip.ZipFile)1 CoreException (org.eclipse.core.runtime.CoreException)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStatus (org.eclipse.core.runtime.IStatus)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 Status (org.eclipse.core.runtime.Status)1 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 TarFile (org.eclipse.ui.internal.wizards.datatransfer.TarFile)1 TarLeveledStructureProvider (org.eclipse.ui.internal.wizards.datatransfer.TarLeveledStructureProvider)1 ZipLeveledStructureProvider (org.eclipse.ui.internal.wizards.datatransfer.ZipLeveledStructureProvider)1