Commit | Line | Data |
---|---|---|
417a4110 | 1 | /******************************************************************************* |
150ae90e | 2 | * Copyright (c) 2016 Ericsson |
417a4110 BH |
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 | ||
b9c84b9c BH |
16 | import org.eclipse.jdt.annotation.NonNull; |
17 | import org.eclipse.jdt.annotation.Nullable; | |
417a4110 BH |
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; | |
b9c84b9c | 24 | import org.eclipse.tracecompass.internal.tmf.remote.ui.wizards.fetch.model.RemoteImportProfileElement; |
417a4110 BH |
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$ | |
abbc1d7e BH |
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$ | |
417a4110 BH |
41 | |
42 | // ------------------------------------------------------------------------ | |
43 | // Attributes | |
44 | // ------------------------------------------------------------------------ | |
45 | private IStructuredSelection fSelection; | |
46 | private RemoteFetchLogWizardPage fFetchLogWizardPage; | |
47 | private RemoteFetchLogWizardRemotePage fFetchLogRemotePage; | |
48 | ||
b9c84b9c | 49 | private @Nullable RemoteImportProfileElement fRemoteProfile = null; |
150ae90e | 50 | private @Nullable String fExperimentName = null; |
b9c84b9c | 51 | |
417a4110 BH |
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 | ||
b9c84b9c BH |
68 | /** |
69 | * Create wizard with pre-defined remote profile | |
70 | * @param profile | |
71 | * a remote profile | |
150ae90e BH |
72 | * @param experimentName |
73 | * A name of an experiment to create and add traces to, or null | |
74 | * for no experiment | |
b9c84b9c | 75 | */ |
150ae90e | 76 | public RemoteFetchLogWizard(@NonNull RemoteImportProfileElement profile, @Nullable String experimentName) { |
b9c84b9c BH |
77 | this(); |
78 | fRemoteProfile = profile; | |
150ae90e | 79 | fExperimentName = experimentName; |
b9c84b9c BH |
80 | } |
81 | ||
417a4110 BH |
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(); | |
b9c84b9c BH |
102 | if (fRemoteProfile == null) { |
103 | fFetchLogWizardPage = new RemoteFetchLogWizardPage(RemoteMessages.RemoteFetchLogWizardPage_Title, fSelection); | |
104 | addPage(fFetchLogWizardPage); | |
105 | } | |
150ae90e | 106 | fFetchLogRemotePage = new RemoteFetchLogWizardRemotePage(RemoteMessages.RemoteFetchLogWizardRemotePage_Title, fSelection, fRemoteProfile, fExperimentName); |
417a4110 BH |
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() { | |
b9c84b9c BH |
123 | if (fFetchLogWizardPage != null) { |
124 | return fFetchLogWizardPage.canFlipToNextPage(); | |
125 | } | |
126 | return super.canFinish(); | |
417a4110 | 127 | } |
417a4110 | 128 | } |