use of org.eclipse.ui.wizards.datatransfer.ImportOperation in project webtools.sourceediting by eclipse.
the class ExampleProjectCreationOperation method importFilesFromZip.
private void importFilesFromZip(ZipFile srcZipFile, IPath destPath, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
ZipFileStructureProvider structureProvider = new ZipFileStructureProvider(srcZipFile);
ImportOperation op = new ImportOperation(destPath, structureProvider.getRoot(), structureProvider, overwriteQuery);
op.run(monitor);
}
use of org.eclipse.ui.wizards.datatransfer.ImportOperation in project che by eclipse.
the class JavaProjectHelper method importFilesFromZip.
public 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 translationstudio8 by heartsome.
the class ImportProjectWizardPage method createExistingProject.
/**
* Create the project described in record. If it is successful return true.
*
* @param record
* @return boolean <code>true</code> if successful
* @throws InterruptedException
*/
private boolean createExistingProject(final ProjectRecord record, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
String projectName = record.getProjectName();
final IWorkspace workspace = ResourcesPlugin.getWorkspace();
final IProject project = workspace.getRoot().getProject(projectName);
createdProjects.add(project);
if (record.description == null) {
// error case
record.description = workspace.newProjectDescription(projectName);
IPath locationPath = new Path(record.projectSystemFile.getAbsolutePath());
// If it is under the root use the default location
if (Platform.getLocation().isPrefixOf(locationPath)) {
record.description.setLocation(null);
} else {
record.description.setLocation(locationPath);
}
} else {
record.description.setName(projectName);
}
if (record.projectArchiveFile != null) {
// import from archive
List fileSystemObjects = structureProvider.getChildren(record.parent);
structureProvider.setStrip(record.level);
ImportOperation operation = new ImportOperation(project.getFullPath(), structureProvider.getRoot(), structureProvider, this, fileSystemObjects);
operation.setContext(getShell());
operation.run(monitor);
return true;
}
// import from file system
File importSource = null;
if (copyFiles) {
// import project from location copying files - use default project
// location for this workspace
URI locationURI = record.description.getLocationURI();
// some error condition occured.
if (locationURI != null) {
// validate the location of the project being copied
IStatus result = ResourcesPlugin.getWorkspace().validateProjectLocationURI(project, locationURI);
if (!result.isOK())
throw new InvocationTargetException(new CoreException(result));
importSource = new File(locationURI);
IProjectDescription desc = workspace.newProjectDescription(projectName);
desc.setBuildSpec(record.description.getBuildSpec());
desc.setComment(record.description.getComment());
desc.setDynamicReferences(record.description.getDynamicReferences());
desc.setNatureIds(record.description.getNatureIds());
desc.setReferencedProjects(record.description.getReferencedProjects());
record.description = desc;
}
}
try {
monitor.beginTask(DataTransferMessages.WizardProjectsImportPage_CreateProjectsTask, 100);
project.create(record.description, new SubProgressMonitor(monitor, 30));
project.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(monitor, 70));
} catch (CoreException e) {
throw new InvocationTargetException(e);
} finally {
monitor.done();
}
// import operation to import project files if copy checkbox is selected
if (copyFiles && importSource != null) {
List filesToImport = FileSystemStructureProvider.INSTANCE.getChildren(importSource);
ImportOperation operation = new ImportOperation(project.getFullPath(), importSource, FileSystemStructureProvider.INSTANCE, this, filesToImport);
operation.setContext(getShell());
// need to overwrite
operation.setOverwriteResources(true);
// .project, .classpath
// files
operation.setCreateContainerStructure(false);
operation.run(monitor);
}
return true;
}
use of org.eclipse.ui.wizards.datatransfer.ImportOperation in project tdi-studio-se by Talend.
the class ImportProjectsUtilities method importProject.
private static void importProject(Shell shell, IImportStructureProvider provider, Object source, IPath path, boolean overwriteResources, boolean createContainerStructure, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
//$NON-NLS-1$
monitor.beginTask(Messages.getString("ImportProjectsUtilities.task.importingProject"), 100);
ArrayList fileSystemObjects = new ArrayList();
ImportProjectsUtilities.getFilesForProject(fileSystemObjects, provider, source);
ImportOperation operation = new ImportOperation(path, source, provider, new MyOverwriteQuery(), fileSystemObjects);
operation.setContext(shell);
operation.setOverwriteResources(overwriteResources);
operation.setCreateContainerStructure(createContainerStructure);
operation.run(new SubProgressMonitor(monitor, 95));
monitor.worked(5);
monitor.done();
}
use of org.eclipse.ui.wizards.datatransfer.ImportOperation in project linuxtools by eclipse.
the class AbstractTest method createExternalProject.
/**
* Create a CDT project outside the default workspace.
*
* @param bundle
* The plug-in bundle.
* @param projname
* The name of the project.
* @param absProjectPath
* Absolute path to the directory to which the project should be
* mapped outside the workspace.
* @return A new external CDT project.
* @throws CoreException
* @throws URISyntaxException
* @throws IOException
* @throws InvocationTargetException
* @throws InterruptedException
*/
protected IProject createExternalProject(Bundle bundle, final String projname, final Path absProjectPath) throws CoreException, URISyntaxException, IOException, InvocationTargetException, InterruptedException {
IProject externalProject;
// Turn off auto-building
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceDescription wspDesc = workspace.getDescription();
wspDesc.setAutoBuilding(false);
workspace.setDescription(wspDesc);
// Create external project
IWorkspaceRoot root = workspace.getRoot();
externalProject = root.getProject(projname);
IProjectDescription description = workspace.newProjectDescription(projname);
URI fileProjectURL = new URI("file://" + absProjectPath.toString());
description.setLocationURI(fileProjectURL);
externalProject = CCorePlugin.getDefault().createCDTProject(description, externalProject, new NullProgressMonitor());
assertNotNull(externalProject);
externalProject.open(null);
try {
// CDT opens the Project with BACKGROUND_REFRESH enabled which
// causes the
// refresh manager to refresh the project 200ms later. This Job
// interferes
// with the resource change handler firing see: bug 271264
Job.getJobManager().join(ResourcesPlugin.FAMILY_AUTO_REFRESH, null);
} catch (Exception e) {
// Ignore
}
assertTrue(externalProject.isOpen());
// Import boiler-plate files which can then be built and profiled
URL location = FileLocator.find(bundle, new Path("resources/" + projname), // $NON-NLS-1$
null);
File testDir = new File(FileLocator.toFileURL(location).toURI());
ImportOperation op = new ImportOperation(externalProject.getFullPath(), testDir, FileSystemStructureProvider.INSTANCE, new IOverwriteQuery() {
@Override
public String queryOverwrite(String pathString) {
return ALL;
}
});
op.setCreateContainerStructure(false);
op.run(null);
IStatus status = op.getStatus();
if (!status.isOK()) {
throw new CoreException(status);
}
// Make sure import went well
assertNotNull(externalProject.findMember(new Path(IMPORTED_SOURCE_FILE)));
// Index the project
IIndexManager indexMgr = CCorePlugin.getIndexManager();
indexMgr.joinIndexer(IIndexManager.FOREVER, new NullProgressMonitor());
// These natures must be enabled at this point to continue
assertTrue(externalProject.isNatureEnabled(ScannerConfigNature.NATURE_ID));
assertTrue(externalProject.isNatureEnabled(ManagedCProjectNature.MNG_NATURE_ID));
return externalProject;
}
Aggregations