Commit | Line | Data |
---|---|---|
6e651d8b MAL |
1 | /******************************************************************************* |
2 | * Copyright (c) 2013 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are | |
5 | * made available under the terms of the Eclipse Public License v1.0 which | |
6 | * accompanies this distribution, and is available at | |
7 | * http://www.eclipse.org/legal/epl-v10.html | |
8 | * | |
9 | * Contributors: | |
10 | * Marc-Andre Laperle - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.internal.tmf.ui.project.wizards.tracepkg.importexport; | |
14 | ||
195355a9 MAL |
15 | import java.util.ArrayList; |
16 | import java.util.List; | |
17 | ||
6e651d8b MAL |
18 | import org.eclipse.jface.dialogs.IDialogSettings; |
19 | import org.eclipse.jface.viewers.IStructuredSelection; | |
20 | import org.eclipse.jface.wizard.Wizard; | |
21 | import org.eclipse.linuxtools.internal.tmf.ui.Activator; | |
22 | import org.eclipse.linuxtools.tmf.ui.project.model.TmfTraceElement; | |
23 | import org.eclipse.ui.IExportWizard; | |
24 | import org.eclipse.ui.IWorkbench; | |
25 | ||
26 | /** | |
27 | * Wizard for exporting a trace package | |
28 | * | |
29 | * @author Marc-Andre Laperle | |
30 | */ | |
31 | public class ExportTracePackageWizard extends Wizard implements IExportWizard { | |
32 | ||
33 | private static final String STORE_EXPORT_TRACE_WIZARD = "ExportTraceWizard"; //$NON-NLS-1$ | |
34 | private IStructuredSelection fSelection; | |
195355a9 | 35 | private List<TmfTraceElement> fSelectedTraces; |
6e651d8b MAL |
36 | private ExportTracePackageWizardPage fPage; |
37 | ||
38 | /** | |
39 | * Constructor for the export trace wizard | |
40 | */ | |
41 | public ExportTracePackageWizard() { | |
42 | IDialogSettings workbenchSettings = Activator.getDefault().getDialogSettings(); | |
43 | IDialogSettings section = workbenchSettings | |
44 | .getSection(STORE_EXPORT_TRACE_WIZARD); | |
45 | if (section == null) { | |
46 | section = workbenchSettings.addNewSection(STORE_EXPORT_TRACE_WIZARD); | |
47 | } | |
48 | setDialogSettings(section); | |
195355a9 MAL |
49 | fSelectedTraces = new ArrayList<TmfTraceElement>(); |
50 | } | |
51 | ||
52 | /** | |
53 | * Constructor for the export trace wizard with known selected traces | |
54 | * | |
55 | * @param selectedTraces | |
56 | * the selected traces | |
57 | */ | |
58 | public ExportTracePackageWizard(List<TmfTraceElement> selectedTraces) { | |
59 | this(); | |
60 | fSelectedTraces = selectedTraces; | |
6e651d8b MAL |
61 | } |
62 | ||
63 | @Override | |
64 | public void init(IWorkbench workbench, IStructuredSelection selection) { | |
65 | fSelection = selection; | |
195355a9 | 66 | |
6e651d8b MAL |
67 | setNeedsProgressMonitor(true); |
68 | } | |
69 | ||
70 | @Override | |
71 | public boolean performFinish() { | |
72 | return fPage.finish(); | |
73 | } | |
74 | ||
75 | @Override | |
76 | public void addPages() { | |
77 | super.addPages(); | |
195355a9 MAL |
78 | fPage = new ExportTracePackageWizardPage(fSelection, fSelectedTraces); |
79 | if (fSelectedTraces.isEmpty()) { | |
6e651d8b MAL |
80 | addPage(new ExportTracePackageSelectTraceWizardPage()); |
81 | } | |
82 | addPage(fPage); | |
83 | } | |
84 | } |