13dc2b2f9850f9466e75220a6c25f63befaa11cb
[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) 2015 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
51 // ------------------------------------------------------------------------
52 // Constructor(s)
53 // ------------------------------------------------------------------------
54 /**
55 * Standard constructor
56 */
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);
63 }
64 setDialogSettings(section);
65 }
66
67 /**
68 * Create wizard with pre-defined remote profile
69 * @param profile
70 * a remote profile
71 */
72 public RemoteFetchLogWizard(@NonNull RemoteImportProfileElement profile) {
73 this();
74 fRemoteProfile = profile;
75 }
76
77 // ------------------------------------------------------------------------
78 // Operations
79 // ------------------------------------------------------------------------
80 @Override
81 public void init(IWorkbench workbench, IStructuredSelection selection) {
82 fSelection = selection;
83
84 List<?> selectedResources = IDE.computeSelectedResources(selection);
85 if (!selectedResources.isEmpty()) {
86 fSelection = new StructuredSelection(selectedResources);
87 }
88
89 setWindowTitle(RemoteMessages.RemoteFetchLogWizard_Title);
90 setDefaultPageImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, ICON_PATH));
91 setNeedsProgressMonitor(true);
92 }
93
94 @Override
95 public void addPages() {
96 super.addPages();
97 if (fRemoteProfile == null) {
98 fFetchLogWizardPage = new RemoteFetchLogWizardPage(RemoteMessages.RemoteFetchLogWizardPage_Title, fSelection);
99 addPage(fFetchLogWizardPage);
100 }
101 fFetchLogRemotePage = new RemoteFetchLogWizardRemotePage(RemoteMessages.RemoteFetchLogWizardRemotePage_Title, fSelection, fRemoteProfile);
102 addPage(fFetchLogRemotePage);
103 }
104
105 @Override
106 public boolean performFinish() {
107 return fFetchLogRemotePage.finish();
108 }
109
110 @Override
111 public boolean performCancel() {
112 fFetchLogRemotePage.cancel();
113 return super.performCancel();
114 }
115
116 @Override
117 public boolean canFinish() {
118 if (fFetchLogWizardPage != null) {
119 return fFetchLogWizardPage.canFlipToNextPage();
120 }
121 return super.canFinish();
122 }
123 }
This page took 0.033931 seconds and 5 git commands to generate.