KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ui > wizards > ProjectSetImportWizard


1 /*******************************************************************************
2  * Copyright (c) 2000, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ui.wizards;
12
13 import java.lang.reflect.InvocationTargetException JavaDoc;
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 JavaDoc;
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)); //$NON-NLS-1$
37
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 JavaDoc e) {
49             return true;
50         } catch (InvocationTargetException JavaDoc e) {
51             Throwable JavaDoc 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 JavaDoc) {
57                 throw (RuntimeException JavaDoc)target;
58             }
59             if (target instanceof Error JavaDoc) {
60                 throw (Error JavaDoc)target;
61             }
62             if (target instanceof SAXException JavaDoc) {
63                 ErrorDialog.openError(getShell(), null, null, new Status(IStatus.ERROR, TeamUIPlugin.ID, 0, NLS.bind(TeamUIMessages.ProjectSetImportWizard_2, new String JavaDoc[] { 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 JavaDoc[] { target.getMessage() }), target));
67         }
68         return result[0];
69     }
70         
71     public void init(IWorkbench workbench, IStructuredSelection selection) {
72         // The code that finds "selection" is broken (it is always empty), so we
73
// must dig for the selection in the workbench.
74
PsfFilenameStore.setDefaultFromSelection(workbench);
75     }
76 }
77
Popular Tags