1 /*******************************************************************************
2 * Copyright (c) 2010, 2013 Ericsson
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.wizards
;
15 import java
.io
.BufferedReader
;
16 import java
.io
.ByteArrayInputStream
;
17 import java
.io
.IOException
;
18 import java
.io
.InputStream
;
19 import java
.io
.InputStreamReader
;
20 import java
.text
.ParseException
;
21 import java
.text
.SimpleDateFormat
;
22 import java
.util
.ArrayList
;
23 import java
.util
.Date
;
24 import java
.util
.List
;
26 import javax
.xml
.parsers
.DocumentBuilder
;
27 import javax
.xml
.parsers
.DocumentBuilderFactory
;
28 import javax
.xml
.parsers
.ParserConfigurationException
;
30 import org
.eclipse
.core
.resources
.IFile
;
31 import org
.eclipse
.core
.runtime
.CoreException
;
32 import org
.eclipse
.jface
.viewers
.AbstractTreeViewer
;
33 import org
.eclipse
.jface
.viewers
.ColumnLabelProvider
;
34 import org
.eclipse
.jface
.viewers
.ISelection
;
35 import org
.eclipse
.jface
.viewers
.ISelectionChangedListener
;
36 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
37 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
38 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
39 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
40 import org
.eclipse
.jface
.viewers
.TreeViewer
;
41 import org
.eclipse
.jface
.viewers
.Viewer
;
42 import org
.eclipse
.jface
.wizard
.WizardPage
;
43 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Activator
;
44 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Messages
;
45 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomTraceDefinition
;
46 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomXmlTrace
;
47 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomXmlTraceDefinition
;
48 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomXmlTraceDefinition
.InputAttribute
;
49 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomXmlTraceDefinition
.InputElement
;
50 import org
.eclipse
.swt
.SWT
;
51 import org
.eclipse
.swt
.browser
.Browser
;
52 import org
.eclipse
.swt
.browser
.TitleEvent
;
53 import org
.eclipse
.swt
.browser
.TitleListener
;
54 import org
.eclipse
.swt
.custom
.SashForm
;
55 import org
.eclipse
.swt
.custom
.ScrolledComposite
;
56 import org
.eclipse
.swt
.custom
.StyleRange
;
57 import org
.eclipse
.swt
.custom
.StyledText
;
58 import org
.eclipse
.swt
.events
.ModifyEvent
;
59 import org
.eclipse
.swt
.events
.ModifyListener
;
60 import org
.eclipse
.swt
.events
.SelectionAdapter
;
61 import org
.eclipse
.swt
.events
.SelectionEvent
;
62 import org
.eclipse
.swt
.events
.SelectionListener
;
63 import org
.eclipse
.swt
.graphics
.Color
;
64 import org
.eclipse
.swt
.graphics
.Font
;
65 import org
.eclipse
.swt
.graphics
.FontData
;
66 import org
.eclipse
.swt
.graphics
.Image
;
67 import org
.eclipse
.swt
.layout
.FillLayout
;
68 import org
.eclipse
.swt
.layout
.GridData
;
69 import org
.eclipse
.swt
.layout
.GridLayout
;
70 import org
.eclipse
.swt
.widgets
.Button
;
71 import org
.eclipse
.swt
.widgets
.Combo
;
72 import org
.eclipse
.swt
.widgets
.Composite
;
73 import org
.eclipse
.swt
.widgets
.Display
;
74 import org
.eclipse
.swt
.widgets
.Group
;
75 import org
.eclipse
.swt
.widgets
.Label
;
76 import org
.eclipse
.swt
.widgets
.Shell
;
77 import org
.eclipse
.swt
.widgets
.Text
;
78 import org
.w3c
.dom
.Document
;
79 import org
.w3c
.dom
.Element
;
80 import org
.w3c
.dom
.NamedNodeMap
;
81 import org
.w3c
.dom
.Node
;
82 import org
.w3c
.dom
.NodeList
;
83 import org
.xml
.sax
.EntityResolver
;
84 import org
.xml
.sax
.ErrorHandler
;
85 import org
.xml
.sax
.InputSource
;
86 import org
.xml
.sax
.SAXException
;
87 import org
.xml
.sax
.SAXParseException
;
90 * Input wizard page for custom XML trace parsers.
92 * @author Patrick Tasse
94 public class CustomXmlParserInputWizardPage
extends WizardPage
{
96 private static final String DEFAULT_TIMESTAMP_FORMAT
= "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$
97 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$
98 private static final Image ELEMENT_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/element_icon.gif"); //$NON-NLS-1$
99 private static final Image ADD_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$
100 private static final Image ADD_NEXT_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/addnext_button.gif"); //$NON-NLS-1$
101 private static final Image ADD_CHILD_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/addchild_button.gif"); //$NON-NLS-1$
102 private static final Image ADD_MANY_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/addmany_button.gif"); //$NON-NLS-1$
103 private static final Image DELETE_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$
104 private static final Image MOVE_UP_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/moveup_button.gif"); //$NON-NLS-1$
105 private static final Image MOVE_DOWN_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/movedown_button.gif"); //$NON-NLS-1$
106 private static final Image HELP_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/help_button.gif"); //$NON-NLS-1$
107 private static final Color COLOR_LIGHT_RED
= new Color(Display
.getDefault(), 255, 192, 192);
108 private static final Color COLOR_TEXT_BACKGROUND
= Display
.getDefault().getSystemColor(SWT
.COLOR_WHITE
);
109 private static final Color COLOR_WIDGET_BACKGROUND
= Display
.getDefault().getSystemColor(SWT
.COLOR_WIDGET_BACKGROUND
);
111 private final ISelection selection
;
112 private CustomXmlTraceDefinition definition
;
113 private String editDefinitionName
;
114 private String defaultDescription
;
115 private ElementNode selectedElement
;
116 private Composite container
;
117 private Text logtypeText
;
118 private Text timeStampOutputFormatText
;
119 private Text timeStampPreviewText
;
120 private Button removeButton
;
121 private Button addChildButton
;
122 private Button addNextButton
;
123 private Button moveUpButton
;
124 private Button moveDownButton
;
125 private ScrolledComposite elementScrolledComposite
;
126 private TreeViewer treeViewer
;
127 private Composite elementContainer
;
128 private Text errorText
;
129 private StyledText inputText
;
130 private Font fixedFont
;
131 private UpdateListener updateListener
;
132 private Browser helpBrowser
;
133 private Element documentElement
;
135 // variables used recursively through element traversal
136 private String timeStampValue
;
137 private String timeStampFormat
;
138 private boolean timeStampFound
;
139 private int logEntriesCount
;
140 private boolean logEntryFound
;
150 protected CustomXmlParserInputWizardPage(ISelection selection
, CustomXmlTraceDefinition definition
) {
151 super("CustomXmlParserWizardPage"); //$NON-NLS-1$
152 if (definition
== null) {
153 setTitle(Messages
.CustomXmlParserInputWizardPage_titleNew
);
154 defaultDescription
= Messages
.CustomXmlParserInputWizardPage_descriptionNew
;
156 setTitle(Messages
.CustomXmlParserInputWizardPage_titleEdit
);
157 defaultDescription
= Messages
.CustomXmlParserInputWizardPage_descriptionEdit
;
159 setDescription(defaultDescription
);
160 this.selection
= selection
;
161 this.definition
= definition
;
162 if (definition
!= null) {
163 this.editDefinitionName
= definition
.definitionName
;
168 public void createControl(Composite parent
) {
169 container
= new Composite(parent
, SWT
.NULL
);
170 container
.setLayout(new GridLayout());
172 updateListener
= new UpdateListener();
174 Composite headerComposite
= new Composite(container
, SWT
.FILL
);
175 GridLayout headerLayout
= new GridLayout(5, false);
176 headerLayout
.marginHeight
= 0;
177 headerLayout
.marginWidth
= 0;
178 headerComposite
.setLayout(headerLayout
);
179 headerComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
181 Label logtypeLabel
= new Label(headerComposite
, SWT
.NULL
);
182 logtypeLabel
.setText(Messages
.CustomXmlParserInputWizardPage_logType
);
184 logtypeText
= new Text(headerComposite
, SWT
.BORDER
| SWT
.SINGLE
);
185 logtypeText
.setLayoutData(new GridData(120, SWT
.DEFAULT
));
187 Label timeStampFormatLabel
= new Label(headerComposite
, SWT
.NULL
);
188 timeStampFormatLabel
.setText(Messages
.CustomXmlParserInputWizardPage_timestampFormat
);
190 timeStampOutputFormatText
= new Text(headerComposite
, SWT
.BORDER
| SWT
.SINGLE
);
191 timeStampOutputFormatText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
192 timeStampOutputFormatText
.setText(DEFAULT_TIMESTAMP_FORMAT
);
194 Button dateFormatHelpButton
= new Button(headerComposite
, SWT
.PUSH
);
195 dateFormatHelpButton
.setImage(HELP_IMAGE
);
196 dateFormatHelpButton
.setToolTipText(Messages
.CustomXmlParserInputWizardPage_dateFormatHelp
);
197 dateFormatHelpButton
.addSelectionListener(new SelectionAdapter() {
199 public void widgetSelected(SelectionEvent e
) {
200 openHelpShell(SIMPLE_DATE_FORMAT_URL
);
204 Label timeStampPreviewLabel
= new Label(headerComposite
, SWT
.NULL
);
205 timeStampPreviewLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false, 3, 1));
206 timeStampPreviewLabel
.setText(Messages
.CustomXmlParserInputWizardPage_preview
);
208 timeStampPreviewText
= new Text(headerComposite
, SWT
.BORDER
| SWT
.SINGLE
| SWT
.READ_ONLY
);
209 timeStampPreviewText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 2, 1));
210 timeStampPreviewText
.setText("*no time stamp element or attribute*"); //$NON-NLS-1$
214 SashForm vSash
= new SashForm(container
, SWT
.VERTICAL
);
215 vSash
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
216 vSash
.setBackground(vSash
.getDisplay().getSystemColor(SWT
.COLOR_GRAY
));
218 SashForm hSash
= new SashForm(vSash
, SWT
.HORIZONTAL
);
219 hSash
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
221 ScrolledComposite treeScrolledComposite
= new ScrolledComposite(hSash
, SWT
.V_SCROLL
| SWT
.H_SCROLL
);
222 treeScrolledComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
223 Composite treeContainer
= new Composite(treeScrolledComposite
, SWT
.NONE
);
224 treeContainer
.setLayout(new FillLayout());
225 treeScrolledComposite
.setContent(treeContainer
);
226 treeScrolledComposite
.setExpandHorizontal(true);
227 treeScrolledComposite
.setExpandVertical(true);
229 treeViewer
= new TreeViewer(treeContainer
, SWT
.SINGLE
| SWT
.BORDER
);
230 treeViewer
.setContentProvider(new InputElementTreeNodeContentProvider());
231 treeViewer
.setLabelProvider(new InputElementTreeLabelProvider());
232 treeViewer
.addSelectionChangedListener(new InputElementTreeSelectionChangedListener());
233 treeContainer
.layout();
235 treeScrolledComposite
236 .setMinSize(treeContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, treeContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
);
238 elementScrolledComposite
= new ScrolledComposite(hSash
, SWT
.V_SCROLL
);
239 elementScrolledComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
240 elementContainer
= new Composite(elementScrolledComposite
, SWT
.NONE
);
241 GridLayout gl
= new GridLayout();
244 elementContainer
.setLayout(gl
);
245 elementScrolledComposite
.setContent(elementContainer
);
246 elementScrolledComposite
.setExpandHorizontal(true);
247 elementScrolledComposite
.setExpandVertical(true);
249 if (definition
== null) {
250 definition
= new CustomXmlTraceDefinition();
252 loadDefinition(definition
);
253 treeViewer
.expandAll();
254 elementContainer
.layout();
256 logtypeText
.addModifyListener(updateListener
);
257 timeStampOutputFormatText
.addModifyListener(updateListener
);
259 elementScrolledComposite
.setMinSize(elementContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
,
260 elementContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
262 hSash
.setWeights(new int[] { 1, 2 });
264 if (definition
.rootInputElement
== null) {
265 removeButton
.setEnabled(false);
266 addChildButton
.setToolTipText(Messages
.CustomXmlParserInputWizardPage_addDocumentElement
);
267 addNextButton
.setEnabled(false);
268 moveUpButton
.setEnabled(false);
269 moveDownButton
.setEnabled(false);
270 } else { // root is selected
271 addNextButton
.setEnabled(false);
274 Composite sashBottom
= new Composite(vSash
, SWT
.NONE
);
275 GridLayout sashBottomLayout
= new GridLayout(2, false);
276 sashBottomLayout
.marginHeight
= 0;
277 sashBottomLayout
.marginWidth
= 0;
278 sashBottom
.setLayout(sashBottomLayout
);
280 Label previewLabel
= new Label(sashBottom
, SWT
.NULL
);
281 previewLabel
.setText(Messages
.CustomXmlParserInputWizardPage_previewInput
);
283 errorText
= new Text(sashBottom
, SWT
.SINGLE
| SWT
.READ_ONLY
);
284 errorText
.setBackground(COLOR_WIDGET_BACKGROUND
);
285 errorText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
286 errorText
.setVisible(false);
288 inputText
= new StyledText(sashBottom
, SWT
.MULTI
| SWT
.V_SCROLL
| SWT
.H_SCROLL
);
289 if (fixedFont
== null) {
290 if (System
.getProperty("os.name").contains("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$
291 fixedFont
= new Font(Display
.getCurrent(), new FontData("Courier New", 10, SWT
.NORMAL
)); //$NON-NLS-1$
293 fixedFont
= new Font(Display
.getCurrent(), new FontData("Monospace", 10, SWT
.NORMAL
)); //$NON-NLS-1$
296 inputText
.setFont(fixedFont
);
297 GridData gd
= new GridData(SWT
.FILL
, SWT
.FILL
, true, true, 2, 1);
298 gd
.heightHint
= inputText
.computeSize(SWT
.DEFAULT
, inputText
.getLineHeight() * 4).y
;
300 inputText
.setLayoutData(gd
);
301 inputText
.setText(getSelectionText());
302 inputText
.addModifyListener(new ModifyListener() {
304 public void modifyText(ModifyEvent e
) {
305 parseXmlInput(inputText
.getText());
308 inputText
.addModifyListener(updateListener
);
310 vSash
.setWeights(new int[] { hSash
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
, sashBottom
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
});
312 setControl(container
);
315 private void createButtonBar() {
316 Composite buttonBar
= new Composite(container
, SWT
.NONE
);
317 GridLayout buttonBarLayout
= new GridLayout(6, false);
318 buttonBarLayout
.marginHeight
= 0;
319 buttonBarLayout
.marginWidth
= 0;
320 buttonBar
.setLayout(buttonBarLayout
);
322 removeButton
= new Button(buttonBar
, SWT
.PUSH
);
323 removeButton
.setImage(DELETE_IMAGE
);
324 removeButton
.setToolTipText(Messages
.CustomXmlParserInputWizardPage_removeElement
);
325 removeButton
.addSelectionListener(new SelectionAdapter() {
327 public void widgetSelected(SelectionEvent e
) {
328 if (treeViewer
.getSelection().isEmpty() || selectedElement
== null) {
332 InputElement inputElement
= (InputElement
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
333 if (inputElement
== definition
.rootInputElement
) {
334 definition
.rootInputElement
= null;
336 inputElement
.parentElement
.childElements
.remove(inputElement
);
338 treeViewer
.refresh();
341 removeButton
.setEnabled(false);
342 if (definition
.rootInputElement
== null) {
343 addChildButton
.setEnabled(true);
344 addChildButton
.setToolTipText(Messages
.CustomXmlParserInputWizardPage_addDocumentEleemnt
);
346 addChildButton
.setEnabled(false);
348 addNextButton
.setEnabled(false);
349 moveUpButton
.setEnabled(false);
350 moveDownButton
.setEnabled(false);
354 addChildButton
= new Button(buttonBar
, SWT
.PUSH
);
355 addChildButton
.setImage(ADD_CHILD_IMAGE
);
356 addChildButton
.setToolTipText(Messages
.CustomXmlParserInputWizardPage_addChildElement
);
357 addChildButton
.addSelectionListener(new SelectionAdapter() {
359 public void widgetSelected(SelectionEvent e
) {
360 InputElement inputElement
= new InputElement("", false, CustomXmlTraceDefinition
.TAG_IGNORE
, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
361 if (definition
.rootInputElement
== null) {
362 definition
.rootInputElement
= inputElement
;
363 inputElement
.elementName
= getChildNameSuggestion(null);
364 } else if (treeViewer
.getSelection().isEmpty()) {
367 InputElement parentInputElement
= (InputElement
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
368 parentInputElement
.addChild(inputElement
);
369 inputElement
.elementName
= getChildNameSuggestion(parentInputElement
);
371 treeViewer
.refresh();
372 treeViewer
.setSelection(new StructuredSelection(inputElement
), true);
376 addNextButton
= new Button(buttonBar
, SWT
.PUSH
);
377 addNextButton
.setImage(ADD_NEXT_IMAGE
);
378 addNextButton
.setToolTipText(Messages
.CustomXmlParserInputWizardPage_addNextElement
);
379 addNextButton
.addSelectionListener(new SelectionAdapter() {
381 public void widgetSelected(SelectionEvent e
) {
382 InputElement inputElement
= new InputElement("", false, CustomXmlTraceDefinition
.TAG_IGNORE
, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
383 if (definition
.rootInputElement
== null) {
384 definition
.rootInputElement
= inputElement
;
385 inputElement
.elementName
= getChildNameSuggestion(null);
386 } else if (treeViewer
.getSelection().isEmpty()) {
389 InputElement previousInputElement
= (InputElement
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
390 if (previousInputElement
== definition
.rootInputElement
) {
393 previousInputElement
.addNext(inputElement
);
394 inputElement
.elementName
= getChildNameSuggestion(inputElement
.parentElement
);
396 treeViewer
.refresh();
397 treeViewer
.setSelection(new StructuredSelection(inputElement
), true);
401 Button feelingLuckyButton
= new Button(buttonBar
, SWT
.PUSH
);
402 feelingLuckyButton
.setImage(ADD_MANY_IMAGE
);
403 feelingLuckyButton
.setToolTipText(Messages
.CustomXmlParserInputWizardPage_feelingLucky
);
404 feelingLuckyButton
.addSelectionListener(new SelectionAdapter() {
406 public void widgetSelected(SelectionEvent e
) {
407 InputElement inputElement
= null;
408 if (definition
.rootInputElement
== null) {
409 if (getChildNameSuggestion(null).length() != 0) {
410 inputElement
= new InputElement(getChildNameSuggestion(null), false, CustomXmlTraceDefinition
.TAG_IGNORE
, 0, "", null); //$NON-NLS-1$
411 definition
.rootInputElement
= inputElement
;
412 feelingLucky(inputElement
);
416 } else if (treeViewer
.getSelection().isEmpty()) {
419 inputElement
= (InputElement
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
420 feelingLucky(inputElement
);
422 treeViewer
.refresh();
423 treeViewer
.setSelection(new StructuredSelection(inputElement
), true);
424 treeViewer
.expandToLevel(inputElement
, AbstractTreeViewer
.ALL_LEVELS
);
428 moveUpButton
= new Button(buttonBar
, SWT
.PUSH
);
429 moveUpButton
.setImage(MOVE_UP_IMAGE
);
430 moveUpButton
.setToolTipText(Messages
.CustomXmlParserInputWizardPage_moveUp
);
431 moveUpButton
.addSelectionListener(new SelectionAdapter() {
433 public void widgetSelected(SelectionEvent e
) {
434 if (treeViewer
.getSelection().isEmpty()) {
437 InputElement inputElement
= (InputElement
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
438 if (inputElement
== definition
.rootInputElement
) {
441 inputElement
.moveUp();
442 treeViewer
.refresh();
448 moveDownButton
= new Button(buttonBar
, SWT
.PUSH
);
449 moveDownButton
.setImage(MOVE_DOWN_IMAGE
);
450 moveDownButton
.setToolTipText(Messages
.CustomXmlParserInputWizardPage_moveDown
);
451 moveDownButton
.addSelectionListener(new SelectionAdapter() {
453 public void widgetSelected(SelectionEvent e
) {
454 if (treeViewer
.getSelection().isEmpty()) {
457 InputElement inputElement
= (InputElement
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
458 if (inputElement
== definition
.rootInputElement
) {
461 inputElement
.moveDown();
462 treeViewer
.refresh();
469 private void feelingLucky(InputElement inputElement
) {
471 String attributeName
= getAttributeNameSuggestion(inputElement
);
472 if (attributeName
.length() == 0) {
475 InputAttribute attribute
= new InputAttribute(attributeName
, attributeName
, 0, ""); //$NON-NLS-1$
476 inputElement
.addAttribute(attribute
);
479 String childName
= getChildNameSuggestion(inputElement
);
480 if (childName
.length() == 0) {
483 InputElement childElement
= new InputElement(childName
, false, CustomXmlTraceDefinition
.TAG_IGNORE
, 0, "", null); //$NON-NLS-1$
484 inputElement
.addChild(childElement
);
485 feelingLucky(childElement
);
489 private static class InputElementTreeNodeContentProvider
implements ITreeContentProvider
{
492 public Object
[] getElements(Object inputElement
) {
493 CustomXmlTraceDefinition def
= (CustomXmlTraceDefinition
) inputElement
;
494 if (def
.rootInputElement
!= null) {
495 return new Object
[] { def
.rootInputElement
};
497 return new Object
[0];
501 public Object
[] getChildren(Object parentElement
) {
502 InputElement inputElement
= (InputElement
) parentElement
;
503 if (inputElement
.childElements
== null) {
504 return new InputElement
[0];
506 return inputElement
.childElements
.toArray();
510 public boolean hasChildren(Object element
) {
511 InputElement inputElement
= (InputElement
) element
;
512 return (inputElement
.childElements
!= null && inputElement
.childElements
.size() > 0);
516 public void dispose() {
520 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
524 public Object
getParent(Object element
) {
525 InputElement inputElement
= (InputElement
) element
;
526 return inputElement
.parentElement
;
530 private static class InputElementTreeLabelProvider
extends ColumnLabelProvider
{
533 public Image
getImage(Object element
) {
534 return ELEMENT_IMAGE
;
538 public String
getText(Object element
) {
539 InputElement inputElement
= (InputElement
) element
;
540 return (inputElement
.elementName
.trim().length() == 0) ?
"?" : inputElement
.elementName
; //$NON-NLS-1$
544 private class InputElementTreeSelectionChangedListener
implements ISelectionChangedListener
{
546 public void selectionChanged(SelectionChangedEvent event
) {
547 if (selectedElement
!= null) {
548 selectedElement
.dispose();
550 if (!(event
.getSelection().isEmpty()) && event
.getSelection() instanceof IStructuredSelection
) {
551 IStructuredSelection sel
= (IStructuredSelection
) event
.getSelection();
552 InputElement inputElement
= (InputElement
) sel
.getFirstElement();
553 selectedElement
= new ElementNode(elementContainer
, inputElement
);
554 elementContainer
.layout();
555 elementScrolledComposite
.setMinSize(elementContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
,
556 elementContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
560 removeButton
.setEnabled(true);
561 addChildButton
.setEnabled(true);
562 addChildButton
.setToolTipText(Messages
.CustomXmlParserInputWizardPage_addChildElement
);
563 if (definition
.rootInputElement
== inputElement
) {
564 addNextButton
.setEnabled(false);
566 addNextButton
.setEnabled(true);
568 moveUpButton
.setEnabled(true);
569 moveDownButton
.setEnabled(true);
571 removeButton
.setEnabled(false);
572 if (definition
.rootInputElement
== null) {
573 addChildButton
.setEnabled(true);
574 addChildButton
.setToolTipText(Messages
.CustomXmlParserInputWizardPage_addDocumentElement
);
576 addChildButton
.setEnabled(false);
578 addNextButton
.setEnabled(false);
579 moveUpButton
.setEnabled(false);
580 moveDownButton
.setEnabled(false);
586 public void dispose() {
587 if (fixedFont
!= null) {
594 private void loadDefinition(CustomXmlTraceDefinition def
) {
595 logtypeText
.setText(def
.definitionName
);
596 timeStampOutputFormatText
.setText(def
.timeStampOutputFormat
);
597 treeViewer
.setInput(def
);
599 if (def
.rootInputElement
!= null) {
600 treeViewer
.setSelection(new StructuredSelection(def
.rootInputElement
));
604 private String
getName(InputElement inputElement
) {
605 String name
= (inputElement
.elementName
.trim().length() == 0) ?
"?" : inputElement
.elementName
.trim(); //$NON-NLS-1$
606 if (inputElement
.parentElement
== null) {
609 return getName(inputElement
.parentElement
) + " : " + name
; //$NON-NLS-1$
612 private String
getName(InputAttribute inputAttribute
, InputElement inputElement
) {
613 String name
= (inputAttribute
.attributeName
.trim().length() == 0) ?
"?" : inputAttribute
.attributeName
.trim(); //$NON-NLS-1$
614 return getName(inputElement
) + " : " + name
; //$NON-NLS-1$
618 public void setVisible(boolean visible
) {
623 super.setVisible(visible
);
627 * Get the global list of input names.
629 * @return The list of input names
631 public List
<String
> getInputNames() {
632 return getInputNames(definition
.rootInputElement
);
636 * Get the list of input names for a given element.
638 * @param inputElement
640 * @return The input names for this element
642 public List
<String
> getInputNames(InputElement inputElement
) {
643 List
<String
> inputs
= new ArrayList
<String
>();
644 if (inputElement
.inputName
!= null && !inputElement
.inputName
.equals(CustomXmlTraceDefinition
.TAG_IGNORE
)) {
645 String inputName
= inputElement
.inputName
;
646 if (!inputs
.contains(inputName
)) {
647 inputs
.add(inputName
);
650 if (inputElement
.attributes
!= null) {
651 for (InputAttribute attribute
: inputElement
.attributes
) {
652 String inputName
= attribute
.inputName
;
653 if (!inputs
.contains(inputName
)) {
654 inputs
.add(inputName
);
658 if (inputElement
.childElements
!= null) {
659 for (InputElement childInputElement
: inputElement
.childElements
) {
660 for (String inputName
: getInputNames(childInputElement
)) {
661 if (!inputs
.contains(inputName
)) {
662 inputs
.add(inputName
);
670 private void removeElement() {
671 selectedElement
.dispose();
672 selectedElement
= null;
673 elementContainer
.layout();
674 elementScrolledComposite
.setMinSize(elementContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
,
675 elementContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
679 private String
getSelectionText() {
680 InputStream inputStream
= null;
681 if (this.selection
instanceof IStructuredSelection
) {
682 Object sel
= ((IStructuredSelection
) this.selection
).getFirstElement();
683 if (sel
instanceof IFile
) {
684 IFile file
= (IFile
) sel
;
686 inputStream
= file
.getContents();
687 } catch (CoreException e
) {
688 return ""; //$NON-NLS-1$
692 if (inputStream
!= null) {
693 BufferedReader reader
= null;
695 reader
= new BufferedReader(new InputStreamReader(inputStream
));
696 StringBuilder sb
= new StringBuilder();
698 while ((line
= reader
.readLine()) != null) {
699 sb
.append(line
+ "\n"); //$NON-NLS-1$
701 parseXmlInput(sb
.toString());
703 return sb
.toString();
704 } catch (IOException e
) {
705 return ""; //$NON-NLS-1$
708 return ""; //$NON-NLS-1$
711 private void parseXmlInput(final String string
) {
713 DocumentBuilderFactory dbf
= DocumentBuilderFactory
.newInstance();
714 DocumentBuilder db
= dbf
.newDocumentBuilder();
716 // The following allows xml parsing without access to the dtd
717 EntityResolver resolver
= new EntityResolver() {
719 public InputSource
resolveEntity(String publicId
, String systemId
) {
720 String empty
= ""; //$NON-NLS-1$
721 ByteArrayInputStream bais
= new ByteArrayInputStream(empty
.getBytes());
722 return new InputSource(bais
);
725 db
.setEntityResolver(resolver
);
727 // The following catches xml parsing exceptions
728 db
.setErrorHandler(new ErrorHandler() {
730 public void error(SAXParseException saxparseexception
) throws SAXException
{
734 public void warning(SAXParseException saxparseexception
) throws SAXException
{
738 public void fatalError(SAXParseException saxparseexception
) throws SAXException
{
739 if (string
.trim().length() != 0) {
740 errorText
.setText(saxparseexception
.getMessage());
741 errorText
.setBackground(COLOR_LIGHT_RED
);
742 errorText
.setVisible(true);
744 throw saxparseexception
;
748 errorText
.setVisible(false);
750 doc
= db
.parse(new ByteArrayInputStream(string
.getBytes()));
751 documentElement
= doc
.getDocumentElement();
752 } catch (ParserConfigurationException e
) {
753 Activator
.getDefault().logError("Error pasing XML input string: " + string
, e
); //$NON-NLS-1$
754 documentElement
= null;
755 } catch (SAXException e
) {
756 documentElement
= null;
757 } catch (IOException e
) {
758 Activator
.getDefault().logError("Error pasing XML input string: " + string
, e
); //$NON-NLS-1$
759 documentElement
= null;
763 private void initValues() {
764 timeStampValue
= null;
765 timeStampFormat
= null;
767 logEntryFound
= false;
770 private void updatePreviews() {
771 if (inputText
== null) {
772 // early update during construction
775 inputText
.setStyleRanges(new StyleRange
[] {});
776 if (selectedElement
== null) {
782 selectedElement
.updatePreview();
784 if (timeStampValue
!= null && timeStampFormat
!= null) {
786 SimpleDateFormat dateFormat
= new SimpleDateFormat(timeStampFormat
);
787 Date date
= dateFormat
.parse(timeStampValue
);
788 dateFormat
= new SimpleDateFormat(timeStampOutputFormatText
.getText().trim());
789 timeStampPreviewText
.setText(dateFormat
.format(date
));
790 } catch (ParseException e
) {
791 timeStampPreviewText
.setText("*parse exception* [" + timeStampValue
+ "] <> [" + timeStampFormat
+ "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
792 } catch (IllegalArgumentException e
) {
793 timeStampPreviewText
.setText("*parse exception* [Illegal Argument]"); //$NON-NLS-1$
796 timeStampPreviewText
.setText("*no matching time stamp*"); //$NON-NLS-1$
800 private void openHelpShell(String url
) {
801 if (helpBrowser
!= null && !helpBrowser
.isDisposed()) {
802 helpBrowser
.getShell().setActive();
803 if (!helpBrowser
.getUrl().equals(url
)) {
804 helpBrowser
.setUrl(url
);
808 final Shell helpShell
= new Shell(getShell(), SWT
.SHELL_TRIM
);
809 helpShell
.setLayout(new FillLayout());
810 helpBrowser
= new Browser(helpShell
, SWT
.NONE
);
811 helpBrowser
.addTitleListener(new TitleListener() {
813 public void changed(TitleEvent event
) {
814 helpShell
.setText(event
.title
);
817 helpBrowser
.setBounds(0, 0, 600, 400);
820 helpBrowser
.setUrl(url
);
823 private class UpdateListener
implements ModifyListener
, SelectionListener
{
826 public void modifyText(ModifyEvent e
) {
832 public void widgetDefaultSelected(SelectionEvent e
) {
838 public void widgetSelected(SelectionEvent e
) {
845 private class ElementNode
{
846 private final InputElement inputElement
;
847 private final Group group
;
848 private List
<Attribute
> attributes
= new ArrayList
<Attribute
>();
849 private List
<ElementNode
> childElements
= new ArrayList
<ElementNode
>();
850 private Text elementNameText
;
851 private Composite tagComposite
;
852 private Combo tagCombo
;
853 private Label tagLabel
;
854 private Text tagText
;
855 private Combo actionCombo
;
856 private Label previewLabel
;
857 private Text previewText
;
858 private Button logEntryButton
;
859 private Label fillerLabel
;
860 private Composite addAttributeComposite
;
861 private Button addAttributeButton
;
862 private Label addAttributeLabel
;
864 public ElementNode(Composite parent
, InputElement inputElement
) {
865 this.inputElement
= inputElement
;
867 group
= new Group(parent
, SWT
.NONE
);
868 GridLayout gl
= new GridLayout(2, false);
871 group
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
872 group
.setText(getName(inputElement
));
874 Label label
= new Label(group
, SWT
.NULL
);
875 label
.setText(Messages
.CustomXmlParserInputWizardPage_elementName
);
876 label
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
878 elementNameText
= new Text(group
, SWT
.BORDER
| SWT
.SINGLE
);
879 GridData gd
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
881 elementNameText
.setLayoutData(gd
);
882 elementNameText
.addModifyListener(new ModifyListener() {
884 public void modifyText(ModifyEvent e
) {
885 ElementNode
.this.inputElement
.elementName
= elementNameText
.getText().trim();
886 group
.setText(getName(ElementNode
.this.inputElement
));
889 elementNameText
.setText(inputElement
.elementName
);
890 elementNameText
.addModifyListener(updateListener
);
892 if (inputElement
.parentElement
!= null) {
893 previewLabel
= new Label(group
, SWT
.NULL
);
894 previewLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
895 previewLabel
.setText(Messages
.CustomXmlParserInputWizardPage_preview
);
897 previewText
= new Text(group
, SWT
.BORDER
| SWT
.SINGLE
| SWT
.READ_ONLY
);
898 gd
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
900 previewText
.setLayoutData(gd
);
901 previewText
.setText(Messages
.CustomXmlParserInputWizardPage_noMatchingElement
);
902 previewText
.setBackground(COLOR_WIDGET_BACKGROUND
);
904 logEntryButton
= new Button(group
, SWT
.CHECK
);
905 logEntryButton
.setText(Messages
.CustomXmlParserInputWizardPage_logEntry
);
906 logEntryButton
.setSelection(inputElement
.logEntry
);
907 logEntryButton
.addSelectionListener(new SelectionListener() {
909 public void widgetDefaultSelected(SelectionEvent e
) {
913 public void widgetSelected(SelectionEvent e
) {
914 InputElement parentElem
= ElementNode
.this.inputElement
.parentElement
;
915 while (parentElem
!= null) {
916 parentElem
.logEntry
= false;
917 parentElem
= parentElem
.parentElement
;
921 logEntryButton
.addSelectionListener(updateListener
);
923 tagComposite
= new Composite(group
, SWT
.FILL
);
924 GridLayout tagLayout
= new GridLayout(4, false);
925 tagLayout
.marginWidth
= 0;
926 tagLayout
.marginHeight
= 0;
927 tagComposite
.setLayout(tagLayout
);
928 tagComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
930 tagCombo
= new Combo(tagComposite
, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
931 tagCombo
.setItems(new String
[] { CustomXmlTraceDefinition
.TAG_IGNORE
, CustomTraceDefinition
.TAG_TIMESTAMP
,
932 CustomTraceDefinition
.TAG_MESSAGE
, CustomTraceDefinition
.TAG_OTHER
});
933 tagCombo
.setVisibleItemCount(tagCombo
.getItemCount());
934 tagCombo
.addSelectionListener(new SelectionListener() {
936 public void widgetDefaultSelected(SelectionEvent e
) {
940 public void widgetSelected(SelectionEvent e
) {
941 tagText
.removeModifyListener(updateListener
);
942 switch (tagCombo
.getSelectionIndex()) {
944 tagLabel
.setVisible(false);
945 tagText
.setVisible(false);
946 actionCombo
.setVisible(false);
948 case 1: // Time Stamp
949 tagLabel
.setText(Messages
.CustomXmlParserInputWizardPage_format
);
950 tagLabel
.setVisible(true);
951 tagText
.setVisible(true);
952 tagText
.addModifyListener(updateListener
);
953 actionCombo
.setVisible(true);
956 tagLabel
.setVisible(false);
957 tagText
.setVisible(false);
958 actionCombo
.setVisible(true);
961 tagLabel
.setText(Messages
.CustomXmlParserInputWizardPage_tagName
);
962 tagLabel
.setVisible(true);
963 if (tagText
.getText().trim().length() == 0) {
964 tagText
.setText(elementNameText
.getText().trim());
966 tagText
.setVisible(true);
967 tagText
.addModifyListener(updateListener
);
968 actionCombo
.setVisible(true);
973 tagComposite
.layout();
979 tagLabel
= new Label(tagComposite
, SWT
.NULL
);
980 tagLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
982 tagText
= new Text(tagComposite
, SWT
.BORDER
| SWT
.SINGLE
);
983 gd
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
985 tagText
.setLayoutData(gd
);
987 actionCombo
= new Combo(tagComposite
, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
988 actionCombo
.setItems(new String
[] { Messages
.CustomXmlParserInputWizardPage_set
, Messages
.CustomXmlParserInputWizardPage_append
,
989 Messages
.CustomXmlParserInputWizardPage_appendWith
});
990 actionCombo
.select(inputElement
.inputAction
);
991 actionCombo
.addSelectionListener(updateListener
);
993 if (inputElement
.inputName
.equals(CustomXmlTraceDefinition
.TAG_IGNORE
)) {
995 tagLabel
.setVisible(false);
996 tagText
.setVisible(false);
997 actionCombo
.setVisible(false);
998 } else if (inputElement
.inputName
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1000 tagLabel
.setText(Messages
.CustomXmlParserInputWizardPage_format
);
1001 tagText
.setText(inputElement
.inputFormat
);
1002 tagText
.addModifyListener(updateListener
);
1003 } else if (inputElement
.inputName
.equals(CustomTraceDefinition
.TAG_MESSAGE
)) {
1005 tagLabel
.setVisible(false);
1006 tagText
.setVisible(false);
1009 tagLabel
.setText(Messages
.CustomXmlParserInputWizardPage_tagName
);
1010 tagText
.setText(inputElement
.inputName
);
1011 tagText
.addModifyListener(updateListener
);
1015 if (inputElement
.attributes
!= null) {
1016 for (InputAttribute inputAttribute
: inputElement
.attributes
) {
1017 Attribute attribute
= new Attribute(group
, this, inputAttribute
, attributes
.size() + 1);
1018 attributes
.add(attribute
);
1025 private void updatePreview() {
1026 Element element
= getPreviewElement(inputElement
);
1027 if (inputElement
.parentElement
!= null) { // no preview text for
1029 previewText
.setText(Messages
.CustomXmlParserInputWizardPage_noMatchingElement
);
1030 if (element
!= null) {
1031 previewText
.setText(CustomXmlTrace
.parseElement(element
, new StringBuffer()).toString());
1032 if (logEntryButton
.getSelection()) {
1033 if (!logEntryFound
) {
1034 logEntryFound
= true;
1037 logEntryButton
.setSelection(false); // remove nested
1041 if (tagCombo
.getText().equals(CustomTraceDefinition
.TAG_TIMESTAMP
) && logEntriesCount
<= 1) {
1042 String value
= previewText
.getText().trim();
1043 if (value
.length() != 0) {
1044 if (actionCombo
.getSelectionIndex() == CustomTraceDefinition
.ACTION_SET
) {
1045 timeStampValue
= value
;
1046 timeStampFormat
= tagText
.getText().trim();
1047 } else if (actionCombo
.getSelectionIndex() == CustomTraceDefinition
.ACTION_APPEND
) {
1048 if (timeStampValue
!= null) {
1049 timeStampValue
+= value
;
1050 timeStampFormat
+= tagText
.getText().trim();
1052 timeStampValue
= value
;
1053 timeStampFormat
= tagText
.getText().trim();
1055 } else if (actionCombo
.getSelectionIndex() == CustomTraceDefinition
.ACTION_APPEND_WITH_SEPARATOR
) {
1056 if (timeStampValue
!= null) {
1057 timeStampValue
+= " | " + value
; //$NON-NLS-1$
1058 timeStampFormat
+= " | " + tagText
.getText().trim(); //$NON-NLS-1$
1060 timeStampValue
= value
;
1061 timeStampFormat
= tagText
.getText().trim();
1068 for (Attribute attribute
: attributes
) {
1069 if (element
!= null) {
1070 String value
= element
.getAttribute(attribute
.attributeNameText
.getText().trim());
1071 if (value
.length() != 0) {
1072 attribute
.previewText
.setText(value
);
1073 if (attribute
.tagCombo
.getText().equals(CustomTraceDefinition
.TAG_TIMESTAMP
) && logEntriesCount
<= 1) {
1074 if (attribute
.actionCombo
.getSelectionIndex() == CustomTraceDefinition
.ACTION_SET
) {
1075 timeStampValue
= value
;
1076 timeStampFormat
= attribute
.tagText
.getText().trim();
1077 } else if (attribute
.actionCombo
.getSelectionIndex() == CustomTraceDefinition
.ACTION_APPEND
) {
1078 if (timeStampValue
!= null) {
1079 timeStampValue
+= value
;
1080 timeStampFormat
+= attribute
.tagText
.getText().trim();
1082 timeStampValue
= value
;
1083 timeStampFormat
= attribute
.tagText
.getText().trim();
1085 } else if (attribute
.actionCombo
.getSelectionIndex() == CustomTraceDefinition
.ACTION_APPEND_WITH_SEPARATOR
) {
1086 if (timeStampValue
!= null) {
1087 timeStampValue
+= " | " + value
; //$NON-NLS-1$
1088 timeStampFormat
+= " | " + attribute
.tagText
.getText().trim(); //$NON-NLS-1$
1090 timeStampValue
= value
;
1091 timeStampFormat
= attribute
.tagText
.getText().trim();
1096 attribute
.previewText
.setText(Messages
.CustomXmlParserInputWizardPage_noMatchingAttribute
);
1099 attribute
.previewText
.setText(Messages
.CustomXmlParserInputWizardPage_noMatchingElement
);
1102 for (ElementNode child
: childElements
) {
1103 child
.updatePreview();
1105 if (logEntryButton
!= null && logEntryButton
.getSelection()) {
1106 logEntryFound
= false;
1110 private void createAddButton() {
1111 fillerLabel
= new Label(group
, SWT
.NONE
);
1113 addAttributeComposite
= new Composite(group
, SWT
.NONE
);
1114 addAttributeComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1115 GridLayout addAttributeLayout
= new GridLayout(2, false);
1116 addAttributeLayout
.marginHeight
= 0;
1117 addAttributeLayout
.marginWidth
= 0;
1118 addAttributeComposite
.setLayout(addAttributeLayout
);
1120 addAttributeButton
= new Button(addAttributeComposite
, SWT
.PUSH
);
1121 addAttributeButton
.setImage(ADD_IMAGE
);
1122 addAttributeButton
.setToolTipText(Messages
.CustomXmlParserInputWizardPage_addAttribute
);
1123 addAttributeButton
.addSelectionListener(new SelectionAdapter() {
1125 public void widgetSelected(SelectionEvent e
) {
1127 String attributeName
= getAttributeNameSuggestion(inputElement
);
1128 InputAttribute inputAttribute
= new InputAttribute(attributeName
, attributeName
, 0, ""); //$NON-NLS-1$
1129 attributes
.add(new Attribute(group
, ElementNode
.this, inputAttribute
, attributes
.size() + 1));
1131 elementContainer
.layout();
1132 elementScrolledComposite
.setMinSize(elementContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
,
1133 elementContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
1134 group
.getParent().layout();
1140 addAttributeLabel
= new Label(addAttributeComposite
, SWT
.NULL
);
1141 addAttributeLabel
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1142 addAttributeLabel
.setText(Messages
.CustomXmlParserInputWizardPage_newAttibute
);
1145 private void removeAddButton() {
1146 fillerLabel
.dispose();
1147 addAttributeComposite
.dispose();
1150 private void removeAttribute(int attributeNumber
) {
1151 int nb
= attributeNumber
;
1152 if (--nb
< attributes
.size()) {
1153 attributes
.remove(nb
).dispose();
1154 for (int i
= nb
; i
< attributes
.size(); i
++) {
1155 attributes
.get(i
).setAttributeNumber(i
+ 1);
1157 elementContainer
.layout();
1158 elementScrolledComposite
.setMinSize(elementContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
,
1159 elementContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
1160 group
.getParent().layout();
1164 private void dispose() {
1168 private void extractInputs() {
1169 inputElement
.elementName
= elementNameText
.getText().trim();
1170 if (inputElement
.parentElement
!= null) {
1171 inputElement
.logEntry
= logEntryButton
.getSelection();
1172 if (tagCombo
.getText().equals(CustomTraceDefinition
.TAG_OTHER
)) {
1173 inputElement
.inputName
= tagText
.getText().trim();
1175 inputElement
.inputName
= tagCombo
.getText();
1176 if (tagCombo
.getText().equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1177 inputElement
.inputFormat
= tagText
.getText().trim();
1180 inputElement
.inputAction
= actionCombo
.getSelectionIndex();
1182 inputElement
.attributes
= new ArrayList
<InputAttribute
>(attributes
.size());
1183 for (int i
= 0; i
< attributes
.size(); i
++) {
1184 Attribute attribute
= attributes
.get(i
);
1185 InputAttribute inputAttribute
= new InputAttribute();
1186 inputAttribute
.attributeName
= attribute
.attributeNameText
.getText().trim();
1187 if (attribute
.tagCombo
.getText().equals(CustomTraceDefinition
.TAG_OTHER
)) {
1188 inputAttribute
.inputName
= attribute
.tagText
.getText().trim();
1190 inputAttribute
.inputName
= attribute
.tagCombo
.getText();
1191 if (attribute
.tagCombo
.getText().equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1192 inputAttribute
.inputFormat
= attribute
.tagText
.getText().trim();
1195 inputAttribute
.inputAction
= attribute
.actionCombo
.getSelectionIndex();
1196 inputElement
.addAttribute(inputAttribute
);
1201 private class Attribute
{
1202 private ElementNode element
;
1203 private int attributeNumber
;
1205 // children of parent (must be disposed)
1206 private Composite labelComposite
;
1207 private Composite attributeComposite
;
1208 private Label filler
;
1209 private Composite tagComposite
;
1211 // children of labelComposite
1212 private Label attributeLabel
;
1214 // children of attributeComposite
1215 private Text attributeNameText
;
1216 private Text previewText
;
1218 // children of tagComposite
1219 private Combo tagCombo
;
1220 private Label tagLabel
;
1221 private Text tagText
;
1222 private Combo actionCombo
;
1224 public Attribute(Composite parent
, ElementNode element
, InputAttribute inputAttribute
, int attributeNumber
) {
1225 this.element
= element
;
1226 this.attributeNumber
= attributeNumber
;
1228 labelComposite
= new Composite(parent
, SWT
.FILL
);
1229 GridLayout labelLayout
= new GridLayout(2, false);
1230 labelLayout
.marginWidth
= 0;
1231 labelLayout
.marginHeight
= 0;
1232 labelComposite
.setLayout(labelLayout
);
1233 labelComposite
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1235 Button deleteButton
= new Button(labelComposite
, SWT
.PUSH
);
1236 deleteButton
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1237 deleteButton
.setImage(DELETE_IMAGE
);
1238 deleteButton
.setToolTipText(Messages
.CustomXmlParserInputWizardPage_removeAttribute
);
1239 deleteButton
.addSelectionListener(new SelectionAdapter() {
1241 public void widgetSelected(SelectionEvent e
) {
1242 Attribute
.this.element
.removeAttribute(Attribute
.this.attributeNumber
);
1248 attributeLabel
= new Label(labelComposite
, SWT
.NULL
);
1249 attributeLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1250 attributeLabel
.setText(Messages
.CustomXmlParserInputWizardPage_attibute
);
1252 attributeComposite
= new Composite(parent
, SWT
.FILL
);
1253 GridLayout attributeLayout
= new GridLayout(4, false);
1254 attributeLayout
.marginWidth
= 0;
1255 attributeLayout
.marginHeight
= 0;
1256 attributeComposite
.setLayout(attributeLayout
);
1257 attributeComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1259 Label nameLabel
= new Label(attributeComposite
, SWT
.NONE
);
1260 nameLabel
.setText(Messages
.CustomXmlParserInputWizardPage_name
);
1262 attributeNameText
= new Text(attributeComposite
, SWT
.BORDER
| SWT
.SINGLE
);
1263 attributeNameText
.setLayoutData(new GridData(120, SWT
.DEFAULT
));
1264 attributeNameText
.setText(inputAttribute
.attributeName
);
1265 attributeNameText
.addModifyListener(updateListener
);
1267 Label previewLabel
= new Label(attributeComposite
, SWT
.NONE
);
1268 previewLabel
.setText(Messages
.CustomXmlParserInputWizardPage_preview
);
1270 previewText
= new Text(attributeComposite
, SWT
.BORDER
| SWT
.SINGLE
| SWT
.READ_ONLY
);
1271 GridData gd
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
1273 previewText
.setLayoutData(gd
);
1274 previewText
.setText(Messages
.CustomXmlParserInputWizardPage_noMatch
);
1275 previewText
.setBackground(COLOR_WIDGET_BACKGROUND
);
1277 filler
= new Label(parent
, SWT
.NULL
);
1279 tagComposite
= new Composite(parent
, SWT
.FILL
);
1280 GridLayout tagLayout
= new GridLayout(4, false);
1281 tagLayout
.marginWidth
= 0;
1282 tagLayout
.marginHeight
= 0;
1283 tagComposite
.setLayout(tagLayout
);
1284 tagComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1286 tagCombo
= new Combo(tagComposite
, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
1287 tagCombo
.setItems(new String
[] { CustomTraceDefinition
.TAG_TIMESTAMP
, CustomTraceDefinition
.TAG_MESSAGE
,
1288 CustomTraceDefinition
.TAG_OTHER
});
1289 tagCombo
.select(2); // Other
1290 tagCombo
.addSelectionListener(new SelectionListener() {
1292 public void widgetDefaultSelected(SelectionEvent e
) {
1296 public void widgetSelected(SelectionEvent e
) {
1297 tagText
.removeModifyListener(updateListener
);
1298 switch (tagCombo
.getSelectionIndex()) {
1299 case 0: // Time Stamp
1300 tagLabel
.setText(Messages
.CustomXmlParserInputWizardPage_format
);
1301 tagLabel
.setVisible(true);
1302 tagText
.setVisible(true);
1303 tagText
.addModifyListener(updateListener
);
1306 tagLabel
.setVisible(false);
1307 tagText
.setVisible(false);
1310 tagLabel
.setText(Messages
.CustomXmlParserInputWizardPage_tagName
);
1311 tagLabel
.setVisible(true);
1312 if (tagText
.getText().trim().length() == 0) {
1313 tagText
.setText(attributeNameText
.getText().trim());
1315 tagText
.setVisible(true);
1316 tagText
.addModifyListener(updateListener
);
1321 tagComposite
.layout();
1327 tagLabel
= new Label(tagComposite
, SWT
.NULL
);
1328 tagLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1330 tagText
= new Text(tagComposite
, SWT
.BORDER
| SWT
.SINGLE
);
1331 gd
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
1333 tagText
.setLayoutData(gd
);
1334 tagText
.setText(attributeNameText
.getText());
1336 actionCombo
= new Combo(tagComposite
, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
1337 actionCombo
.setItems(new String
[] { Messages
.CustomXmlParserInputWizardPage_set
, Messages
.CustomXmlParserInputWizardPage_append
,
1338 Messages
.CustomXmlParserInputWizardPage_appendWith
});
1339 actionCombo
.select(inputAttribute
.inputAction
);
1340 actionCombo
.addSelectionListener(updateListener
);
1342 if (inputAttribute
.inputName
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1344 tagLabel
.setText(Messages
.CustomXmlParserInputWizardPage_format
);
1345 tagText
.setText(inputAttribute
.inputFormat
);
1346 tagText
.addModifyListener(updateListener
);
1347 } else if (inputAttribute
.inputName
.equals(CustomTraceDefinition
.TAG_MESSAGE
)) {
1349 tagLabel
.setVisible(false);
1350 tagText
.setVisible(false);
1353 tagLabel
.setText(Messages
.CustomXmlParserInputWizardPage_tagName
);
1354 tagText
.setText(inputAttribute
.inputName
);
1355 tagText
.addModifyListener(updateListener
);
1359 private void dispose() {
1360 labelComposite
.dispose();
1361 attributeComposite
.dispose();
1363 tagComposite
.dispose();
1366 private void setAttributeNumber(int attributeNumber
) {
1367 this.attributeNumber
= attributeNumber
;
1368 labelComposite
.layout();
1372 private Element
getPreviewElement(InputElement inputElement
) {
1373 InputElement currentElement
= inputElement
;
1374 Element element
= documentElement
;
1375 if (element
!= null) {
1376 if (!documentElement
.getNodeName().equals(definition
.rootInputElement
.elementName
)) {
1379 ArrayList
<String
> elementNames
= new ArrayList
<String
>();
1380 while (currentElement
!= null) {
1381 elementNames
.add(currentElement
.elementName
);
1382 currentElement
= currentElement
.parentElement
;
1384 for (int i
= elementNames
.size() - 1; --i
>= 0;) {
1385 NodeList childList
= element
.getChildNodes();
1387 for (int j
= 0; j
< childList
.getLength(); j
++) {
1388 Node child
= childList
.item(j
);
1389 if (child
instanceof Element
&& child
.getNodeName().equals(elementNames
.get(i
))) {
1390 element
= (Element
) child
;
1394 if (element
== null) {
1398 if (element
!= null) {
1405 private String
getChildNameSuggestion(InputElement inputElement
) {
1406 if (inputElement
== null) {
1407 if (documentElement
!= null) {
1408 return documentElement
.getNodeName();
1411 Element element
= getPreviewElement(inputElement
);
1412 if (element
!= null) {
1413 NodeList childNodes
= element
.getChildNodes();
1414 for (int i
= 0; i
< childNodes
.getLength(); i
++) {
1415 Node node
= childNodes
.item(i
);
1416 if (node
instanceof Element
) {
1417 boolean unused
= true;
1418 if (inputElement
.childElements
!= null) {
1419 for (InputElement child
: inputElement
.childElements
) {
1420 if (child
.elementName
.equals(node
.getNodeName())) {
1427 return node
.getNodeName();
1433 return ""; //$NON-NLS-1$
1436 private String
getAttributeNameSuggestion(InputElement inputElement
) {
1437 Element element
= getPreviewElement(inputElement
);
1438 if (element
!= null) {
1439 NamedNodeMap attributeMap
= element
.getAttributes();
1440 for (int i
= 0; i
< attributeMap
.getLength(); i
++) {
1441 Node node
= attributeMap
.item(i
);
1442 boolean unused
= true;
1443 if (inputElement
.attributes
!= null) {
1444 for (InputAttribute attribute
: inputElement
.attributes
) {
1445 if (attribute
.attributeName
.equals(node
.getNodeName())) {
1452 return node
.getNodeName();
1456 return ""; //$NON-NLS-1$
1459 private void validate() {
1460 definition
.definitionName
= logtypeText
.getText().trim();
1461 definition
.timeStampOutputFormat
= timeStampOutputFormatText
.getText().trim();
1463 if (selectedElement
!= null) {
1464 selectedElement
.extractInputs();
1465 treeViewer
.refresh();
1468 StringBuffer errors
= new StringBuffer();
1470 if (definition
.definitionName
.length() == 0) {
1471 errors
.append(Messages
.CustomXmlParserInputWizardPage_emptyLogTypeError
);
1472 logtypeText
.setBackground(COLOR_LIGHT_RED
);
1474 logtypeText
.setBackground(COLOR_TEXT_BACKGROUND
);
1475 for (CustomXmlTraceDefinition def
: CustomXmlTraceDefinition
.loadAll()) {
1476 if (definition
.definitionName
.equals(def
.definitionName
) &&
1477 (editDefinitionName
== null || !editDefinitionName
.equals(definition
.definitionName
))) {
1478 errors
.append(Messages
.CustomXmlParserInputWizardPage_duplicatelogTypeError
);
1479 logtypeText
.setBackground(COLOR_LIGHT_RED
);
1485 if (definition
.rootInputElement
== null) {
1486 errors
.append(Messages
.CustomXmlParserInputWizardPage_noDocumentError
);
1489 if (definition
.rootInputElement
!= null) {
1490 logEntryFound
= false;
1491 timeStampFound
= false;
1493 errors
.append(validateElement(definition
.rootInputElement
));
1495 if ((definition
.rootInputElement
.attributes
!= null && definition
.rootInputElement
.attributes
.size() != 0)
1496 || (definition
.rootInputElement
.childElements
!= null && definition
.rootInputElement
.childElements
.size() != 0)
1497 || errors
.length() == 0) {
1498 if (!logEntryFound
) {
1499 errors
.append(Messages
.CustomXmlParserInputWizardPage_missingLogEntryError
);
1502 if (timeStampFound
) {
1503 if (timeStampOutputFormatText
.getText().trim().length() == 0) {
1504 errors
.append(Messages
.CustomXmlParserInputWizardPage_missingTimestampFmtError
);
1505 timeStampOutputFormatText
.setBackground(COLOR_LIGHT_RED
);
1508 new SimpleDateFormat(timeStampOutputFormatText
.getText().trim());
1509 timeStampOutputFormatText
.setBackground(COLOR_TEXT_BACKGROUND
);
1510 } catch (IllegalArgumentException e
) {
1511 errors
.append(Messages
.CustomXmlParserInputWizardPage_invalidTimestampFmtError
);
1512 timeStampOutputFormatText
.setBackground(COLOR_LIGHT_RED
);
1516 timeStampPreviewText
.setText(Messages
.CustomXmlParserInputWizardPage_notimestamporAttributeError
);
1520 timeStampPreviewText
.setText(Messages
.CustomXmlParserInputWizardPage_notimestamporAttributeError
);
1523 if (errors
.length() == 0) {
1524 setDescription(defaultDescription
);
1525 setPageComplete(true);
1527 setDescription(errors
.toString());
1528 setPageComplete(false);
1533 * Clean up the specified XML element.
1535 * @param inputElement
1536 * The element to clean up
1537 * @return The validated element
1539 public StringBuffer
validateElement(InputElement inputElement
) {
1540 StringBuffer errors
= new StringBuffer();
1541 ElementNode elementNode
= null;
1542 if (selectedElement
!= null && selectedElement
.inputElement
.equals(inputElement
)) {
1543 elementNode
= selectedElement
;
1545 if (inputElement
== definition
.rootInputElement
) {
1546 if (inputElement
.elementName
.length() == 0) {
1547 errors
.append(Messages
.CustomXmlParserInputWizardPage_missingDocumentElementError
);
1548 if (elementNode
!= null) {
1549 elementNode
.elementNameText
.setBackground(COLOR_LIGHT_RED
);
1552 if (elementNode
!= null) {
1553 elementNode
.elementNameText
.setBackground(COLOR_TEXT_BACKGROUND
);
1557 if (inputElement
!= definition
.rootInputElement
) {
1558 if (inputElement
.logEntry
) {
1559 logEntryFound
= true;
1561 if (inputElement
.inputName
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1562 timeStampFound
= true;
1563 if (inputElement
.inputFormat
.length() == 0) {
1564 errors
.append(Messages
.CustomXmlParserInputWizardPage_timestampFormatPrompt
1565 + " (" + Messages
.CustomXmlParserInputWizardPage_timestampElementPrompt
+ " " + getName(inputElement
) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1566 if (elementNode
!= null) {
1567 elementNode
.tagText
.setBackground(COLOR_LIGHT_RED
);
1571 new SimpleDateFormat(inputElement
.inputFormat
);
1572 if (elementNode
!= null) {
1573 elementNode
.tagText
.setBackground(COLOR_TEXT_BACKGROUND
);
1575 } catch (IllegalArgumentException e
) {
1576 errors
.append(Messages
.CustomXmlParserInputWizardPage_invalidTimestampFmtError
1577 + " (" + Messages
.CustomXmlParserInputWizardPage_timestampElementPrompt
+ " " + getName(inputElement
) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1578 if (elementNode
!= null) {
1579 elementNode
.tagText
.setBackground(COLOR_LIGHT_RED
);
1583 } else if (inputElement
.inputName
.length() == 0) {
1584 errors
.append(Messages
.CustomXmlParserInputWizardPage_missingInputElementNameError
);
1585 if (elementNode
!= null) {
1586 elementNode
.tagText
.setBackground(COLOR_LIGHT_RED
);
1589 if (elementNode
!= null) {
1590 elementNode
.tagText
.setBackground(COLOR_TEXT_BACKGROUND
);
1594 if (inputElement
.attributes
!= null) {
1595 if (elementNode
!= null) {
1596 for (Attribute attribute
: elementNode
.attributes
) {
1597 attribute
.attributeNameText
.setBackground(COLOR_TEXT_BACKGROUND
);
1600 for (int i
= 0; i
< inputElement
.attributes
.size(); i
++) {
1601 InputAttribute attribute
= inputElement
.attributes
.get(i
);
1602 boolean duplicate
= false;
1603 for (int j
= i
+ 1; j
< inputElement
.attributes
.size(); j
++) {
1604 InputAttribute otherAttribute
= inputElement
.attributes
.get(j
);
1605 if (otherAttribute
.attributeName
.equals(attribute
.attributeName
)) {
1607 if (elementNode
!= null) {
1608 elementNode
.attributes
.get(j
).attributeNameText
.setBackground(COLOR_LIGHT_RED
);
1612 if (attribute
.attributeName
.length() == 0) {
1613 errors
.append(Messages
.CustomXmlParserInputWizardPage_missingAttribute
1614 + " (" + Messages
.CustomXmlParserInputWizardPage_attributePrompt
+ " " + getName(inputElement
) + ": ?). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1615 if (elementNode
!= null) {
1616 elementNode
.attributes
.get(i
).attributeNameText
.setBackground(COLOR_LIGHT_RED
);
1618 } else if (duplicate
) {
1619 errors
.append(Messages
.CustomXmlParserInputWizardPage_duplicateAttributeError
1620 + " (" + Messages
.CustomXmlParserInputWizardPage_attributePrompt
+ " " + getName(attribute
, inputElement
) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1621 if (elementNode
!= null) {
1622 elementNode
.attributes
.get(i
).attributeNameText
.setBackground(COLOR_LIGHT_RED
);
1625 if (attribute
.inputName
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1626 timeStampFound
= true;
1627 if (attribute
.inputFormat
.length() == 0) {
1628 errors
.append(Messages
.CustomXmlParserInputWizardPage_missingTimestampInFmtError
1629 + " (" + Messages
.CustomXmlParserInputWizardPage_attributePrompt
+ " " + getName(attribute
, inputElement
) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1630 if (elementNode
!= null) {
1631 elementNode
.attributes
.get(i
).tagText
.setBackground(COLOR_LIGHT_RED
);
1635 new SimpleDateFormat(attribute
.inputFormat
);
1636 if (elementNode
!= null) {
1637 elementNode
.attributes
.get(i
).tagText
.setBackground(COLOR_TEXT_BACKGROUND
);
1639 } catch (IllegalArgumentException e
) {
1640 errors
.append(Messages
.CustomXmlParserInputWizardPage_invalidTimestampInFmtError
1641 + " (" + Messages
.CustomXmlParserInputWizardPage_attributePrompt
+ " " + getName(attribute
, inputElement
) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1642 if (elementNode
!= null) {
1643 elementNode
.attributes
.get(i
).tagText
.setBackground(COLOR_LIGHT_RED
);
1647 } else if (attribute
.inputName
.length() == 0) {
1648 errors
.append(Messages
.CustomXmlParserInputWizardPage_missingDataGroupNameError
1649 + " (" + Messages
.CustomXmlParserInputWizardPage_attributePrompt
+ " " + getName(attribute
, inputElement
) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1650 if (elementNode
!= null) {
1651 elementNode
.attributes
.get(i
).tagText
.setBackground(COLOR_LIGHT_RED
);
1654 if (elementNode
!= null) {
1655 elementNode
.attributes
.get(i
).tagText
.setBackground(COLOR_TEXT_BACKGROUND
);
1660 if (inputElement
.childElements
!= null) {
1661 for (InputElement child
: inputElement
.childElements
) {
1662 ElementNode childElementNode
= null;
1663 if (selectedElement
!= null && selectedElement
.inputElement
.equals(child
)) {
1664 childElementNode
= selectedElement
;
1666 if (childElementNode
!= null) {
1667 childElementNode
.elementNameText
.setBackground(COLOR_TEXT_BACKGROUND
);
1670 for (int i
= 0; i
< inputElement
.childElements
.size(); i
++) {
1671 InputElement child
= inputElement
.childElements
.get(i
);
1672 ElementNode childElementNode
= null;
1673 if (selectedElement
!= null && selectedElement
.inputElement
.equals(child
)) {
1674 childElementNode
= selectedElement
;
1676 if (child
.elementName
.length() == 0) {
1677 errors
.append(Messages
.CustomXmlParserInputWizardPage_missingElementNameError
1678 + " (" + Messages
.CustomXmlParserInputWizardPage_attributePrompt
+ " " + getName(child
) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1679 if (childElementNode
!= null) {
1680 childElementNode
.elementNameText
.setBackground(COLOR_LIGHT_RED
);
1683 boolean duplicate
= false;
1684 for (int j
= i
+ 1; j
< inputElement
.childElements
.size(); j
++) {
1685 InputElement otherChild
= inputElement
.childElements
.get(j
);
1686 if (otherChild
.elementName
.equals(child
.elementName
)) {
1688 ElementNode otherChildElementNode
= null;
1689 if (selectedElement
!= null && selectedElement
.inputElement
.equals(otherChild
)) {
1690 otherChildElementNode
= selectedElement
;
1692 if (otherChildElementNode
!= null) {
1693 otherChildElementNode
.elementNameText
.setBackground(COLOR_LIGHT_RED
);
1698 errors
.append(Messages
.CustomXmlParserInputWizardPage_duplicateElementNameError
1699 + " (" + Messages
.CustomXmlParserInputWizardPage_attributePrompt
+ " " + getName(child
) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1700 if (childElementNode
!= null) {
1701 childElementNode
.elementNameText
.setBackground(COLOR_LIGHT_RED
);
1706 errors
.append(validateElement(child
));
1713 * Get the trace definition.
1715 * @return The trace definition
1717 public CustomXmlTraceDefinition
getDefinition() {
1722 * Get the raw text input.
1724 * @return The raw text input.
1726 public char[] getInputText() {
1727 return inputText
.getText().toCharArray();