1810
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of the License "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
package com.nokia.carbide.internal.discovery.ui.wizard;
|
|
18 |
|
1818
|
19 |
import java.lang.reflect.InvocationTargetException;
|
|
20 |
import java.text.MessageFormat;
|
|
21 |
|
1824
|
22 |
import org.eclipse.core.runtime.CoreException;
|
|
23 |
import org.eclipse.core.runtime.IStatus;
|
|
24 |
import org.eclipse.jface.dialogs.ErrorDialog;
|
1818
|
25 |
import org.eclipse.jface.dialogs.MessageDialog;
|
1810
|
26 |
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
27 |
import org.eclipse.jface.wizard.Wizard;
|
|
28 |
import org.eclipse.ui.IImportWizard;
|
|
29 |
import org.eclipse.ui.IWorkbench;
|
|
30 |
|
|
31 |
import com.nokia.carbide.discovery.ui.Activator;
|
1824
|
32 |
import com.nokia.carbide.discovery.ui.Messages;
|
1810
|
33 |
|
|
34 |
/**
|
|
35 |
* Wizard for importing installed features from a file and install them
|
|
36 |
*/
|
|
37 |
public class ImportWizard extends Wizard implements IImportWizard {
|
|
38 |
|
|
39 |
private ImportPage importPage;
|
|
40 |
|
|
41 |
public ImportWizard() {
|
|
42 |
}
|
|
43 |
|
|
44 |
@Override
|
|
45 |
public boolean performFinish() {
|
1824
|
46 |
try {
|
|
47 |
ImportExportData data = importPage.getData();
|
|
48 |
getContainer().run(true, true, new FeatureInstallOperation(
|
|
49 |
data.getURIs(), data.getFeatureInfos(), importPage.getWantsOriginalVersions()));
|
|
50 |
} catch (InvocationTargetException e) {
|
|
51 |
Throwable cause = e.getCause();
|
|
52 |
if (cause instanceof CoreException) {
|
|
53 |
IStatus status = ((CoreException) cause).getStatus();
|
|
54 |
Activator.logError(Messages.ImportWizard_ImportFailedError, cause);
|
|
55 |
ErrorDialog.openError(getShell(), Messages.ImportWizard_ErrorTitle, null, status);
|
|
56 |
} else {
|
|
57 |
MessageDialog.openError(getShell(), Messages.ImportWizard_ErrorTitle,
|
|
58 |
MessageFormat.format(Messages.ImportWizard_InstallErrorSimple, cause.getMessage()));
|
1818
|
59 |
}
|
1824
|
60 |
} catch (InterruptedException e) {
|
1818
|
61 |
}
|
1810
|
62 |
return true;
|
|
63 |
}
|
|
64 |
|
|
65 |
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
|
66 |
setDefaultPageImageDescriptor(Activator.getImageDescriptor("icons\\install_wiz.gif")); //$NON-NLS-1$
|
1818
|
67 |
setNeedsProgressMonitor(true);
|
1824
|
68 |
setWindowTitle(Messages.ImportWizard_Title);
|
1810
|
69 |
importPage = new ImportPage();
|
|
70 |
addPage(importPage);
|
|
71 |
}
|
|
72 |
|
|
73 |
}
|