Commit | Line | Data |
---|---|---|
a0a88f65 | 1 | /******************************************************************************* |
60ae41e1 | 2 | * Copyright (c) 2010, 2014 Ericsson |
a0a88f65 AM |
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: | |
f6aa55e2 | 10 | * Patrick Tasse - Initial API and implementation |
a0a88f65 AM |
11 | *******************************************************************************/ |
12 | ||
be222f56 PT |
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; | |
47aafe74 | 18 | import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTxtTraceDefinition; |
be222f56 PT |
19 | import org.eclipse.ui.INewWizard; |
20 | import org.eclipse.ui.IWorkbench; | |
21 | ||
a0a88f65 AM |
22 | /** |
23 | * Wizard for custom text trace parsers. | |
24 | * | |
f6aa55e2 | 25 | * @author Patrick Tasse |
a0a88f65 | 26 | */ |
be222f56 PT |
27 | public class CustomTxtParserWizard extends Wizard implements INewWizard { |
28 | ||
29 | CustomTxtParserInputWizardPage inputPage; | |
30 | CustomTxtParserOutputWizardPage outputPage; | |
31 | private ISelection selection; | |
32 | CustomTxtTraceDefinition definition; | |
332527a4 | 33 | String initialCategoryName; |
391a0796 | 34 | String initialDefinitionName; |
be222f56 | 35 | |
a0a88f65 AM |
36 | /** |
37 | * Default constructor | |
38 | */ | |
be222f56 PT |
39 | public CustomTxtParserWizard() { |
40 | super(); | |
41 | } | |
42 | ||
a0a88f65 AM |
43 | /** |
44 | * Constructor | |
45 | * | |
46 | * @param definition | |
47 | * The trace definition | |
48 | */ | |
be222f56 PT |
49 | public CustomTxtParserWizard(CustomTxtTraceDefinition definition) { |
50 | super(); | |
51 | this.definition = definition; | |
332527a4 PT |
52 | if (definition != null) { |
53 | initialCategoryName = definition.categoryName; | |
54 | initialDefinitionName = definition.definitionName; | |
55 | } | |
be222f56 PT |
56 | } |
57 | ||
58 | @Override | |
59 | public boolean performFinish() { | |
60 | CustomTxtTraceDefinition def = outputPage.getDefinition(); | |
332527a4 PT |
61 | if (definition != null && (!initialCategoryName.equals(def.categoryName) || |
62 | !initialDefinitionName.equals(def.definitionName))) { | |
63 | CustomTxtTraceDefinition.delete(initialCategoryName, initialDefinitionName); | |
be222f56 PT |
64 | } |
65 | def.save(); | |
66 | return true; | |
67 | } | |
68 | ||
be222f56 | 69 | @Override |
a0a88f65 | 70 | public void addPages() { |
be222f56 PT |
71 | inputPage = new CustomTxtParserInputWizardPage(selection, definition); |
72 | addPage(inputPage); | |
73 | outputPage = new CustomTxtParserOutputWizardPage(this); | |
74 | addPage(outputPage); | |
75 | } | |
76 | ||
a0a88f65 | 77 | @Override |
3dca7aa5 AM |
78 | public void init(IWorkbench workbench, IStructuredSelection sel) { |
79 | this.selection = sel; | |
be222f56 PT |
80 | } |
81 | ||
82 | } |