1 /*******************************************************************************
2 * Copyright (c) 2015 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;
51 // ------------------------------------------------------------------------
53 // ------------------------------------------------------------------------
55 * Standard constructor
57 public RemoteFetchLogWizard() {
58 IDialogSettings workbenchSettings
= Activator
.getDefault().getDialogSettings();
59 IDialogSettings section
= workbenchSettings
60 .getSection(FETCH_LOG_WIZARD
);
61 if (section
== null) {
62 section
= workbenchSettings
.addNewSection(FETCH_LOG_WIZARD
);
64 setDialogSettings(section
);
68 * Create wizard with pre-defined remote profile
72 public RemoteFetchLogWizard(@NonNull RemoteImportProfileElement profile
) {
74 fRemoteProfile
= profile
;
77 // ------------------------------------------------------------------------
79 // ------------------------------------------------------------------------
81 public void init(IWorkbench workbench
, IStructuredSelection selection
) {
82 fSelection
= selection
;
84 List
<?
> selectedResources
= IDE
.computeSelectedResources(selection
);
85 if (!selectedResources
.isEmpty()) {
86 fSelection
= new StructuredSelection(selectedResources
);
89 setWindowTitle(RemoteMessages
.RemoteFetchLogWizard_Title
);
90 setDefaultPageImageDescriptor(AbstractUIPlugin
.imageDescriptorFromPlugin(PLUGIN_ID
, ICON_PATH
));
91 setNeedsProgressMonitor(true);
95 public void addPages() {
97 if (fRemoteProfile
== null) {
98 fFetchLogWizardPage
= new RemoteFetchLogWizardPage(RemoteMessages
.RemoteFetchLogWizardPage_Title
, fSelection
);
99 addPage(fFetchLogWizardPage
);
101 fFetchLogRemotePage
= new RemoteFetchLogWizardRemotePage(RemoteMessages
.RemoteFetchLogWizardRemotePage_Title
, fSelection
, fRemoteProfile
);
102 addPage(fFetchLogRemotePage
);
106 public boolean performFinish() {
107 return fFetchLogRemotePage
.finish();
111 public boolean performCancel() {
112 fFetchLogRemotePage
.cancel();
113 return super.performCancel();
117 public boolean canFinish() {
118 if (fFetchLogWizardPage
!= null) {
119 return fFetchLogWizardPage
.canFlipToNextPage();
121 return super.canFinish();