Merge branch 'master' into lttng-kepler
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / parsers / wizards / CustomXmlParserInputWizardPage.java
index 11c6eb1c19629800b7620e5d8aaa57bd2731f584..58aa11eebcb433b72238160efcdd04790ff2711f 100644 (file)
-package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;\r
-\r
-import java.io.BufferedReader;\r
-import java.io.ByteArrayInputStream;\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.io.InputStreamReader;\r
-import java.text.ParseException;\r
-import java.text.SimpleDateFormat;\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.List;\r
-\r
-import javax.xml.parsers.DocumentBuilder;\r
-import javax.xml.parsers.DocumentBuilderFactory;\r
-import javax.xml.parsers.ParserConfigurationException;\r
-\r
-import org.eclipse.core.resources.IFile;\r
-import org.eclipse.core.runtime.CoreException;\r
-import org.eclipse.jface.viewers.AbstractTreeViewer;\r
-import org.eclipse.jface.viewers.ColumnLabelProvider;\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.jface.viewers.ISelectionChangedListener;\r
-import org.eclipse.jface.viewers.IStructuredSelection;\r
-import org.eclipse.jface.viewers.ITreeContentProvider;\r
-import org.eclipse.jface.viewers.SelectionChangedEvent;\r
-import org.eclipse.jface.viewers.StructuredSelection;\r
-import org.eclipse.jface.viewers.TreeViewer;\r
-import org.eclipse.jface.viewers.Viewer;\r
-import org.eclipse.jface.wizard.WizardPage;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Activator;\r
-import org.eclipse.linuxtools.internal.tmf.ui.Messages;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputAttribute;\r
-import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputElement;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.browser.Browser;\r
-import org.eclipse.swt.browser.TitleEvent;\r
-import org.eclipse.swt.browser.TitleListener;\r
-import org.eclipse.swt.custom.SashForm;\r
-import org.eclipse.swt.custom.ScrolledComposite;\r
-import org.eclipse.swt.custom.StyleRange;\r
-import org.eclipse.swt.custom.StyledText;\r
-import org.eclipse.swt.events.ModifyEvent;\r
-import org.eclipse.swt.events.ModifyListener;\r
-import org.eclipse.swt.events.SelectionAdapter;\r
-import org.eclipse.swt.events.SelectionEvent;\r
-import org.eclipse.swt.events.SelectionListener;\r
-import org.eclipse.swt.graphics.Color;\r
-import org.eclipse.swt.graphics.Font;\r
-import org.eclipse.swt.graphics.FontData;\r
-import org.eclipse.swt.graphics.Image;\r
-import org.eclipse.swt.layout.FillLayout;\r
-import org.eclipse.swt.layout.GridData;\r
-import org.eclipse.swt.layout.GridLayout;\r
-import org.eclipse.swt.widgets.Button;\r
-import org.eclipse.swt.widgets.Combo;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Display;\r
-import org.eclipse.swt.widgets.Group;\r
-import org.eclipse.swt.widgets.Label;\r
-import org.eclipse.swt.widgets.Shell;\r
-import org.eclipse.swt.widgets.Text;\r
-import org.w3c.dom.Document;\r
-import org.w3c.dom.Element;\r
-import org.w3c.dom.NamedNodeMap;\r
-import org.w3c.dom.Node;\r
-import org.w3c.dom.NodeList;\r
-import org.xml.sax.EntityResolver;\r
-import org.xml.sax.ErrorHandler;\r
-import org.xml.sax.InputSource;\r
-import org.xml.sax.SAXException;\r
-import org.xml.sax.SAXParseException;\r
-\r
-public class CustomXmlParserInputWizardPage extends WizardPage {\r
-\r
-    private static final String DEFAULT_TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$\r
-    private static final String SIMPLE_DATE_FORMAT_URL = "http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html#skip-navbar_top"; //$NON-NLS-1$\r
-    private static final Image elementImage = Activator.getDefault().getImageFromPath("/icons/elcl16/element_icon.gif"); //$NON-NLS-1$\r
-    private static final Image addImage = Activator.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$\r
-    private static final Image addNextImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addnext_button.gif"); //$NON-NLS-1$\r
-    private static final Image addChildImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addchild_button.gif"); //$NON-NLS-1$\r
-    private static final Image addManyImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addmany_button.gif"); //$NON-NLS-1$\r
-    private static final Image deleteImage = Activator.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$\r
-    private static final Image moveUpImage = Activator.getDefault().getImageFromPath("/icons/elcl16/moveup_button.gif"); //$NON-NLS-1$\r
-    private static final Image moveDownImage = Activator.getDefault().getImageFromPath("/icons/elcl16/movedown_button.gif"); //$NON-NLS-1$\r
-    private static final Image helpImage = Activator.getDefault().getImageFromPath("/icons/elcl16/help_button.gif"); //$NON-NLS-1$\r
-    private static final Color COLOR_LIGHT_RED = new Color(Display.getDefault(), 255, 192, 192);\r
-    private static final Color COLOR_TEXT_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);\r
-    private static final Color COLOR_WIDGET_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);\r
-\r
-    private final ISelection selection;\r
-    private CustomXmlTraceDefinition definition;\r
-    private String editDefinitionName;\r
-    private String defaultDescription;\r
-    private ElementNode selectedElement;\r
-    private Composite container;\r
-    private Text logtypeText;\r
-    private Text timeStampOutputFormatText;\r
-    private Text timeStampPreviewText;\r
-    private Button removeButton;\r
-    private Button addChildButton;\r
-    private Button addNextButton;\r
-    private Button moveUpButton;\r
-    private Button moveDownButton;\r
-    private Button feelingLuckyButton;\r
-    private ScrolledComposite treeScrolledComposite;\r
-    private ScrolledComposite elementScrolledComposite;\r
-    private TreeViewer treeViewer;\r
-    private Composite treeContainer;\r
-    private Composite elementContainer;\r
-    private Text errorText;\r
-    private StyledText inputText;\r
-    private Font fixedFont;\r
-    private UpdateListener updateListener;\r
-    private Browser helpBrowser;\r
-    private Element documentElement;\r
-\r
-    // variables used recursively through element traversal\r
-    private String timeStampValue;\r
-    private String timeStampFormat;\r
-    private boolean timeStampFound;\r
-    private int logEntriesCount;\r
-    private boolean logEntryFound;\r
-\r
-    protected CustomXmlParserInputWizardPage(ISelection selection, CustomXmlTraceDefinition definition) {\r
-        super("CustomXmlParserWizardPage"); //$NON-NLS-1$\r
-        if (definition == null) {\r
-            setTitle(Messages.CustomXmlParserInputWizardPage_titleNew);\r
-            defaultDescription = Messages.CustomXmlParserInputWizardPage_descriptionNew;\r
-        } else {\r
-            setTitle(Messages.CustomXmlParserInputWizardPage_titleEdit);\r
-            defaultDescription = Messages.CustomXmlParserInputWizardPage_descriptionEdit;\r
-        }\r
-        setDescription(defaultDescription);\r
-        this.selection = selection;\r
-        this.definition = definition;\r
-        if (definition != null) {\r
-            this.editDefinitionName = definition.definitionName;\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void createControl(Composite parent) {\r
-        container = new Composite(parent, SWT.NULL);\r
-        container.setLayout(new GridLayout());\r
-\r
-        updateListener = new UpdateListener();\r
-\r
-        Composite headerComposite = new Composite(container, SWT.FILL);\r
-        GridLayout headerLayout = new GridLayout(5, false);\r
-        headerLayout.marginHeight = 0;\r
-        headerLayout.marginWidth = 0;\r
-        headerComposite.setLayout(headerLayout);\r
-        headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-        Label logtypeLabel = new Label(headerComposite, SWT.NULL);\r
-        logtypeLabel.setText(Messages.CustomXmlParserInputWizardPage_logType);\r
-\r
-        logtypeText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);\r
-        logtypeText.setLayoutData(new GridData(120, SWT.DEFAULT));\r
-\r
-        Label timeStampFormatLabel = new Label(headerComposite, SWT.NULL);\r
-        timeStampFormatLabel.setText(Messages.CustomXmlParserInputWizardPage_timestampFormat);\r
-\r
-        timeStampOutputFormatText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);\r
-        timeStampOutputFormatText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-        timeStampOutputFormatText.setText(DEFAULT_TIMESTAMP_FORMAT);\r
-\r
-        Button dateFormatHelpButton = new Button(headerComposite, SWT.PUSH);\r
-        dateFormatHelpButton.setImage(helpImage);\r
-        dateFormatHelpButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_dateFormatHelp);\r
-        dateFormatHelpButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                openHelpShell(SIMPLE_DATE_FORMAT_URL);\r
-            }\r
-        });\r
-\r
-        Label timeStampPreviewLabel = new Label(headerComposite, SWT.NULL);\r
-        timeStampPreviewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 3, 1));\r
-        timeStampPreviewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);\r
-\r
-        timeStampPreviewText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);\r
-        timeStampPreviewText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));\r
-        timeStampPreviewText.setText("*no time stamp element or attribute*"); //$NON-NLS-1$\r
-\r
-        createButtonBar();\r
-\r
-        SashForm vSash = new SashForm(container, SWT.VERTICAL);\r
-        vSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        vSash.setBackground(vSash.getDisplay().getSystemColor(SWT.COLOR_GRAY));\r
-\r
-        SashForm hSash = new SashForm(vSash, SWT.HORIZONTAL);\r
-        hSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-\r
-        treeScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL | SWT.H_SCROLL);\r
-        treeScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        treeContainer = new Composite(treeScrolledComposite, SWT.NONE);\r
-        treeContainer.setLayout(new FillLayout());\r
-        treeScrolledComposite.setContent(treeContainer);\r
-        treeScrolledComposite.setExpandHorizontal(true);\r
-        treeScrolledComposite.setExpandVertical(true);\r
-\r
-        treeViewer = new TreeViewer(treeContainer, SWT.SINGLE | SWT.BORDER);\r
-        treeViewer.setContentProvider(new InputElementTreeNodeContentProvider());\r
-        treeViewer.setLabelProvider(new InputElementTreeLabelProvider());\r
-        treeViewer.addSelectionChangedListener(new InputElementTreeSelectionChangedListener());\r
-        treeContainer.layout();\r
-\r
-        treeScrolledComposite\r
-                .setMinSize(treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);\r
-\r
-        elementScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL);\r
-        elementScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));\r
-        elementContainer = new Composite(elementScrolledComposite, SWT.NONE);\r
-        GridLayout gl = new GridLayout();\r
-        gl.marginHeight = 1;\r
-        gl.marginWidth = 0;\r
-        elementContainer.setLayout(gl);\r
-        elementScrolledComposite.setContent(elementContainer);\r
-        elementScrolledComposite.setExpandHorizontal(true);\r
-        elementScrolledComposite.setExpandVertical(true);\r
-\r
-        if (definition == null) {\r
-            definition = new CustomXmlTraceDefinition();\r
-        }\r
-        loadDefinition(definition);\r
-        treeViewer.expandAll();\r
-        elementContainer.layout();\r
-\r
-        logtypeText.addModifyListener(updateListener);\r
-        timeStampOutputFormatText.addModifyListener(updateListener);\r
-\r
-        elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,\r
-                elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);\r
-\r
-        hSash.setWeights(new int[] { 1, 2 });\r
-\r
-        if (definition.rootInputElement == null) {\r
-            removeButton.setEnabled(false);\r
-            addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentElement);\r
-            addNextButton.setEnabled(false);\r
-            moveUpButton.setEnabled(false);\r
-            moveDownButton.setEnabled(false);\r
-        } else { // root is selected\r
-            addNextButton.setEnabled(false);\r
-        }\r
-\r
-        Composite sashBottom = new Composite(vSash, SWT.NONE);\r
-        GridLayout sashBottomLayout = new GridLayout(2, false);\r
-        sashBottomLayout.marginHeight = 0;\r
-        sashBottomLayout.marginWidth = 0;\r
-        sashBottom.setLayout(sashBottomLayout);\r
-\r
-        Label previewLabel = new Label(sashBottom, SWT.NULL);\r
-        previewLabel.setText(Messages.CustomXmlParserInputWizardPage_previewInput);\r
-\r
-        errorText = new Text(sashBottom, SWT.SINGLE | SWT.READ_ONLY);\r
-        errorText.setBackground(COLOR_WIDGET_BACKGROUND);\r
-        errorText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-        errorText.setVisible(false);\r
-\r
-        inputText = new StyledText(sashBottom, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);\r
-        if (fixedFont == null) {\r
-            if (System.getProperty("os.name").contains("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$\r
-                fixedFont = new Font(Display.getCurrent(), new FontData("Courier New", 10, SWT.NORMAL)); //$NON-NLS-1$\r
-            } else {\r
-                fixedFont = new Font(Display.getCurrent(), new FontData("Monospace", 10, SWT.NORMAL)); //$NON-NLS-1$\r
-            }\r
-        }\r
-        inputText.setFont(fixedFont);\r
-        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);\r
-        gd.heightHint = inputText.computeSize(SWT.DEFAULT, inputText.getLineHeight() * 4).y;\r
-        gd.widthHint = 800;\r
-        inputText.setLayoutData(gd);\r
-        inputText.setText(getSelectionText());\r
-        inputText.addModifyListener(new ModifyListener() {\r
-            @Override\r
-            public void modifyText(ModifyEvent e) {\r
-                parseXmlInput(inputText.getText());\r
-            }\r
-        });\r
-        inputText.addModifyListener(updateListener);\r
-\r
-        vSash.setWeights(new int[] { hSash.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sashBottom.computeSize(SWT.DEFAULT, SWT.DEFAULT).y });\r
-\r
-        setControl(container);\r
-    }\r
-\r
-    private void createButtonBar() {\r
-        Composite buttonBar = new Composite(container, SWT.NONE);\r
-        GridLayout buttonBarLayout = new GridLayout(6, false);\r
-        buttonBarLayout.marginHeight = 0;\r
-        buttonBarLayout.marginWidth = 0;\r
-        buttonBar.setLayout(buttonBarLayout);\r
-\r
-        removeButton = new Button(buttonBar, SWT.PUSH);\r
-        removeButton.setImage(deleteImage);\r
-        removeButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_removeElement);\r
-        removeButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                if (treeViewer.getSelection().isEmpty() || selectedElement == null) {\r
-                    return;\r
-                }\r
-                removeElement();\r
-                InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                if (inputElement == definition.rootInputElement) {\r
-                    definition.rootInputElement = null;\r
-                } else {\r
-                    inputElement.parentElement.childElements.remove(inputElement);\r
-                }\r
-                treeViewer.refresh();\r
-                validate();\r
-                updatePreviews();\r
-                removeButton.setEnabled(false);\r
-                if (definition.rootInputElement == null) {\r
-                    addChildButton.setEnabled(true);\r
-                    addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentEleemnt);\r
-                } else {\r
-                    addChildButton.setEnabled(false);\r
-                }\r
-                addNextButton.setEnabled(false);\r
-                moveUpButton.setEnabled(false);\r
-                moveDownButton.setEnabled(false);\r
-            }\r
-        });\r
-\r
-        addChildButton = new Button(buttonBar, SWT.PUSH);\r
-        addChildButton.setImage(addChildImage);\r
-        addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addChildElement);\r
-        addChildButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                InputElement inputElement = new InputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$\r
-                if (definition.rootInputElement == null) {\r
-                    definition.rootInputElement = inputElement;\r
-                    inputElement.elementName = getChildNameSuggestion(null);\r
-                } else if (treeViewer.getSelection().isEmpty()) {\r
-                    return;\r
-                } else {\r
-                    InputElement parentInputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                    parentInputElement.addChild(inputElement);\r
-                    inputElement.elementName = getChildNameSuggestion(parentInputElement);\r
-                }\r
-                treeViewer.refresh();\r
-                treeViewer.setSelection(new StructuredSelection(inputElement), true);\r
-            }\r
-        });\r
-\r
-        addNextButton = new Button(buttonBar, SWT.PUSH);\r
-        addNextButton.setImage(addNextImage);\r
-        addNextButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addNextElement);\r
-        addNextButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                InputElement inputElement = new InputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$\r
-                if (definition.rootInputElement == null) {\r
-                    definition.rootInputElement = inputElement;\r
-                    inputElement.elementName = getChildNameSuggestion(null);\r
-                } else if (treeViewer.getSelection().isEmpty()) {\r
-                    return;\r
-                } else {\r
-                    InputElement previousInputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                    if (previousInputElement == definition.rootInputElement) {\r
-                        return;\r
-                    }\r
-                    previousInputElement.addNext(inputElement);\r
-                    inputElement.elementName = getChildNameSuggestion(inputElement.parentElement);\r
-                }\r
-                treeViewer.refresh();\r
-                treeViewer.setSelection(new StructuredSelection(inputElement), true);\r
-            }\r
-        });\r
-\r
-        feelingLuckyButton = new Button(buttonBar, SWT.PUSH);\r
-        feelingLuckyButton.setImage(addManyImage);\r
-        feelingLuckyButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_feelingLucky);\r
-        feelingLuckyButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                InputElement inputElement = null;\r
-                if (definition.rootInputElement == null) {\r
-                    if (getChildNameSuggestion(null).length() != 0) {\r
-                        inputElement = new InputElement(getChildNameSuggestion(null), false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$\r
-                        definition.rootInputElement = inputElement;\r
-                        feelingLucky(inputElement);\r
-                    } else {\r
-                        return;\r
-                    }\r
-                } else if (treeViewer.getSelection().isEmpty()) {\r
-                    return;\r
-                } else {\r
-                    inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                    feelingLucky(inputElement);\r
-                }\r
-                treeViewer.refresh();\r
-                treeViewer.setSelection(new StructuredSelection(inputElement), true);\r
-                treeViewer.expandToLevel(inputElement, AbstractTreeViewer.ALL_LEVELS);\r
-            }\r
-        });\r
-\r
-        moveUpButton = new Button(buttonBar, SWT.PUSH);\r
-        moveUpButton.setImage(moveUpImage);\r
-        moveUpButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_moveUp);\r
-        moveUpButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                if (treeViewer.getSelection().isEmpty()) {\r
-                    return;\r
-                }\r
-                InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                if (inputElement == definition.rootInputElement) {\r
-                    return;\r
-                }\r
-                inputElement.moveUp();\r
-                treeViewer.refresh();\r
-                validate();\r
-                updatePreviews();\r
-            }\r
-        });\r
-\r
-        moveDownButton = new Button(buttonBar, SWT.PUSH);\r
-        moveDownButton.setImage(moveDownImage);\r
-        moveDownButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_moveDown);\r
-        moveDownButton.addSelectionListener(new SelectionAdapter() {\r
-            @Override\r
-            public void widgetSelected(SelectionEvent e) {\r
-                if (treeViewer.getSelection().isEmpty()) {\r
-                    return;\r
-                }\r
-                InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();\r
-                if (inputElement == definition.rootInputElement) {\r
-                    return;\r
-                }\r
-                inputElement.moveDown();\r
-                treeViewer.refresh();\r
-                validate();\r
-                updatePreviews();\r
-            }\r
-        });\r
-    }\r
-\r
-    private void feelingLucky(InputElement inputElement) {\r
-        while (true) {\r
-            String attributeName = getAttributeNameSuggestion(inputElement);\r
-            if (attributeName.length() == 0) {\r
-                break;\r
-            }\r
-            InputAttribute attribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$\r
-            inputElement.addAttribute(attribute);\r
-        }\r
-        while (true) {\r
-            String childName = getChildNameSuggestion(inputElement);\r
-            if (childName.length() == 0) {\r
-                break;\r
-            }\r
-            InputElement childElement = new InputElement(childName, false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$\r
-            inputElement.addChild(childElement);\r
-            feelingLucky(childElement);\r
-        }\r
-    }\r
-\r
-    private static class InputElementTreeNodeContentProvider implements ITreeContentProvider {\r
-\r
-        @Override\r
-        public Object[] getElements(Object inputElement) {\r
-            CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) inputElement;\r
-            if (def.rootInputElement != null) {\r
-                return new Object[] { def.rootInputElement };\r
-            }\r
-            return new Object[0];\r
-        }\r
-\r
-        @Override\r
-        public Object[] getChildren(Object parentElement) {\r
-            InputElement inputElement = (InputElement) parentElement;\r
-            if (inputElement.childElements == null) {\r
-                return new InputElement[0];\r
-            }\r
-            return inputElement.childElements.toArray();\r
-        }\r
-\r
-        @Override\r
-        public boolean hasChildren(Object element) {\r
-            InputElement inputElement = (InputElement) element;\r
-            return (inputElement.childElements != null && inputElement.childElements.size() > 0);\r
-        }\r
-\r
-        @Override\r
-        public void dispose() {\r
-        }\r
-\r
-        @Override\r
-        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {\r
-        }\r
-\r
-        @Override\r
-        public Object getParent(Object element) {\r
-            InputElement inputElement = (InputElement) element;\r
-            return inputElement.parentElement;\r
-        }\r
-    }\r
-\r
-    private static class InputElementTreeLabelProvider extends ColumnLabelProvider {\r
-\r
-        @Override\r
-        public Image getImage(Object element) {\r
-            return elementImage;\r
-        }\r
-\r
-        @Override\r
-        public String getText(Object element) {\r
-            InputElement inputElement = (InputElement) element;\r
-            return (inputElement.elementName.trim().length() == 0) ? "?" : inputElement.elementName; //$NON-NLS-1$\r
-        }\r
-    }\r
-\r
-    private class InputElementTreeSelectionChangedListener implements ISelectionChangedListener {\r
-        @Override\r
-        public void selectionChanged(SelectionChangedEvent event) {\r
-            if (selectedElement != null) {\r
-                selectedElement.dispose();\r
-            }\r
-            if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) {\r
-                IStructuredSelection selection = (IStructuredSelection) event.getSelection();\r
-                InputElement inputElement = (InputElement) selection.getFirstElement();\r
-                selectedElement = new ElementNode(elementContainer, inputElement);\r
-                elementContainer.layout();\r
-                elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,\r
-                        elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);\r
-                container.layout();\r
-                validate();\r
-                updatePreviews();\r
-                removeButton.setEnabled(true);\r
-                addChildButton.setEnabled(true);\r
-                addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addChildElement);\r
-                if (definition.rootInputElement == inputElement) {\r
-                    addNextButton.setEnabled(false);\r
-                } else {\r
-                    addNextButton.setEnabled(true);\r
-                }\r
-                moveUpButton.setEnabled(true);\r
-                moveDownButton.setEnabled(true);\r
-            } else {\r
-                removeButton.setEnabled(false);\r
-                if (definition.rootInputElement == null) {\r
-                    addChildButton.setEnabled(true);\r
-                    addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentElement);\r
-                } else {\r
-                    addChildButton.setEnabled(false);\r
-                }\r
-                addNextButton.setEnabled(false);\r
-                moveUpButton.setEnabled(false);\r
-                moveDownButton.setEnabled(false);\r
-            }\r
-        }\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see org.eclipse.jface.dialogs.DialogPage#dispose()\r
-     */\r
-    @Override\r
-    public void dispose() {\r
-        if (fixedFont != null) {\r
-            fixedFont.dispose();\r
-            fixedFont = null;\r
-        }\r
-        super.dispose();\r
-    }\r
-\r
-    private void loadDefinition(CustomXmlTraceDefinition def) {\r
-        logtypeText.setText(def.definitionName);\r
-        timeStampOutputFormatText.setText(def.timeStampOutputFormat);\r
-        treeViewer.setInput(def);\r
-\r
-        if (def.rootInputElement != null) {\r
-            treeViewer.setSelection(new StructuredSelection(def.rootInputElement));\r
-        }\r
-    }\r
-\r
-    private String getName(InputElement inputElement) {\r
-        String name = (inputElement.elementName.trim().length() == 0) ? "?" : inputElement.elementName.trim(); //$NON-NLS-1$\r
-        if (inputElement.parentElement == null) {\r
-            return name;\r
-        }\r
-        return getName(inputElement.parentElement) + " : " + name; //$NON-NLS-1$\r
-    }\r
-\r
-    private String getName(InputAttribute inputAttribute, InputElement inputElement) {\r
-        String name = (inputAttribute.attributeName.trim().length() == 0) ? "?" : inputAttribute.attributeName.trim(); //$NON-NLS-1$\r
-        return getName(inputElement) + " : " + name; //$NON-NLS-1$\r
-    }\r
-\r
-    /*\r
-     * (non-Javadoc)\r
-     *\r
-     * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)\r
-     */\r
-    @Override\r
-    public void setVisible(boolean visible) {\r
-        if (visible) {\r
-            validate();\r
-            updatePreviews();\r
-        }\r
-        super.setVisible(visible);\r
-    }\r
-\r
-    public List<String> getInputNames() {\r
-        return getInputNames(definition.rootInputElement);\r
-    }\r
-\r
-    public List<String> getInputNames(InputElement inputElement) {\r
-        List<String> inputs = new ArrayList<String>();\r
-        if (inputElement.inputName != null && !inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {\r
-            String inputName = inputElement.inputName;\r
-            if (!inputs.contains(inputName)) {\r
-                inputs.add(inputName);\r
-            }\r
-        }\r
-        if (inputElement.attributes != null) {\r
-            for (InputAttribute attribute : inputElement.attributes) {\r
-                String inputName = attribute.inputName;\r
-                if (!inputs.contains(inputName)) {\r
-                    inputs.add(inputName);\r
-                }\r
-            }\r
-        }\r
-        if (inputElement.childElements != null) {\r
-            for (InputElement childInputElement : inputElement.childElements) {\r
-                for (String inputName : getInputNames(childInputElement)) {\r
-                    if (!inputs.contains(inputName)) {\r
-                        inputs.add(inputName);\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return inputs;\r
-    }\r
-\r
-    private void removeElement() {\r
-        selectedElement.dispose();\r
-        selectedElement = null;\r
-        elementContainer.layout();\r
-        elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,\r
-                elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);\r
-        container.layout();\r
-    }\r
-\r
-    private String getSelectionText() {\r
-        InputStream inputStream = null;\r
-        if (this.selection instanceof IStructuredSelection) {\r
-            Object selection = ((IStructuredSelection) this.selection).getFirstElement();\r
-            if (selection instanceof IFile) {\r
-                IFile file = (IFile) selection;\r
-                try {\r
-                    inputStream = file.getContents();\r
-                } catch (CoreException e) {\r
-                    return ""; //$NON-NLS-1$\r
-                }\r
-            }\r
-        }\r
-        if (inputStream != null) {\r
-            BufferedReader reader = null;\r
-            try {\r
-                reader = new BufferedReader(new InputStreamReader(inputStream));\r
-                StringBuilder sb = new StringBuilder();\r
-                String line = null;\r
-                while ((line = reader.readLine()) != null) {\r
-                    sb.append(line + "\n"); //$NON-NLS-1$\r
-                }\r
-                parseXmlInput(sb.toString());\r
-                reader.close();\r
-                return sb.toString();\r
-            } catch (IOException e) {\r
-                return ""; //$NON-NLS-1$\r
-            }\r
-        }\r
-        return ""; //$NON-NLS-1$\r
-    }\r
-\r
-    private void parseXmlInput(final String string) {\r
-        try {\r
-            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();\r
-            DocumentBuilder db = dbf.newDocumentBuilder();\r
-\r
-            // The following allows xml parsing without access to the dtd\r
-            EntityResolver resolver = new EntityResolver() {\r
-                @Override\r
-                public InputSource resolveEntity(String publicId, String systemId) {\r
-                    String empty = ""; //$NON-NLS-1$\r
-                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());\r
-                    return new InputSource(bais);\r
-                }\r
-            };\r
-            db.setEntityResolver(resolver);\r
-\r
-            // The following catches xml parsing exceptions\r
-            db.setErrorHandler(new ErrorHandler() {\r
-                @Override\r
-                public void error(SAXParseException saxparseexception) throws SAXException {\r
-                }\r
-\r
-                @Override\r
-                public void warning(SAXParseException saxparseexception) throws SAXException {\r
-                }\r
-\r
-                @Override\r
-                public void fatalError(SAXParseException saxparseexception) throws SAXException {\r
-                    if (string.trim().length() != 0) {\r
-                        errorText.setText(saxparseexception.getMessage());\r
-                        errorText.setBackground(COLOR_LIGHT_RED);\r
-                        errorText.setVisible(true);\r
-                    }\r
-                    throw saxparseexception;\r
-                }\r
-            });\r
-\r
-            errorText.setVisible(false);\r
-            Document doc = null;\r
-            doc = db.parse(new ByteArrayInputStream(string.getBytes()));\r
-            documentElement = doc.getDocumentElement();\r
-        } catch (ParserConfigurationException e) {\r
-            Activator.getDefault().logError("Error pasing XML input string: " + string, e); //$NON-NLS-1$\r
-            documentElement = null;\r
-        } catch (SAXException e) {\r
-            documentElement = null;\r
-        } catch (IOException e) {\r
-            Activator.getDefault().logError("Error pasing XML input string: " + string, e); //$NON-NLS-1$\r
-            documentElement = null;\r
-        }\r
-    }\r
-\r
-    private void updatePreviews() {\r
-        updatePreviews(false);\r
-    }\r
-\r
-    private void initValues() {\r
-        timeStampValue = null;\r
-        timeStampFormat = null;\r
-        logEntriesCount = 0;\r
-        logEntryFound = false;\r
-    }\r
-\r
-    private void updatePreviews(boolean updateAll) {\r
-        if (inputText == null) {\r
-            // early update during construction\r
-            return;\r
-        }\r
-        inputText.setStyleRanges(new StyleRange[] {});\r
-        if (selectedElement == null) {\r
-            return;\r
-        }\r
-\r
-        initValues();\r
-\r
-        selectedElement.updatePreview();\r
-\r
-        if (timeStampValue != null && timeStampFormat != null) {\r
-            try {\r
-                SimpleDateFormat dateFormat = new SimpleDateFormat(timeStampFormat);\r
-                Date date = dateFormat.parse(timeStampValue);\r
-                dateFormat = new SimpleDateFormat(timeStampOutputFormatText.getText().trim());\r
-                timeStampPreviewText.setText(dateFormat.format(date));\r
-            } catch (ParseException e) {\r
-                timeStampPreviewText.setText("*parse exception* [" + timeStampValue + "] <> [" + timeStampFormat + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-            } catch (IllegalArgumentException e) {\r
-                timeStampPreviewText.setText("*parse exception* [Illegal Argument]"); //$NON-NLS-1$\r
-            }\r
-        } else {\r
-            timeStampPreviewText.setText("*no matching time stamp*"); //$NON-NLS-1$\r
-        }\r
-    }\r
-\r
-    private void openHelpShell(String url) {\r
-        if (helpBrowser != null && !helpBrowser.isDisposed()) {\r
-            helpBrowser.getShell().setActive();\r
-            if (!helpBrowser.getUrl().equals(url)) {\r
-                helpBrowser.setUrl(url);\r
-            }\r
-            return;\r
-        }\r
-        final Shell helpShell = new Shell(getShell(), SWT.SHELL_TRIM);\r
-        helpShell.setLayout(new FillLayout());\r
-        helpBrowser = new Browser(helpShell, SWT.NONE);\r
-        helpBrowser.addTitleListener(new TitleListener() {\r
-            @Override\r
-            public void changed(TitleEvent event) {\r
-                helpShell.setText(event.title);\r
-            }\r
-        });\r
-        helpBrowser.setBounds(0, 0, 600, 400);\r
-        helpShell.pack();\r
-        helpShell.open();\r
-        helpBrowser.setUrl(url);\r
-    }\r
-\r
-    private class UpdateListener implements ModifyListener, SelectionListener {\r
-\r
-        @Override\r
-        public void modifyText(ModifyEvent e) {\r
-            validate();\r
-            updatePreviews();\r
-        }\r
-\r
-        @Override\r
-        public void widgetDefaultSelected(SelectionEvent e) {\r
-            validate();\r
-            updatePreviews();\r
-        }\r
-\r
-        @Override\r
-        public void widgetSelected(SelectionEvent e) {\r
-            validate();\r
-            updatePreviews();\r
-        }\r
-\r
-    }\r
-\r
-    private class ElementNode {\r
-        final InputElement inputElement;\r
-        final Group group;\r
-        List<Attribute> attributes = new ArrayList<Attribute>();\r
-        List<ElementNode> childElements = new ArrayList<ElementNode>();\r
-        Text elementNameText;\r
-        Composite tagComposite;\r
-        Combo tagCombo;\r
-        Label tagLabel;\r
-        Text tagText;\r
-        Combo actionCombo;\r
-        Label previewLabel;\r
-        Text previewText;\r
-        Button logEntryButton;\r
-        Label fillerLabel;\r
-        Composite addAttributeComposite;\r
-        Button addAttributeButton;\r
-        Label addAttributeLabel;\r
-\r
-        public ElementNode(Composite parent, InputElement inputElement) {\r
-            this.inputElement = inputElement;\r
-\r
-            group = new Group(parent, SWT.NONE);\r
-            GridLayout gl = new GridLayout(2, false);\r
-            gl.marginHeight = 0;\r
-            group.setLayout(gl);\r
-            group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            group.setText(getName(inputElement));\r
-\r
-            Label label = new Label(group, SWT.NULL);\r
-            label.setText(Messages.CustomXmlParserInputWizardPage_elementName);\r
-            label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-\r
-            elementNameText = new Text(group, SWT.BORDER | SWT.SINGLE);\r
-            GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
-            gd.widthHint = 0;\r
-            elementNameText.setLayoutData(gd);\r
-            elementNameText.addModifyListener(new ModifyListener() {\r
-                @Override\r
-                public void modifyText(ModifyEvent e) {\r
-                    ElementNode.this.inputElement.elementName = elementNameText.getText().trim();\r
-                    group.setText(getName(ElementNode.this.inputElement));\r
-                }\r
-            });\r
-            elementNameText.setText(inputElement.elementName);\r
-            elementNameText.addModifyListener(updateListener);\r
-\r
-            if (inputElement.parentElement != null) {\r
-                previewLabel = new Label(group, SWT.NULL);\r
-                previewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-                previewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);\r
-\r
-                previewText = new Text(group, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);\r
-                gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
-                gd.widthHint = 0;\r
-                previewText.setLayoutData(gd);\r
-                previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);\r
-                previewText.setBackground(COLOR_WIDGET_BACKGROUND);\r
-\r
-                logEntryButton = new Button(group, SWT.CHECK);\r
-                logEntryButton.setText(Messages.CustomXmlParserInputWizardPage_logEntry);\r
-                logEntryButton.setSelection(inputElement.logEntry);\r
-                logEntryButton.addSelectionListener(new SelectionListener() {\r
-                    @Override\r
-                    public void widgetDefaultSelected(SelectionEvent e) {\r
-                    }\r
-\r
-                    @Override\r
-                    public void widgetSelected(SelectionEvent e) {\r
-                        InputElement parent = ElementNode.this.inputElement.parentElement;\r
-                        while (parent != null) {\r
-                            parent.logEntry = false;\r
-                            parent = parent.parentElement;\r
-                        }\r
-                    }\r
-                });\r
-                logEntryButton.addSelectionListener(updateListener);\r
-\r
-                tagComposite = new Composite(group, SWT.FILL);\r
-                GridLayout tagLayout = new GridLayout(4, false);\r
-                tagLayout.marginWidth = 0;\r
-                tagLayout.marginHeight = 0;\r
-                tagComposite.setLayout(tagLayout);\r
-                tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-                tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);\r
-                tagCombo.setItems(new String[] { CustomXmlTraceDefinition.TAG_IGNORE, CustomTraceDefinition.TAG_TIMESTAMP,\r
-                        CustomTraceDefinition.TAG_MESSAGE, CustomTraceDefinition.TAG_OTHER });\r
-                tagCombo.setVisibleItemCount(tagCombo.getItemCount());\r
-                tagCombo.addSelectionListener(new SelectionListener() {\r
-                    @Override\r
-                    public void widgetDefaultSelected(SelectionEvent e) {\r
-                    }\r
-\r
-                    @Override\r
-                    public void widgetSelected(SelectionEvent e) {\r
-                        tagText.removeModifyListener(updateListener);\r
-                        switch (tagCombo.getSelectionIndex()) {\r
-                        case 0: // Ignore\r
-                            tagLabel.setVisible(false);\r
-                            tagText.setVisible(false);\r
-                            actionCombo.setVisible(false);\r
-                            break;\r
-                        case 1: // Time Stamp\r
-                            tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);\r
-                            tagLabel.setVisible(true);\r
-                            tagText.setVisible(true);\r
-                            tagText.addModifyListener(updateListener);\r
-                            actionCombo.setVisible(true);\r
-                            break;\r
-                        case 2: // Message\r
-                            tagLabel.setVisible(false);\r
-                            tagText.setVisible(false);\r
-                            actionCombo.setVisible(true);\r
-                            break;\r
-                        case 3: // Other\r
-                            tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);\r
-                            tagLabel.setVisible(true);\r
-                            if (tagText.getText().trim().length() == 0) {\r
-                                tagText.setText(elementNameText.getText().trim());\r
-                            }\r
-                            tagText.setVisible(true);\r
-                            tagText.addModifyListener(updateListener);\r
-                            actionCombo.setVisible(true);\r
-                            break;\r
-                        default:\r
-                            break;\r
-                        }\r
-                        tagComposite.layout();\r
-                        validate();\r
-                        updatePreviews();\r
-                    }\r
-                });\r
-\r
-                tagLabel = new Label(tagComposite, SWT.NULL);\r
-                tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-\r
-                tagText = new Text(tagComposite, SWT.BORDER | SWT.SINGLE);\r
-                gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
-                gd.widthHint = 0;\r
-                tagText.setLayoutData(gd);\r
-\r
-                actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);\r
-                actionCombo.setItems(new String[] { Messages.CustomXmlParserInputWizardPage_set, Messages.CustomXmlParserInputWizardPage_append,\r
-                        Messages.CustomXmlParserInputWizardPage_appendWith });\r
-                actionCombo.select(inputElement.inputAction);\r
-                actionCombo.addSelectionListener(updateListener);\r
-\r
-                if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {\r
-                    tagCombo.select(0);\r
-                    tagLabel.setVisible(false);\r
-                    tagText.setVisible(false);\r
-                    actionCombo.setVisible(false);\r
-                } else if (inputElement.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                    tagCombo.select(1);\r
-                    tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);\r
-                    tagText.setText(inputElement.inputFormat);\r
-                    tagText.addModifyListener(updateListener);\r
-                } else if (inputElement.inputName.equals(CustomTraceDefinition.TAG_MESSAGE)) {\r
-                    tagCombo.select(2);\r
-                    tagLabel.setVisible(false);\r
-                    tagText.setVisible(false);\r
-                } else {\r
-                    tagCombo.select(3);\r
-                    tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);\r
-                    tagText.setText(inputElement.inputName);\r
-                    tagText.addModifyListener(updateListener);\r
-                }\r
-            }\r
-\r
-            if (inputElement.attributes != null) {\r
-                for (InputAttribute inputAttribute : inputElement.attributes) {\r
-                    Attribute attribute = new Attribute(group, this, inputAttribute, attributes.size() + 1);\r
-                    attributes.add(attribute);\r
-                }\r
-            }\r
-\r
-            createAddButton();\r
-        }\r
-\r
-        private void updatePreview() {\r
-            Element element = getPreviewElement(inputElement);\r
-            if (inputElement.parentElement != null) { // no preview text for\r
-                                                      // document element\r
-                previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);\r
-                if (element != null) {\r
-                    previewText.setText(CustomXmlTrace.parseElement(element, new StringBuffer()).toString());\r
-                    if (logEntryButton.getSelection()) {\r
-                        if (!logEntryFound) {\r
-                            logEntryFound = true;\r
-                            logEntriesCount++;\r
-                        } else {\r
-                            logEntryButton.setSelection(false); // remove nested\r
-                                                                // log entry\r
-                        }\r
-                    }\r
-                    if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {\r
-                        String value = previewText.getText().trim();\r
-                        if (value.length() != 0) {\r
-                            if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_SET) {\r
-                                timeStampValue = value;\r
-                                timeStampFormat = tagText.getText().trim();\r
-                            } else if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND) {\r
-                                if (timeStampValue != null) {\r
-                                    timeStampValue += value;\r
-                                    timeStampFormat += tagText.getText().trim();\r
-                                } else {\r
-                                    timeStampValue = value;\r
-                                    timeStampFormat = tagText.getText().trim();\r
-                                }\r
-                            } else if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
-                                if (timeStampValue != null) {\r
-                                    timeStampValue += " | " + value; //$NON-NLS-1$\r
-                                    timeStampFormat += " | " + tagText.getText().trim(); //$NON-NLS-1$\r
-                                } else {\r
-                                    timeStampValue = value;\r
-                                    timeStampFormat = tagText.getText().trim();\r
-                                }\r
-                            }\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-            for (Attribute attribute : attributes) {\r
-                if (element != null) {\r
-                    String value = element.getAttribute(attribute.attributeNameText.getText().trim());\r
-                    if (value.length() != 0) {\r
-                        attribute.previewText.setText(value);\r
-                        if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {\r
-                            if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_SET) {\r
-                                timeStampValue = value;\r
-                                timeStampFormat = attribute.tagText.getText().trim();\r
-                            } else if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND) {\r
-                                if (timeStampValue != null) {\r
-                                    timeStampValue += value;\r
-                                    timeStampFormat += attribute.tagText.getText().trim();\r
-                                } else {\r
-                                    timeStampValue = value;\r
-                                    timeStampFormat = attribute.tagText.getText().trim();\r
-                                }\r
-                            } else if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {\r
-                                if (timeStampValue != null) {\r
-                                    timeStampValue += " | " + value; //$NON-NLS-1$\r
-                                    timeStampFormat += " | " + attribute.tagText.getText().trim(); //$NON-NLS-1$\r
-                                } else {\r
-                                    timeStampValue = value;\r
-                                    timeStampFormat = attribute.tagText.getText().trim();\r
-                                }\r
-                            }\r
-                        }\r
-                    } else {\r
-                        attribute.previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingAttribute);\r
-                    }\r
-                } else {\r
-                    attribute.previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);\r
-                }\r
-            }\r
-            for (ElementNode child : childElements) {\r
-                child.updatePreview();\r
-            }\r
-            if (logEntryButton != null && logEntryButton.getSelection()) {\r
-                logEntryFound = false;\r
-            }\r
-        }\r
-\r
-        private void createAddButton() {\r
-            fillerLabel = new Label(group, SWT.NONE);\r
-\r
-            addAttributeComposite = new Composite(group, SWT.NONE);\r
-            addAttributeComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            GridLayout addAttributeLayout = new GridLayout(2, false);\r
-            addAttributeLayout.marginHeight = 0;\r
-            addAttributeLayout.marginWidth = 0;\r
-            addAttributeComposite.setLayout(addAttributeLayout);\r
-\r
-            addAttributeButton = new Button(addAttributeComposite, SWT.PUSH);\r
-            addAttributeButton.setImage(addImage);\r
-            addAttributeButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addAttribute);\r
-            addAttributeButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    removeAddButton();\r
-                    String attributeName = getAttributeNameSuggestion(inputElement);\r
-                    InputAttribute inputAttribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$\r
-                    attributes.add(new Attribute(group, ElementNode.this, inputAttribute, attributes.size() + 1));\r
-                    createAddButton();\r
-                    elementContainer.layout();\r
-                    elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,\r
-                            elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);\r
-                    group.getParent().layout();\r
-                    validate();\r
-                    updatePreviews();\r
-                }\r
-            });\r
-\r
-            addAttributeLabel = new Label(addAttributeComposite, SWT.NULL);\r
-            addAttributeLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-            addAttributeLabel.setText(Messages.CustomXmlParserInputWizardPage_newAttibute);\r
-        }\r
-\r
-        private void removeAddButton() {\r
-            fillerLabel.dispose();\r
-            addAttributeComposite.dispose();\r
-        }\r
-\r
-        private void removeAttribute(int attributeNumber) {\r
-            if (--attributeNumber < attributes.size()) {\r
-                attributes.remove(attributeNumber).dispose();\r
-                for (int i = attributeNumber; i < attributes.size(); i++) {\r
-                    attributes.get(i).setAttributeNumber(i + 1);\r
-                }\r
-                elementContainer.layout();\r
-                elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,\r
-                        elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);\r
-                group.getParent().layout();\r
-            }\r
-        }\r
-\r
-        private void dispose() {\r
-            group.dispose();\r
-        }\r
-\r
-        private void extractInputs() {\r
-            inputElement.elementName = elementNameText.getText().trim();\r
-            if (inputElement.parentElement != null) {\r
-                inputElement.logEntry = logEntryButton.getSelection();\r
-                if (tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {\r
-                    inputElement.inputName = tagText.getText().trim();\r
-                } else {\r
-                    inputElement.inputName = tagCombo.getText();\r
-                    if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                        inputElement.inputFormat = tagText.getText().trim();\r
-                    }\r
-                }\r
-                inputElement.inputAction = actionCombo.getSelectionIndex();\r
-            }\r
-            inputElement.attributes = new ArrayList<InputAttribute>(attributes.size());\r
-            for (int i = 0; i < attributes.size(); i++) {\r
-                Attribute attribute = attributes.get(i);\r
-                InputAttribute inputAttribute = new InputAttribute();\r
-                inputAttribute.attributeName = attribute.attributeNameText.getText().trim();\r
-                if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {\r
-                    inputAttribute.inputName = attribute.tagText.getText().trim();\r
-                } else {\r
-                    inputAttribute.inputName = attribute.tagCombo.getText();\r
-                    if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                        inputAttribute.inputFormat = attribute.tagText.getText().trim();\r
-                    }\r
-                }\r
-                inputAttribute.inputAction = attribute.actionCombo.getSelectionIndex();\r
-                inputElement.addAttribute(inputAttribute);\r
-            }\r
-        }\r
-    }\r
-\r
-    private class Attribute {\r
-        ElementNode element;\r
-        int attributeNumber;\r
-\r
-        // children of parent (must be disposed)\r
-        Composite labelComposite;\r
-        Composite attributeComposite;\r
-        Label filler;\r
-        Composite tagComposite;\r
-\r
-        // children of labelComposite\r
-        Label attributeLabel;\r
-\r
-        // children of attributeComposite\r
-        Text attributeNameText;\r
-        Text previewText;\r
-\r
-        // children of tagComposite\r
-        Combo tagCombo;\r
-        Label tagLabel;\r
-        Text tagText;\r
-        Combo actionCombo;\r
-\r
-        public Attribute(Composite parent, ElementNode element, InputAttribute inputAttribute, int attributeNumber) {\r
-            this.element = element;\r
-            this.attributeNumber = attributeNumber;\r
-\r
-            labelComposite = new Composite(parent, SWT.FILL);\r
-            GridLayout labelLayout = new GridLayout(2, false);\r
-            labelLayout.marginWidth = 0;\r
-            labelLayout.marginHeight = 0;\r
-            labelComposite.setLayout(labelLayout);\r
-            labelComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-\r
-            Button deleteButton = new Button(labelComposite, SWT.PUSH);\r
-            deleteButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-            deleteButton.setImage(deleteImage);\r
-            deleteButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_removeAttribute);\r
-            deleteButton.addSelectionListener(new SelectionAdapter() {\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    Attribute.this.element.removeAttribute(Attribute.this.attributeNumber);\r
-                    validate();\r
-                    updatePreviews();\r
-                }\r
-            });\r
-\r
-            attributeLabel = new Label(labelComposite, SWT.NULL);\r
-            attributeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-            attributeLabel.setText(Messages.CustomXmlParserInputWizardPage_attibute);\r
-\r
-            attributeComposite = new Composite(parent, SWT.FILL);\r
-            GridLayout attributeLayout = new GridLayout(4, false);\r
-            attributeLayout.marginWidth = 0;\r
-            attributeLayout.marginHeight = 0;\r
-            attributeComposite.setLayout(attributeLayout);\r
-            attributeComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-            Label nameLabel = new Label(attributeComposite, SWT.NONE);\r
-            nameLabel.setText(Messages.CustomXmlParserInputWizardPage_name);\r
-\r
-            attributeNameText = new Text(attributeComposite, SWT.BORDER | SWT.SINGLE);\r
-            attributeNameText.setLayoutData(new GridData(120, SWT.DEFAULT));\r
-            attributeNameText.setText(inputAttribute.attributeName);\r
-            attributeNameText.addModifyListener(updateListener);\r
-\r
-            Label previewLabel = new Label(attributeComposite, SWT.NONE);\r
-            previewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);\r
-\r
-            previewText = new Text(attributeComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);\r
-            GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
-            gd.widthHint = 0;\r
-            previewText.setLayoutData(gd);\r
-            previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatch);\r
-            previewText.setBackground(COLOR_WIDGET_BACKGROUND);\r
-\r
-            filler = new Label(parent, SWT.NULL);\r
-\r
-            tagComposite = new Composite(parent, SWT.FILL);\r
-            GridLayout tagLayout = new GridLayout(4, false);\r
-            tagLayout.marginWidth = 0;\r
-            tagLayout.marginHeight = 0;\r
-            tagComposite.setLayout(tagLayout);\r
-            tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));\r
-\r
-            tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);\r
-            tagCombo.setItems(new String[] { CustomTraceDefinition.TAG_TIMESTAMP, CustomTraceDefinition.TAG_MESSAGE,\r
-                    CustomTraceDefinition.TAG_OTHER });\r
-            tagCombo.select(2); // Other\r
-            tagCombo.addSelectionListener(new SelectionListener() {\r
-                @Override\r
-                public void widgetDefaultSelected(SelectionEvent e) {\r
-                }\r
-\r
-                @Override\r
-                public void widgetSelected(SelectionEvent e) {\r
-                    tagText.removeModifyListener(updateListener);\r
-                    switch (tagCombo.getSelectionIndex()) {\r
-                    case 0: // Time Stamp\r
-                        tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);\r
-                        tagLabel.setVisible(true);\r
-                        tagText.setVisible(true);\r
-                        tagText.addModifyListener(updateListener);\r
-                        break;\r
-                    case 1: // Message\r
-                        tagLabel.setVisible(false);\r
-                        tagText.setVisible(false);\r
-                        break;\r
-                    case 2: // Other\r
-                        tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);\r
-                        tagLabel.setVisible(true);\r
-                        if (tagText.getText().trim().length() == 0) {\r
-                            tagText.setText(attributeNameText.getText().trim());\r
-                        }\r
-                        tagText.setVisible(true);\r
-                        tagText.addModifyListener(updateListener);\r
-                        break;\r
-                    default:\r
-                        break;\r
-                    }\r
-                    tagComposite.layout();\r
-                    validate();\r
-                    updatePreviews();\r
-                }\r
-            });\r
-\r
-            tagLabel = new Label(tagComposite, SWT.NULL);\r
-            tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));\r
-\r
-            tagText = new Text(tagComposite, SWT.BORDER | SWT.SINGLE);\r
-            gd = new GridData(SWT.FILL, SWT.CENTER, true, false);\r
-            gd.widthHint = 0;\r
-            tagText.setLayoutData(gd);\r
-            tagText.setText(attributeNameText.getText());\r
-\r
-            actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);\r
-            actionCombo.setItems(new String[] { Messages.CustomXmlParserInputWizardPage_set, Messages.CustomXmlParserInputWizardPage_append,\r
-                    Messages.CustomXmlParserInputWizardPage_appendWith });\r
-            actionCombo.select(inputAttribute.inputAction);\r
-            actionCombo.addSelectionListener(updateListener);\r
-\r
-            if (inputAttribute.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                tagCombo.select(0);\r
-                tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);\r
-                tagText.setText(inputAttribute.inputFormat);\r
-                tagText.addModifyListener(updateListener);\r
-            } else if (inputAttribute.inputName.equals(CustomTraceDefinition.TAG_MESSAGE)) {\r
-                tagCombo.select(1);\r
-                tagLabel.setVisible(false);\r
-                tagText.setVisible(false);\r
-            } else {\r
-                tagCombo.select(2);\r
-                tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);\r
-                tagText.setText(inputAttribute.inputName);\r
-                tagText.addModifyListener(updateListener);\r
-            }\r
-        }\r
-\r
-        private void dispose() {\r
-            labelComposite.dispose();\r
-            attributeComposite.dispose();\r
-            filler.dispose();\r
-            tagComposite.dispose();\r
-        }\r
-\r
-        private void setAttributeNumber(int attributeNumber) {\r
-            this.attributeNumber = attributeNumber;\r
-            labelComposite.layout();\r
-        }\r
-    }\r
-\r
-    private Element getPreviewElement(InputElement inputElement) {\r
-        Element element = documentElement;\r
-        if (element != null) {\r
-            if (!documentElement.getNodeName().equals(definition.rootInputElement.elementName)) {\r
-                return null;\r
-            }\r
-            ArrayList<String> elementNames = new ArrayList<String>();\r
-            while (inputElement != null) {\r
-                elementNames.add(inputElement.elementName);\r
-                inputElement = inputElement.parentElement;\r
-            }\r
-            for (int i = elementNames.size() - 1; --i >= 0;) {\r
-                NodeList childList = element.getChildNodes();\r
-                element = null;\r
-                for (int j = 0; j < childList.getLength(); j++) {\r
-                    Node child = childList.item(j);\r
-                    if (child instanceof Element && child.getNodeName().equals(elementNames.get(i))) {\r
-                        element = (Element) child;\r
-                        break;\r
-                    }\r
-                }\r
-                if (element == null) {\r
-                    break;\r
-                }\r
-            }\r
-            if (element != null) {\r
-                return element;\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
-    private String getChildNameSuggestion(InputElement inputElement) {\r
-        if (inputElement == null) {\r
-            if (documentElement != null) {\r
-                return documentElement.getNodeName();\r
-            }\r
-        } else {\r
-            Element element = getPreviewElement(inputElement);\r
-            if (element != null) {\r
-                NodeList childNodes = element.getChildNodes();\r
-                for (int i = 0; i < childNodes.getLength(); i++) {\r
-                    Node node = childNodes.item(i);\r
-                    if (node instanceof Element) {\r
-                        boolean unused = true;\r
-                        if (inputElement.childElements != null) {\r
-                            for (InputElement child : inputElement.childElements) {\r
-                                if (child.elementName.equals(node.getNodeName())) {\r
-                                    unused = false;\r
-                                    break;\r
-                                }\r
-                            }\r
-                        }\r
-                        if (unused) {\r
-                            return node.getNodeName();\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return ""; //$NON-NLS-1$\r
-    }\r
-\r
-    private String getAttributeNameSuggestion(InputElement inputElement) {\r
-        Element element = getPreviewElement(inputElement);\r
-        if (element != null) {\r
-            NamedNodeMap attributeMap = element.getAttributes();\r
-            for (int i = 0; i < attributeMap.getLength(); i++) {\r
-                Node node = attributeMap.item(i);\r
-                boolean unused = true;\r
-                if (inputElement.attributes != null) {\r
-                    for (InputAttribute attribute : inputElement.attributes) {\r
-                        if (attribute.attributeName.equals(node.getNodeName())) {\r
-                            unused = false;\r
-                            break;\r
-                        }\r
-                    }\r
-                }\r
-                if (unused) {\r
-                    return node.getNodeName();\r
-                }\r
-            }\r
-        }\r
-        return ""; //$NON-NLS-1$\r
-    }\r
-\r
-    private void validate() {\r
-        definition.definitionName = logtypeText.getText().trim();\r
-        definition.timeStampOutputFormat = timeStampOutputFormatText.getText().trim();\r
-\r
-        if (selectedElement != null) {\r
-            selectedElement.extractInputs();\r
-            treeViewer.refresh();\r
-        }\r
-\r
-        StringBuffer errors = new StringBuffer();\r
-\r
-        if (definition.definitionName.length() == 0) {\r
-            errors.append(Messages.CustomXmlParserInputWizardPage_emptyLogTypeError);\r
-            logtypeText.setBackground(COLOR_LIGHT_RED);\r
-        } else {\r
-            logtypeText.setBackground(COLOR_TEXT_BACKGROUND);\r
-            for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {\r
-                if (definition.definitionName.equals(def.definitionName)) {\r
-                    if (editDefinitionName == null || !editDefinitionName.equals(definition.definitionName)) {\r
-                        errors.append(Messages.CustomXmlParserInputWizardPage_duplicatelogTypeError);\r
-                        logtypeText.setBackground(COLOR_LIGHT_RED);\r
-                        break;\r
-                    }\r
-                }\r
-            }\r
-        }\r
-\r
-        if (definition.rootInputElement == null) {\r
-            errors.append(Messages.CustomXmlParserInputWizardPage_noDocumentError);\r
-        }\r
-\r
-        if (definition.rootInputElement != null) {\r
-            logEntryFound = false;\r
-            timeStampFound = false;\r
-\r
-            errors.append(validateElement(definition.rootInputElement));\r
-\r
-            if ((definition.rootInputElement.attributes != null && definition.rootInputElement.attributes.size() != 0)\r
-                    || (definition.rootInputElement.childElements != null && definition.rootInputElement.childElements.size() != 0)\r
-                    || errors.length() == 0) {\r
-                if (!logEntryFound) {\r
-                    errors.append(Messages.CustomXmlParserInputWizardPage_missingLogEntryError);\r
-                }\r
-\r
-                if (timeStampFound) {\r
-                    if (timeStampOutputFormatText.getText().trim().length() == 0) {\r
-                        errors.append(Messages.CustomXmlParserInputWizardPage_missingTimestampFmtError);\r
-                        timeStampOutputFormatText.setBackground(COLOR_LIGHT_RED);\r
-                    } else {\r
-                        try {\r
-                            new SimpleDateFormat(timeStampOutputFormatText.getText().trim());\r
-                            timeStampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                        } catch (IllegalArgumentException e) {\r
-                            errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampFmtError);\r
-                            timeStampOutputFormatText.setBackground(COLOR_LIGHT_RED);\r
-                        }\r
-                    }\r
-                } else {\r
-                    timeStampPreviewText.setText(Messages.CustomXmlParserInputWizardPage_notimestamporAttributeError);\r
-                }\r
-            }\r
-        } else {\r
-            timeStampPreviewText.setText(Messages.CustomXmlParserInputWizardPage_notimestamporAttributeError);\r
-        }\r
-\r
-        if (errors.length() == 0) {\r
-            setDescription(defaultDescription);\r
-            setPageComplete(true);\r
-        } else {\r
-            setDescription(errors.toString());\r
-            setPageComplete(false);\r
-        }\r
-    }\r
-\r
-    public StringBuffer validateElement(InputElement inputElement) {\r
-        StringBuffer errors = new StringBuffer();\r
-        ElementNode elementNode = null;\r
-        if (selectedElement != null && selectedElement.inputElement.equals(inputElement)) {\r
-            elementNode = selectedElement;\r
-        }\r
-        if (inputElement == definition.rootInputElement) {\r
-            if (inputElement.elementName.length() == 0) {\r
-                errors.append(Messages.CustomXmlParserInputWizardPage_missingDocumentElementError);\r
-                if (elementNode != null) {\r
-                    elementNode.elementNameText.setBackground(COLOR_LIGHT_RED);\r
-                }\r
-            } else {\r
-                if (elementNode != null) {\r
-                    elementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                }\r
-            }\r
-        }\r
-        if (inputElement != definition.rootInputElement) {\r
-            if (inputElement.logEntry) {\r
-                logEntryFound = true;\r
-            }\r
-            if (inputElement.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                timeStampFound = true;\r
-                if (inputElement.inputFormat.length() == 0) {\r
-                    errors.append(Messages.CustomXmlParserInputWizardPage_timestampFormatPrompt\r
-                            + " (" + Messages.CustomXmlParserInputWizardPage_timestampElementPrompt + " " + getName(inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                    if (elementNode != null) {\r
-                        elementNode.tagText.setBackground(COLOR_LIGHT_RED);\r
-                    }\r
-                } else {\r
-                    try {\r
-                        new SimpleDateFormat(inputElement.inputFormat);\r
-                        if (elementNode != null) {\r
-                            elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                        }\r
-                    } catch (IllegalArgumentException e) {\r
-                        errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampFmtError\r
-                                + " (" + Messages.CustomXmlParserInputWizardPage_timestampElementPrompt + " " + getName(inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                        if (elementNode != null) {\r
-                            elementNode.tagText.setBackground(COLOR_LIGHT_RED);\r
-                        }\r
-                    }\r
-                }\r
-            } else if (inputElement.inputName.length() == 0) {\r
-                errors.append(Messages.CustomXmlParserInputWizardPage_missingInputElementNameError);\r
-                if (elementNode != null) {\r
-                    elementNode.tagText.setBackground(COLOR_LIGHT_RED);\r
-                }\r
-            } else {\r
-                if (elementNode != null) {\r
-                    elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                }\r
-            }\r
-        }\r
-        if (inputElement.attributes != null) {\r
-            if (elementNode != null) {\r
-                for (Attribute attribute : elementNode.attributes) {\r
-                    attribute.attributeNameText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                }\r
-            }\r
-            for (int i = 0; i < inputElement.attributes.size(); i++) {\r
-                InputAttribute attribute = inputElement.attributes.get(i);\r
-                boolean duplicate = false;\r
-                for (int j = i + 1; j < inputElement.attributes.size(); j++) {\r
-                    InputAttribute otherAttribute = inputElement.attributes.get(j);\r
-                    if (otherAttribute.attributeName.equals(attribute.attributeName)) {\r
-                        duplicate = true;\r
-                        if (elementNode != null) {\r
-                            elementNode.attributes.get(j).attributeNameText.setBackground(COLOR_LIGHT_RED);\r
-                        }\r
-                    }\r
-                }\r
-                if (attribute.attributeName.length() == 0) {\r
-                    errors.append(Messages.CustomXmlParserInputWizardPage_missingAttribute\r
-                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(inputElement) + ": ?). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                    if (elementNode != null) {\r
-                        elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);\r
-                    }\r
-                } else if (duplicate) {\r
-                    errors.append(Messages.CustomXmlParserInputWizardPage_duplicateAttributeError\r
-                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                    if (elementNode != null) {\r
-                        elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);\r
-                    }\r
-                }\r
-                if (attribute.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {\r
-                    timeStampFound = true;\r
-                    if (attribute.inputFormat.length() == 0) {\r
-                        errors.append(Messages.CustomXmlParserInputWizardPage_missingTimestampInFmtError\r
-                                + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                        if (elementNode != null) {\r
-                            elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);\r
-                        }\r
-                    } else {\r
-                        try {\r
-                            new SimpleDateFormat(attribute.inputFormat);\r
-                            if (elementNode != null) {\r
-                                elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                            }\r
-                        } catch (IllegalArgumentException e) {\r
-                            errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampInFmtError\r
-                                    + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                            if (elementNode != null) {\r
-                                elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);\r
-                            }\r
-                        }\r
-                    }\r
-                } else if (attribute.inputName.length() == 0) {\r
-                    errors.append(Messages.CustomXmlParserInputWizardPage_missingDataGroupNameError\r
-                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                    if (elementNode != null) {\r
-                        elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);\r
-                    }\r
-                } else {\r
-                    if (elementNode != null) {\r
-                        elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        if (inputElement.childElements != null) {\r
-            for (InputElement child : inputElement.childElements) {\r
-                ElementNode childElementNode = null;\r
-                if (selectedElement != null && selectedElement.inputElement.equals(child)) {\r
-                    childElementNode = selectedElement;\r
-                }\r
-                if (childElementNode != null) {\r
-                    childElementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND);\r
-                }\r
-            }\r
-            for (int i = 0; i < inputElement.childElements.size(); i++) {\r
-                InputElement child = inputElement.childElements.get(i);\r
-                ElementNode childElementNode = null;\r
-                if (selectedElement != null && selectedElement.inputElement.equals(child)) {\r
-                    childElementNode = selectedElement;\r
-                }\r
-                if (child.elementName.length() == 0) {\r
-                    errors.append(Messages.CustomXmlParserInputWizardPage_missingElementNameError\r
-                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(child) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                    if (childElementNode != null) {\r
-                        childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);\r
-                    }\r
-                } else {\r
-                    boolean duplicate = false;\r
-                    for (int j = i + 1; j < inputElement.childElements.size(); j++) {\r
-                        InputElement otherChild = inputElement.childElements.get(j);\r
-                        if (otherChild.elementName.equals(child.elementName)) {\r
-                            duplicate = true;\r
-                            ElementNode otherChildElementNode = null;\r
-                            if (selectedElement != null && selectedElement.inputElement.equals(otherChild)) {\r
-                                otherChildElementNode = selectedElement;\r
-                            }\r
-                            if (otherChildElementNode != null) {\r
-                                otherChildElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);\r
-                            }\r
-                        }\r
-                    }\r
-                    if (duplicate) {\r
-                        errors.append(Messages.CustomXmlParserInputWizardPage_duplicateElementNameError\r
-                                + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(child) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$\r
-                        if (childElementNode != null) {\r
-                            childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);\r
-                        }\r
-                    }\r
-                }\r
-\r
-                errors.append(validateElement(child));\r
-            }\r
-        }\r
-        return errors;\r
-    }\r
-\r
-    public CustomXmlTraceDefinition getDefinition() {\r
-        return definition;\r
-    }\r
-\r
-    public char[] getInputText() {\r
-        return inputText.getText().toCharArray();\r
-    }\r
-}\r
+package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.viewers.AbstractTreeViewer;
+import org.eclipse.jface.viewers.ColumnLabelProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
+import org.eclipse.linuxtools.internal.tmf.ui.Messages;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputAttribute;
+import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputElement;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.browser.Browser;
+import org.eclipse.swt.browser.TitleEvent;
+import org.eclipse.swt.browser.TitleListener;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.custom.StyleRange;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.EntityResolver;
+import org.xml.sax.ErrorHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+public class CustomXmlParserInputWizardPage extends WizardPage {
+
+    private static final String DEFAULT_TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$
+    private static final String SIMPLE_DATE_FORMAT_URL = "http://java.sun.com/javase/6/docs/api/java/text/SimpleDateFormat.html#skip-navbar_top"; //$NON-NLS-1$
+    private static final Image elementImage = Activator.getDefault().getImageFromPath("/icons/elcl16/element_icon.gif"); //$NON-NLS-1$
+    private static final Image addImage = Activator.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$
+    private static final Image addNextImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addnext_button.gif"); //$NON-NLS-1$
+    private static final Image addChildImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addchild_button.gif"); //$NON-NLS-1$
+    private static final Image addManyImage = Activator.getDefault().getImageFromPath("/icons/elcl16/addmany_button.gif"); //$NON-NLS-1$
+    private static final Image deleteImage = Activator.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$
+    private static final Image moveUpImage = Activator.getDefault().getImageFromPath("/icons/elcl16/moveup_button.gif"); //$NON-NLS-1$
+    private static final Image moveDownImage = Activator.getDefault().getImageFromPath("/icons/elcl16/movedown_button.gif"); //$NON-NLS-1$
+    private static final Image helpImage = Activator.getDefault().getImageFromPath("/icons/elcl16/help_button.gif"); //$NON-NLS-1$
+    private static final Color COLOR_LIGHT_RED = new Color(Display.getDefault(), 255, 192, 192);
+    private static final Color COLOR_TEXT_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
+    private static final Color COLOR_WIDGET_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
+
+    private final ISelection selection;
+    private CustomXmlTraceDefinition definition;
+    private String editDefinitionName;
+    private String defaultDescription;
+    private ElementNode selectedElement;
+    private Composite container;
+    private Text logtypeText;
+    private Text timeStampOutputFormatText;
+    private Text timeStampPreviewText;
+    private Button removeButton;
+    private Button addChildButton;
+    private Button addNextButton;
+    private Button moveUpButton;
+    private Button moveDownButton;
+    private Button feelingLuckyButton;
+    private ScrolledComposite treeScrolledComposite;
+    private ScrolledComposite elementScrolledComposite;
+    private TreeViewer treeViewer;
+    private Composite treeContainer;
+    private Composite elementContainer;
+    private Text errorText;
+    private StyledText inputText;
+    private Font fixedFont;
+    private UpdateListener updateListener;
+    private Browser helpBrowser;
+    private Element documentElement;
+
+    // variables used recursively through element traversal
+    private String timeStampValue;
+    private String timeStampFormat;
+    private boolean timeStampFound;
+    private int logEntriesCount;
+    private boolean logEntryFound;
+
+    protected CustomXmlParserInputWizardPage(ISelection selection, CustomXmlTraceDefinition definition) {
+        super("CustomXmlParserWizardPage"); //$NON-NLS-1$
+        if (definition == null) {
+            setTitle(Messages.CustomXmlParserInputWizardPage_titleNew);
+            defaultDescription = Messages.CustomXmlParserInputWizardPage_descriptionNew;
+        } else {
+            setTitle(Messages.CustomXmlParserInputWizardPage_titleEdit);
+            defaultDescription = Messages.CustomXmlParserInputWizardPage_descriptionEdit;
+        }
+        setDescription(defaultDescription);
+        this.selection = selection;
+        this.definition = definition;
+        if (definition != null) {
+            this.editDefinitionName = definition.definitionName;
+        }
+    }
+
+    @Override
+    public void createControl(Composite parent) {
+        container = new Composite(parent, SWT.NULL);
+        container.setLayout(new GridLayout());
+
+        updateListener = new UpdateListener();
+
+        Composite headerComposite = new Composite(container, SWT.FILL);
+        GridLayout headerLayout = new GridLayout(5, false);
+        headerLayout.marginHeight = 0;
+        headerLayout.marginWidth = 0;
+        headerComposite.setLayout(headerLayout);
+        headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+        Label logtypeLabel = new Label(headerComposite, SWT.NULL);
+        logtypeLabel.setText(Messages.CustomXmlParserInputWizardPage_logType);
+
+        logtypeText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);
+        logtypeText.setLayoutData(new GridData(120, SWT.DEFAULT));
+
+        Label timeStampFormatLabel = new Label(headerComposite, SWT.NULL);
+        timeStampFormatLabel.setText(Messages.CustomXmlParserInputWizardPage_timestampFormat);
+
+        timeStampOutputFormatText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);
+        timeStampOutputFormatText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+        timeStampOutputFormatText.setText(DEFAULT_TIMESTAMP_FORMAT);
+
+        Button dateFormatHelpButton = new Button(headerComposite, SWT.PUSH);
+        dateFormatHelpButton.setImage(helpImage);
+        dateFormatHelpButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_dateFormatHelp);
+        dateFormatHelpButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                openHelpShell(SIMPLE_DATE_FORMAT_URL);
+            }
+        });
+
+        Label timeStampPreviewLabel = new Label(headerComposite, SWT.NULL);
+        timeStampPreviewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 3, 1));
+        timeStampPreviewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);
+
+        timeStampPreviewText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
+        timeStampPreviewText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
+        timeStampPreviewText.setText("*no time stamp element or attribute*"); //$NON-NLS-1$
+
+        createButtonBar();
+
+        SashForm vSash = new SashForm(container, SWT.VERTICAL);
+        vSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        vSash.setBackground(vSash.getDisplay().getSystemColor(SWT.COLOR_GRAY));
+
+        SashForm hSash = new SashForm(vSash, SWT.HORIZONTAL);
+        hSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+
+        treeScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL | SWT.H_SCROLL);
+        treeScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        treeContainer = new Composite(treeScrolledComposite, SWT.NONE);
+        treeContainer.setLayout(new FillLayout());
+        treeScrolledComposite.setContent(treeContainer);
+        treeScrolledComposite.setExpandHorizontal(true);
+        treeScrolledComposite.setExpandVertical(true);
+
+        treeViewer = new TreeViewer(treeContainer, SWT.SINGLE | SWT.BORDER);
+        treeViewer.setContentProvider(new InputElementTreeNodeContentProvider());
+        treeViewer.setLabelProvider(new InputElementTreeLabelProvider());
+        treeViewer.addSelectionChangedListener(new InputElementTreeSelectionChangedListener());
+        treeContainer.layout();
+
+        treeScrolledComposite
+                .setMinSize(treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
+
+        elementScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL);
+        elementScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
+        elementContainer = new Composite(elementScrolledComposite, SWT.NONE);
+        GridLayout gl = new GridLayout();
+        gl.marginHeight = 1;
+        gl.marginWidth = 0;
+        elementContainer.setLayout(gl);
+        elementScrolledComposite.setContent(elementContainer);
+        elementScrolledComposite.setExpandHorizontal(true);
+        elementScrolledComposite.setExpandVertical(true);
+
+        if (definition == null) {
+            definition = new CustomXmlTraceDefinition();
+        }
+        loadDefinition(definition);
+        treeViewer.expandAll();
+        elementContainer.layout();
+
+        logtypeText.addModifyListener(updateListener);
+        timeStampOutputFormatText.addModifyListener(updateListener);
+
+        elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
+                elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
+
+        hSash.setWeights(new int[] { 1, 2 });
+
+        if (definition.rootInputElement == null) {
+            removeButton.setEnabled(false);
+            addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentElement);
+            addNextButton.setEnabled(false);
+            moveUpButton.setEnabled(false);
+            moveDownButton.setEnabled(false);
+        } else { // root is selected
+            addNextButton.setEnabled(false);
+        }
+
+        Composite sashBottom = new Composite(vSash, SWT.NONE);
+        GridLayout sashBottomLayout = new GridLayout(2, false);
+        sashBottomLayout.marginHeight = 0;
+        sashBottomLayout.marginWidth = 0;
+        sashBottom.setLayout(sashBottomLayout);
+
+        Label previewLabel = new Label(sashBottom, SWT.NULL);
+        previewLabel.setText(Messages.CustomXmlParserInputWizardPage_previewInput);
+
+        errorText = new Text(sashBottom, SWT.SINGLE | SWT.READ_ONLY);
+        errorText.setBackground(COLOR_WIDGET_BACKGROUND);
+        errorText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+        errorText.setVisible(false);
+
+        inputText = new StyledText(sashBottom, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
+        if (fixedFont == null) {
+            if (System.getProperty("os.name").contains("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$
+                fixedFont = new Font(Display.getCurrent(), new FontData("Courier New", 10, SWT.NORMAL)); //$NON-NLS-1$
+            } else {
+                fixedFont = new Font(Display.getCurrent(), new FontData("Monospace", 10, SWT.NORMAL)); //$NON-NLS-1$
+            }
+        }
+        inputText.setFont(fixedFont);
+        GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
+        gd.heightHint = inputText.computeSize(SWT.DEFAULT, inputText.getLineHeight() * 4).y;
+        gd.widthHint = 800;
+        inputText.setLayoutData(gd);
+        inputText.setText(getSelectionText());
+        inputText.addModifyListener(new ModifyListener() {
+            @Override
+            public void modifyText(ModifyEvent e) {
+                parseXmlInput(inputText.getText());
+            }
+        });
+        inputText.addModifyListener(updateListener);
+
+        vSash.setWeights(new int[] { hSash.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sashBottom.computeSize(SWT.DEFAULT, SWT.DEFAULT).y });
+
+        setControl(container);
+    }
+
+    private void createButtonBar() {
+        Composite buttonBar = new Composite(container, SWT.NONE);
+        GridLayout buttonBarLayout = new GridLayout(6, false);
+        buttonBarLayout.marginHeight = 0;
+        buttonBarLayout.marginWidth = 0;
+        buttonBar.setLayout(buttonBarLayout);
+
+        removeButton = new Button(buttonBar, SWT.PUSH);
+        removeButton.setImage(deleteImage);
+        removeButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_removeElement);
+        removeButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                if (treeViewer.getSelection().isEmpty() || selectedElement == null) {
+                    return;
+                }
+                removeElement();
+                InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                if (inputElement == definition.rootInputElement) {
+                    definition.rootInputElement = null;
+                } else {
+                    inputElement.parentElement.childElements.remove(inputElement);
+                }
+                treeViewer.refresh();
+                validate();
+                updatePreviews();
+                removeButton.setEnabled(false);
+                if (definition.rootInputElement == null) {
+                    addChildButton.setEnabled(true);
+                    addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentEleemnt);
+                } else {
+                    addChildButton.setEnabled(false);
+                }
+                addNextButton.setEnabled(false);
+                moveUpButton.setEnabled(false);
+                moveDownButton.setEnabled(false);
+            }
+        });
+
+        addChildButton = new Button(buttonBar, SWT.PUSH);
+        addChildButton.setImage(addChildImage);
+        addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addChildElement);
+        addChildButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                InputElement inputElement = new InputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
+                if (definition.rootInputElement == null) {
+                    definition.rootInputElement = inputElement;
+                    inputElement.elementName = getChildNameSuggestion(null);
+                } else if (treeViewer.getSelection().isEmpty()) {
+                    return;
+                } else {
+                    InputElement parentInputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                    parentInputElement.addChild(inputElement);
+                    inputElement.elementName = getChildNameSuggestion(parentInputElement);
+                }
+                treeViewer.refresh();
+                treeViewer.setSelection(new StructuredSelection(inputElement), true);
+            }
+        });
+
+        addNextButton = new Button(buttonBar, SWT.PUSH);
+        addNextButton.setImage(addNextImage);
+        addNextButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addNextElement);
+        addNextButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                InputElement inputElement = new InputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
+                if (definition.rootInputElement == null) {
+                    definition.rootInputElement = inputElement;
+                    inputElement.elementName = getChildNameSuggestion(null);
+                } else if (treeViewer.getSelection().isEmpty()) {
+                    return;
+                } else {
+                    InputElement previousInputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                    if (previousInputElement == definition.rootInputElement) {
+                        return;
+                    }
+                    previousInputElement.addNext(inputElement);
+                    inputElement.elementName = getChildNameSuggestion(inputElement.parentElement);
+                }
+                treeViewer.refresh();
+                treeViewer.setSelection(new StructuredSelection(inputElement), true);
+            }
+        });
+
+        feelingLuckyButton = new Button(buttonBar, SWT.PUSH);
+        feelingLuckyButton.setImage(addManyImage);
+        feelingLuckyButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_feelingLucky);
+        feelingLuckyButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                InputElement inputElement = null;
+                if (definition.rootInputElement == null) {
+                    if (getChildNameSuggestion(null).length() != 0) {
+                        inputElement = new InputElement(getChildNameSuggestion(null), false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$
+                        definition.rootInputElement = inputElement;
+                        feelingLucky(inputElement);
+                    } else {
+                        return;
+                    }
+                } else if (treeViewer.getSelection().isEmpty()) {
+                    return;
+                } else {
+                    inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                    feelingLucky(inputElement);
+                }
+                treeViewer.refresh();
+                treeViewer.setSelection(new StructuredSelection(inputElement), true);
+                treeViewer.expandToLevel(inputElement, AbstractTreeViewer.ALL_LEVELS);
+            }
+        });
+
+        moveUpButton = new Button(buttonBar, SWT.PUSH);
+        moveUpButton.setImage(moveUpImage);
+        moveUpButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_moveUp);
+        moveUpButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                if (treeViewer.getSelection().isEmpty()) {
+                    return;
+                }
+                InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                if (inputElement == definition.rootInputElement) {
+                    return;
+                }
+                inputElement.moveUp();
+                treeViewer.refresh();
+                validate();
+                updatePreviews();
+            }
+        });
+
+        moveDownButton = new Button(buttonBar, SWT.PUSH);
+        moveDownButton.setImage(moveDownImage);
+        moveDownButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_moveDown);
+        moveDownButton.addSelectionListener(new SelectionAdapter() {
+            @Override
+            public void widgetSelected(SelectionEvent e) {
+                if (treeViewer.getSelection().isEmpty()) {
+                    return;
+                }
+                InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
+                if (inputElement == definition.rootInputElement) {
+                    return;
+                }
+                inputElement.moveDown();
+                treeViewer.refresh();
+                validate();
+                updatePreviews();
+            }
+        });
+    }
+
+    private void feelingLucky(InputElement inputElement) {
+        while (true) {
+            String attributeName = getAttributeNameSuggestion(inputElement);
+            if (attributeName.length() == 0) {
+                break;
+            }
+            InputAttribute attribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$
+            inputElement.addAttribute(attribute);
+        }
+        while (true) {
+            String childName = getChildNameSuggestion(inputElement);
+            if (childName.length() == 0) {
+                break;
+            }
+            InputElement childElement = new InputElement(childName, false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$
+            inputElement.addChild(childElement);
+            feelingLucky(childElement);
+        }
+    }
+
+    private static class InputElementTreeNodeContentProvider implements ITreeContentProvider {
+
+        @Override
+        public Object[] getElements(Object inputElement) {
+            CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) inputElement;
+            if (def.rootInputElement != null) {
+                return new Object[] { def.rootInputElement };
+            }
+            return new Object[0];
+        }
+
+        @Override
+        public Object[] getChildren(Object parentElement) {
+            InputElement inputElement = (InputElement) parentElement;
+            if (inputElement.childElements == null) {
+                return new InputElement[0];
+            }
+            return inputElement.childElements.toArray();
+        }
+
+        @Override
+        public boolean hasChildren(Object element) {
+            InputElement inputElement = (InputElement) element;
+            return (inputElement.childElements != null && inputElement.childElements.size() > 0);
+        }
+
+        @Override
+        public void dispose() {
+        }
+
+        @Override
+        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+        }
+
+        @Override
+        public Object getParent(Object element) {
+            InputElement inputElement = (InputElement) element;
+            return inputElement.parentElement;
+        }
+    }
+
+    private static class InputElementTreeLabelProvider extends ColumnLabelProvider {
+
+        @Override
+        public Image getImage(Object element) {
+            return elementImage;
+        }
+
+        @Override
+        public String getText(Object element) {
+            InputElement inputElement = (InputElement) element;
+            return (inputElement.elementName.trim().length() == 0) ? "?" : inputElement.elementName; //$NON-NLS-1$
+        }
+    }
+
+    private class InputElementTreeSelectionChangedListener implements ISelectionChangedListener {
+        @Override
+        public void selectionChanged(SelectionChangedEvent event) {
+            if (selectedElement != null) {
+                selectedElement.dispose();
+            }
+            if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) {
+                IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+                InputElement inputElement = (InputElement) selection.getFirstElement();
+                selectedElement = new ElementNode(elementContainer, inputElement);
+                elementContainer.layout();
+                elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
+                        elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
+                container.layout();
+                validate();
+                updatePreviews();
+                removeButton.setEnabled(true);
+                addChildButton.setEnabled(true);
+                addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addChildElement);
+                if (definition.rootInputElement == inputElement) {
+                    addNextButton.setEnabled(false);
+                } else {
+                    addNextButton.setEnabled(true);
+                }
+                moveUpButton.setEnabled(true);
+                moveDownButton.setEnabled(true);
+            } else {
+                removeButton.setEnabled(false);
+                if (definition.rootInputElement == null) {
+                    addChildButton.setEnabled(true);
+                    addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentElement);
+                } else {
+                    addChildButton.setEnabled(false);
+                }
+                addNextButton.setEnabled(false);
+                moveUpButton.setEnabled(false);
+                moveDownButton.setEnabled(false);
+            }
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.eclipse.jface.dialogs.DialogPage#dispose()
+     */
+    @Override
+    public void dispose() {
+        if (fixedFont != null) {
+            fixedFont.dispose();
+            fixedFont = null;
+        }
+        super.dispose();
+    }
+
+    private void loadDefinition(CustomXmlTraceDefinition def) {
+        logtypeText.setText(def.definitionName);
+        timeStampOutputFormatText.setText(def.timeStampOutputFormat);
+        treeViewer.setInput(def);
+
+        if (def.rootInputElement != null) {
+            treeViewer.setSelection(new StructuredSelection(def.rootInputElement));
+        }
+    }
+
+    private String getName(InputElement inputElement) {
+        String name = (inputElement.elementName.trim().length() == 0) ? "?" : inputElement.elementName.trim(); //$NON-NLS-1$
+        if (inputElement.parentElement == null) {
+            return name;
+        }
+        return getName(inputElement.parentElement) + " : " + name; //$NON-NLS-1$
+    }
+
+    private String getName(InputAttribute inputAttribute, InputElement inputElement) {
+        String name = (inputAttribute.attributeName.trim().length() == 0) ? "?" : inputAttribute.attributeName.trim(); //$NON-NLS-1$
+        return getName(inputElement) + " : " + name; //$NON-NLS-1$
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
+     */
+    @Override
+    public void setVisible(boolean visible) {
+        if (visible) {
+            validate();
+            updatePreviews();
+        }
+        super.setVisible(visible);
+    }
+
+    public List<String> getInputNames() {
+        return getInputNames(definition.rootInputElement);
+    }
+
+    public List<String> getInputNames(InputElement inputElement) {
+        List<String> inputs = new ArrayList<String>();
+        if (inputElement.inputName != null && !inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
+            String inputName = inputElement.inputName;
+            if (!inputs.contains(inputName)) {
+                inputs.add(inputName);
+            }
+        }
+        if (inputElement.attributes != null) {
+            for (InputAttribute attribute : inputElement.attributes) {
+                String inputName = attribute.inputName;
+                if (!inputs.contains(inputName)) {
+                    inputs.add(inputName);
+                }
+            }
+        }
+        if (inputElement.childElements != null) {
+            for (InputElement childInputElement : inputElement.childElements) {
+                for (String inputName : getInputNames(childInputElement)) {
+                    if (!inputs.contains(inputName)) {
+                        inputs.add(inputName);
+                    }
+                }
+            }
+        }
+        return inputs;
+    }
+
+    private void removeElement() {
+        selectedElement.dispose();
+        selectedElement = null;
+        elementContainer.layout();
+        elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
+                elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
+        container.layout();
+    }
+
+    private String getSelectionText() {
+        InputStream inputStream = null;
+        if (this.selection instanceof IStructuredSelection) {
+            Object selection = ((IStructuredSelection) this.selection).getFirstElement();
+            if (selection instanceof IFile) {
+                IFile file = (IFile) selection;
+                try {
+                    inputStream = file.getContents();
+                } catch (CoreException e) {
+                    return ""; //$NON-NLS-1$
+                }
+            }
+        }
+        if (inputStream != null) {
+            BufferedReader reader = null;
+            try {
+                reader = new BufferedReader(new InputStreamReader(inputStream));
+                StringBuilder sb = new StringBuilder();
+                String line = null;
+                while ((line = reader.readLine()) != null) {
+                    sb.append(line + "\n"); //$NON-NLS-1$
+                }
+                parseXmlInput(sb.toString());
+                reader.close();
+                return sb.toString();
+            } catch (IOException e) {
+                return ""; //$NON-NLS-1$
+            }
+        }
+        return ""; //$NON-NLS-1$
+    }
+
+    private void parseXmlInput(final String string) {
+        try {
+            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+            DocumentBuilder db = dbf.newDocumentBuilder();
+
+            // The following allows xml parsing without access to the dtd
+            EntityResolver resolver = new EntityResolver() {
+                @Override
+                public InputSource resolveEntity(String publicId, String systemId) {
+                    String empty = ""; //$NON-NLS-1$
+                    ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
+                    return new InputSource(bais);
+                }
+            };
+            db.setEntityResolver(resolver);
+
+            // The following catches xml parsing exceptions
+            db.setErrorHandler(new ErrorHandler() {
+                @Override
+                public void error(SAXParseException saxparseexception) throws SAXException {
+                }
+
+                @Override
+                public void warning(SAXParseException saxparseexception) throws SAXException {
+                }
+
+                @Override
+                public void fatalError(SAXParseException saxparseexception) throws SAXException {
+                    if (string.trim().length() != 0) {
+                        errorText.setText(saxparseexception.getMessage());
+                        errorText.setBackground(COLOR_LIGHT_RED);
+                        errorText.setVisible(true);
+                    }
+                    throw saxparseexception;
+                }
+            });
+
+            errorText.setVisible(false);
+            Document doc = null;
+            doc = db.parse(new ByteArrayInputStream(string.getBytes()));
+            documentElement = doc.getDocumentElement();
+        } catch (ParserConfigurationException e) {
+            Activator.getDefault().logError("Error pasing XML input string: " + string, e); //$NON-NLS-1$
+            documentElement = null;
+        } catch (SAXException e) {
+            documentElement = null;
+        } catch (IOException e) {
+            Activator.getDefault().logError("Error pasing XML input string: " + string, e); //$NON-NLS-1$
+            documentElement = null;
+        }
+    }
+
+    private void updatePreviews() {
+        updatePreviews(false);
+    }
+
+    private void initValues() {
+        timeStampValue = null;
+        timeStampFormat = null;
+        logEntriesCount = 0;
+        logEntryFound = false;
+    }
+
+    private void updatePreviews(boolean updateAll) {
+        if (inputText == null) {
+            // early update during construction
+            return;
+        }
+        inputText.setStyleRanges(new StyleRange[] {});
+        if (selectedElement == null) {
+            return;
+        }
+
+        initValues();
+
+        selectedElement.updatePreview();
+
+        if (timeStampValue != null && timeStampFormat != null) {
+            try {
+                SimpleDateFormat dateFormat = new SimpleDateFormat(timeStampFormat);
+                Date date = dateFormat.parse(timeStampValue);
+                dateFormat = new SimpleDateFormat(timeStampOutputFormatText.getText().trim());
+                timeStampPreviewText.setText(dateFormat.format(date));
+            } catch (ParseException e) {
+                timeStampPreviewText.setText("*parse exception* [" + timeStampValue + "] <> [" + timeStampFormat + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+            } catch (IllegalArgumentException e) {
+                timeStampPreviewText.setText("*parse exception* [Illegal Argument]"); //$NON-NLS-1$
+            }
+        } else {
+            timeStampPreviewText.setText("*no matching time stamp*"); //$NON-NLS-1$
+        }
+    }
+
+    private void openHelpShell(String url) {
+        if (helpBrowser != null && !helpBrowser.isDisposed()) {
+            helpBrowser.getShell().setActive();
+            if (!helpBrowser.getUrl().equals(url)) {
+                helpBrowser.setUrl(url);
+            }
+            return;
+        }
+        final Shell helpShell = new Shell(getShell(), SWT.SHELL_TRIM);
+        helpShell.setLayout(new FillLayout());
+        helpBrowser = new Browser(helpShell, SWT.NONE);
+        helpBrowser.addTitleListener(new TitleListener() {
+            @Override
+            public void changed(TitleEvent event) {
+                helpShell.setText(event.title);
+            }
+        });
+        helpBrowser.setBounds(0, 0, 600, 400);
+        helpShell.pack();
+        helpShell.open();
+        helpBrowser.setUrl(url);
+    }
+
+    private class UpdateListener implements ModifyListener, SelectionListener {
+
+        @Override
+        public void modifyText(ModifyEvent e) {
+            validate();
+            updatePreviews();
+        }
+
+        @Override
+        public void widgetDefaultSelected(SelectionEvent e) {
+            validate();
+            updatePreviews();
+        }
+
+        @Override
+        public void widgetSelected(SelectionEvent e) {
+            validate();
+            updatePreviews();
+        }
+
+    }
+
+    private class ElementNode {
+        final InputElement inputElement;
+        final Group group;
+        List<Attribute> attributes = new ArrayList<Attribute>();
+        List<ElementNode> childElements = new ArrayList<ElementNode>();
+        Text elementNameText;
+        Composite tagComposite;
+        Combo tagCombo;
+        Label tagLabel;
+        Text tagText;
+        Combo actionCombo;
+        Label previewLabel;
+        Text previewText;
+        Button logEntryButton;
+        Label fillerLabel;
+        Composite addAttributeComposite;
+        Button addAttributeButton;
+        Label addAttributeLabel;
+
+        public ElementNode(Composite parent, InputElement inputElement) {
+            this.inputElement = inputElement;
+
+            group = new Group(parent, SWT.NONE);
+            GridLayout gl = new GridLayout(2, false);
+            gl.marginHeight = 0;
+            group.setLayout(gl);
+            group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            group.setText(getName(inputElement));
+
+            Label label = new Label(group, SWT.NULL);
+            label.setText(Messages.CustomXmlParserInputWizardPage_elementName);
+            label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+            elementNameText = new Text(group, SWT.BORDER | SWT.SINGLE);
+            GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+            gd.widthHint = 0;
+            elementNameText.setLayoutData(gd);
+            elementNameText.addModifyListener(new ModifyListener() {
+                @Override
+                public void modifyText(ModifyEvent e) {
+                    ElementNode.this.inputElement.elementName = elementNameText.getText().trim();
+                    group.setText(getName(ElementNode.this.inputElement));
+                }
+            });
+            elementNameText.setText(inputElement.elementName);
+            elementNameText.addModifyListener(updateListener);
+
+            if (inputElement.parentElement != null) {
+                previewLabel = new Label(group, SWT.NULL);
+                previewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+                previewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);
+
+                previewText = new Text(group, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
+                gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+                gd.widthHint = 0;
+                previewText.setLayoutData(gd);
+                previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);
+                previewText.setBackground(COLOR_WIDGET_BACKGROUND);
+
+                logEntryButton = new Button(group, SWT.CHECK);
+                logEntryButton.setText(Messages.CustomXmlParserInputWizardPage_logEntry);
+                logEntryButton.setSelection(inputElement.logEntry);
+                logEntryButton.addSelectionListener(new SelectionListener() {
+                    @Override
+                    public void widgetDefaultSelected(SelectionEvent e) {
+                    }
+
+                    @Override
+                    public void widgetSelected(SelectionEvent e) {
+                        InputElement parent = ElementNode.this.inputElement.parentElement;
+                        while (parent != null) {
+                            parent.logEntry = false;
+                            parent = parent.parentElement;
+                        }
+                    }
+                });
+                logEntryButton.addSelectionListener(updateListener);
+
+                tagComposite = new Composite(group, SWT.FILL);
+                GridLayout tagLayout = new GridLayout(4, false);
+                tagLayout.marginWidth = 0;
+                tagLayout.marginHeight = 0;
+                tagComposite.setLayout(tagLayout);
+                tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+                tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
+                tagCombo.setItems(new String[] { CustomXmlTraceDefinition.TAG_IGNORE, CustomTraceDefinition.TAG_TIMESTAMP,
+                        CustomTraceDefinition.TAG_MESSAGE, CustomTraceDefinition.TAG_OTHER });
+                tagCombo.setVisibleItemCount(tagCombo.getItemCount());
+                tagCombo.addSelectionListener(new SelectionListener() {
+                    @Override
+                    public void widgetDefaultSelected(SelectionEvent e) {
+                    }
+
+                    @Override
+                    public void widgetSelected(SelectionEvent e) {
+                        tagText.removeModifyListener(updateListener);
+                        switch (tagCombo.getSelectionIndex()) {
+                        case 0: // Ignore
+                            tagLabel.setVisible(false);
+                            tagText.setVisible(false);
+                            actionCombo.setVisible(false);
+                            break;
+                        case 1: // Time Stamp
+                            tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
+                            tagLabel.setVisible(true);
+                            tagText.setVisible(true);
+                            tagText.addModifyListener(updateListener);
+                            actionCombo.setVisible(true);
+                            break;
+                        case 2: // Message
+                            tagLabel.setVisible(false);
+                            tagText.setVisible(false);
+                            actionCombo.setVisible(true);
+                            break;
+                        case 3: // Other
+                            tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
+                            tagLabel.setVisible(true);
+                            if (tagText.getText().trim().length() == 0) {
+                                tagText.setText(elementNameText.getText().trim());
+                            }
+                            tagText.setVisible(true);
+                            tagText.addModifyListener(updateListener);
+                            actionCombo.setVisible(true);
+                            break;
+                        default:
+                            break;
+                        }
+                        tagComposite.layout();
+                        validate();
+                        updatePreviews();
+                    }
+                });
+
+                tagLabel = new Label(tagComposite, SWT.NULL);
+                tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+                tagText = new Text(tagComposite, SWT.BORDER | SWT.SINGLE);
+                gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+                gd.widthHint = 0;
+                tagText.setLayoutData(gd);
+
+                actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
+                actionCombo.setItems(new String[] { Messages.CustomXmlParserInputWizardPage_set, Messages.CustomXmlParserInputWizardPage_append,
+                        Messages.CustomXmlParserInputWizardPage_appendWith });
+                actionCombo.select(inputElement.inputAction);
+                actionCombo.addSelectionListener(updateListener);
+
+                if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
+                    tagCombo.select(0);
+                    tagLabel.setVisible(false);
+                    tagText.setVisible(false);
+                    actionCombo.setVisible(false);
+                } else if (inputElement.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                    tagCombo.select(1);
+                    tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
+                    tagText.setText(inputElement.inputFormat);
+                    tagText.addModifyListener(updateListener);
+                } else if (inputElement.inputName.equals(CustomTraceDefinition.TAG_MESSAGE)) {
+                    tagCombo.select(2);
+                    tagLabel.setVisible(false);
+                    tagText.setVisible(false);
+                } else {
+                    tagCombo.select(3);
+                    tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
+                    tagText.setText(inputElement.inputName);
+                    tagText.addModifyListener(updateListener);
+                }
+            }
+
+            if (inputElement.attributes != null) {
+                for (InputAttribute inputAttribute : inputElement.attributes) {
+                    Attribute attribute = new Attribute(group, this, inputAttribute, attributes.size() + 1);
+                    attributes.add(attribute);
+                }
+            }
+
+            createAddButton();
+        }
+
+        private void updatePreview() {
+            Element element = getPreviewElement(inputElement);
+            if (inputElement.parentElement != null) { // no preview text for
+                                                      // document element
+                previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);
+                if (element != null) {
+                    previewText.setText(CustomXmlTrace.parseElement(element, new StringBuffer()).toString());
+                    if (logEntryButton.getSelection()) {
+                        if (!logEntryFound) {
+                            logEntryFound = true;
+                            logEntriesCount++;
+                        } else {
+                            logEntryButton.setSelection(false); // remove nested
+                                                                // log entry
+                        }
+                    }
+                    if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {
+                        String value = previewText.getText().trim();
+                        if (value.length() != 0) {
+                            if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_SET) {
+                                timeStampValue = value;
+                                timeStampFormat = tagText.getText().trim();
+                            } else if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND) {
+                                if (timeStampValue != null) {
+                                    timeStampValue += value;
+                                    timeStampFormat += tagText.getText().trim();
+                                } else {
+                                    timeStampValue = value;
+                                    timeStampFormat = tagText.getText().trim();
+                                }
+                            } else if (actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
+                                if (timeStampValue != null) {
+                                    timeStampValue += " | " + value; //$NON-NLS-1$
+                                    timeStampFormat += " | " + tagText.getText().trim(); //$NON-NLS-1$
+                                } else {
+                                    timeStampValue = value;
+                                    timeStampFormat = tagText.getText().trim();
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+            for (Attribute attribute : attributes) {
+                if (element != null) {
+                    String value = element.getAttribute(attribute.attributeNameText.getText().trim());
+                    if (value.length() != 0) {
+                        attribute.previewText.setText(value);
+                        if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {
+                            if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_SET) {
+                                timeStampValue = value;
+                                timeStampFormat = attribute.tagText.getText().trim();
+                            } else if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND) {
+                                if (timeStampValue != null) {
+                                    timeStampValue += value;
+                                    timeStampFormat += attribute.tagText.getText().trim();
+                                } else {
+                                    timeStampValue = value;
+                                    timeStampFormat = attribute.tagText.getText().trim();
+                                }
+                            } else if (attribute.actionCombo.getSelectionIndex() == CustomTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
+                                if (timeStampValue != null) {
+                                    timeStampValue += " | " + value; //$NON-NLS-1$
+                                    timeStampFormat += " | " + attribute.tagText.getText().trim(); //$NON-NLS-1$
+                                } else {
+                                    timeStampValue = value;
+                                    timeStampFormat = attribute.tagText.getText().trim();
+                                }
+                            }
+                        }
+                    } else {
+                        attribute.previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingAttribute);
+                    }
+                } else {
+                    attribute.previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);
+                }
+            }
+            for (ElementNode child : childElements) {
+                child.updatePreview();
+            }
+            if (logEntryButton != null && logEntryButton.getSelection()) {
+                logEntryFound = false;
+            }
+        }
+
+        private void createAddButton() {
+            fillerLabel = new Label(group, SWT.NONE);
+
+            addAttributeComposite = new Composite(group, SWT.NONE);
+            addAttributeComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            GridLayout addAttributeLayout = new GridLayout(2, false);
+            addAttributeLayout.marginHeight = 0;
+            addAttributeLayout.marginWidth = 0;
+            addAttributeComposite.setLayout(addAttributeLayout);
+
+            addAttributeButton = new Button(addAttributeComposite, SWT.PUSH);
+            addAttributeButton.setImage(addImage);
+            addAttributeButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addAttribute);
+            addAttributeButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    removeAddButton();
+                    String attributeName = getAttributeNameSuggestion(inputElement);
+                    InputAttribute inputAttribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$
+                    attributes.add(new Attribute(group, ElementNode.this, inputAttribute, attributes.size() + 1));
+                    createAddButton();
+                    elementContainer.layout();
+                    elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
+                            elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
+                    group.getParent().layout();
+                    validate();
+                    updatePreviews();
+                }
+            });
+
+            addAttributeLabel = new Label(addAttributeComposite, SWT.NULL);
+            addAttributeLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+            addAttributeLabel.setText(Messages.CustomXmlParserInputWizardPage_newAttibute);
+        }
+
+        private void removeAddButton() {
+            fillerLabel.dispose();
+            addAttributeComposite.dispose();
+        }
+
+        private void removeAttribute(int attributeNumber) {
+            if (--attributeNumber < attributes.size()) {
+                attributes.remove(attributeNumber).dispose();
+                for (int i = attributeNumber; i < attributes.size(); i++) {
+                    attributes.get(i).setAttributeNumber(i + 1);
+                }
+                elementContainer.layout();
+                elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
+                        elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
+                group.getParent().layout();
+            }
+        }
+
+        private void dispose() {
+            group.dispose();
+        }
+
+        private void extractInputs() {
+            inputElement.elementName = elementNameText.getText().trim();
+            if (inputElement.parentElement != null) {
+                inputElement.logEntry = logEntryButton.getSelection();
+                if (tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {
+                    inputElement.inputName = tagText.getText().trim();
+                } else {
+                    inputElement.inputName = tagCombo.getText();
+                    if (tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                        inputElement.inputFormat = tagText.getText().trim();
+                    }
+                }
+                inputElement.inputAction = actionCombo.getSelectionIndex();
+            }
+            inputElement.attributes = new ArrayList<InputAttribute>(attributes.size());
+            for (int i = 0; i < attributes.size(); i++) {
+                Attribute attribute = attributes.get(i);
+                InputAttribute inputAttribute = new InputAttribute();
+                inputAttribute.attributeName = attribute.attributeNameText.getText().trim();
+                if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {
+                    inputAttribute.inputName = attribute.tagText.getText().trim();
+                } else {
+                    inputAttribute.inputName = attribute.tagCombo.getText();
+                    if (attribute.tagCombo.getText().equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                        inputAttribute.inputFormat = attribute.tagText.getText().trim();
+                    }
+                }
+                inputAttribute.inputAction = attribute.actionCombo.getSelectionIndex();
+                inputElement.addAttribute(inputAttribute);
+            }
+        }
+    }
+
+    private class Attribute {
+        ElementNode element;
+        int attributeNumber;
+
+        // children of parent (must be disposed)
+        Composite labelComposite;
+        Composite attributeComposite;
+        Label filler;
+        Composite tagComposite;
+
+        // children of labelComposite
+        Label attributeLabel;
+
+        // children of attributeComposite
+        Text attributeNameText;
+        Text previewText;
+
+        // children of tagComposite
+        Combo tagCombo;
+        Label tagLabel;
+        Text tagText;
+        Combo actionCombo;
+
+        public Attribute(Composite parent, ElementNode element, InputAttribute inputAttribute, int attributeNumber) {
+            this.element = element;
+            this.attributeNumber = attributeNumber;
+
+            labelComposite = new Composite(parent, SWT.FILL);
+            GridLayout labelLayout = new GridLayout(2, false);
+            labelLayout.marginWidth = 0;
+            labelLayout.marginHeight = 0;
+            labelComposite.setLayout(labelLayout);
+            labelComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+            Button deleteButton = new Button(labelComposite, SWT.PUSH);
+            deleteButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+            deleteButton.setImage(deleteImage);
+            deleteButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_removeAttribute);
+            deleteButton.addSelectionListener(new SelectionAdapter() {
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    Attribute.this.element.removeAttribute(Attribute.this.attributeNumber);
+                    validate();
+                    updatePreviews();
+                }
+            });
+
+            attributeLabel = new Label(labelComposite, SWT.NULL);
+            attributeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+            attributeLabel.setText(Messages.CustomXmlParserInputWizardPage_attibute);
+
+            attributeComposite = new Composite(parent, SWT.FILL);
+            GridLayout attributeLayout = new GridLayout(4, false);
+            attributeLayout.marginWidth = 0;
+            attributeLayout.marginHeight = 0;
+            attributeComposite.setLayout(attributeLayout);
+            attributeComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+            Label nameLabel = new Label(attributeComposite, SWT.NONE);
+            nameLabel.setText(Messages.CustomXmlParserInputWizardPage_name);
+
+            attributeNameText = new Text(attributeComposite, SWT.BORDER | SWT.SINGLE);
+            attributeNameText.setLayoutData(new GridData(120, SWT.DEFAULT));
+            attributeNameText.setText(inputAttribute.attributeName);
+            attributeNameText.addModifyListener(updateListener);
+
+            Label previewLabel = new Label(attributeComposite, SWT.NONE);
+            previewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);
+
+            previewText = new Text(attributeComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
+            GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+            gd.widthHint = 0;
+            previewText.setLayoutData(gd);
+            previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatch);
+            previewText.setBackground(COLOR_WIDGET_BACKGROUND);
+
+            filler = new Label(parent, SWT.NULL);
+
+            tagComposite = new Composite(parent, SWT.FILL);
+            GridLayout tagLayout = new GridLayout(4, false);
+            tagLayout.marginWidth = 0;
+            tagLayout.marginHeight = 0;
+            tagComposite.setLayout(tagLayout);
+            tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+
+            tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
+            tagCombo.setItems(new String[] { CustomTraceDefinition.TAG_TIMESTAMP, CustomTraceDefinition.TAG_MESSAGE,
+                    CustomTraceDefinition.TAG_OTHER });
+            tagCombo.select(2); // Other
+            tagCombo.addSelectionListener(new SelectionListener() {
+                @Override
+                public void widgetDefaultSelected(SelectionEvent e) {
+                }
+
+                @Override
+                public void widgetSelected(SelectionEvent e) {
+                    tagText.removeModifyListener(updateListener);
+                    switch (tagCombo.getSelectionIndex()) {
+                    case 0: // Time Stamp
+                        tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
+                        tagLabel.setVisible(true);
+                        tagText.setVisible(true);
+                        tagText.addModifyListener(updateListener);
+                        break;
+                    case 1: // Message
+                        tagLabel.setVisible(false);
+                        tagText.setVisible(false);
+                        break;
+                    case 2: // Other
+                        tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
+                        tagLabel.setVisible(true);
+                        if (tagText.getText().trim().length() == 0) {
+                            tagText.setText(attributeNameText.getText().trim());
+                        }
+                        tagText.setVisible(true);
+                        tagText.addModifyListener(updateListener);
+                        break;
+                    default:
+                        break;
+                    }
+                    tagComposite.layout();
+                    validate();
+                    updatePreviews();
+                }
+            });
+
+            tagLabel = new Label(tagComposite, SWT.NULL);
+            tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+
+            tagText = new Text(tagComposite, SWT.BORDER | SWT.SINGLE);
+            gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+            gd.widthHint = 0;
+            tagText.setLayoutData(gd);
+            tagText.setText(attributeNameText.getText());
+
+            actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
+            actionCombo.setItems(new String[] { Messages.CustomXmlParserInputWizardPage_set, Messages.CustomXmlParserInputWizardPage_append,
+                    Messages.CustomXmlParserInputWizardPage_appendWith });
+            actionCombo.select(inputAttribute.inputAction);
+            actionCombo.addSelectionListener(updateListener);
+
+            if (inputAttribute.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                tagCombo.select(0);
+                tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
+                tagText.setText(inputAttribute.inputFormat);
+                tagText.addModifyListener(updateListener);
+            } else if (inputAttribute.inputName.equals(CustomTraceDefinition.TAG_MESSAGE)) {
+                tagCombo.select(1);
+                tagLabel.setVisible(false);
+                tagText.setVisible(false);
+            } else {
+                tagCombo.select(2);
+                tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
+                tagText.setText(inputAttribute.inputName);
+                tagText.addModifyListener(updateListener);
+            }
+        }
+
+        private void dispose() {
+            labelComposite.dispose();
+            attributeComposite.dispose();
+            filler.dispose();
+            tagComposite.dispose();
+        }
+
+        private void setAttributeNumber(int attributeNumber) {
+            this.attributeNumber = attributeNumber;
+            labelComposite.layout();
+        }
+    }
+
+    private Element getPreviewElement(InputElement inputElement) {
+        Element element = documentElement;
+        if (element != null) {
+            if (!documentElement.getNodeName().equals(definition.rootInputElement.elementName)) {
+                return null;
+            }
+            ArrayList<String> elementNames = new ArrayList<String>();
+            while (inputElement != null) {
+                elementNames.add(inputElement.elementName);
+                inputElement = inputElement.parentElement;
+            }
+            for (int i = elementNames.size() - 1; --i >= 0;) {
+                NodeList childList = element.getChildNodes();
+                element = null;
+                for (int j = 0; j < childList.getLength(); j++) {
+                    Node child = childList.item(j);
+                    if (child instanceof Element && child.getNodeName().equals(elementNames.get(i))) {
+                        element = (Element) child;
+                        break;
+                    }
+                }
+                if (element == null) {
+                    break;
+                }
+            }
+            if (element != null) {
+                return element;
+            }
+        }
+        return null;
+    }
+
+    private String getChildNameSuggestion(InputElement inputElement) {
+        if (inputElement == null) {
+            if (documentElement != null) {
+                return documentElement.getNodeName();
+            }
+        } else {
+            Element element = getPreviewElement(inputElement);
+            if (element != null) {
+                NodeList childNodes = element.getChildNodes();
+                for (int i = 0; i < childNodes.getLength(); i++) {
+                    Node node = childNodes.item(i);
+                    if (node instanceof Element) {
+                        boolean unused = true;
+                        if (inputElement.childElements != null) {
+                            for (InputElement child : inputElement.childElements) {
+                                if (child.elementName.equals(node.getNodeName())) {
+                                    unused = false;
+                                    break;
+                                }
+                            }
+                        }
+                        if (unused) {
+                            return node.getNodeName();
+                        }
+                    }
+                }
+            }
+        }
+        return ""; //$NON-NLS-1$
+    }
+
+    private String getAttributeNameSuggestion(InputElement inputElement) {
+        Element element = getPreviewElement(inputElement);
+        if (element != null) {
+            NamedNodeMap attributeMap = element.getAttributes();
+            for (int i = 0; i < attributeMap.getLength(); i++) {
+                Node node = attributeMap.item(i);
+                boolean unused = true;
+                if (inputElement.attributes != null) {
+                    for (InputAttribute attribute : inputElement.attributes) {
+                        if (attribute.attributeName.equals(node.getNodeName())) {
+                            unused = false;
+                            break;
+                        }
+                    }
+                }
+                if (unused) {
+                    return node.getNodeName();
+                }
+            }
+        }
+        return ""; //$NON-NLS-1$
+    }
+
+    private void validate() {
+        definition.definitionName = logtypeText.getText().trim();
+        definition.timeStampOutputFormat = timeStampOutputFormatText.getText().trim();
+
+        if (selectedElement != null) {
+            selectedElement.extractInputs();
+            treeViewer.refresh();
+        }
+
+        StringBuffer errors = new StringBuffer();
+
+        if (definition.definitionName.length() == 0) {
+            errors.append(Messages.CustomXmlParserInputWizardPage_emptyLogTypeError);
+            logtypeText.setBackground(COLOR_LIGHT_RED);
+        } else {
+            logtypeText.setBackground(COLOR_TEXT_BACKGROUND);
+            for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
+                if (definition.definitionName.equals(def.definitionName)) {
+                    if (editDefinitionName == null || !editDefinitionName.equals(definition.definitionName)) {
+                        errors.append(Messages.CustomXmlParserInputWizardPage_duplicatelogTypeError);
+                        logtypeText.setBackground(COLOR_LIGHT_RED);
+                        break;
+                    }
+                }
+            }
+        }
+
+        if (definition.rootInputElement == null) {
+            errors.append(Messages.CustomXmlParserInputWizardPage_noDocumentError);
+        }
+
+        if (definition.rootInputElement != null) {
+            logEntryFound = false;
+            timeStampFound = false;
+
+            errors.append(validateElement(definition.rootInputElement));
+
+            if ((definition.rootInputElement.attributes != null && definition.rootInputElement.attributes.size() != 0)
+                    || (definition.rootInputElement.childElements != null && definition.rootInputElement.childElements.size() != 0)
+                    || errors.length() == 0) {
+                if (!logEntryFound) {
+                    errors.append(Messages.CustomXmlParserInputWizardPage_missingLogEntryError);
+                }
+
+                if (timeStampFound) {
+                    if (timeStampOutputFormatText.getText().trim().length() == 0) {
+                        errors.append(Messages.CustomXmlParserInputWizardPage_missingTimestampFmtError);
+                        timeStampOutputFormatText.setBackground(COLOR_LIGHT_RED);
+                    } else {
+                        try {
+                            new SimpleDateFormat(timeStampOutputFormatText.getText().trim());
+                            timeStampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);
+                        } catch (IllegalArgumentException e) {
+                            errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampFmtError);
+                            timeStampOutputFormatText.setBackground(COLOR_LIGHT_RED);
+                        }
+                    }
+                } else {
+                    timeStampPreviewText.setText(Messages.CustomXmlParserInputWizardPage_notimestamporAttributeError);
+                }
+            }
+        } else {
+            timeStampPreviewText.setText(Messages.CustomXmlParserInputWizardPage_notimestamporAttributeError);
+        }
+
+        if (errors.length() == 0) {
+            setDescription(defaultDescription);
+            setPageComplete(true);
+        } else {
+            setDescription(errors.toString());
+            setPageComplete(false);
+        }
+    }
+
+    public StringBuffer validateElement(InputElement inputElement) {
+        StringBuffer errors = new StringBuffer();
+        ElementNode elementNode = null;
+        if (selectedElement != null && selectedElement.inputElement.equals(inputElement)) {
+            elementNode = selectedElement;
+        }
+        if (inputElement == definition.rootInputElement) {
+            if (inputElement.elementName.length() == 0) {
+                errors.append(Messages.CustomXmlParserInputWizardPage_missingDocumentElementError);
+                if (elementNode != null) {
+                    elementNode.elementNameText.setBackground(COLOR_LIGHT_RED);
+                }
+            } else {
+                if (elementNode != null) {
+                    elementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND);
+                }
+            }
+        }
+        if (inputElement != definition.rootInputElement) {
+            if (inputElement.logEntry) {
+                logEntryFound = true;
+            }
+            if (inputElement.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                timeStampFound = true;
+                if (inputElement.inputFormat.length() == 0) {
+                    errors.append(Messages.CustomXmlParserInputWizardPage_timestampFormatPrompt
+                            + " (" + Messages.CustomXmlParserInputWizardPage_timestampElementPrompt + " " + getName(inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    if (elementNode != null) {
+                        elementNode.tagText.setBackground(COLOR_LIGHT_RED);
+                    }
+                } else {
+                    try {
+                        new SimpleDateFormat(inputElement.inputFormat);
+                        if (elementNode != null) {
+                            elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);
+                        }
+                    } catch (IllegalArgumentException e) {
+                        errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampFmtError
+                                + " (" + Messages.CustomXmlParserInputWizardPage_timestampElementPrompt + " " + getName(inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                        if (elementNode != null) {
+                            elementNode.tagText.setBackground(COLOR_LIGHT_RED);
+                        }
+                    }
+                }
+            } else if (inputElement.inputName.length() == 0) {
+                errors.append(Messages.CustomXmlParserInputWizardPage_missingInputElementNameError);
+                if (elementNode != null) {
+                    elementNode.tagText.setBackground(COLOR_LIGHT_RED);
+                }
+            } else {
+                if (elementNode != null) {
+                    elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);
+                }
+            }
+        }
+        if (inputElement.attributes != null) {
+            if (elementNode != null) {
+                for (Attribute attribute : elementNode.attributes) {
+                    attribute.attributeNameText.setBackground(COLOR_TEXT_BACKGROUND);
+                }
+            }
+            for (int i = 0; i < inputElement.attributes.size(); i++) {
+                InputAttribute attribute = inputElement.attributes.get(i);
+                boolean duplicate = false;
+                for (int j = i + 1; j < inputElement.attributes.size(); j++) {
+                    InputAttribute otherAttribute = inputElement.attributes.get(j);
+                    if (otherAttribute.attributeName.equals(attribute.attributeName)) {
+                        duplicate = true;
+                        if (elementNode != null) {
+                            elementNode.attributes.get(j).attributeNameText.setBackground(COLOR_LIGHT_RED);
+                        }
+                    }
+                }
+                if (attribute.attributeName.length() == 0) {
+                    errors.append(Messages.CustomXmlParserInputWizardPage_missingAttribute
+                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(inputElement) + ": ?). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    if (elementNode != null) {
+                        elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);
+                    }
+                } else if (duplicate) {
+                    errors.append(Messages.CustomXmlParserInputWizardPage_duplicateAttributeError
+                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    if (elementNode != null) {
+                        elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);
+                    }
+                }
+                if (attribute.inputName.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
+                    timeStampFound = true;
+                    if (attribute.inputFormat.length() == 0) {
+                        errors.append(Messages.CustomXmlParserInputWizardPage_missingTimestampInFmtError
+                                + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                        if (elementNode != null) {
+                            elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);
+                        }
+                    } else {
+                        try {
+                            new SimpleDateFormat(attribute.inputFormat);
+                            if (elementNode != null) {
+                                elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND);
+                            }
+                        } catch (IllegalArgumentException e) {
+                            errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampInFmtError
+                                    + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                            if (elementNode != null) {
+                                elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);
+                            }
+                        }
+                    }
+                } else if (attribute.inputName.length() == 0) {
+                    errors.append(Messages.CustomXmlParserInputWizardPage_missingDataGroupNameError
+                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    if (elementNode != null) {
+                        elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);
+                    }
+                } else {
+                    if (elementNode != null) {
+                        elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND);
+                    }
+                }
+            }
+        }
+        if (inputElement.childElements != null) {
+            for (InputElement child : inputElement.childElements) {
+                ElementNode childElementNode = null;
+                if (selectedElement != null && selectedElement.inputElement.equals(child)) {
+                    childElementNode = selectedElement;
+                }
+                if (childElementNode != null) {
+                    childElementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND);
+                }
+            }
+            for (int i = 0; i < inputElement.childElements.size(); i++) {
+                InputElement child = inputElement.childElements.get(i);
+                ElementNode childElementNode = null;
+                if (selectedElement != null && selectedElement.inputElement.equals(child)) {
+                    childElementNode = selectedElement;
+                }
+                if (child.elementName.length() == 0) {
+                    errors.append(Messages.CustomXmlParserInputWizardPage_missingElementNameError
+                            + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(child) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    if (childElementNode != null) {
+                        childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);
+                    }
+                } else {
+                    boolean duplicate = false;
+                    for (int j = i + 1; j < inputElement.childElements.size(); j++) {
+                        InputElement otherChild = inputElement.childElements.get(j);
+                        if (otherChild.elementName.equals(child.elementName)) {
+                            duplicate = true;
+                            ElementNode otherChildElementNode = null;
+                            if (selectedElement != null && selectedElement.inputElement.equals(otherChild)) {
+                                otherChildElementNode = selectedElement;
+                            }
+                            if (otherChildElementNode != null) {
+                                otherChildElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);
+                            }
+                        }
+                    }
+                    if (duplicate) {
+                        errors.append(Messages.CustomXmlParserInputWizardPage_duplicateElementNameError
+                                + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(child) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                        if (childElementNode != null) {
+                            childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);
+                        }
+                    }
+                }
+
+                errors.append(validateElement(child));
+            }
+        }
+        return errors;
+    }
+
+    public CustomXmlTraceDefinition getDefinition() {
+        return definition;
+    }
+
+    public char[] getInputText() {
+        return inputText.getText().toCharArray();
+    }
+}
This page took 0.111996 seconds and 5 git commands to generate.