| 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.jface.dialogs.IDialogSettings; |
| 17 | import org.eclipse.jface.viewers.IStructuredSelection; |
| 18 | import org.eclipse.jface.viewers.StructuredSelection; |
| 19 | import org.eclipse.jface.wizard.Wizard; |
| 20 | import org.eclipse.tracecompass.internal.tmf.remote.ui.Activator; |
| 21 | import org.eclipse.tracecompass.internal.tmf.remote.ui.messages.RemoteMessages; |
| 22 | import org.eclipse.ui.IImportWizard; |
| 23 | import org.eclipse.ui.IWorkbench; |
| 24 | import org.eclipse.ui.ide.IDE; |
| 25 | import org.eclipse.ui.plugin.AbstractUIPlugin; |
| 26 | |
| 27 | /** |
| 28 | * Wizard for remote fetching of logs and traces. |
| 29 | */ |
| 30 | public class RemoteFetchLogWizard extends Wizard implements IImportWizard { |
| 31 | |
| 32 | // ------------------------------------------------------------------------ |
| 33 | // Constants |
| 34 | // ------------------------------------------------------------------------ |
| 35 | private static final String FETCH_LOG_WIZARD = "RemoteFetchLogWizard"; //$NON-NLS-1$ |
| 36 | private static final String PLUGIN_ID = Activator.PLUGIN_ID; |
| 37 | private static final String ICON_PATH = "icons/elcl16/fetch_log_wiz.gif"; //$NON-NLS-1$ |
| 38 | |
| 39 | // ------------------------------------------------------------------------ |
| 40 | // Attributes |
| 41 | // ------------------------------------------------------------------------ |
| 42 | private IStructuredSelection fSelection; |
| 43 | private RemoteFetchLogWizardPage fFetchLogWizardPage; |
| 44 | private RemoteFetchLogWizardRemotePage fFetchLogRemotePage; |
| 45 | |
| 46 | // ------------------------------------------------------------------------ |
| 47 | // Constructor(s) |
| 48 | // ------------------------------------------------------------------------ |
| 49 | /** |
| 50 | * Standard constructor |
| 51 | */ |
| 52 | public RemoteFetchLogWizard() { |
| 53 | IDialogSettings workbenchSettings = Activator.getDefault().getDialogSettings(); |
| 54 | IDialogSettings section = workbenchSettings |
| 55 | .getSection(FETCH_LOG_WIZARD); |
| 56 | if (section == null) { |
| 57 | section = workbenchSettings.addNewSection(FETCH_LOG_WIZARD); |
| 58 | } |
| 59 | setDialogSettings(section); |
| 60 | } |
| 61 | |
| 62 | // ------------------------------------------------------------------------ |
| 63 | // Operations |
| 64 | // ------------------------------------------------------------------------ |
| 65 | @Override |
| 66 | public void init(IWorkbench workbench, IStructuredSelection selection) { |
| 67 | fSelection = selection; |
| 68 | |
| 69 | List<?> selectedResources = IDE.computeSelectedResources(selection); |
| 70 | if (!selectedResources.isEmpty()) { |
| 71 | fSelection = new StructuredSelection(selectedResources); |
| 72 | } |
| 73 | |
| 74 | setWindowTitle(RemoteMessages.RemoteFetchLogWizard_Title); |
| 75 | setDefaultPageImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(PLUGIN_ID, ICON_PATH)); |
| 76 | setNeedsProgressMonitor(true); |
| 77 | } |
| 78 | |
| 79 | @Override |
| 80 | public void addPages() { |
| 81 | super.addPages(); |
| 82 | fFetchLogWizardPage = new RemoteFetchLogWizardPage(RemoteMessages.RemoteFetchLogWizardPage_Title, fSelection); |
| 83 | addPage(fFetchLogWizardPage); |
| 84 | fFetchLogRemotePage = new RemoteFetchLogWizardRemotePage(RemoteMessages.RemoteFetchLogWizardRemotePage_Title, fSelection); |
| 85 | addPage(fFetchLogRemotePage); |
| 86 | } |
| 87 | |
| 88 | @Override |
| 89 | public boolean performFinish() { |
| 90 | return fFetchLogRemotePage.finish(); |
| 91 | } |
| 92 | |
| 93 | @Override |
| 94 | public boolean performCancel() { |
| 95 | fFetchLogRemotePage.cancel(); |
| 96 | return super.performCancel(); |
| 97 | } |
| 98 | |
| 99 | @Override |
| 100 | public boolean canFinish() { |
| 101 | return fFetchLogWizardPage.canFlipToNextPage(); |
| 102 | } |
| 103 | |
| 104 | } |