1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.lttng
.ui
.views
.project
.dialogs
;
15 import java
.util
.List
;
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
;
29 * <b><u>ImportTraceWizard</u></b>
32 * TODO: Implement me. Please.
34 @SuppressWarnings("restriction")
35 public class ImportTraceWizard
extends Wizard
implements IImportWizard
{
37 private IWorkbench fWorkbench
;
38 private IStructuredSelection fSelection
;
39 private ImportTraceWizardPage fMainPage
;
44 public ImportTraceWizard() {
45 IDialogSettings workbenchSettings
= WorkbenchPlugin
.getDefault().getDialogSettings();
46 IDialogSettings section
= workbenchSettings
.getSection("LTTngTraceImportWizard");
47 if (section
== null) {
48 section
= workbenchSettings
.addNewSection("LTTngTraceImportWizard");
51 setDialogSettings(section
);
55 * @see org.eclipse.jface.wizard.Wizard#addPages()
58 public void addPages() {
60 fMainPage
= new ImportTraceWizardPage(fWorkbench
, fSelection
);
65 * @see org.eclipse.ui.IWorkbenchWizard#init(org.eclipse.ui.IWorkbench, org.eclipse.jface.viewers.IStructuredSelection)
67 @SuppressWarnings("rawtypes")
68 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
69 fWorkbench
= workbench
;
70 fSelection
= selection
;
72 List selectedResources
= IDE
.computeSelectedResources(selection
);
73 if (!selectedResources
.isEmpty()) {
74 fSelection
= new StructuredSelection(selectedResources
);
77 setWindowTitle(DataTransferMessages
.DataTransfer_importTitle
);
78 setDefaultPageImageDescriptor(IDEWorkbenchPlugin
.getIDEImageDescriptor("wizban/importdir_wiz.png"));
79 setNeedsProgressMonitor(true);
82 public ImportTraceWizardPage
getMainPage() {
87 * performFinish is called after the "finish" button is pressed in the import wizard
88 * If we return "false", the wizard will not close.
90 * We perform here version check on the imported LTTng trace
94 public boolean performFinish() {
96 if ( fMainPage
.getDestination().equals( fMainPage
.getInitialContainerString() ) ) {
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
);
109 return fMainPage
.finish();
113 public boolean canFinish() {
114 return fMainPage
.isSelectedElementsValidLttngTraces();