use of org.eclipse.ui.dialogs.IOverwriteQuery in project knime-core by knime.
the class KnimeResourceUtil method importWorkflowIntoWorkspace.
/**
* Stores the flow in the archive in the local workspace.
*
* @param destination the name of the new workflow. Must denote a flow (if
* it exists it is overwritten).
* @param zippedWorkflow
* @throws IOException
* @throws ZipException
* @throws InterruptedException
* @throws InvocationTargetException
*/
private static void importWorkflowIntoWorkspace(final IPath destination, final File zippedWorkflow) throws ZipException, IOException, InvocationTargetException, InterruptedException {
ZipFile zFile = new ZipFile(zippedWorkflow);
ZipLeveledStructProvider importStructureProvider = new ZipLeveledStructProvider(zFile);
importStructureProvider.setStrip(1);
ZipEntry root = (ZipEntry) importStructureProvider.getRoot();
List<ZipEntry> rootChild = importStructureProvider.getChildren(root);
if (rootChild.size() == 1) {
// the zipped workflow normally contains only one dir
root = rootChild.get(0);
}
LOGGER.debug("Importing workflow. Destination:" + destination.toString());
try {
final ImportOperation iOper = new ImportOperation(destination, root, importStructureProvider, new IOverwriteQuery() {
@Override
public String queryOverwrite(final String pathString) {
return IOverwriteQuery.YES;
}
});
PlatformUI.getWorkbench().getProgressService().busyCursorWhile(new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
iOper.run(monitor);
}
});
} finally {
importStructureProvider.closeArchive();
}
}
use of org.eclipse.ui.dialogs.IOverwriteQuery in project n4js by eclipse.
the class ProjectTestsUtils method importProject.
private static IProject importProject(File probandsFolder, String projectName, boolean prepareDotProject) throws Exception {
File projectSourceFolder = new File(probandsFolder, projectName);
if (!projectSourceFolder.exists()) {
throw new IllegalArgumentException("proband not found in " + projectSourceFolder);
}
if (prepareDotProject) {
prepareDotProject(projectSourceFolder);
}
IProgressMonitor monitor = new NullProgressMonitor();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IProjectDescription newProjectDescription = workspace.newProjectDescription(projectName);
IProject project = workspace.getRoot().getProject(projectName);
project.create(newProjectDescription, monitor);
project.open(monitor);
if (!project.getLocation().toFile().exists()) {
throw new IllegalArgumentException("test project correctly created in " + project.getLocation());
}
IOverwriteQuery overwriteQuery = new IOverwriteQuery() {
@Override
public String queryOverwrite(String file) {
return ALL;
}
};
ImportOperation importOperation = new ImportOperation(project.getFullPath(), projectSourceFolder, FileSystemStructureProvider.INSTANCE, overwriteQuery);
importOperation.setCreateContainerStructure(false);
importOperation.run(monitor);
return project;
}
use of org.eclipse.ui.dialogs.IOverwriteQuery in project statecharts by Yakindu.
the class GitRepositoryExampleService method importExample.
@Override
public void importExample(ExampleData edata, IProgressMonitor monitor) {
try {
IProjectDescription original = ResourcesPlugin.getWorkspace().loadProjectDescription(new Path(edata.getProjectDir().getAbsolutePath()).append("/.project"));
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(edata.getProjectDir().getName());
IProjectDescription clone = ResourcesPlugin.getWorkspace().newProjectDescription(original.getName());
clone.setBuildSpec(original.getBuildSpec());
clone.setComment(original.getComment());
clone.setDynamicReferences(original.getDynamicReferences());
clone.setNatureIds(original.getNatureIds());
clone.setReferencedProjects(original.getReferencedProjects());
if (project.exists()) {
return;
}
project.create(clone, monitor);
project.open(monitor);
@SuppressWarnings("unchecked") List<IFile> filesToImport = FileSystemStructureProvider.INSTANCE.getChildren(edata.getProjectDir());
ImportOperation io = new ImportOperation(project.getFullPath(), edata.getProjectDir(), FileSystemStructureProvider.INSTANCE, new IOverwriteQuery() {
@Override
public String queryOverwrite(String pathString) {
return IOverwriteQuery.ALL;
}
}, filesToImport);
io.setOverwriteResources(true);
io.setCreateContainerStructure(false);
io.run(monitor);
project.refreshLocal(IProject.DEPTH_INFINITE, monitor);
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.eclipse.ui.dialogs.IOverwriteQuery in project webtools.sourceediting by eclipse.
the class ProjectUnzipUtility method importFile.
/**
* @param fileToImport
* the file you wish to import
* @param folderPath
* the container path within the workspace
*/
public void importFile(File fileToImport, String folderPath) {
WorkspaceProgressMonitor importProgress = new WorkspaceProgressMonitor();
try {
if (fileToImport.exists()) {
IPath containerPath = new Path(folderPath);
IImportStructureProvider provider = FileSystemStructureProvider.INSTANCE;
IOverwriteQuery overwriteImplementor = new MyOverwriteQuery();
File[] filesToImport = { fileToImport };
ImportOperation importOp = new ImportOperation(containerPath, null, provider, overwriteImplementor, Arrays.asList(filesToImport));
importOp.setCreateContainerStructure(false);
importOp.setOverwriteResources(true);
importOp.run(importProgress);
} else {
System.out.println("handle source doesn't exist");
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
importProgress.done();
}
}
use of org.eclipse.ui.dialogs.IOverwriteQuery in project webtools.sourceediting by eclipse.
the class ProjectUnzipUtility method importFile.
/**
* @param fileToImport
* the file you wish to import
* @param folderPath
* the container path within the workspace
*/
public void importFile(File fileToImport, String folderPath) {
WorkspaceProgressMonitor importProgress = new WorkspaceProgressMonitor();
try {
if (fileToImport.exists()) {
IPath containerPath = new Path(folderPath);
// fCreatedProjects.add(folderPath);
IImportStructureProvider provider = FileSystemStructureProvider.INSTANCE;
IOverwriteQuery overwriteImplementor = new MyOverwriteQuery();
File[] filesToImport = { fileToImport };
ImportOperation importOp = new ImportOperation(containerPath, null, provider, overwriteImplementor, Arrays.asList(filesToImport));
importOp.setCreateContainerStructure(false);
importOp.setOverwriteResources(true);
importOp.run(importProgress);
} else {
System.out.println("handle source doesn't exist");
}
} catch (Exception ex) {
ex.printStackTrace();
} finally {
importProgress.done();
}
}
Aggregations