1 11 package org.eclipse.team.internal.ui.wizards; 12 13 import java.lang.reflect.InvocationTargetException ; 14 15 import org.eclipse.core.runtime.IStatus; 16 import org.eclipse.core.runtime.Status; 17 import org.eclipse.jface.dialogs.ErrorDialog; 18 import org.eclipse.jface.viewers.IStructuredSelection; 19 import org.eclipse.jface.wizard.Wizard; 20 import org.eclipse.osgi.util.NLS; 21 import org.eclipse.team.core.TeamException; 22 import org.eclipse.team.internal.ui.*; 23 import org.eclipse.ui.IImportWizard; 24 import org.eclipse.ui.IWorkbench; 25 import org.xml.sax.SAXException ; 26 27 public class ProjectSetImportWizard extends Wizard implements IImportWizard { 28 ImportProjectSetMainPage mainPage; 29 30 public ProjectSetImportWizard() { 31 setNeedsProgressMonitor(true); 32 setWindowTitle(TeamUIMessages.ProjectSetImportWizard_Project_Set_1); 33 } 34 35 public void addPages() { 36 mainPage = new ImportProjectSetMainPage("projectSetMainPage", TeamUIMessages.ProjectSetImportWizard_Import_a_Project_Set_3, TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_PROJECTSET_IMPORT_BANNER)); addPage(mainPage); 38 } 39 40 public boolean performFinish() { 41 final boolean[] result = new boolean[] {false}; 42 try { 43 ImportProjectSetOperation op = new ImportProjectSetOperation( 44 mainPage.isRunInBackgroundOn() ? null : getContainer(), 45 mainPage.getFileName(), mainPage.getWorkingSetName()); 46 op.run(); 47 result[0] = true; 48 } catch (InterruptedException e) { 49 return true; 50 } catch (InvocationTargetException e) { 51 Throwable target = e.getTargetException(); 52 if (target instanceof TeamException) { 53 ErrorDialog.openError(getShell(), null, null, ((TeamException)target).getStatus()); 54 return false; 55 } 56 if (target instanceof RuntimeException ) { 57 throw (RuntimeException )target; 58 } 59 if (target instanceof Error ) { 60 throw (Error )target; 61 } 62 if (target instanceof SAXException ) { 63 ErrorDialog.openError(getShell(), null, null, new Status(IStatus.ERROR, TeamUIPlugin.ID, 0, NLS.bind(TeamUIMessages.ProjectSetImportWizard_2, new String [] { target.getMessage() }), target)); 64 return false; 65 } 66 ErrorDialog.openError(getShell(), null, null, new Status(IStatus.ERROR, TeamUIPlugin.ID, 0, NLS.bind(TeamUIMessages.ProjectSetImportWizard_3, new String [] { target.getMessage() }), target)); 67 } 68 return result[0]; 69 } 70 71 public void init(IWorkbench workbench, IStructuredSelection selection) { 72 PsfFilenameStore.setDefaultFromSelection(workbench); 75 } 76 } 77 | Popular Tags |