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;
}
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;
}
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;
}
Aggregations