(no commit message)
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / project / dialogs / ImportTraceWizard.java
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
13 package org.eclipse.linuxtools.lttng.ui.views.project.dialogs;
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.ui.IImportWizard;
22 import org.eclipse.ui.IWorkbench;
23 import org.eclipse.ui.ide.IDE;
24 import org.eclipse.ui.internal.WorkbenchPlugin;
25 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
26 import 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")
35 public class ImportTraceWizard extends Wizard implements IImportWizard {
36
37 private IWorkbench fWorkbench;
38 private IStructuredSelection fSelection;
39 private ImportTraceWizardPage fMainPage;
40
41 /**
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 }
50
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 */
67 @SuppressWarnings("rawtypes")
68 public void init(IWorkbench workbench, IStructuredSelection selection) {
69 fWorkbench = workbench;
70 fSelection = selection;
71
72 List selectedResources = IDE.computeSelectedResources(selection);
73 if (!selectedResources.isEmpty()) {
74 fSelection = new StructuredSelection(selectedResources);
75 }
76
77 setWindowTitle(DataTransferMessages.DataTransfer_importTitle);
78 setDefaultPageImageDescriptor(IDEWorkbenchPlugin.getIDEImageDescriptor("wizban/importdir_wiz.png"));
79 setNeedsProgressMonitor(true);
80 }
81
82 public ImportTraceWizardPage getMainPage() {
83 return fMainPage;
84 }
85
86 /**
87 * performFinish is called after the "finish" button is pressed in the import wizard
88 * If we return "false", the wizard will not close.
89 *
90 * We perform here version check on the imported LTTng trace
91 *
92 */
93 @Override
94 public boolean performFinish() {
95
96 if ( fMainPage.getDestination().equals( fMainPage.getInitialContainerString() ) ) {
97
98 String errMessage[] = { "Error : import destination is wrong." };
99 errMessage = fMainPage.extendErrorMessage(errMessage, "");
100 errMessage = fMainPage.extendErrorMessage(errMessage, "You cannot import your trace directly into the \"" + fMainPage.getInitialContainerString() + "\"");
101 errMessage = fMainPage.extendErrorMessage(errMessage, "The trace has to be into a subdirectly, like \"" + fMainPage.getInitialContainerString() + "/MyTrace\"" );
102 errMessage = fMainPage.extendErrorMessage(errMessage, "");
103 errMessage = fMainPage.extendErrorMessage(errMessage, "Please change the destination folder.");
104 fMainPage.showVersionErrorPopup(errMessage);
105
106 return false;
107 }
108
109 return fMainPage.finish();
110 }
111
112 @Override
113 public boolean canFinish() {
114 return fMainPage.isSelectedElementsValidLttngTraces();
115 }
116
117 }
This page took 0.032761 seconds and 5 git commands to generate.