use of org.eclipse.ui.internal.wizards.datatransfer.TarException in project tdi-studio-se by Talend.
the class ImportProjectAsWizard method performFinish.
/**
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
@Override
public boolean performFinish() {
if (getContainer().getCurrentPage().equals(manyProjectsPage)) {
isImportedSeveralProject = true;
return manyProjectsPage.createProjects();
} else {
isImportedSeveralProject = false;
name = mainPage.getName().trim().replace(' ', '_');
final String technicalName = mainPage.getTechnicalName();
final String sourcePath = mainPage.getSourcePath();
final boolean isArchive = mainPage.isArchive();
// see bug 4600, update the external lib path, make it possible to
// copy external jar files into tos
updateExternalLibPath();
final Shell shell = getShell();
ProgressDialog progressDialog = new ProgressDialog(shell) {
private IProgressMonitor monitorWrap;
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitorWrap = new EventLoopProgressMonitor(monitor);
try {
if (!isArchive) {
ImportProjectsUtilities.importProjectAs(shell, name, technicalName, sourcePath, monitorWrap);
} else {
// type.equalsIgnoreCase("archive")
ImportProjectsUtilities.importArchiveProjectAs(shell, name, technicalName, sourcePath, monitorWrap);
}
} catch (IOException e) {
throw new InvocationTargetException(e);
} catch (TarException e) {
throw new InvocationTargetException(e);
}
monitorWrap.done();
//$NON-NLS-1$
MessageDialog.openInformation(//$NON-NLS-1$
shell, //$NON-NLS-1$
Messages.getString("ImportProjectAction.messageDialogTitle.project"), //$NON-NLS-1$
Messages.getString("ImportProjectAction.messageDialogContent.projectImportedSuccessfully"));
}
};
try {
progressDialog.executeProcess();
} catch (InvocationTargetException e) {
MessageBoxExceptionHandler.process(e.getTargetException(), shell);
return false;
} catch (InterruptedException e) {
IProject[] projects = org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getProjects();
for (IProject project : projects) {
if (project.getName().equalsIgnoreCase(name)) {
try {
project.delete(true, true, null);
} catch (CoreException ee) {
ExceptionHandler.process(ee);
}
}
}
return false;
}
return true;
}
}
use of org.eclipse.ui.internal.wizards.datatransfer.TarException in project tdi-studio-se by Talend.
the class TalendWizardProjectsImportPage method getProjectRecords.
@Override
public ProjectRecord[] getProjectRecords() {
if (sourcePath == null || sourcePath.length() == 0) {
return new ProjectRecord[0];
}
ProjectRecord[] selectedProjects = super.getProjectRecords();
Collection files = new ArrayList();
List projects = new ArrayList();
ProjectRecord[] selected = null;
for (ProjectRecord selectedProject : selectedProjects) {
projects.add(selectedProject);
}
final File directory = new File(sourcePath);
if (ArchiveFileManipulations.isTarFile(sourcePath)) {
try {
TarFile sourceTarFile = new TarFile(sourcePath);
if (sourceTarFile == null) {
return new ProjectRecord[0];
}
structureProvider = new TarLeveledStructureProvider(sourceTarFile);
Object child = structureProvider.getRoot();
collectProjectFilesFromProvider(files, child, 0);
selected = new ProjectRecord[files.size()];
Iterator filesIterator = files.iterator();
int j = 0;
while (filesIterator.hasNext()) {
TalendProjectRecord file = (TalendProjectRecord) filesIterator.next();
for (int i = 0; i < projects.size(); i++) {
if (file.getProjectName().equals(((ProjectRecord) projects.get(i)).getProjectName())) {
selected[j] = (ProjectRecord) projects.get(i);
j++;
}
}
}
} catch (TarException e) {
// displayErrorDialog(DataTransferMessages.TarImport_badFormat);
//$NON-NLS-1$
displayErrorDialog(Messages.getString("DataTransferMessages.TarImport_badFormat"));
} catch (IOException e) {
// displayErrorDialog(DataTransferMessages.ZipImport_couldNotRead);
//$NON-NLS-1$
displayErrorDialog(Messages.getString("DataTransferMessages.ZipImport_couldNotRead"));
}
} else if (ArchiveFileManipulations.isZipFile(sourcePath)) {
try {
ZipFile sourceFile = new ZipFile(sourcePath);
if (sourceFile == null) {
return new ProjectRecord[0];
}
structureProvider = new ZipLeveledStructureProvider(sourceFile);
Object child = structureProvider.getRoot();
collectProjectFilesFromProvider(files, child, 0);
selected = new ProjectRecord[files.size()];
Iterator filesIterator = files.iterator();
int j = 0;
while (filesIterator.hasNext()) {
TalendProjectRecord file = (TalendProjectRecord) filesIterator.next();
for (int i = 0; i < projects.size(); i++) {
if (file.getProjectName().equals(((ProjectRecord) projects.get(i)).getProjectName())) {
selected[j] = (ProjectRecord) projects.get(i);
j++;
}
}
}
} catch (IOException e) {
// displayErrorDialog(DataTransferMessages.ZipImport_badFormat);
//$NON-NLS-1$
displayErrorDialog(Messages.getString("DataTransferMessages.ZipImport_badFormat"));
}
} else if (directory.isDirectory()) {
collectProjectFilesFromDirectory(files, directory, null);
selected = new ProjectRecord[files.size()];
Iterator filesIterator = files.iterator();
int j = 0;
while (filesIterator.hasNext()) {
File file = (File) filesIterator.next();
for (int i = 0; i < projects.size(); i++) {
if (file.getParentFile().getName().equals(((ProjectRecord) projects.get(i)).getProjectName())) {
selected[j] = (ProjectRecord) projects.get(i);
j++;
}
}
}
}
return selected;
}
use of org.eclipse.ui.internal.wizards.datatransfer.TarException in project tdi-studio-se by Talend.
the class DemoImportTestUtil method getResourceManager.
public static ResourcesManager getResourceManager(DemoProjectBean checkedProjectBean) {
ResourcesManager resManager = null;
try {
Bundle bundle = Platform.getBundle(checkedProjectBean.getPluginId());
URL demoURL = FileLocator.find(bundle, new Path(checkedProjectBean.getDemoProjectFilePath()), null);
demoURL = FileLocator.toFileURL(demoURL);
String filePath = new Path(demoURL.getFile()).toOSString();
File srcFile = new File(filePath);
FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
resManager = fileUnityManager.doUnify();
} catch (ZipException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (TarException e) {
e.printStackTrace();
}
return resManager;
}
use of org.eclipse.ui.internal.wizards.datatransfer.TarException in project tdi-studio-se by Talend.
the class ImportDemoProjectItemsPage method getResourceManagers.
private List<ResourcesManager> getResourceManagers(List<DemoProjectBean> checkedProjectBean) {
List<ResourcesManager> resManagers = new ArrayList<ResourcesManager>();
try {
for (DemoProjectBean pro : checkedProjectBean) {
ResourcesManager resManager = null;
Bundle bundle = Platform.getBundle(pro.getPluginId());
URL demoURL = FileLocator.find(bundle, new Path(pro.getDemoProjectFilePath()), null);
demoURL = FileLocator.toFileURL(demoURL);
String filePath = new Path(demoURL.getFile()).toOSString();
File srcFile = new File(filePath);
// TUP-1924:use UnityManager here ,same with import normal items.
FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
resManager = fileUnityManager.doUnify();
if (resManager != null) {
resManagers.add(resManager);
}
}
} catch (ZipException e) {
//$NON-NLS-1$
displayErrorDialog(Messages.getString("ImportItemsWizardPage_ZipImport_badFormat"));
} catch (TarException e) {
//$NON-NLS-1$
displayErrorDialog(Messages.getString("ImportItemsWizardPage_TarImport_badFormat"));
} catch (FileNotFoundException e) {
ExceptionHandler.process(e);
} catch (IOException e) {
ExceptionHandler.process(e);
}
return resManagers;
}
use of org.eclipse.ui.internal.wizards.datatransfer.TarException in project tdi-studio-se by Talend.
the class DemoImportTestUtil method getResourceManagers.
public static List<ResourcesManager> getResourceManagers(List<DemoProjectBean> checkedProjectBean) {
List<ResourcesManager> resManagers = new ArrayList<ResourcesManager>();
try {
for (DemoProjectBean pro : checkedProjectBean) {
ResourcesManager resManager = null;
Bundle bundle = Platform.getBundle(pro.getPluginId());
URL demoURL = FileLocator.find(bundle, new Path(pro.getDemoProjectFilePath()), null);
demoURL = FileLocator.toFileURL(demoURL);
String filePath = new Path(demoURL.getFile()).toOSString();
File srcFile = new File(filePath);
FileResourcesUnityManager fileUnityManager = ResourcesManagerFactory.getInstance().createFileUnityManager(srcFile);
resManager = fileUnityManager.doUnify();
if (resManager != null) {
resManagers.add(resManager);
}
}
} catch (ZipException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (TarException e) {
e.printStackTrace();
}
return resManagers;
}
Aggregations