Search in sources :

Example 16 with ImportOperation

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

the class WorkflowImportOperation method createWorkflowFromFile.

/**
 * @param workflow the workflow dir to import
 * @param target the destination path to import the workflow to
 * @param monitor a progress monitor to report progress to
 * @return the created import operation
 */
protected ImportOperation createWorkflowFromFile(final WorkflowImportElementFromFile workflow, final IPath target, final IProgressMonitor monitor) {
    monitor.beginTask(workflow.getName(), 1);
    ImportOperation operation = null;
    if (workflow.isWorkflow()) {
        List<File> filesToImport = new ArrayList<File>();
        getFilesForWorkflow(filesToImport, workflow.getFile());
        operation = new ImportOperation(target, workflow.getFile(), FileSystemStructureProvider.INSTANCE, new IOverwriteQuery() {

            @Override
            public String queryOverwrite(final String pathString) {
                return IOverwriteQuery.YES;
            }
        });
    } else {
        // store path to create a meta info file
        m_missingMetaInfoLocations.add(target);
    // no workflow -> no import
    }
    monitor.done();
    return operation;
}
Also used : IOverwriteQuery(org.eclipse.ui.dialogs.IOverwriteQuery) ImportOperation(org.eclipse.ui.wizards.datatransfer.ImportOperation) ArrayList(java.util.ArrayList) MetaInfoFile(org.knime.workbench.ui.metainfo.model.MetaInfoFile) File(java.io.File)

Example 17 with ImportOperation

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

the class WorkflowImportOperation method createWorkflowFromArchive.

/**
 * @param workflow workflow im port element
 * @param target the destination path of this workflow
 * @param monitor a submonitor to report progress to
 * @return the prepared import operation
 */
protected ImportOperation createWorkflowFromArchive(final WorkflowImportElementFromArchive workflow, final IPath target, final IProgressMonitor monitor) {
    // import only workflow -> the path to them will be created anyway
    // by ContainerGenerator in ImportOperation
    monitor.beginTask(workflow.getName(), 1);
    ImportOperation op = null;
    if (workflow.isWorkflow()) {
        op = new ImportOperation(target, workflow.getEntry(), workflow.getProvider(), new IOverwriteQuery() {

            @Override
            public String queryOverwrite(final String pathString) {
                return IOverwriteQuery.YES;
            }
        });
    } else {
        // store path to create a meta info file
        m_missingMetaInfoLocations.add(target);
    // no workflow -> no import
    }
    monitor.done();
    return op;
}
Also used : IOverwriteQuery(org.eclipse.ui.dialogs.IOverwriteQuery) ImportOperation(org.eclipse.ui.wizards.datatransfer.ImportOperation)

Example 18 with ImportOperation

use of org.eclipse.ui.wizards.datatransfer.ImportOperation in project yamcs-studio by yamcs.

the class Application method createProject.

protected IProject createProject(URL location, String sourceFolder) throws CoreException {
    var project = ResourcesPlugin.getWorkspace().getRoot().getProject(sourceFolder);
    try {
        project.create(new NullProgressMonitor());
        project.open(new NullProgressMonitor());
    } catch (CoreException e) {
        MessageDialog.openError(null, "Error", String.format("Error creating project %s: %s", project.getName(), e.getMessage()));
        return null;
    }
    try {
        var templateRoot = new File(location.getPath(), sourceFolder);
        var structureProvider = new RelativeFileSystemStructureProvider(templateRoot);
        var operation = new ImportOperation(project.getFullPath(), templateRoot, structureProvider, pathString -> IOverwriteQuery.ALL, structureProvider.getChildren(templateRoot));
        operation.setContext(Display.getDefault().getActiveShell());
        operation.run(null);
    } catch (Exception e) {
        throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getLocalizedMessage()));
    }
    return project;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) CoreException(org.eclipse.core.runtime.CoreException) ImportOperation(org.eclipse.ui.wizards.datatransfer.ImportOperation) File(java.io.File) IOException(java.io.IOException) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

ImportOperation (org.eclipse.ui.wizards.datatransfer.ImportOperation)18 File (java.io.File)9 IOverwriteQuery (org.eclipse.ui.dialogs.IOverwriteQuery)8 IPath (org.eclipse.core.runtime.IPath)7 IProject (org.eclipse.core.resources.IProject)6 CoreException (org.eclipse.core.runtime.CoreException)6 Path (org.eclipse.core.runtime.Path)6 IOException (java.io.IOException)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 IProjectDescription (org.eclipse.core.resources.IProjectDescription)5 ZipFile (java.util.zip.ZipFile)4 IWorkspace (org.eclipse.core.resources.IWorkspace)4 IStatus (org.eclipse.core.runtime.IStatus)4 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)4 ArrayList (java.util.ArrayList)3 SubProgressMonitor (org.eclipse.core.runtime.SubProgressMonitor)3 ZipFileStructureProvider (org.eclipse.ui.wizards.datatransfer.ZipFileStructureProvider)3 URI (java.net.URI)2 URL (java.net.URL)2 IIndexManager (org.eclipse.cdt.core.index.IIndexManager)2