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