1 /*******************************************************************************
2 * Copyright (c) 2016 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 * Bernd Hufmann - Initial API and implementation
11 *******************************************************************************/
12 package org
.eclipse
.tracecompass
.internal
.tmf
.remote
.ui
.wizards
.fetch
;
14 import java
.util
.List
;
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
;
31 * Wizard for remote fetching of logs and traces.
33 public class RemoteFetchLogWizard
extends Wizard
implements IImportWizard
{
35 // ------------------------------------------------------------------------
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$
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
45 private IStructuredSelection fSelection
;
46 private RemoteFetchLogWizardPage fFetchLogWizardPage
;
47 private RemoteFetchLogWizardRemotePage fFetchLogRemotePage
;
49 private @Nullable RemoteImportProfileElement fRemoteProfile
= null;
50 private @Nullable String fExperimentName
= null;
52 // ------------------------------------------------------------------------
54 // ------------------------------------------------------------------------
56 * Standard constructor
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
);
65 setDialogSettings(section
);
69 * Create wizard with pre-defined remote profile
72 * @param experimentName
73 * A name of an experiment to create and add traces to, or null
76 public RemoteFetchLogWizard(@NonNull RemoteImportProfileElement profile
, @Nullable String experimentName
) {
78 fRemoteProfile
= profile
;
79 fExperimentName
= experimentName
;
82 // ------------------------------------------------------------------------
84 // ------------------------------------------------------------------------
86 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
87 fSelection
= selection
;
89 List
<?
> selectedResources
= IDE
.computeSelectedResources(selection
);
90 if (!selectedResources
.isEmpty()) {
91 fSelection
= new StructuredSelection(selectedResources
);
94 setWindowTitle(RemoteMessages
.RemoteFetchLogWizard_Title
);
95 setDefaultPageImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(PLUGIN_ID
, ICON_PATH
));
96 setNeedsProgressMonitor(true);
100 public void addPages() {
102 if (fRemoteProfile
== null) {
103 fFetchLogWizardPage
= new RemoteFetchLogWizardPage(RemoteMessages
.RemoteFetchLogWizardPage_Title
, fSelection
);
104 addPage(fFetchLogWizardPage
);
106 fFetchLogRemotePage
= new RemoteFetchLogWizardRemotePage(RemoteMessages
.RemoteFetchLogWizardRemotePage_Title
, fSelection
, fRemoteProfile
, fExperimentName
);
107 addPage(fFetchLogRemotePage
);
111 public boolean performFinish() {
112 return fFetchLogRemotePage
.finish();
116 public boolean performCancel() {
117 fFetchLogRemotePage
.cancel();
118 return super.performCancel();
122 public boolean canFinish() {
123 if (fFetchLogWizardPage
!= null) {
124 return fFetchLogWizardPage
.canFlipToNextPage();
126 return super.canFinish();