control: support creating of experiments when importing a trace session
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.remote.ui / src / org / eclipse / tracecompass / internal / tmf / remote / ui / wizards / fetch / RemoteFetchLogWizard.java
1 /*******************************************************************************
2 * Copyright (c) 2016 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 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
12 package org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch;
13
14 import java.util.List;
15
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.eclipse.jdt.annotation.Nullable;
18 import org.eclipse.jface.dialogs.IDialogSettings;
19 import org.eclipse.jface.viewers.IStructuredSelection;
20 import org.eclipse.jface.viewers.StructuredSelection;
21 import org.eclipse.jface.wizard.Wizard;
22 import org.eclipse.tracecompass.internal.tmf.remote.ui.Activator;
23 import org.eclipse.tracecompass.internal.tmf.remote.ui.messages.RemoteMessages;
24 import org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportProfileElement;
25 import org.eclipse.ui.IImportWizard;
26 import org.eclipse.ui.IWorkbench;
27 import org.eclipse.ui.ide.IDE;
28 import org.eclipse.ui.plugin.AbstractUIPlugin;
29
30 /**
31 * Wizard for remote fetching of logs and traces.
32 */
33 public class RemoteFetchLogWizard extends Wizard implements IImportWizard {
34
35 // ------------------------------------------------------------------------
36 // Constants
37 // ------------------------------------------------------------------------
38 private static final String FETCH_LOG_WIZARD = "RemoteFetchLogWizard"; //$NON-NLS-1$
39 private static final String PLUGIN_ID = Activator.PLUGIN_ID;
40 private static final String ICON_PATH = "icons/elcl16/fetch_log_wiz.gif"; //$NON-NLS-1$
41
42 // ------------------------------------------------------------------------
43 // Attributes
44 // ------------------------------------------------------------------------
45 private IStructuredSelection fSelection;
46 private RemoteFetchLogWizardPage fFetchLogWizardPage;
47 private RemoteFetchLogWizardRemotePage fFetchLogRemotePage;
48
49 private @Nullable RemoteImportProfileElement fRemoteProfile = null;
50 private @Nullable String fExperimentName = null;
51
52 // ------------------------------------------------------------------------
53 // Constructor(s)
54 // ------------------------------------------------------------------------
55 /**
56 * Standard constructor
57 */
58 public RemoteFetchLogWizard() {
59 IDialogSettings workbenchSettings = Activator.getDefault().getDialogSettings();
60 IDialogSettings section = workbenchSettings
61 .getSection(FETCH_LOG_WIZARD);
62 if (section == null) {
63 section = workbenchSettings.addNewSection(FETCH_LOG_WIZARD);
64 }
65 setDialogSettings(section);
66 }
67
68 /**
69 * Create wizard with pre-defined remote profile
70 * @param profile
71 * a remote profile
72 * @param experimentName
73 * A name of an experiment to create and add traces to, or null
74 * for no experiment
75 */
76 public RemoteFetchLogWizard(@NonNull RemoteImportProfileElement profile, @Nullable String experimentName) {
77 this();
78 fRemoteProfile = profile;
79 fExperimentName = experimentName;
80 }
81
82 // ------------------------------------------------------------------------
83 // Operations
84 // ------------------------------------------------------------------------
85 @Override
86 public void init(IWorkbench workbench, IStructuredSelection selection) {
87 fSelection = selection;
88
89 List<?> selectedResources = IDE.computeSelectedResources(selection);
90 if (!selectedResources.isEmpty()) {
91 fSelection = new StructuredSelection(selectedResources);
92 }
93
94 setWindowTitle(RemoteMessages.RemoteFetchLogWizard_Title);
95 setDefaultPageImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, ICON_PATH));
96 setNeedsProgressMonitor(true);
97 }
98
99 @Override
100 public void addPages() {
101 super.addPages();
102 if (fRemoteProfile == null) {
103 fFetchLogWizardPage = new RemoteFetchLogWizardPage(RemoteMessages.RemoteFetchLogWizardPage_Title, fSelection);
104 addPage(fFetchLogWizardPage);
105 }
106 fFetchLogRemotePage = new RemoteFetchLogWizardRemotePage(RemoteMessages.RemoteFetchLogWizardRemotePage_Title, fSelection, fRemoteProfile, fExperimentName);
107 addPage(fFetchLogRemotePage);
108 }
109
110 @Override
111 public boolean performFinish() {
112 return fFetchLogRemotePage.finish();
113 }
114
115 @Override
116 public boolean performCancel() {
117 fFetchLogRemotePage.cancel();
118 return super.performCancel();
119 }
120
121 @Override
122 public boolean canFinish() {
123 if (fFetchLogWizardPage != null) {
124 return fFetchLogWizardPage.canFlipToNextPage();
125 }
126 return super.canFinish();
127 }
128 }
This page took 0.032383 seconds and 5 git commands to generate.