tmf: Move plugins to their own sub-directory
[deliverable/tracecompass.git] / tmf / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / internal / tmf / ui / parsers / wizards / CustomXmlParserWizard.java
1 /*******************************************************************************
2 * Copyright (c) 2010, 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 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
12
13 package org.eclipse.tracecompass.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.tracecompass.internal.tmf.ui.parsers.CustomParserUtils;
19 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTrace;
20 import org.eclipse.tracecompass.tmf.core.parsers.custom.CustomXmlTraceDefinition;
21 import org.eclipse.ui.INewWizard;
22 import org.eclipse.ui.IWorkbench;
23
24 /**
25 * Wizard for custom XML trace parsers.
26 *
27 * @author Patrick Tasse
28 */
29 public class CustomXmlParserWizard extends Wizard implements INewWizard {
30
31 CustomXmlParserInputWizardPage inputPage;
32 CustomXmlParserOutputWizardPage outputPage;
33 private ISelection selection;
34 CustomXmlTraceDefinition definition;
35 String initialCategoryName;
36 String initialDefinitionName;
37
38 /**
39 * Default constructor
40 */
41 public CustomXmlParserWizard() {
42 super();
43 }
44
45 /**
46 * Constructor
47 *
48 * @param definition
49 * The trace definition
50 */
51 public CustomXmlParserWizard(CustomXmlTraceDefinition definition) {
52 super();
53 this.definition = definition;
54 if (definition != null) {
55 initialCategoryName = definition.categoryName;
56 initialDefinitionName = definition.definitionName;
57 }
58 }
59
60 @Override
61 public boolean performFinish() {
62 CustomXmlTraceDefinition def = outputPage.getDefinition();
63 if (definition != null) {
64 if (!initialCategoryName.equals(def.categoryName) || !initialDefinitionName.equals(def.definitionName)) {
65 CustomXmlTraceDefinition.delete(initialCategoryName, initialDefinitionName);
66 }
67 CustomParserUtils.cleanup(CustomXmlTrace.buildTraceTypeId(initialCategoryName, initialDefinitionName));
68 }
69 def.save();
70 return true;
71 }
72
73 /**
74 * Adding the page to the wizard.
75 */
76
77 @Override
78 public void addPages() {
79 inputPage = new CustomXmlParserInputWizardPage(selection, definition);
80 addPage(inputPage);
81 outputPage = new CustomXmlParserOutputWizardPage(this);
82 addPage(outputPage);
83 }
84
85 @Override
86 public void init(IWorkbench workbench, IStructuredSelection sel) {
87 this.selection = sel;
88 }
89
90 }
This page took 0.033202 seconds and 5 git commands to generate.