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 |
|
|
22 |
import org.eclipse.core.runtime.IProgressMonitor;
|
|
23 |
import org.eclipse.jface.dialogs.MessageDialog;
|
|
24 |
import org.eclipse.jface.operation.IRunnableWithProgress;
|
1810
|
25 |
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
26 |
import org.eclipse.jface.wizard.Wizard;
|
|
27 |
import org.eclipse.ui.IImportWizard;
|
|
28 |
import org.eclipse.ui.IWorkbench;
|
|
29 |
|
|
30 |
import com.nokia.carbide.discovery.ui.Activator;
|
|
31 |
|
|
32 |
/**
|
|
33 |
* Wizard for importing installed features from a file and install them
|
|
34 |
*/
|
|
35 |
public class ImportWizard extends Wizard implements IImportWizard {
|
|
36 |
|
|
37 |
private ImportPage importPage;
|
|
38 |
|
|
39 |
public ImportWizard() {
|
|
40 |
}
|
|
41 |
|
|
42 |
@Override
|
|
43 |
public boolean performFinish() {
|
1818
|
44 |
final ImportExportData data = importPage.getData();
|
|
45 |
IRunnableWithProgress runnable = new IRunnableWithProgress() {
|
|
46 |
@Override
|
|
47 |
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
|
|
48 |
try {
|
|
49 |
P2Utils.doInstall(data.getURIs(), data.getFeatureInfos(), data.getWantsVersions(), monitor);
|
|
50 |
} catch (Exception e) {
|
|
51 |
throw new InvocationTargetException(e);
|
|
52 |
}
|
|
53 |
}
|
|
54 |
};
|
|
55 |
|
|
56 |
try {
|
|
57 |
getContainer().run(true, true, runnable);
|
|
58 |
} catch (Exception e) {
|
|
59 |
MessageDialog.openError(getShell(), "Error",
|
|
60 |
MessageFormat.format("Could not install due to error: {0}", e.getLocalizedMessage()));
|
|
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);
|
1810
|
68 |
setWindowTitle("Import Installed Feature Configuration");
|
|
69 |
importPage = new ImportPage();
|
|
70 |
addPage(importPage);
|
|
71 |
}
|
|
72 |
|
|
73 |
}
|