| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2013 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 | * Patrick Tassé - Initial API and implementation |
| 11 | *******************************************************************************/ |
| 12 | |
| 13 | package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards; |
| 14 | |
| 15 | import org.eclipse.jface.viewers.ISelection; |
| 16 | import org.eclipse.jface.viewers.IStructuredSelection; |
| 17 | import org.eclipse.jface.wizard.Wizard; |
| 18 | import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTxtTraceDefinition; |
| 19 | import org.eclipse.ui.INewWizard; |
| 20 | import org.eclipse.ui.IWorkbench; |
| 21 | |
| 22 | /** |
| 23 | * Wizard for custom text trace parsers. |
| 24 | * |
| 25 | * @author Patrick Tassé |
| 26 | */ |
| 27 | public class CustomTxtParserWizard extends Wizard implements INewWizard { |
| 28 | |
| 29 | CustomTxtParserInputWizardPage inputPage; |
| 30 | CustomTxtParserOutputWizardPage outputPage; |
| 31 | private ISelection selection; |
| 32 | CustomTxtTraceDefinition definition; |
| 33 | |
| 34 | /** |
| 35 | * Default constructor |
| 36 | */ |
| 37 | public CustomTxtParserWizard() { |
| 38 | super(); |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * Constructor |
| 43 | * |
| 44 | * @param definition |
| 45 | * The trace definition |
| 46 | */ |
| 47 | public CustomTxtParserWizard(CustomTxtTraceDefinition definition) { |
| 48 | super(); |
| 49 | this.definition = definition; |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public boolean performFinish() { |
| 54 | CustomTxtTraceDefinition def = outputPage.getDefinition(); |
| 55 | if (definition != null && !definition.definitionName.equals(def.definitionName)) { |
| 56 | CustomTxtTraceDefinition.delete(definition.definitionName); |
| 57 | } |
| 58 | def.save(); |
| 59 | return true; |
| 60 | } |
| 61 | |
| 62 | @Override |
| 63 | public void addPages() { |
| 64 | inputPage = new CustomTxtParserInputWizardPage(selection, definition); |
| 65 | addPage(inputPage); |
| 66 | outputPage = new CustomTxtParserOutputWizardPage(this); |
| 67 | addPage(outputPage); |
| 68 | } |
| 69 | |
| 70 | @Override |
| 71 | public void init(IWorkbench workbench, IStructuredSelection sel) { |
| 72 | this.selection = sel; |
| 73 | } |
| 74 | |
| 75 | } |