Contribute CNF based TMF project handling
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / project / wizards / ImportTraceWizard.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 2011 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 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.linuxtools.tmf.ui.project.wizards;
14
15 import java.util.List;
16
17 import org.eclipse.jface.dialogs.IDialogSettings;
18 import org.eclipse.jface.viewers.IStructuredSelection;
19 import org.eclipse.jface.viewers.StructuredSelection;
20 import org.eclipse.jface.wizard.Wizard;
21 import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin;
22 import org.eclipse.ui.IImportWizard;
23 import org.eclipse.ui.IWorkbench;
24 import org.eclipse.ui.ide.IDE;
25
26 /**
27 * <b><u>ImportTraceWizard</u></b>
28 * <p>
29 */
30 public class ImportTraceWizard extends Wizard implements IImportWizard {
31
32 // ------------------------------------------------------------------------
33 // Constants
34 // ------------------------------------------------------------------------
35
36 static private final String PLUGIN_ID = TmfUiPlugin.PLUGIN_ID;
37 static private final String IMPORT_WIZARD = "ImportTraceWizard"; //$NON-NLS-1$
38 static private final String ICON_PATH = "icons/wizban/trace_import_wiz.png"; //$NON-NLS-1$
39
40 // ------------------------------------------------------------------------
41 // Attributes
42 // ------------------------------------------------------------------------
43
44 private IWorkbench fWorkbench;
45 private IStructuredSelection fSelection;
46 private ImportTraceWizardPage fTraceImportWizardPage;
47
48 // ------------------------------------------------------------------------
49 // Constructor
50 // ------------------------------------------------------------------------
51
52 public ImportTraceWizard() {
53 IDialogSettings workbenchSettings = TmfUiPlugin.getDefault().getDialogSettings();
54 IDialogSettings section = workbenchSettings.getSection(IMPORT_WIZARD);
55 if (section == null) {
56 section = workbenchSettings.addNewSection(IMPORT_WIZARD);
57 }
58 setDialogSettings(section);
59 }
60
61 // ------------------------------------------------------------------------
62 // Wizard
63 // ------------------------------------------------------------------------
64
65 @Override
66 public void init(IWorkbench workbench, IStructuredSelection selection) {
67 fWorkbench = workbench;
68 fSelection = selection;
69
70 List<?> selectedResources = IDE.computeSelectedResources(selection);
71 if (!selectedResources.isEmpty()) {
72 fSelection = new StructuredSelection(selectedResources);
73 }
74
75 setWindowTitle(Messages.ImportTraceWizard_DialogTitle);
76 setDefaultPageImageDescriptor(TmfUiPlugin.imageDescriptorFromPlugin(PLUGIN_ID, ICON_PATH));
77 setNeedsProgressMonitor(true);
78 }
79
80 @Override
81 public void addPages() {
82 super.addPages();
83 fTraceImportWizardPage = new ImportTraceWizardPage(fWorkbench, fSelection);
84 addPage(fTraceImportWizardPage);
85 }
86
87 @Override
88 public boolean performFinish() {
89 return fTraceImportWizardPage.finish();
90 }
91
92 }
This page took 0.033049 seconds and 5 git commands to generate.