use of org.eclipse.ui.wizards.datatransfer.ImportOperation in project jbosstools-hibernate by jbosstools.
the class JavaProjectHelper method importFilesFromZip.
private static void importFilesFromZip(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor) throws InvocationTargetException {
ZipFileStructureProvider structureProvider = new ZipFileStructureProvider(srcZipFile);
try {
ImportOperation op = new ImportOperation(destPath, structureProvider.getRoot(), structureProvider, new ImportOverwriteQuery());
op.run(monitor);
} catch (InterruptedException e) {
// should not happen
}
}
use of org.eclipse.ui.wizards.datatransfer.ImportOperation 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.wizards.datatransfer.ImportOperation 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.wizards.datatransfer.ImportOperation 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.wizards.datatransfer.ImportOperation 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