Merge branch 'master' into lttng_2_0_control_dev
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / parsers / wizards / CustomXmlParserInputWizardPage.java
1 package org.eclipse.linuxtools.internal.tmf.ui.parsers.wizards;
2
3 import java.io.BufferedReader;
4 import java.io.ByteArrayInputStream;
5 import java.io.IOException;
6 import java.io.InputStream;
7 import java.io.InputStreamReader;
8 import java.text.ParseException;
9 import java.text.SimpleDateFormat;
10 import java.util.ArrayList;
11 import java.util.Date;
12 import java.util.List;
13
14 import javax.xml.parsers.DocumentBuilder;
15 import javax.xml.parsers.DocumentBuilderFactory;
16 import javax.xml.parsers.ParserConfigurationException;
17
18 import org.eclipse.core.resources.IFile;
19 import org.eclipse.core.runtime.CoreException;
20 import org.eclipse.jface.viewers.ColumnLabelProvider;
21 import org.eclipse.jface.viewers.ISelection;
22 import org.eclipse.jface.viewers.ISelectionChangedListener;
23 import org.eclipse.jface.viewers.IStructuredSelection;
24 import org.eclipse.jface.viewers.ITreeContentProvider;
25 import org.eclipse.jface.viewers.SelectionChangedEvent;
26 import org.eclipse.jface.viewers.StructuredSelection;
27 import org.eclipse.jface.viewers.TreeViewer;
28 import org.eclipse.jface.viewers.Viewer;
29 import org.eclipse.jface.wizard.WizardPage;
30 import org.eclipse.linuxtools.internal.tmf.ui.Messages;
31 import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;
32 import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTrace;
33 import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition;
34 import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputAttribute;
35 import org.eclipse.linuxtools.internal.tmf.ui.parsers.custom.CustomXmlTraceDefinition.InputElement;
36 import org.eclipse.swt.SWT;
37 import org.eclipse.swt.browser.Browser;
38 import org.eclipse.swt.browser.TitleEvent;
39 import org.eclipse.swt.browser.TitleListener;
40 import org.eclipse.swt.custom.SashForm;
41 import org.eclipse.swt.custom.ScrolledComposite;
42 import org.eclipse.swt.custom.StyleRange;
43 import org.eclipse.swt.custom.StyledText;
44 import org.eclipse.swt.events.ModifyEvent;
45 import org.eclipse.swt.events.ModifyListener;
46 import org.eclipse.swt.events.SelectionAdapter;
47 import org.eclipse.swt.events.SelectionEvent;
48 import org.eclipse.swt.events.SelectionListener;
49 import org.eclipse.swt.graphics.Color;
50 import org.eclipse.swt.graphics.Font;
51 import org.eclipse.swt.graphics.FontData;
52 import org.eclipse.swt.graphics.Image;
53 import org.eclipse.swt.layout.FillLayout;
54 import org.eclipse.swt.layout.GridData;
55 import org.eclipse.swt.layout.GridLayout;
56 import org.eclipse.swt.widgets.Button;
57 import org.eclipse.swt.widgets.Combo;
58 import org.eclipse.swt.widgets.Composite;
59 import org.eclipse.swt.widgets.Display;
60 import org.eclipse.swt.widgets.Group;
61 import org.eclipse.swt.widgets.Label;
62 import org.eclipse.swt.widgets.Shell;
63 import org.eclipse.swt.widgets.Text;
64 import org.w3c.dom.Document;
65 import org.w3c.dom.Element;
66 import org.w3c.dom.NamedNodeMap;
67 import org.w3c.dom.Node;
68 import org.w3c.dom.NodeList;
69 import org.xml.sax.EntityResolver;
70 import org.xml.sax.ErrorHandler;
71 import org.xml.sax.InputSource;
72 import org.xml.sax.SAXException;
73 import org.xml.sax.SAXParseException;
74
75 public class CustomXmlParserInputWizardPage extends WizardPage {
76
77 private static final String DEFAULT_TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$
78 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$
79 private static final Image elementImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/element_icon.gif"); //$NON-NLS-1$
80 private static final Image addImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$
81 private static final Image addNextImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/addnext_button.gif"); //$NON-NLS-1$
82 private static final Image addChildImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/addchild_button.gif"); //$NON-NLS-1$
83 private static final Image addManyImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/addmany_button.gif"); //$NON-NLS-1$
84 private static final Image deleteImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$
85 private static final Image moveUpImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/moveup_button.gif"); //$NON-NLS-1$
86 private static final Image moveDownImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/movedown_button.gif"); //$NON-NLS-1$
87 private static final Image helpImage = TmfUiPlugin.getDefault().getImageFromPath("/icons/elcl16/help_button.gif"); //$NON-NLS-1$
88 private static final Color COLOR_LIGHT_RED = new Color(Display.getDefault(), 255, 192, 192);
89 private static final Color COLOR_TEXT_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WHITE);
90 private static final Color COLOR_WIDGET_BACKGROUND = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
91
92 private final ISelection selection;
93 private CustomXmlTraceDefinition definition;
94 private String editDefinitionName;
95 private String defaultDescription;
96 private ElementNode selectedElement;
97 private Composite container;
98 private Text logtypeText;
99 private Text timeStampOutputFormatText;
100 private Text timeStampPreviewText;
101 private Button removeButton;
102 private Button addChildButton;
103 private Button addNextButton;
104 private Button moveUpButton;
105 private Button moveDownButton;
106 private Button feelingLuckyButton;
107 private ScrolledComposite treeScrolledComposite;
108 private ScrolledComposite elementScrolledComposite;
109 private TreeViewer treeViewer;
110 private Composite treeContainer;
111 private Composite elementContainer;
112 private Text errorText;
113 private StyledText inputText;
114 private Font fixedFont;
115 private UpdateListener updateListener;
116 private Browser helpBrowser;
117 private Element documentElement;
118
119 // variables used recursively through element traversal
120 private String timeStampValue;
121 private String timeStampFormat;
122 private boolean timeStampFound;
123 private int logEntriesCount;
124 private boolean logEntryFound;
125
126 protected CustomXmlParserInputWizardPage(ISelection selection, CustomXmlTraceDefinition definition) {
127 super("CustomXmlParserWizardPage"); //$NON-NLS-1$
128 if (definition == null) {
129 setTitle(Messages.CustomXmlParserInputWizardPage_titleNew);
130 defaultDescription = Messages.CustomXmlParserInputWizardPage_descriptionNew;
131 } else {
132 setTitle(Messages.CustomXmlParserInputWizardPage_titleEdit);
133 defaultDescription = Messages.CustomXmlParserInputWizardPage_descriptionEdit;
134 }
135 setDescription(defaultDescription);
136 this.selection = selection;
137 this.definition = definition;
138 if (definition != null) {
139 this.editDefinitionName = definition.definitionName;
140 }
141 }
142
143 @Override
144 public void createControl(Composite parent) {
145 container = new Composite(parent, SWT.NULL);
146 container.setLayout(new GridLayout());
147
148 updateListener = new UpdateListener();
149
150 Composite headerComposite = new Composite(container, SWT.FILL);
151 GridLayout headerLayout = new GridLayout(5, false);
152 headerLayout.marginHeight = 0;
153 headerLayout.marginWidth = 0;
154 headerComposite.setLayout(headerLayout);
155 headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
156
157 Label logtypeLabel = new Label(headerComposite, SWT.NULL);
158 logtypeLabel.setText(Messages.CustomXmlParserInputWizardPage_logType);
159
160 logtypeText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);
161 logtypeText.setLayoutData(new GridData(120, SWT.DEFAULT));
162
163 Label timeStampFormatLabel = new Label(headerComposite, SWT.NULL);
164 timeStampFormatLabel.setText(Messages.CustomXmlParserInputWizardPage_timestampFormat);
165
166 timeStampOutputFormatText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);
167 timeStampOutputFormatText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
168 timeStampOutputFormatText.setText(DEFAULT_TIMESTAMP_FORMAT);
169
170 Button dateFormatHelpButton = new Button(headerComposite, SWT.PUSH);
171 dateFormatHelpButton.setImage(helpImage);
172 dateFormatHelpButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_dateFormatHelp);
173 dateFormatHelpButton.addSelectionListener(new SelectionAdapter() {
174 @Override
175 public void widgetSelected(SelectionEvent e) {
176 openHelpShell(SIMPLE_DATE_FORMAT_URL);
177 }
178 });
179
180 Label timeStampPreviewLabel = new Label(headerComposite, SWT.NULL);
181 timeStampPreviewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 3, 1));
182 timeStampPreviewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);
183
184 timeStampPreviewText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
185 timeStampPreviewText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
186 timeStampPreviewText.setText("*no time stamp element or attribute*"); //$NON-NLS-1$
187
188 createButtonBar();
189
190 SashForm vSash = new SashForm(container, SWT.VERTICAL);
191 vSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
192 vSash.setBackground(vSash.getDisplay().getSystemColor(SWT.COLOR_GRAY));
193
194 SashForm hSash = new SashForm(vSash, SWT.HORIZONTAL);
195 hSash.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
196
197 treeScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL | SWT.H_SCROLL);
198 treeScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
199 treeContainer = new Composite(treeScrolledComposite, SWT.NONE);
200 treeContainer.setLayout(new FillLayout());
201 treeScrolledComposite.setContent(treeContainer);
202 treeScrolledComposite.setExpandHorizontal(true);
203 treeScrolledComposite.setExpandVertical(true);
204
205 treeViewer = new TreeViewer(treeContainer, SWT.SINGLE | SWT.BORDER);
206 treeViewer.setContentProvider(new InputElementTreeNodeContentProvider());
207 treeViewer.setLabelProvider(new InputElementTreeLabelProvider());
208 treeViewer.addSelectionChangedListener(new InputElementTreeSelectionChangedListener());
209 treeContainer.layout();
210
211 treeScrolledComposite
212 .setMinSize(treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, treeContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y);
213
214 elementScrolledComposite = new ScrolledComposite(hSash, SWT.V_SCROLL);
215 elementScrolledComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
216 elementContainer = new Composite(elementScrolledComposite, SWT.NONE);
217 GridLayout gl = new GridLayout();
218 gl.marginHeight = 1;
219 gl.marginWidth = 0;
220 elementContainer.setLayout(gl);
221 elementScrolledComposite.setContent(elementContainer);
222 elementScrolledComposite.setExpandHorizontal(true);
223 elementScrolledComposite.setExpandVertical(true);
224
225 if (definition == null) {
226 definition = new CustomXmlTraceDefinition();
227 }
228 loadDefinition(definition);
229 treeViewer.expandAll();
230 elementContainer.layout();
231
232 logtypeText.addModifyListener(updateListener);
233 timeStampOutputFormatText.addModifyListener(updateListener);
234
235 elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
236 elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
237
238 hSash.setWeights(new int[] { 1, 2 });
239
240 if (definition.rootInputElement == null) {
241 removeButton.setEnabled(false);
242 addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentElement);
243 addNextButton.setEnabled(false);
244 moveUpButton.setEnabled(false);
245 moveDownButton.setEnabled(false);
246 } else { // root is selected
247 addNextButton.setEnabled(false);
248 }
249
250 Composite sashBottom = new Composite(vSash, SWT.NONE);
251 GridLayout sashBottomLayout = new GridLayout(2, false);
252 sashBottomLayout.marginHeight = 0;
253 sashBottomLayout.marginWidth = 0;
254 sashBottom.setLayout(sashBottomLayout);
255
256 Label previewLabel = new Label(sashBottom, SWT.NULL);
257 previewLabel.setText(Messages.CustomXmlParserInputWizardPage_previewInput);
258
259 errorText = new Text(sashBottom, SWT.SINGLE | SWT.READ_ONLY);
260 errorText.setBackground(COLOR_WIDGET_BACKGROUND);
261 errorText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
262 errorText.setVisible(false);
263
264 inputText = new StyledText(sashBottom, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
265 if (fixedFont == null) {
266 if (System.getProperty("os.name").contains("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$
267 fixedFont = new Font(Display.getCurrent(), new FontData("Courier New", 10, SWT.NORMAL)); //$NON-NLS-1$
268 } else {
269 fixedFont = new Font(Display.getCurrent(), new FontData("Monospace", 10, SWT.NORMAL)); //$NON-NLS-1$
270 }
271 }
272 inputText.setFont(fixedFont);
273 GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
274 gd.heightHint = inputText.computeSize(SWT.DEFAULT, inputText.getLineHeight() * 4).y;
275 gd.widthHint = 800;
276 inputText.setLayoutData(gd);
277 inputText.setText(getSelectionText());
278 inputText.addModifyListener(new ModifyListener() {
279 @Override
280 public void modifyText(ModifyEvent e) {
281 parseXmlInput(inputText.getText());
282 }
283 });
284 inputText.addModifyListener(updateListener);
285
286 vSash.setWeights(new int[] { hSash.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sashBottom.computeSize(SWT.DEFAULT, SWT.DEFAULT).y });
287
288 setControl(container);
289 }
290
291 private void createButtonBar() {
292 Composite buttonBar = new Composite(container, SWT.NONE);
293 GridLayout buttonBarLayout = new GridLayout(6, false);
294 buttonBarLayout.marginHeight = 0;
295 buttonBarLayout.marginWidth = 0;
296 buttonBar.setLayout(buttonBarLayout);
297
298 removeButton = new Button(buttonBar, SWT.PUSH);
299 removeButton.setImage(deleteImage);
300 removeButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_removeElement);
301 removeButton.addSelectionListener(new SelectionAdapter() {
302 @Override
303 public void widgetSelected(SelectionEvent e) {
304 if (treeViewer.getSelection().isEmpty() || selectedElement == null)
305 return;
306 removeElement();
307 InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
308 if (inputElement == definition.rootInputElement) {
309 definition.rootInputElement = null;
310 } else {
311 inputElement.parentElement.childElements.remove(inputElement);
312 }
313 treeViewer.refresh();
314 validate();
315 updatePreviews();
316 removeButton.setEnabled(false);
317 if (definition.rootInputElement == null) {
318 addChildButton.setEnabled(true);
319 addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentEleemnt);
320 } else {
321 addChildButton.setEnabled(false);
322 }
323 addNextButton.setEnabled(false);
324 moveUpButton.setEnabled(false);
325 moveDownButton.setEnabled(false);
326 }
327 });
328
329 addChildButton = new Button(buttonBar, SWT.PUSH);
330 addChildButton.setImage(addChildImage);
331 addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addChildElement);
332 addChildButton.addSelectionListener(new SelectionAdapter() {
333 @Override
334 public void widgetSelected(SelectionEvent e) {
335 InputElement inputElement = new InputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
336 if (definition.rootInputElement == null) {
337 definition.rootInputElement = inputElement;
338 inputElement.elementName = getChildNameSuggestion(null);
339 } else if (treeViewer.getSelection().isEmpty()) {
340 return;
341 } else {
342 InputElement parentInputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
343 parentInputElement.addChild(inputElement);
344 inputElement.elementName = getChildNameSuggestion(parentInputElement);
345 }
346 treeViewer.refresh();
347 treeViewer.setSelection(new StructuredSelection(inputElement), true);
348 }
349 });
350
351 addNextButton = new Button(buttonBar, SWT.PUSH);
352 addNextButton.setImage(addNextImage);
353 addNextButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addNextElement);
354 addNextButton.addSelectionListener(new SelectionAdapter() {
355 @Override
356 public void widgetSelected(SelectionEvent e) {
357 InputElement inputElement = new InputElement("", false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$ //$NON-NLS-2$
358 if (definition.rootInputElement == null) {
359 definition.rootInputElement = inputElement;
360 inputElement.elementName = getChildNameSuggestion(null);
361 } else if (treeViewer.getSelection().isEmpty()) {
362 return;
363 } else {
364 InputElement previousInputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
365 if (previousInputElement == definition.rootInputElement) {
366 return;
367 } else {
368 previousInputElement.addNext(inputElement);
369 inputElement.elementName = getChildNameSuggestion(inputElement.parentElement);
370 }
371 }
372 treeViewer.refresh();
373 treeViewer.setSelection(new StructuredSelection(inputElement), true);
374 }
375 });
376
377 feelingLuckyButton = new Button(buttonBar, SWT.PUSH);
378 feelingLuckyButton.setImage(addManyImage);
379 feelingLuckyButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_feelingLucky);
380 feelingLuckyButton.addSelectionListener(new SelectionAdapter() {
381 @Override
382 public void widgetSelected(SelectionEvent e) {
383 InputElement inputElement = null;
384 if (definition.rootInputElement == null) {
385 if (getChildNameSuggestion(null).length() != 0) {
386 inputElement = new InputElement(getChildNameSuggestion(null), false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$
387 definition.rootInputElement = inputElement;
388 feelingLucky(inputElement);
389 } else {
390 return;
391 }
392 } else if (treeViewer.getSelection().isEmpty()) {
393 return;
394 } else {
395 inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
396 feelingLucky(inputElement);
397 }
398 treeViewer.refresh();
399 treeViewer.setSelection(new StructuredSelection(inputElement), true);
400 treeViewer.expandToLevel(inputElement, TreeViewer.ALL_LEVELS);
401 }
402 });
403
404 moveUpButton = new Button(buttonBar, SWT.PUSH);
405 moveUpButton.setImage(moveUpImage);
406 moveUpButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_moveUp);
407 moveUpButton.addSelectionListener(new SelectionAdapter() {
408 @Override
409 public void widgetSelected(SelectionEvent e) {
410 if (treeViewer.getSelection().isEmpty())
411 return;
412 InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
413 if (inputElement == definition.rootInputElement) {
414 return;
415 } else {
416 inputElement.moveUp();
417 }
418 treeViewer.refresh();
419 validate();
420 updatePreviews();
421 }
422 });
423
424 moveDownButton = new Button(buttonBar, SWT.PUSH);
425 moveDownButton.setImage(moveDownImage);
426 moveDownButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_moveDown);
427 moveDownButton.addSelectionListener(new SelectionAdapter() {
428 @Override
429 public void widgetSelected(SelectionEvent e) {
430 if (treeViewer.getSelection().isEmpty())
431 return;
432 InputElement inputElement = (InputElement) ((IStructuredSelection) treeViewer.getSelection()).getFirstElement();
433 if (inputElement == definition.rootInputElement) {
434 return;
435 } else {
436 inputElement.moveDown();
437 }
438 treeViewer.refresh();
439 validate();
440 updatePreviews();
441 }
442 });
443 }
444
445 private void feelingLucky(InputElement inputElement) {
446 while (true) {
447 String attributeName = getAttributeNameSuggestion(inputElement);
448 if (attributeName.length() == 0) {
449 break;
450 } else {
451 InputAttribute attribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$
452 inputElement.addAttribute(attribute);
453 }
454 }
455 while (true) {
456 String childName = getChildNameSuggestion(inputElement);
457 if (childName.length() == 0) {
458 break;
459 } else {
460 InputElement childElement = new InputElement(childName, false, CustomXmlTraceDefinition.TAG_IGNORE, 0, "", null); //$NON-NLS-1$
461 inputElement.addChild(childElement);
462 feelingLucky(childElement);
463 }
464 }
465 }
466
467 private static class InputElementTreeNodeContentProvider implements ITreeContentProvider {
468
469 @Override
470 public Object[] getElements(Object inputElement) {
471 CustomXmlTraceDefinition def = (CustomXmlTraceDefinition) inputElement;
472 if (def.rootInputElement != null) {
473 return new Object[] { def.rootInputElement };
474 } else {
475 return new Object[0];
476 }
477 }
478
479 @Override
480 public Object[] getChildren(Object parentElement) {
481 InputElement inputElement = (InputElement) parentElement;
482 if (inputElement.childElements == null)
483 return new InputElement[0];
484 return inputElement.childElements.toArray();
485 }
486
487 @Override
488 public boolean hasChildren(Object element) {
489 InputElement inputElement = (InputElement) element;
490 return (inputElement.childElements != null && inputElement.childElements.size() > 0);
491 }
492
493 @Override
494 public void dispose() {
495 }
496
497 @Override
498 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
499 }
500
501 @Override
502 public Object getParent(Object element) {
503 InputElement inputElement = (InputElement) element;
504 return inputElement.parentElement;
505 }
506 }
507
508 private static class InputElementTreeLabelProvider extends ColumnLabelProvider {
509
510 @Override
511 public Image getImage(Object element) {
512 return elementImage;
513 }
514
515 @Override
516 public String getText(Object element) {
517 InputElement inputElement = (InputElement) element;
518 return (inputElement.elementName.trim().length() == 0) ? "?" : inputElement.elementName; //$NON-NLS-1$
519 }
520 }
521
522 private class InputElementTreeSelectionChangedListener implements ISelectionChangedListener {
523 @Override
524 public void selectionChanged(SelectionChangedEvent event) {
525 if (selectedElement != null) {
526 selectedElement.dispose();
527 }
528 if (!(event.getSelection().isEmpty()) && event.getSelection() instanceof IStructuredSelection) {
529 IStructuredSelection selection = (IStructuredSelection) event.getSelection();
530 InputElement inputElement = (InputElement) selection.getFirstElement();
531 selectedElement = new ElementNode(elementContainer, inputElement);
532 elementContainer.layout();
533 elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
534 elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
535 container.layout();
536 validate();
537 updatePreviews();
538 removeButton.setEnabled(true);
539 addChildButton.setEnabled(true);
540 addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addChildElement);
541 if (definition.rootInputElement == inputElement) {
542 addNextButton.setEnabled(false);
543 } else {
544 addNextButton.setEnabled(true);
545 }
546 moveUpButton.setEnabled(true);
547 moveDownButton.setEnabled(true);
548 } else {
549 removeButton.setEnabled(false);
550 if (definition.rootInputElement == null) {
551 addChildButton.setEnabled(true);
552 addChildButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addDocumentElement);
553 } else {
554 addChildButton.setEnabled(false);
555 }
556 addNextButton.setEnabled(false);
557 moveUpButton.setEnabled(false);
558 moveDownButton.setEnabled(false);
559 }
560 }
561 }
562
563 /*
564 * (non-Javadoc)
565 *
566 * @see org.eclipse.jface.dialogs.DialogPage#dispose()
567 */
568 @Override
569 public void dispose() {
570 if (fixedFont != null) {
571 fixedFont.dispose();
572 fixedFont = null;
573 }
574 super.dispose();
575 }
576
577 private void loadDefinition(CustomXmlTraceDefinition def) {
578 logtypeText.setText(def.definitionName);
579 timeStampOutputFormatText.setText(def.timeStampOutputFormat);
580 treeViewer.setInput(def);
581
582 if (def.rootInputElement != null) {
583 treeViewer.setSelection(new StructuredSelection(def.rootInputElement));
584 }
585 }
586
587 private String getName(InputElement inputElement) {
588 String name = (inputElement.elementName.trim().length() == 0) ? "?" : inputElement.elementName.trim(); //$NON-NLS-1$
589 if (inputElement.parentElement == null) {
590 return name;
591 }
592 return getName(inputElement.parentElement) + " : " + name; //$NON-NLS-1$
593 }
594
595 private String getName(InputAttribute inputAttribute, InputElement inputElement) {
596 String name = (inputAttribute.attributeName.trim().length() == 0) ? "?" : inputAttribute.attributeName.trim(); //$NON-NLS-1$
597 return getName(inputElement) + " : " + name; //$NON-NLS-1$
598 }
599
600 /*
601 * (non-Javadoc)
602 *
603 * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
604 */
605 @Override
606 public void setVisible(boolean visible) {
607 if (visible) {
608 validate();
609 updatePreviews();
610 }
611 super.setVisible(visible);
612 }
613
614 public List<String> getInputNames() {
615 return getInputNames(definition.rootInputElement);
616 }
617
618 public List<String> getInputNames(InputElement inputElement) {
619 List<String> inputs = new ArrayList<String>();
620 if (inputElement.inputName != null && !inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
621 String inputName = inputElement.inputName;
622 if (!inputs.contains(inputName)) {
623 inputs.add(inputName);
624 }
625 }
626 if (inputElement.attributes != null) {
627 for (InputAttribute attribute : inputElement.attributes) {
628 String inputName = attribute.inputName;
629 if (!inputs.contains(inputName)) {
630 inputs.add(inputName);
631 }
632 }
633 }
634 if (inputElement.childElements != null) {
635 for (InputElement childInputElement : inputElement.childElements) {
636 for (String inputName : getInputNames(childInputElement)) {
637 if (!inputs.contains(inputName)) {
638 inputs.add(inputName);
639 }
640 }
641 }
642 }
643 return inputs;
644 }
645
646 private void removeElement() {
647 selectedElement.dispose();
648 selectedElement = null;
649 elementContainer.layout();
650 elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
651 elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
652 container.layout();
653 }
654
655 private String getSelectionText() {
656 InputStream inputStream = null;
657 if (this.selection instanceof IStructuredSelection) {
658 Object selection = ((IStructuredSelection) this.selection).getFirstElement();
659 if (selection instanceof IFile) {
660 IFile file = (IFile) selection;
661 try {
662 inputStream = file.getContents();
663 } catch (CoreException e) {
664 return ""; //$NON-NLS-1$
665 }
666 }
667 }
668 if (inputStream != null) {
669 BufferedReader reader = null;
670 try {
671 reader = new BufferedReader(new InputStreamReader(inputStream));
672 StringBuilder sb = new StringBuilder();
673 String line = null;
674 while ((line = reader.readLine()) != null) {
675 sb.append(line + "\n"); //$NON-NLS-1$
676 }
677 parseXmlInput(sb.toString());
678 reader.close();
679 return sb.toString();
680 } catch (IOException e) {
681 return ""; //$NON-NLS-1$
682 }
683 }
684 return ""; //$NON-NLS-1$
685 }
686
687 private void parseXmlInput(final String string) {
688 try {
689 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
690 DocumentBuilder db = dbf.newDocumentBuilder();
691
692 // The following allows xml parsing without access to the dtd
693 EntityResolver resolver = new EntityResolver() {
694 @Override
695 public InputSource resolveEntity(String publicId, String systemId) {
696 String empty = ""; //$NON-NLS-1$
697 ByteArrayInputStream bais = new ByteArrayInputStream(empty.getBytes());
698 return new InputSource(bais);
699 }
700 };
701 db.setEntityResolver(resolver);
702
703 // The following catches xml parsing exceptions
704 db.setErrorHandler(new ErrorHandler() {
705 @Override
706 public void error(SAXParseException saxparseexception) throws SAXException {
707 }
708
709 @Override
710 public void warning(SAXParseException saxparseexception) throws SAXException {
711 }
712
713 @Override
714 public void fatalError(SAXParseException saxparseexception) throws SAXException {
715 if (string.trim().length() != 0) {
716 errorText.setText(saxparseexception.getMessage());
717 errorText.setBackground(COLOR_LIGHT_RED);
718 errorText.setVisible(true);
719 }
720 throw saxparseexception;
721 }
722 });
723
724 errorText.setVisible(false);
725 Document doc = null;
726 doc = db.parse(new ByteArrayInputStream(string.getBytes()));
727 documentElement = doc.getDocumentElement();
728 } catch (ParserConfigurationException e) {
729 e.printStackTrace();
730 documentElement = null;
731 } catch (SAXException e) {
732 documentElement = null;
733 } catch (IOException e) {
734 e.printStackTrace();
735 documentElement = null;
736 }
737 }
738
739 private void updatePreviews() {
740 updatePreviews(false);
741 }
742
743 private void initValues() {
744 timeStampValue = null;
745 timeStampFormat = null;
746 logEntriesCount = 0;
747 logEntryFound = false;
748 }
749
750 private void updatePreviews(boolean updateAll) {
751 if (inputText == null) {
752 // early update during construction
753 return;
754 }
755 inputText.setStyleRanges(new StyleRange[] {});
756 if (selectedElement == null) {
757 return;
758 }
759
760 initValues();
761
762 selectedElement.updatePreview();
763
764 if (timeStampValue != null && timeStampFormat != null) {
765 try {
766 SimpleDateFormat dateFormat = new SimpleDateFormat(timeStampFormat);
767 Date date = dateFormat.parse(timeStampValue);
768 dateFormat = new SimpleDateFormat(timeStampOutputFormatText.getText().trim());
769 timeStampPreviewText.setText(dateFormat.format(date));
770 } catch (ParseException e) {
771 timeStampPreviewText.setText("*parse exception* [" + timeStampValue + "] <> [" + timeStampFormat + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
772 } catch (IllegalArgumentException e) {
773 timeStampPreviewText.setText("*parse exception* [Illegal Argument]"); //$NON-NLS-1$
774 }
775 } else {
776 timeStampPreviewText.setText("*no matching time stamp*"); //$NON-NLS-1$
777 }
778 }
779
780 private void openHelpShell(String url) {
781 if (helpBrowser != null && !helpBrowser.isDisposed()) {
782 helpBrowser.getShell().setActive();
783 if (!helpBrowser.getUrl().equals(url)) {
784 helpBrowser.setUrl(url);
785 }
786 return;
787 }
788 final Shell helpShell = new Shell(getShell(), SWT.SHELL_TRIM);
789 helpShell.setLayout(new FillLayout());
790 helpBrowser = new Browser(helpShell, SWT.NONE);
791 helpBrowser.addTitleListener(new TitleListener() {
792 @Override
793 public void changed(TitleEvent event) {
794 helpShell.setText(event.title);
795 }
796 });
797 helpBrowser.setBounds(0, 0, 600, 400);
798 helpShell.pack();
799 helpShell.open();
800 helpBrowser.setUrl(url);
801 }
802
803 private class UpdateListener implements ModifyListener, SelectionListener {
804
805 @Override
806 public void modifyText(ModifyEvent e) {
807 validate();
808 updatePreviews();
809 }
810
811 @Override
812 public void widgetDefaultSelected(SelectionEvent e) {
813 validate();
814 updatePreviews();
815 }
816
817 @Override
818 public void widgetSelected(SelectionEvent e) {
819 validate();
820 updatePreviews();
821 }
822
823 }
824
825 private class ElementNode {
826 final InputElement inputElement;
827 final Group group;
828 ArrayList<Attribute> attributes = new ArrayList<Attribute>();
829 ArrayList<ElementNode> childElements = new ArrayList<ElementNode>();
830 Text elementNameText;
831 Composite tagComposite;
832 Combo tagCombo;
833 Label tagLabel;
834 Text tagText;
835 Combo actionCombo;
836 Label previewLabel;
837 Text previewText;
838 Button logEntryButton;
839 Label fillerLabel;
840 Composite addAttributeComposite;
841 Button addAttributeButton;
842 Label addAttributeLabel;
843
844 public ElementNode(Composite parent, InputElement inputElement) {
845 this.inputElement = inputElement;
846
847 group = new Group(parent, SWT.NONE);
848 GridLayout gl = new GridLayout(2, false);
849 gl.marginHeight = 0;
850 group.setLayout(gl);
851 group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
852 group.setText(getName(inputElement));
853
854 Label label = new Label(group, SWT.NULL);
855 label.setText(Messages.CustomXmlParserInputWizardPage_elementName);
856 label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
857
858 elementNameText = new Text(group, SWT.BORDER | SWT.SINGLE);
859 GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
860 gd.widthHint = 0;
861 elementNameText.setLayoutData(gd);
862 elementNameText.addModifyListener(new ModifyListener() {
863 @Override
864 public void modifyText(ModifyEvent e) {
865 ElementNode.this.inputElement.elementName = elementNameText.getText().trim();
866 group.setText(getName(ElementNode.this.inputElement));
867 }
868 });
869 elementNameText.setText(inputElement.elementName);
870 elementNameText.addModifyListener(updateListener);
871
872 if (inputElement.parentElement != null) {
873 previewLabel = new Label(group, SWT.NULL);
874 previewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
875 previewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);
876
877 previewText = new Text(group, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
878 gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
879 gd.widthHint = 0;
880 previewText.setLayoutData(gd);
881 previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);
882 previewText.setBackground(COLOR_WIDGET_BACKGROUND);
883
884 logEntryButton = new Button(group, SWT.CHECK);
885 logEntryButton.setText(Messages.CustomXmlParserInputWizardPage_logEntry);
886 logEntryButton.setSelection(inputElement.logEntry);
887 logEntryButton.addSelectionListener(new SelectionListener() {
888 @Override
889 public void widgetDefaultSelected(SelectionEvent e) {
890 }
891
892 @Override
893 public void widgetSelected(SelectionEvent e) {
894 InputElement parent = ElementNode.this.inputElement.parentElement;
895 while (parent != null) {
896 parent.logEntry = false;
897 parent = parent.parentElement;
898 }
899 }
900 });
901 logEntryButton.addSelectionListener(updateListener);
902
903 tagComposite = new Composite(group, SWT.FILL);
904 GridLayout tagLayout = new GridLayout(4, false);
905 tagLayout.marginWidth = 0;
906 tagLayout.marginHeight = 0;
907 tagComposite.setLayout(tagLayout);
908 tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
909
910 tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
911 tagCombo.setItems(new String[] { CustomXmlTraceDefinition.TAG_IGNORE, CustomXmlTraceDefinition.TAG_TIMESTAMP,
912 CustomXmlTraceDefinition.TAG_MESSAGE, CustomXmlTraceDefinition.TAG_OTHER });
913 tagCombo.setVisibleItemCount(tagCombo.getItemCount());
914 tagCombo.addSelectionListener(new SelectionListener() {
915 @Override
916 public void widgetDefaultSelected(SelectionEvent e) {
917 }
918
919 @Override
920 public void widgetSelected(SelectionEvent e) {
921 tagText.removeModifyListener(updateListener);
922 switch (tagCombo.getSelectionIndex()) {
923 case 0: // Ignore
924 tagLabel.setVisible(false);
925 tagText.setVisible(false);
926 actionCombo.setVisible(false);
927 break;
928 case 1: // Time Stamp
929 tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
930 tagLabel.setVisible(true);
931 tagText.setVisible(true);
932 tagText.addModifyListener(updateListener);
933 actionCombo.setVisible(true);
934 break;
935 case 2: // Message
936 tagLabel.setVisible(false);
937 tagText.setVisible(false);
938 actionCombo.setVisible(true);
939 break;
940 case 3: // Other
941 tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
942 tagLabel.setVisible(true);
943 if (tagText.getText().trim().length() == 0) {
944 tagText.setText(elementNameText.getText().trim());
945 }
946 tagText.setVisible(true);
947 tagText.addModifyListener(updateListener);
948 actionCombo.setVisible(true);
949 break;
950 }
951 tagComposite.layout();
952 validate();
953 updatePreviews();
954 }
955 });
956
957 tagLabel = new Label(tagComposite, SWT.NULL);
958 tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
959
960 tagText = new Text(tagComposite, SWT.BORDER | SWT.SINGLE);
961 gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
962 gd.widthHint = 0;
963 tagText.setLayoutData(gd);
964
965 actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
966 actionCombo.setItems(new String[] { Messages.CustomXmlParserInputWizardPage_set, Messages.CustomXmlParserInputWizardPage_append,
967 Messages.CustomXmlParserInputWizardPage_appendWith });
968 actionCombo.select(inputElement.inputAction);
969 actionCombo.addSelectionListener(updateListener);
970
971 if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
972 tagCombo.select(0);
973 tagLabel.setVisible(false);
974 tagText.setVisible(false);
975 actionCombo.setVisible(false);
976 } else if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) {
977 tagCombo.select(1);
978 tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
979 tagText.setText(inputElement.inputFormat);
980 tagText.addModifyListener(updateListener);
981 } else if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_MESSAGE)) {
982 tagCombo.select(2);
983 tagLabel.setVisible(false);
984 tagText.setVisible(false);
985 } else {
986 tagCombo.select(3);
987 tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
988 tagText.setText(inputElement.inputName);
989 tagText.addModifyListener(updateListener);
990 }
991 }
992
993 if (inputElement.attributes != null) {
994 for (InputAttribute inputAttribute : inputElement.attributes) {
995 Attribute attribute = new Attribute(group, this, inputAttribute, attributes.size() + 1);
996 attributes.add(attribute);
997 }
998 }
999
1000 createAddButton();
1001 }
1002
1003 private void updatePreview() {
1004 Element element = getPreviewElement(inputElement);
1005 if (inputElement.parentElement != null) { // no preview text for
1006 // document element
1007 previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);
1008 if (element != null) {
1009 previewText.setText(CustomXmlTrace.parseElement(element, new StringBuffer()).toString());
1010 if (logEntryButton.getSelection()) {
1011 if (logEntryFound == false) {
1012 logEntryFound = true;
1013 logEntriesCount++;
1014 } else {
1015 logEntryButton.setSelection(false); // remove nested
1016 // log entry
1017 }
1018 }
1019 if (tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {
1020 String value = previewText.getText().trim();
1021 if (value.length() != 0) {
1022 if (actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_SET) {
1023 timeStampValue = value;
1024 timeStampFormat = tagText.getText().trim();
1025 } else if (actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_APPEND) {
1026 if (timeStampValue != null) {
1027 timeStampValue += value;
1028 timeStampFormat += tagText.getText().trim();
1029 } else {
1030 timeStampValue = value;
1031 timeStampFormat = tagText.getText().trim();
1032 }
1033 } else if (actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
1034 if (timeStampValue != null) {
1035 timeStampValue += " | " + value; //$NON-NLS-1$
1036 timeStampFormat += " | " + tagText.getText().trim(); //$NON-NLS-1$
1037 } else {
1038 timeStampValue = value;
1039 timeStampFormat = tagText.getText().trim();
1040 }
1041 }
1042 }
1043 }
1044 }
1045 }
1046 for (Attribute attribute : attributes) {
1047 if (element != null) {
1048 String value = element.getAttribute(attribute.attributeNameText.getText().trim());
1049 if (value.length() != 0) {
1050 attribute.previewText.setText(value);
1051 if (attribute.tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_TIMESTAMP) && logEntriesCount <= 1) {
1052 if (attribute.actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_SET) {
1053 timeStampValue = value;
1054 timeStampFormat = attribute.tagText.getText().trim();
1055 } else if (attribute.actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_APPEND) {
1056 if (timeStampValue != null) {
1057 timeStampValue += value;
1058 timeStampFormat += attribute.tagText.getText().trim();
1059 } else {
1060 timeStampValue = value;
1061 timeStampFormat = attribute.tagText.getText().trim();
1062 }
1063 } else if (attribute.actionCombo.getSelectionIndex() == CustomXmlTraceDefinition.ACTION_APPEND_WITH_SEPARATOR) {
1064 if (timeStampValue != null) {
1065 timeStampValue += " | " + value; //$NON-NLS-1$
1066 timeStampFormat += " | " + attribute.tagText.getText().trim(); //$NON-NLS-1$
1067 } else {
1068 timeStampValue = value;
1069 timeStampFormat = attribute.tagText.getText().trim();
1070 }
1071 }
1072 }
1073 } else {
1074 attribute.previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingAttribute);
1075 }
1076 } else {
1077 attribute.previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatchingElement);
1078 }
1079 }
1080 for (ElementNode child : childElements) {
1081 child.updatePreview();
1082 }
1083 if (logEntryButton != null && logEntryButton.getSelection()) {
1084 logEntryFound = false;
1085 }
1086 }
1087
1088 private void createAddButton() {
1089 fillerLabel = new Label(group, SWT.NONE);
1090
1091 addAttributeComposite = new Composite(group, SWT.NONE);
1092 addAttributeComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
1093 GridLayout addAttributeLayout = new GridLayout(2, false);
1094 addAttributeLayout.marginHeight = 0;
1095 addAttributeLayout.marginWidth = 0;
1096 addAttributeComposite.setLayout(addAttributeLayout);
1097
1098 addAttributeButton = new Button(addAttributeComposite, SWT.PUSH);
1099 addAttributeButton.setImage(addImage);
1100 addAttributeButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_addAttribute);
1101 addAttributeButton.addSelectionListener(new SelectionAdapter() {
1102 @Override
1103 public void widgetSelected(SelectionEvent e) {
1104 removeAddButton();
1105 String attributeName = getAttributeNameSuggestion(inputElement);
1106 InputAttribute inputAttribute = new InputAttribute(attributeName, attributeName, 0, ""); //$NON-NLS-1$
1107 attributes.add(new Attribute(group, ElementNode.this, inputAttribute, attributes.size() + 1));
1108 createAddButton();
1109 elementContainer.layout();
1110 elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
1111 elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
1112 group.getParent().layout();
1113 validate();
1114 updatePreviews();
1115 }
1116 });
1117
1118 addAttributeLabel = new Label(addAttributeComposite, SWT.NULL);
1119 addAttributeLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
1120 addAttributeLabel.setText(Messages.CustomXmlParserInputWizardPage_newAttibute);
1121 }
1122
1123 private void removeAddButton() {
1124 fillerLabel.dispose();
1125 addAttributeComposite.dispose();
1126 }
1127
1128 private void removeAttribute(int attributeNumber) {
1129 if (--attributeNumber < attributes.size()) {
1130 attributes.remove(attributeNumber).dispose();
1131 for (int i = attributeNumber; i < attributes.size(); i++) {
1132 attributes.get(i).setAttributeNumber(i + 1);
1133 }
1134 elementContainer.layout();
1135 elementScrolledComposite.setMinSize(elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x,
1136 elementContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
1137 group.getParent().layout();
1138 }
1139 }
1140
1141 private void dispose() {
1142 group.dispose();
1143 }
1144
1145 private void extractInputs() {
1146 inputElement.elementName = elementNameText.getText().trim();
1147 if (inputElement.parentElement != null) {
1148 inputElement.logEntry = logEntryButton.getSelection();
1149 if (tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_OTHER)) {
1150 inputElement.inputName = tagText.getText().trim();
1151 } else {
1152 inputElement.inputName = tagCombo.getText();
1153 if (tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) {
1154 inputElement.inputFormat = tagText.getText().trim();
1155 }
1156 }
1157 inputElement.inputAction = actionCombo.getSelectionIndex();
1158 }
1159 inputElement.attributes = new ArrayList<InputAttribute>(attributes.size());
1160 for (int i = 0; i < attributes.size(); i++) {
1161 Attribute attribute = attributes.get(i);
1162 InputAttribute inputAttribute = new InputAttribute();
1163 inputAttribute.attributeName = attribute.attributeNameText.getText().trim();
1164 if (attribute.tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_OTHER)) {
1165 inputAttribute.inputName = attribute.tagText.getText().trim();
1166 } else {
1167 inputAttribute.inputName = attribute.tagCombo.getText();
1168 if (attribute.tagCombo.getText().equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) {
1169 inputAttribute.inputFormat = attribute.tagText.getText().trim();
1170 }
1171 }
1172 inputAttribute.inputAction = attribute.actionCombo.getSelectionIndex();
1173 inputElement.addAttribute(inputAttribute);
1174 }
1175 }
1176 }
1177
1178 private class Attribute {
1179 ElementNode element;
1180 int attributeNumber;
1181
1182 // children of parent (must be disposed)
1183 Composite labelComposite;
1184 Composite attributeComposite;
1185 Label filler;
1186 Composite tagComposite;
1187
1188 // children of labelComposite
1189 Label attributeLabel;
1190
1191 // children of attributeComposite
1192 Text attributeNameText;
1193 Text previewText;
1194
1195 // children of tagComposite
1196 Combo tagCombo;
1197 Label tagLabel;
1198 Text tagText;
1199 Combo actionCombo;
1200
1201 public Attribute(Composite parent, ElementNode element, InputAttribute inputAttribute, int attributeNumber) {
1202 this.element = element;
1203 this.attributeNumber = attributeNumber;
1204
1205 labelComposite = new Composite(parent, SWT.FILL);
1206 GridLayout labelLayout = new GridLayout(2, false);
1207 labelLayout.marginWidth = 0;
1208 labelLayout.marginHeight = 0;
1209 labelComposite.setLayout(labelLayout);
1210 labelComposite.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
1211
1212 Button deleteButton = new Button(labelComposite, SWT.PUSH);
1213 deleteButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
1214 deleteButton.setImage(deleteImage);
1215 deleteButton.setToolTipText(Messages.CustomXmlParserInputWizardPage_removeAttribute);
1216 deleteButton.addSelectionListener(new SelectionAdapter() {
1217 @Override
1218 public void widgetSelected(SelectionEvent e) {
1219 Attribute.this.element.removeAttribute(Attribute.this.attributeNumber);
1220 validate();
1221 updatePreviews();
1222 }
1223 });
1224
1225 attributeLabel = new Label(labelComposite, SWT.NULL);
1226 attributeLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
1227 attributeLabel.setText(Messages.CustomXmlParserInputWizardPage_attibute);
1228
1229 attributeComposite = new Composite(parent, SWT.FILL);
1230 GridLayout attributeLayout = new GridLayout(4, false);
1231 attributeLayout.marginWidth = 0;
1232 attributeLayout.marginHeight = 0;
1233 attributeComposite.setLayout(attributeLayout);
1234 attributeComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
1235
1236 Label nameLabel = new Label(attributeComposite, SWT.NONE);
1237 nameLabel.setText(Messages.CustomXmlParserInputWizardPage_name);
1238
1239 attributeNameText = new Text(attributeComposite, SWT.BORDER | SWT.SINGLE);
1240 attributeNameText.setLayoutData(new GridData(120, SWT.DEFAULT));
1241 attributeNameText.setText(inputAttribute.attributeName);
1242 attributeNameText.addModifyListener(updateListener);
1243
1244 Label previewLabel = new Label(attributeComposite, SWT.NONE);
1245 previewLabel.setText(Messages.CustomXmlParserInputWizardPage_preview);
1246
1247 previewText = new Text(attributeComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
1248 GridData gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
1249 gd.widthHint = 0;
1250 previewText.setLayoutData(gd);
1251 previewText.setText(Messages.CustomXmlParserInputWizardPage_noMatch);
1252 previewText.setBackground(COLOR_WIDGET_BACKGROUND);
1253
1254 filler = new Label(parent, SWT.NULL);
1255
1256 tagComposite = new Composite(parent, SWT.FILL);
1257 GridLayout tagLayout = new GridLayout(4, false);
1258 tagLayout.marginWidth = 0;
1259 tagLayout.marginHeight = 0;
1260 tagComposite.setLayout(tagLayout);
1261 tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
1262
1263 tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
1264 tagCombo.setItems(new String[] { CustomXmlTraceDefinition.TAG_TIMESTAMP, CustomXmlTraceDefinition.TAG_MESSAGE,
1265 CustomXmlTraceDefinition.TAG_OTHER });
1266 tagCombo.select(2); // Other
1267 tagCombo.addSelectionListener(new SelectionListener() {
1268 @Override
1269 public void widgetDefaultSelected(SelectionEvent e) {
1270 }
1271
1272 @Override
1273 public void widgetSelected(SelectionEvent e) {
1274 tagText.removeModifyListener(updateListener);
1275 switch (tagCombo.getSelectionIndex()) {
1276 case 0: // Time Stamp
1277 tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
1278 tagLabel.setVisible(true);
1279 tagText.setVisible(true);
1280 tagText.addModifyListener(updateListener);
1281 break;
1282 case 1: // Message
1283 tagLabel.setVisible(false);
1284 tagText.setVisible(false);
1285 break;
1286 case 2: // Other
1287 tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
1288 tagLabel.setVisible(true);
1289 if (tagText.getText().trim().length() == 0) {
1290 tagText.setText(attributeNameText.getText().trim());
1291 }
1292 tagText.setVisible(true);
1293 tagText.addModifyListener(updateListener);
1294 break;
1295 }
1296 tagComposite.layout();
1297 validate();
1298 updatePreviews();
1299 }
1300 });
1301
1302 tagLabel = new Label(tagComposite, SWT.NULL);
1303 tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
1304
1305 tagText = new Text(tagComposite, SWT.BORDER | SWT.SINGLE);
1306 gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
1307 gd.widthHint = 0;
1308 tagText.setLayoutData(gd);
1309 tagText.setText(attributeNameText.getText());
1310
1311 actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
1312 actionCombo.setItems(new String[] { Messages.CustomXmlParserInputWizardPage_set, Messages.CustomXmlParserInputWizardPage_append,
1313 Messages.CustomXmlParserInputWizardPage_appendWith });
1314 actionCombo.select(inputAttribute.inputAction);
1315 actionCombo.addSelectionListener(updateListener);
1316
1317 if (inputAttribute.inputName.equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) {
1318 tagCombo.select(0);
1319 tagLabel.setText(Messages.CustomXmlParserInputWizardPage_format);
1320 tagText.setText(inputAttribute.inputFormat);
1321 tagText.addModifyListener(updateListener);
1322 } else if (inputAttribute.inputName.equals(CustomXmlTraceDefinition.TAG_MESSAGE)) {
1323 tagCombo.select(1);
1324 tagLabel.setVisible(false);
1325 tagText.setVisible(false);
1326 } else {
1327 tagCombo.select(2);
1328 tagLabel.setText(Messages.CustomXmlParserInputWizardPage_tagName);
1329 tagText.setText(inputAttribute.inputName);
1330 tagText.addModifyListener(updateListener);
1331 }
1332 }
1333
1334 private void dispose() {
1335 labelComposite.dispose();
1336 attributeComposite.dispose();
1337 filler.dispose();
1338 tagComposite.dispose();
1339 }
1340
1341 private void setAttributeNumber(int attributeNumber) {
1342 this.attributeNumber = attributeNumber;
1343 labelComposite.layout();
1344 }
1345 }
1346
1347 private Element getPreviewElement(InputElement inputElement) {
1348 Element element = documentElement;
1349 if (element != null) {
1350 if (!documentElement.getNodeName().equals(definition.rootInputElement.elementName)) {
1351 return null;
1352 }
1353 ArrayList<String> elementNames = new ArrayList<String>();
1354 while (inputElement != null) {
1355 elementNames.add(inputElement.elementName);
1356 inputElement = inputElement.parentElement;
1357 }
1358 for (int i = elementNames.size() - 1; --i >= 0;) {
1359 NodeList childList = element.getChildNodes();
1360 element = null;
1361 for (int j = 0; j < childList.getLength(); j++) {
1362 Node child = childList.item(j);
1363 if (child instanceof Element && child.getNodeName().equals(elementNames.get(i))) {
1364 element = (Element) child;
1365 break;
1366 }
1367 }
1368 if (element == null) {
1369 break;
1370 }
1371 }
1372 if (element != null) {
1373 return element;
1374 }
1375 }
1376 return null;
1377 }
1378
1379 private String getChildNameSuggestion(InputElement inputElement) {
1380 if (inputElement == null) {
1381 if (documentElement != null) {
1382 return documentElement.getNodeName();
1383 }
1384 } else {
1385 Element element = getPreviewElement(inputElement);
1386 if (element != null) {
1387 NodeList childNodes = element.getChildNodes();
1388 for (int i = 0; i < childNodes.getLength(); i++) {
1389 Node node = childNodes.item(i);
1390 if (node instanceof Element) {
1391 boolean unused = true;
1392 if (inputElement.childElements != null) {
1393 for (InputElement child : inputElement.childElements) {
1394 if (child.elementName.equals(node.getNodeName())) {
1395 unused = false;
1396 break;
1397 }
1398 }
1399 }
1400 if (unused) {
1401 return node.getNodeName();
1402 }
1403 }
1404 }
1405 }
1406 }
1407 return ""; //$NON-NLS-1$
1408 }
1409
1410 private String getAttributeNameSuggestion(InputElement inputElement) {
1411 Element element = getPreviewElement(inputElement);
1412 if (element != null) {
1413 NamedNodeMap attributeMap = element.getAttributes();
1414 for (int i = 0; i < attributeMap.getLength(); i++) {
1415 Node node = attributeMap.item(i);
1416 boolean unused = true;
1417 if (inputElement.attributes != null) {
1418 for (InputAttribute attribute : inputElement.attributes) {
1419 if (attribute.attributeName.equals(node.getNodeName())) {
1420 unused = false;
1421 break;
1422 }
1423 }
1424 }
1425 if (unused) {
1426 return node.getNodeName();
1427 }
1428 }
1429 }
1430 return ""; //$NON-NLS-1$
1431 }
1432
1433 private void validate() {
1434 definition.definitionName = logtypeText.getText().trim();
1435 definition.timeStampOutputFormat = timeStampOutputFormatText.getText().trim();
1436
1437 if (selectedElement != null) {
1438 selectedElement.extractInputs();
1439 treeViewer.refresh();
1440 }
1441
1442 StringBuffer errors = new StringBuffer();
1443
1444 if (definition.definitionName.length() == 0) {
1445 errors.append(Messages.CustomXmlParserInputWizardPage_emptyLogTypeError);
1446 logtypeText.setBackground(COLOR_LIGHT_RED);
1447 } else {
1448 logtypeText.setBackground(COLOR_TEXT_BACKGROUND);
1449 for (CustomXmlTraceDefinition def : CustomXmlTraceDefinition.loadAll()) {
1450 if (definition.definitionName.equals(def.definitionName)) {
1451 if (editDefinitionName == null || !editDefinitionName.equals(definition.definitionName)) {
1452 errors.append(Messages.CustomXmlParserInputWizardPage_duplicatelogTypeError);
1453 logtypeText.setBackground(COLOR_LIGHT_RED);
1454 break;
1455 }
1456 }
1457 }
1458 }
1459
1460 if (definition.rootInputElement == null) {
1461 errors.append(Messages.CustomXmlParserInputWizardPage_noDocumentError);
1462 }
1463
1464 if (definition.rootInputElement != null) {
1465 logEntryFound = false;
1466 timeStampFound = false;
1467
1468 errors.append(validateElement(definition.rootInputElement));
1469
1470 if ((definition.rootInputElement.attributes != null && definition.rootInputElement.attributes.size() != 0)
1471 || (definition.rootInputElement.childElements != null && definition.rootInputElement.childElements.size() != 0)
1472 || errors.length() == 0) {
1473 if (!logEntryFound) {
1474 errors.append(Messages.CustomXmlParserInputWizardPage_missingLogEntryError);
1475 }
1476
1477 if (timeStampFound) {
1478 if (timeStampOutputFormatText.getText().trim().length() == 0) {
1479 errors.append(Messages.CustomXmlParserInputWizardPage_missingTimestampFmtError);
1480 timeStampOutputFormatText.setBackground(COLOR_LIGHT_RED);
1481 } else {
1482 try {
1483 new SimpleDateFormat(timeStampOutputFormatText.getText().trim());
1484 timeStampOutputFormatText.setBackground(COLOR_TEXT_BACKGROUND);
1485 } catch (IllegalArgumentException e) {
1486 errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampFmtError);
1487 timeStampOutputFormatText.setBackground(COLOR_LIGHT_RED);
1488 }
1489 }
1490 } else {
1491 timeStampPreviewText.setText(Messages.CustomXmlParserInputWizardPage_notimestamporAttributeError);
1492 }
1493 }
1494 } else {
1495 timeStampPreviewText.setText(Messages.CustomXmlParserInputWizardPage_notimestamporAttributeError);
1496 }
1497
1498 if (errors.length() == 0) {
1499 setDescription(defaultDescription);
1500 setPageComplete(true);
1501 } else {
1502 setDescription(errors.toString());
1503 setPageComplete(false);
1504 }
1505 }
1506
1507 public StringBuffer validateElement(InputElement inputElement) {
1508 StringBuffer errors = new StringBuffer();
1509 ElementNode elementNode = null;
1510 if (selectedElement != null && selectedElement.inputElement.equals(inputElement))
1511 elementNode = selectedElement;
1512 if (inputElement == definition.rootInputElement) {
1513 if (inputElement.elementName.length() == 0) {
1514 errors.append(Messages.CustomXmlParserInputWizardPage_missingDocumentElementError);
1515 if (elementNode != null)
1516 elementNode.elementNameText.setBackground(COLOR_LIGHT_RED);
1517 } else {
1518 if (elementNode != null)
1519 elementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND);
1520 }
1521 }
1522 if (inputElement != definition.rootInputElement) {
1523 if (inputElement.logEntry) {
1524 logEntryFound = true;
1525 }
1526 if (inputElement.inputName.equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) {
1527 timeStampFound = true;
1528 if (inputElement.inputFormat.length() == 0) {
1529 errors.append(Messages.CustomXmlParserInputWizardPage_timestampFormatPrompt
1530 + " (" + Messages.CustomXmlParserInputWizardPage_timestampElementPrompt + " " + getName(inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1531 if (elementNode != null)
1532 elementNode.tagText.setBackground(COLOR_LIGHT_RED);
1533 } else {
1534 try {
1535 new SimpleDateFormat(inputElement.inputFormat);
1536 if (elementNode != null)
1537 elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);
1538 } catch (IllegalArgumentException e) {
1539 errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampFmtError
1540 + " (" + Messages.CustomXmlParserInputWizardPage_timestampElementPrompt + " " + getName(inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1541 if (elementNode != null)
1542 elementNode.tagText.setBackground(COLOR_LIGHT_RED);
1543 }
1544 }
1545 } else if (inputElement.inputName.length() == 0) {
1546 errors.append(Messages.CustomXmlParserInputWizardPage_missingInputElementNameError);
1547 if (elementNode != null)
1548 elementNode.tagText.setBackground(COLOR_LIGHT_RED);
1549 } else {
1550 if (elementNode != null)
1551 elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);
1552 }
1553 }
1554 if (inputElement.attributes != null) {
1555 if (elementNode != null) {
1556 for (Attribute attribute : elementNode.attributes) {
1557 attribute.attributeNameText.setBackground(COLOR_TEXT_BACKGROUND);
1558 }
1559 }
1560 for (int i = 0; i < inputElement.attributes.size(); i++) {
1561 InputAttribute attribute = inputElement.attributes.get(i);
1562 boolean duplicate = false;
1563 for (int j = i + 1; j < inputElement.attributes.size(); j++) {
1564 InputAttribute otherAttribute = inputElement.attributes.get(j);
1565 if (otherAttribute.attributeName.equals(attribute.attributeName)) {
1566 duplicate = true;
1567 if (elementNode != null) {
1568 elementNode.attributes.get(j).attributeNameText.setBackground(COLOR_LIGHT_RED);
1569 }
1570 }
1571 }
1572 if (attribute.attributeName.length() == 0) {
1573 errors.append(Messages.CustomXmlParserInputWizardPage_missingAttribute
1574 + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(inputElement) + ": ?). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1575 if (elementNode != null)
1576 elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);
1577 } else if (duplicate) {
1578 errors.append(Messages.CustomXmlParserInputWizardPage_duplicateAttributeError
1579 + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1580 if (elementNode != null)
1581 elementNode.attributes.get(i).attributeNameText.setBackground(COLOR_LIGHT_RED);
1582 }
1583 if (attribute.inputName.equals(CustomXmlTraceDefinition.TAG_TIMESTAMP)) {
1584 timeStampFound = true;
1585 if (attribute.inputFormat.length() == 0) {
1586 errors.append(Messages.CustomXmlParserInputWizardPage_missingTimestampInFmtError
1587 + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1588 if (elementNode != null)
1589 elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);
1590 } else {
1591 try {
1592 new SimpleDateFormat(attribute.inputFormat);
1593 if (elementNode != null)
1594 elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND);
1595 } catch (IllegalArgumentException e) {
1596 errors.append(Messages.CustomXmlParserInputWizardPage_invalidTimestampInFmtError
1597 + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1598 if (elementNode != null)
1599 elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);
1600 }
1601 }
1602 } else if (attribute.inputName.length() == 0) {
1603 errors.append(Messages.CustomXmlParserInputWizardPage_missingDataGroupNameError
1604 + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(attribute, inputElement) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1605 if (elementNode != null)
1606 elementNode.attributes.get(i).tagText.setBackground(COLOR_LIGHT_RED);
1607 } else {
1608 if (elementNode != null)
1609 elementNode.attributes.get(i).tagText.setBackground(COLOR_TEXT_BACKGROUND);
1610 }
1611 }
1612 }
1613 if (inputElement.childElements != null) {
1614 for (InputElement child : inputElement.childElements) {
1615 ElementNode childElementNode = null;
1616 if (selectedElement != null && selectedElement.inputElement.equals(child))
1617 childElementNode = selectedElement;
1618 if (childElementNode != null)
1619 childElementNode.elementNameText.setBackground(COLOR_TEXT_BACKGROUND);
1620 }
1621 for (int i = 0; i < inputElement.childElements.size(); i++) {
1622 InputElement child = inputElement.childElements.get(i);
1623 ElementNode childElementNode = null;
1624 if (selectedElement != null && selectedElement.inputElement.equals(child))
1625 childElementNode = selectedElement;
1626 if (child.elementName.length() == 0) {
1627 errors.append(Messages.CustomXmlParserInputWizardPage_missingElementNameError
1628 + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(child) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1629 if (childElementNode != null)
1630 childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);
1631 } else {
1632 boolean duplicate = false;
1633 for (int j = i + 1; j < inputElement.childElements.size(); j++) {
1634 InputElement otherChild = inputElement.childElements.get(j);
1635 if (otherChild.elementName.equals(child.elementName)) {
1636 duplicate = true;
1637 ElementNode otherChildElementNode = null;
1638 if (selectedElement != null && selectedElement.inputElement.equals(otherChild))
1639 otherChildElementNode = selectedElement;
1640 if (otherChildElementNode != null)
1641 otherChildElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);
1642 }
1643 }
1644 if (duplicate) {
1645 errors.append(Messages.CustomXmlParserInputWizardPage_duplicateElementNameError
1646 + " (" + Messages.CustomXmlParserInputWizardPage_attributePrompt + " " + getName(child) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1647 if (childElementNode != null)
1648 childElementNode.elementNameText.setBackground(COLOR_LIGHT_RED);
1649 }
1650 }
1651
1652 errors.append(validateElement(child));
1653 }
1654 }
1655 return errors;
1656 }
1657
1658 public CustomXmlTraceDefinition getDefinition() {
1659 return definition;
1660 }
1661
1662 public char[] getInputText() {
1663 return inputText.getText().toCharArray();
1664 }
1665 }
This page took 0.069563 seconds and 6 git commands to generate.