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 |
|
|
18 |
|
|
19 |
package com.nokia.carbide.internal.discovery.ui.wizard;
|
|
20 |
|
|
21 |
import java.io.File;
|
|
22 |
import java.io.FileOutputStream;
|
|
23 |
import java.io.OutputStream;
|
|
24 |
import java.text.MessageFormat;
|
|
25 |
import java.util.Collection;
|
|
26 |
|
|
27 |
import org.eclipse.jface.dialogs.MessageDialog;
|
|
28 |
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
29 |
import org.eclipse.jface.wizard.Wizard;
|
|
30 |
import org.eclipse.ui.IExportWizard;
|
|
31 |
import org.eclipse.ui.IWorkbench;
|
|
32 |
|
|
33 |
import com.nokia.carbide.discovery.ui.Activator;
|
|
34 |
|
|
35 |
/**
|
|
36 |
* Wizard for exporting installed features to a file
|
|
37 |
*/
|
|
38 |
public class ExportWizard extends Wizard implements IExportWizard {
|
|
39 |
|
|
40 |
private ExportPage exportPage;
|
|
41 |
|
|
42 |
public ExportWizard() {
|
|
43 |
}
|
|
44 |
|
|
45 |
public boolean performFinish() {
|
|
46 |
Collection<FeatureInfo> featureInfos = exportPage.getFeatureInfos();
|
|
47 |
File file = exportPage.getFile();
|
|
48 |
OutputStream os;
|
|
49 |
try {
|
|
50 |
os = new FileOutputStream(file);
|
|
51 |
Streamer.writeToXML(os, FeatureUtils.getKnownRepositories(), featureInfos);
|
|
52 |
} catch (Exception e) {
|
|
53 |
MessageDialog.openError(getShell(), "Error",
|
|
54 |
MessageFormat.format("Could not write export file due to error: {0}", e.getLocalizedMessage()));
|
|
55 |
}
|
|
56 |
return true;
|
|
57 |
}
|
|
58 |
|
|
59 |
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
|
60 |
setDefaultPageImageDescriptor(Activator.getImageDescriptor("icons\\install_wiz.gif")); //$NON-NLS-1$
|
|
61 |
setWindowTitle("Export");
|
|
62 |
exportPage = new ExportPage();
|
|
63 |
addPage(exportPage);
|
|
64 |
}
|
|
65 |
|
|
66 |
}
|