2010-10-26 Francois Chouinard <fchouinard@gmail.com> Contribution for Bug309042
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / project / dialogs / ImportTraceWizard.java
CommitLineData
6e512b93
ASL
1/*******************************************************************************
2 * Copyright (c) 2009 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
13package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
14
15import java.util.List;
16
17import org.eclipse.jface.dialogs.IDialogSettings;
18import org.eclipse.jface.viewers.IStructuredSelection;
19import org.eclipse.jface.viewers.StructuredSelection;
20import org.eclipse.jface.wizard.Wizard;
21import org.eclipse.ui.IImportWizard;
22import org.eclipse.ui.IWorkbench;
23import org.eclipse.ui.ide.IDE;
24import org.eclipse.ui.internal.WorkbenchPlugin;
25import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
26import org.eclipse.ui.internal.wizards.datatransfer.DataTransferMessages;
27
28/**
29 * <b><u>ImportTraceWizard</u></b>
30 * <p>
31 *
32 * TODO: Implement me. Please.
33 */
34@SuppressWarnings("restriction")
35public class ImportTraceWizard extends Wizard implements IImportWizard {
36
37 private IWorkbench fWorkbench;
38 private IStructuredSelection fSelection;
39 private ImportTraceWizardPage fMainPage;
40
8e30d685 41 /**
6e512b93
ASL
42 *
43 */
44 public ImportTraceWizard() {
45 IDialogSettings workbenchSettings = WorkbenchPlugin.getDefault().getDialogSettings();
46 IDialogSettings section = workbenchSettings.getSection("LTTngTraceImportWizard");
47 if (section == null) {
48 section = workbenchSettings.addNewSection("LTTngTraceImportWizard");
49 }
8e30d685 50
6e512b93
ASL
51 setDialogSettings(section);
52 }
53
54 /* (non-Javadoc)
55 * @see org.eclipse.jface.wizard.Wizard#addPages()
56 */
57 @Override
58 public void addPages() {
59 super.addPages();
60 fMainPage = new ImportTraceWizardPage(fWorkbench, fSelection);
61 addPage(fMainPage);
62 }
63
64 /* (non-Javadoc)
65 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
66 */
d4011df2 67 @Override
8827c197 68 @SuppressWarnings("rawtypes")
6e512b93
ASL
69 public void init(IWorkbench workbench, IStructuredSelection selection) {
70 fWorkbench = workbench;
71 fSelection = selection;
72
8827c197 73 List selectedResources = IDE.computeSelectedResources(selection);
6e512b93
ASL
74 if (!selectedResources.isEmpty()) {
75 fSelection = new StructuredSelection(selectedResources);
76 }
8e30d685 77
6e512b93
ASL
78 setWindowTitle(DataTransferMessages.DataTransfer_importTitle);
79 setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/importdir_wiz.png"));
80 setNeedsProgressMonitor(true);
81 }
8e30d685
WB
82
83 public ImportTraceWizardPage getMainPage() {
84 return fMainPage;
85 }
86
87 /**
88 * performFinish is called after the "finish" button is pressed in the import wizard
89 * If we return "false", the wizard will not close.
90 *
91 * We perform here version check on the imported LTTng trace
92 *
93 */
6e512b93
ASL
94 @Override
95 public boolean performFinish() {
8e30d685
WB
96
97 if ( fMainPage.getDestination().equals( fMainPage.getInitialContainerString() ) ) {
98
99 String errMessage[] = { "Error : import destination is wrong." };
100 errMessage = fMainPage.extendErrorMessage(errMessage, "");
101 errMessage = fMainPage.extendErrorMessage(errMessage, "You cannot import your trace directly into the \"" + fMainPage.getInitialContainerString() + "\"");
102 errMessage = fMainPage.extendErrorMessage(errMessage, "The trace has to be into a subdirectly, like \"" + fMainPage.getInitialContainerString() + "/MyTrace\"" );
103 errMessage = fMainPage.extendErrorMessage(errMessage, "");
104 errMessage = fMainPage.extendErrorMessage(errMessage, "Please change the destination folder.");
105 fMainPage.showVersionErrorPopup(errMessage);
106
107 return false;
108 }
109
2fbfb67b 110 return fMainPage.finish();
6e512b93 111 }
8e30d685
WB
112
113 @Override
114 public boolean canFinish() {
115 return fMainPage.isSelectedElementsValidLttngTraces();
116 }
6e512b93 117
8e30d685 118}
This page took 0.03196 seconds and 5 git commands to generate.