use of org.eclipse.ui.wizards.datatransfer.IImportStructureProvider in project tdi-studio-se by Talend.
the class ImportProjectsUtilities method importArchiveProject.
public static void importArchiveProject(Shell shell, String technicalName, String sourcePath, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException, TarException, IOException {
IImportStructureProvider provider;
Object source;
if (ArchiveFileManipulations.isZipFile(sourcePath)) {
ZipLeveledStructureProvider zipProvider = new ZipLeveledStructureProvider(new ZipFile(sourcePath));
source = zipProvider.getRoot();
boolean ok = true;
for (Object o : zipProvider.getChildren(source)) {
String label = zipProvider.getLabel(o);
if (!label.equals(IProjectDescription.DESCRIPTION_FILE_NAME) && ok) {
source = o;
} else {
ok = false;
}
}
if (!ok) {
source = zipProvider.getRoot();
}
provider = zipProvider;
} else if (ArchiveFileManipulations.isTarFile(sourcePath)) {
TarLeveledStructureProvider tarProvider = new TarLeveledStructureProvider(new TarFile(sourcePath));
source = tarProvider.getRoot();
boolean ok = true;
for (Object o : tarProvider.getChildren(source)) {
String label = tarProvider.getLabel(o);
if (!label.equals(IProjectDescription.DESCRIPTION_FILE_NAME) && ok) {
source = o;
} else {
ok = false;
}
}
if (!ok) {
source = tarProvider.getRoot();
}
provider = tarProvider;
} else {
//$NON-NLS-1$
throw new IllegalArgumentException(Messages.getString("ImportProjectsUtilities.fileFormatError", sourcePath));
}
importProject(shell, provider, source, new Path(technicalName), false, false, monitor);
}
use of org.eclipse.ui.wizards.datatransfer.IImportStructureProvider in project tdi-studio-se by Talend.
the class ImportProjectsUtilities method importProjectAs.
public static void importProjectAs(Shell shell, String newName, String technicalName, String sourcePath, IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IImportStructureProvider provider = FilterFileSystemStructureProvider.INSTANCE;
importProject(shell, provider, new File(sourcePath), new Path(technicalName), true, false, monitor);
Project project = afterImportAs(newName, technicalName);
// do additional actions after importing projects
AfterImportProjectUtil.runAfterImportProjectActions(new org.talend.core.model.general.Project(project));
}
use of org.eclipse.ui.wizards.datatransfer.IImportStructureProvider 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.IImportStructureProvider 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