1 /*******************************************************************************
2 * Copyright (c) 2010, 2014 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
.tracecompass
.internal
.tmf
.ui
.parsers
.wizards
;
15 import java
.io
.BufferedReader
;
16 import java
.io
.IOException
;
17 import java
.io
.InputStreamReader
;
19 import java
.text
.ParseException
;
20 import java
.util
.ArrayList
;
21 import java
.util
.Arrays
;
22 import java
.util
.HashMap
;
23 import java
.util
.Iterator
;
24 import java
.util
.List
;
26 import java
.util
.Scanner
;
27 import java
.util
.regex
.Matcher
;
28 import java
.util
.regex
.Pattern
;
29 import java
.util
.regex
.PatternSyntaxException
;
31 import org
.eclipse
.core
.resources
.IFile
;
32 import org
.eclipse
.core
.runtime
.CoreException
;
33 import org
.eclipse
.core
.runtime
.FileLocator
;
34 import org
.eclipse
.core
.runtime
.IPath
;
35 import org
.eclipse
.core
.runtime
.Path
;
36 import org
.eclipse
.core
.runtime
.Platform
;
37 import org
.eclipse
.jface
.viewers
.ColumnLabelProvider
;
38 import org
.eclipse
.jface
.viewers
.ISelection
;
39 import org
.eclipse
.jface
.viewers
.ISelectionChangedListener
;
40 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
41 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
42 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
43 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
44 import org
.eclipse
.jface
.viewers
.TreeViewer
;
45 import org
.eclipse
.jface
.viewers
.Viewer
;
46 import org
.eclipse
.jface
.wizard
.WizardPage
;
47 import org
.eclipse
.osgi
.util
.NLS
;
48 import org
.eclipse
.swt
.SWT
;
49 import org
.eclipse
.swt
.browser
.Browser
;
50 import org
.eclipse
.swt
.browser
.TitleEvent
;
51 import org
.eclipse
.swt
.browser
.TitleListener
;
52 import org
.eclipse
.swt
.custom
.SashForm
;
53 import org
.eclipse
.swt
.custom
.ScrolledComposite
;
54 import org
.eclipse
.swt
.custom
.StyleRange
;
55 import org
.eclipse
.swt
.custom
.StyledText
;
56 import org
.eclipse
.swt
.events
.ModifyEvent
;
57 import org
.eclipse
.swt
.events
.ModifyListener
;
58 import org
.eclipse
.swt
.events
.SelectionAdapter
;
59 import org
.eclipse
.swt
.events
.SelectionEvent
;
60 import org
.eclipse
.swt
.events
.SelectionListener
;
61 import org
.eclipse
.swt
.events
.VerifyEvent
;
62 import org
.eclipse
.swt
.events
.VerifyListener
;
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
.graphics
.Point
;
68 import org
.eclipse
.swt
.graphics
.Rectangle
;
69 import org
.eclipse
.swt
.layout
.FillLayout
;
70 import org
.eclipse
.swt
.layout
.GridData
;
71 import org
.eclipse
.swt
.layout
.GridLayout
;
72 import org
.eclipse
.swt
.widgets
.Button
;
73 import org
.eclipse
.swt
.widgets
.Combo
;
74 import org
.eclipse
.swt
.widgets
.Composite
;
75 import org
.eclipse
.swt
.widgets
.Display
;
76 import org
.eclipse
.swt
.widgets
.Group
;
77 import org
.eclipse
.swt
.widgets
.Label
;
78 import org
.eclipse
.swt
.widgets
.Shell
;
79 import org
.eclipse
.swt
.widgets
.Text
;
80 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Activator
;
81 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Messages
;
82 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTraceDefinition
;
83 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTxtTraceDefinition
;
84 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTxtTraceDefinition
.Cardinality
;
85 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTxtTraceDefinition
.InputData
;
86 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTxtTraceDefinition
.InputLine
;
87 import org
.eclipse
.tracecompass
.tmf
.core
.project
.model
.TmfTraceType
;
88 import org
.eclipse
.tracecompass
.tmf
.core
.project
.model
.TraceTypeHelper
;
89 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestampFormat
;
90 import org
.osgi
.framework
.Bundle
;
93 * Input wizard page for custom text parsers.
95 * @author Patrick Tasse
97 public class CustomTxtParserInputWizardPage
extends WizardPage
{
99 private static final String DEFAULT_REGEX
= "\\s*(.*\\S)"; //$NON-NLS-1$
100 private static final String DEFAULT_TIMESTAMP_FORMAT
= "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$
101 private static final String TIMESTAMP_FORMAT_BUNDLE
= "org.eclipse.tracecompass.doc.user"; //$NON-NLS-1$
102 private static final String TIMESTAMP_FORMAT_PATH
= "reference/api/org/eclipse/tracecompass/tmf/core/timestamp/TmfTimestampFormat.html"; //$NON-NLS-1$
103 private static final String PATTERN_URL
= "http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#sum"; //$NON-NLS-1$
104 private static final Image LINE_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/line_icon.gif"); //$NON-NLS-1$
105 private static final Image ADD_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$
106 private static final Image ADD_NEXT_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/addnext_button.gif"); //$NON-NLS-1$
107 private static final Image ADD_CHILD_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/addchild_button.gif"); //$NON-NLS-1$
108 private static final Image DELETE_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$
109 private static final Image MOVE_UP_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/moveup_button.gif"); //$NON-NLS-1$
110 private static final Image MOVE_DOWN_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/movedown_button.gif"); //$NON-NLS-1$
111 private static final Image HELP_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/help_button.gif"); //$NON-NLS-1$
112 private static final Color COLOR_BLACK
= Display
.getDefault().getSystemColor(SWT
.COLOR_BLACK
);
113 private static final Color COLOR_LIGHT_GREEN
= new Color(Display
.getDefault(), 192, 255, 192);
114 private static final Color COLOR_GREEN
= Display
.getDefault().getSystemColor(SWT
.COLOR_GREEN
);
115 private static final Color COLOR_LIGHT_YELLOW
= new Color(Display
.getDefault(), 255, 255, 192);
116 private static final Color COLOR_YELLOW
= Display
.getDefault().getSystemColor(SWT
.COLOR_YELLOW
);
117 private static final Color COLOR_LIGHT_MAGENTA
= new Color(Display
.getDefault(), 255, 192, 255);
118 private static final Color COLOR_MAGENTA
= Display
.getDefault().getSystemColor(SWT
.COLOR_MAGENTA
);
119 private static final Color COLOR_LIGHT_RED
= new Color(Display
.getDefault(), 255, 192, 192);
120 private static final Color COLOR_TEXT_BACKGROUND
= Display
.getDefault().getSystemColor(SWT
.COLOR_WHITE
);
121 private static final Color COLOR_WIDGET_BACKGROUND
= Display
.getDefault().getSystemColor(SWT
.COLOR_WIDGET_BACKGROUND
);
123 private final ISelection selection
;
124 private CustomTxtTraceDefinition definition
;
125 private String editCategoryName
;
126 private String editDefinitionName
;
127 private String defaultDescription
;
128 private Line selectedLine
;
129 private Composite container
;
130 private Text categoryText
;
131 private Text logtypeText
;
132 private Text timestampOutputFormatText
;
133 private Text timestampPreviewText
;
134 private ScrolledComposite lineScrolledComposite
;
135 private TreeViewer treeViewer
;
136 private Composite lineContainer
;
137 private StyledText inputText
;
138 private Font fixedFont
;
139 private UpdateListener updateListener
;
140 private Browser helpBrowser
;
142 // variables used recursively through line traversal
143 private String timeStampFormat
;
144 private boolean timestampFound
;
150 * The Selection object
152 * The trace definition
154 protected CustomTxtParserInputWizardPage(ISelection selection
,
155 CustomTxtTraceDefinition definition
) {
156 super("CustomParserWizardPage"); //$NON-NLS-1$
157 if (definition
== null) {
158 setTitle(Messages
.CustomTxtParserInputWizardPage_windowTitleNew
);
159 defaultDescription
= Messages
.CustomTxtParserInputWizardPage_descriptionNew
;
161 setTitle(Messages
.CustomTxtParserInputWizardPage_windowTitleEdit
);
162 defaultDescription
= Messages
.CustomTxtParserInputWizardPage_desccriptionEdit
;
164 setDescription(defaultDescription
);
165 this.selection
= selection
;
166 this.definition
= definition
;
167 if (definition
!= null) {
168 this.editCategoryName
= definition
.categoryName
;
169 this.editDefinitionName
= definition
.definitionName
;
174 public void createControl(Composite parent
) {
175 container
= new Composite(parent
, SWT
.NULL
);
176 container
.setLayout(new GridLayout());
178 updateListener
= new UpdateListener();
180 Composite headerComposite
= new Composite(container
, SWT
.FILL
);
181 GridLayout headerLayout
= new GridLayout(5, false);
182 headerLayout
.marginHeight
= 0;
183 headerLayout
.marginWidth
= 0;
184 headerComposite
.setLayout(headerLayout
);
185 headerComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
187 Label categoryLabel
= new Label(headerComposite
, SWT
.NULL
);
188 categoryLabel
.setText(Messages
.CustomTxtParserInputWizardPage_category
);
190 categoryText
= new Text(headerComposite
, SWT
.BORDER
| SWT
.SINGLE
);
191 categoryText
.setLayoutData(new GridData(120, SWT
.DEFAULT
));
193 Label timestampFormatLabel
= new Label(headerComposite
, SWT
.NULL
);
194 timestampFormatLabel
.setText(Messages
.CustomTxtParserInputWizardPage_timestampFormat
);
196 timestampOutputFormatText
= new Text(headerComposite
, SWT
.BORDER
| SWT
.SINGLE
);
197 timestampOutputFormatText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
198 timestampOutputFormatText
.setText(DEFAULT_TIMESTAMP_FORMAT
);
200 Button timeStampFormatHelpButton
= new Button(headerComposite
, SWT
.PUSH
);
201 timeStampFormatHelpButton
.setImage(HELP_IMAGE
);
202 timeStampFormatHelpButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_timestampFormatHelp
);
203 timeStampFormatHelpButton
.addSelectionListener(new SelectionAdapter() {
205 public void widgetSelected(SelectionEvent e
) {
206 Bundle plugin
= Platform
.getBundle(TIMESTAMP_FORMAT_BUNDLE
);
207 IPath path
= new Path(TIMESTAMP_FORMAT_PATH
);
208 URL fileURL
= FileLocator
.find(plugin
, path
, null);
210 URL pageURL
= FileLocator
.toFileURL(fileURL
);
211 openHelpShell(pageURL
.toString());
212 } catch (IOException e1
) {
217 Label logtypeLabel
= new Label(headerComposite
, SWT
.NULL
);
218 logtypeLabel
.setText(Messages
.CustomTxtParserInputWizardPage_logType
);
220 logtypeText
= new Text(headerComposite
, SWT
.BORDER
| SWT
.SINGLE
);
221 logtypeText
.setLayoutData(new GridData(120, SWT
.DEFAULT
));
222 logtypeText
.setFocus();
224 Label timestampPreviewLabel
= new Label(headerComposite
, SWT
.NULL
);
225 timestampPreviewLabel
.setText(Messages
.CustomTxtParserInputWizardPage_preview
);
227 timestampPreviewText
= new Text(headerComposite
, SWT
.BORDER
| SWT
.SINGLE
| SWT
.READ_ONLY
);
228 timestampPreviewText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 2, 1));
229 timestampPreviewText
.setText(Messages
.CustomTxtParserInputWizardPage_noMatchingTimestamp
);
231 Composite buttonBar
= new Composite(container
, SWT
.NONE
);
232 GridLayout buttonBarLayout
= new GridLayout(5, false);
233 buttonBarLayout
.marginHeight
= 0;
234 buttonBarLayout
.marginWidth
= 0;
235 buttonBar
.setLayout(buttonBarLayout
);
237 Button removeButton
= new Button(buttonBar
, SWT
.PUSH
);
238 removeButton
.setImage(DELETE_IMAGE
);
239 removeButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_removeLine
);
240 removeButton
.addSelectionListener(new SelectionAdapter() {
242 public void widgetSelected(SelectionEvent e
) {
243 if (treeViewer
.getSelection().isEmpty() || selectedLine
== null) {
247 InputLine inputLine
= (InputLine
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
248 if (inputLine
.parentInput
== null) {
249 definition
.inputs
.remove(inputLine
);
251 inputLine
.parentInput
.childrenInputs
.remove(inputLine
);
253 treeViewer
.refresh();
258 Button addNextButton
= new Button(buttonBar
, SWT
.PUSH
);
259 addNextButton
.setImage(ADD_NEXT_IMAGE
);
260 addNextButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_addNextLine
);
261 addNextButton
.addSelectionListener(new SelectionAdapter() {
263 public void widgetSelected(SelectionEvent e
) {
264 InputLine inputLine
= new InputLine(Cardinality
.ZERO_OR_MORE
, "", null); //$NON-NLS-1$
265 if (((List
<?
>) treeViewer
.getInput()).size() == 0) {
266 definition
.inputs
.add(inputLine
);
267 } else if (treeViewer
.getSelection().isEmpty()) {
270 InputLine previousInputLine
= (InputLine
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
271 if (previousInputLine
.parentInput
== null) {
272 for (int i
= 0; i
< definition
.inputs
.size(); i
++) {
273 if (definition
.inputs
.get(i
).equals(previousInputLine
)) {
274 definition
.inputs
.add(i
+ 1, inputLine
);
278 previousInputLine
.addNext(inputLine
);
281 treeViewer
.refresh();
282 treeViewer
.setSelection(new StructuredSelection(inputLine
), true);
285 Button addChildButton
= new Button(buttonBar
, SWT
.PUSH
);
286 addChildButton
.setImage(ADD_CHILD_IMAGE
);
287 addChildButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_addChildLine
);
288 addChildButton
.addSelectionListener(new SelectionAdapter() {
290 public void widgetSelected(SelectionEvent e
) {
291 InputLine inputLine
= new InputLine(Cardinality
.ZERO_OR_MORE
, "", null); //$NON-NLS-1$
292 if (((List
<?
>) treeViewer
.getInput()).size() == 0) {
293 definition
.inputs
.add(inputLine
);
294 } else if (treeViewer
.getSelection().isEmpty()) {
297 InputLine parentInputLine
= (InputLine
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
298 parentInputLine
.addChild(inputLine
);
300 treeViewer
.refresh();
301 treeViewer
.setSelection(new StructuredSelection(inputLine
), true);
304 Button moveUpButton
= new Button(buttonBar
, SWT
.PUSH
);
305 moveUpButton
.setImage(MOVE_UP_IMAGE
);
306 moveUpButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_moveUp
);
307 moveUpButton
.addSelectionListener(new SelectionAdapter() {
309 public void widgetSelected(SelectionEvent e
) {
310 if (treeViewer
.getSelection().isEmpty()) {
313 InputLine inputLine
= (InputLine
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
314 if (inputLine
.parentInput
== null) {
315 for (int i
= 1; i
< definition
.inputs
.size(); i
++) {
316 if (definition
.inputs
.get(i
).equals(inputLine
)) {
317 definition
.inputs
.add(i
- 1, definition
.inputs
.remove(i
));
324 treeViewer
.refresh();
329 Button moveDownButton
= new Button(buttonBar
, SWT
.PUSH
);
330 moveDownButton
.setImage(MOVE_DOWN_IMAGE
);
331 moveDownButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_moveDown
);
332 moveDownButton
.addSelectionListener(new SelectionAdapter() {
334 public void widgetSelected(SelectionEvent e
) {
335 if (treeViewer
.getSelection().isEmpty()) {
338 InputLine inputLine
= (InputLine
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
339 if (inputLine
.parentInput
== null) {
340 for (int i
= 0; i
< definition
.inputs
.size() - 1; i
++) {
341 if (definition
.inputs
.get(i
).equals(inputLine
)) {
342 definition
.inputs
.add(i
+ 1, definition
.inputs
.remove(i
));
347 inputLine
.moveDown();
349 treeViewer
.refresh();
355 SashForm vSash
= new SashForm(container
, SWT
.VERTICAL
);
356 vSash
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
357 vSash
.setBackground(vSash
.getDisplay().getSystemColor(SWT
.COLOR_GRAY
));
359 SashForm hSash
= new SashForm(vSash
, SWT
.HORIZONTAL
);
360 hSash
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
362 ScrolledComposite treeScrolledComposite
= new ScrolledComposite(hSash
, SWT
.V_SCROLL
| SWT
.H_SCROLL
);
363 GridData gd
= new GridData(SWT
.FILL
, SWT
.FILL
, true, true);
366 treeScrolledComposite
.setLayoutData(gd
);
367 Composite treeContainer
= new Composite(treeScrolledComposite
, SWT
.NONE
);
368 treeContainer
.setLayout(new FillLayout());
369 treeScrolledComposite
.setContent(treeContainer
);
370 treeScrolledComposite
.setExpandHorizontal(true);
371 treeScrolledComposite
.setExpandVertical(true);
373 treeViewer
= new TreeViewer(treeContainer
, SWT
.SINGLE
| SWT
.BORDER
);
374 treeViewer
.setContentProvider(new InputLineTreeNodeContentProvider());
375 treeViewer
.setLabelProvider(new InputLineTreeLabelProvider());
376 treeViewer
.addSelectionChangedListener(new InputLineTreeSelectionChangedListener());
377 treeContainer
.layout();
379 treeScrolledComposite
.setMinSize(treeContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, treeContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
);
381 lineScrolledComposite
= new ScrolledComposite(hSash
, SWT
.V_SCROLL
);
382 lineScrolledComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
383 lineContainer
= new Composite(lineScrolledComposite
, SWT
.NONE
);
384 GridLayout linesLayout
= new GridLayout();
385 linesLayout
.marginHeight
= 1;
386 linesLayout
.marginWidth
= 0;
387 lineContainer
.setLayout(linesLayout
);
388 lineScrolledComposite
.setContent(lineContainer
);
389 lineScrolledComposite
.setExpandHorizontal(true);
390 lineScrolledComposite
.setExpandVertical(true);
392 if (definition
== null) {
393 definition
= new CustomTxtTraceDefinition();
394 definition
.inputs
.add(new InputLine(Cardinality
.ZERO_OR_MORE
, DEFAULT_REGEX
,
395 Arrays
.asList(new InputData(CustomTraceDefinition
.TAG_MESSAGE
, CustomTraceDefinition
.ACTION_SET
))));
397 loadDefinition(definition
);
398 treeViewer
.expandAll();
399 lineContainer
.layout();
401 categoryText
.addModifyListener(updateListener
);
402 logtypeText
.addModifyListener(updateListener
);
403 timestampOutputFormatText
.addModifyListener(updateListener
);
405 lineScrolledComposite
.setMinSize(lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
407 hSash
.setWeights(new int[] { 1, 2 });
409 Composite sashBottom
= new Composite(vSash
, SWT
.NONE
);
410 GridLayout sashBottomLayout
= new GridLayout(3, false);
411 sashBottomLayout
.marginHeight
= 0;
412 sashBottomLayout
.marginWidth
= 0;
413 sashBottom
.setLayout(sashBottomLayout
);
415 Label previewLabel
= new Label(sashBottom
, SWT
.NULL
);
416 previewLabel
.setText(Messages
.CustomTxtParserInputWizardPage_previewInput
);
417 previewLabel
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
419 Button highlightAllButton
= new Button(sashBottom
, SWT
.PUSH
);
420 highlightAllButton
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
421 highlightAllButton
.setText(Messages
.CustomTxtParserInputWizardPage_highlightAll
);
422 highlightAllButton
.addSelectionListener(new SelectionAdapter() {
424 public void widgetSelected(SelectionEvent e
) {
425 updatePreviews(true);
429 Button legendButton
= new Button(sashBottom
, SWT
.PUSH
);
430 legendButton
.setImage(HELP_IMAGE
);
431 legendButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_previewLegend
);
432 legendButton
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
433 legendButton
.addSelectionListener(new SelectionAdapter() {
435 public void widgetSelected(SelectionEvent e
) {
440 inputText
= new StyledText(sashBottom
, SWT
.MULTI
| SWT
.V_SCROLL
| SWT
.H_SCROLL
);
441 if (fixedFont
== null) {
442 if (System
.getProperty("os.name").contains("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$
443 fixedFont
= new Font(Display
.getCurrent(), new FontData("Courier New", 10, SWT
.NORMAL
)); //$NON-NLS-1$
445 fixedFont
= new Font(Display
.getCurrent(), new FontData("Monospace", 10, SWT
.NORMAL
)); //$NON-NLS-1$
448 inputText
.setFont(fixedFont
);
449 gd
= new GridData(SWT
.FILL
, SWT
.FILL
, true, true, 3, 1);
450 gd
.heightHint
= inputText
.computeSize(SWT
.DEFAULT
, inputText
.getLineHeight() * 4).y
;
452 inputText
.setLayoutData(gd
);
453 inputText
.setText(getSelectionText());
454 inputText
.addModifyListener(updateListener
);
456 vSash
.setWeights(new int[] { hSash
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
, sashBottom
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
});
458 setControl(container
);
464 private static class InputLineTreeNodeContentProvider
implements ITreeContentProvider
{
467 public Object
[] getElements(Object inputElement
) {
468 return ((List
<?
>) inputElement
).toArray();
472 public Object
[] getChildren(Object parentElement
) {
473 InputLine inputLine
= (InputLine
) parentElement
;
474 if (inputLine
.childrenInputs
== null) {
475 return new InputLine
[0];
477 return inputLine
.childrenInputs
.toArray();
481 public boolean hasChildren(Object element
) {
482 InputLine inputLine
= (InputLine
) element
;
483 return (inputLine
.childrenInputs
!= null && inputLine
.childrenInputs
.size() > 0);
487 public void dispose() {
491 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
495 public Object
getParent(Object element
) {
496 InputLine inputLine
= (InputLine
) element
;
497 return inputLine
.parentInput
;
501 private class InputLineTreeLabelProvider
extends ColumnLabelProvider
{
504 public Image
getImage(Object element
) {
509 public String
getText(Object element
) {
510 InputLine inputLine
= (InputLine
) element
;
511 if (inputLine
.parentInput
== null) {
512 return "Root Line " + getName(inputLine
) + " " + inputLine
.cardinality
.toString() + " : " + inputLine
.getRegex(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
514 return "Line " + getName(inputLine
) + " " + inputLine
.cardinality
.toString() + " : " + inputLine
.getRegex(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
518 private class InputLineTreeSelectionChangedListener
implements ISelectionChangedListener
{
520 public void selectionChanged(SelectionChangedEvent event
) {
521 if (selectedLine
!= null) {
522 selectedLine
.dispose();
524 if (!(event
.getSelection().isEmpty()) && event
.getSelection() instanceof IStructuredSelection
) {
525 IStructuredSelection sel
= (IStructuredSelection
) event
.getSelection();
526 InputLine inputLine
= (InputLine
) sel
.getFirstElement();
527 selectedLine
= new Line(lineContainer
, getName(inputLine
), inputLine
);
528 lineContainer
.layout();
529 lineScrolledComposite
.setMinSize(lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
538 public void dispose() {
539 if (fixedFont
!= null) {
546 private void loadDefinition(CustomTxtTraceDefinition def
) {
547 categoryText
.setText(def
.categoryName
);
548 logtypeText
.setText(def
.definitionName
);
549 timestampOutputFormatText
.setText(def
.timeStampOutputFormat
);
550 treeViewer
.setInput(def
.inputs
);
551 if (def
.inputs
.size() > 0) {
552 InputLine inputLine
= def
.inputs
.get(0);
553 treeViewer
.setSelection(new StructuredSelection(inputLine
));
557 private String
getName(InputLine inputLine
) {
558 if (inputLine
.parentInput
== null) {
559 return Integer
.toString(definition
.inputs
.indexOf(inputLine
) + 1);
561 return getName(inputLine
.parentInput
) + "." + Integer
.toString(inputLine
.parentInput
.childrenInputs
.indexOf(inputLine
) + 1); //$NON-NLS-1$
565 * Get the global list of input names.
567 * @return The list of input names
569 public List
<String
> getInputNames() {
570 List
<String
> inputs
= new ArrayList
<>();
571 for (InputLine inputLine
: definition
.inputs
) {
572 for (String inputName
: getInputNames(inputLine
)) {
573 if (!inputs
.contains(inputName
)) {
574 inputs
.add(inputName
);
582 * Get the list of input names for the given input line.
586 * @return The list of input names
588 public List
<String
> getInputNames(InputLine inputLine
) {
589 List
<String
> inputs
= new ArrayList
<>();
590 if (inputLine
.columns
!= null) {
591 for (InputData inputData
: inputLine
.columns
) {
592 String inputName
= inputData
.name
;
593 if (!inputs
.contains(inputName
)) {
594 inputs
.add(inputName
);
598 if (inputLine
.childrenInputs
!= null) {
599 for (InputLine childInputLine
: inputLine
.childrenInputs
) {
600 for (String inputName
: getInputNames(childInputLine
)) {
601 if (!inputs
.contains(inputName
)) {
602 inputs
.add(inputName
);
610 private void removeLine() {
611 selectedLine
.dispose();
613 lineContainer
.layout();
614 lineScrolledComposite
.setMinSize(lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
618 private String
getSelectionText() {
619 if (this.selection
instanceof IStructuredSelection
) {
620 Object sel
= ((IStructuredSelection
) this.selection
).getFirstElement();
621 if (sel
instanceof IFile
) {
622 IFile file
= (IFile
) sel
;
623 BufferedReader reader
= null;
625 reader
= new BufferedReader(new InputStreamReader(file
.getContents()));
626 StringBuilder sb
= new StringBuilder();
628 while ((line
= reader
.readLine()) != null) {
629 sb
.append(line
+ "\n"); //$NON-NLS-1$
631 return sb
.toString();
632 } catch (CoreException e
) {
633 return ""; //$NON-NLS-1$
634 } catch (IOException e
) {
635 return ""; //$NON-NLS-1$
637 if (reader
!= null) {
640 } catch (IOException e
) {
646 return ""; //$NON-NLS-1$
649 private void updatePreviews() {
650 updatePreviews(false);
653 private void updatePreviews(boolean updateAll
) {
654 if (inputText
== null) {
655 // early update during construction
658 inputText
.setStyleRanges(new StyleRange
[] {});
660 try (Scanner scanner
= new Scanner(inputText
.getText());) {
661 scanner
.useDelimiter("\n"); //$NON-NLS-1$
664 // skip starting delimiters
665 String skip
= scanner
.findWithinHorizon("\\A\n+", 0); //$NON-NLS-1$
667 rawPos
+= skip
.length();
670 timeStampFormat
= null;
671 if (selectedLine
!= null) {
672 for (InputGroup input
: selectedLine
.inputs
) {
673 input
.previewText
.setText(Messages
.CustomTxtParserInputWizardPage_noMathcingLine
);
677 Map
<String
, String
> data
= new HashMap
<>();
678 int rootLineMatches
= 0;
679 String firstEntryTimeStamp
= null;
680 String firstEntryTimeStampInputFormat
= null;
682 boolean lineIsNull
= true; // needed because of JDT bug with continue at label
683 event
: while (scanner
.hasNext() || !lineIsNull
) {
684 if (rootLineMatches
> 0 && !updateAll
) {
688 line
= scanner
.next();
691 int length
= line
.length();
692 String log
= line
.replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
693 for (InputLine rootInputLine
: definition
.inputs
) {
696 pattern
= rootInputLine
.getPattern();
697 } catch (PatternSyntaxException e
) {
700 Matcher matcher
= pattern
.matcher(log
);
701 if (matcher
.matches()) {
703 inputText
.setStyleRange(new StyleRange(rawPos
, length
,
704 COLOR_BLACK
, COLOR_YELLOW
, SWT
.ITALIC
));
705 data
= new HashMap
<>();
706 timeStampFormat
= null;
707 updatePreviewLine(rootInputLine
, matcher
, data
, rawPos
, rootLineMatches
);
708 if (rootLineMatches
== 1) {
709 firstEntryTimeStamp
= data
.get(CustomTraceDefinition
.TAG_TIMESTAMP
);
710 firstEntryTimeStampInputFormat
= timeStampFormat
;
712 HashMap
<InputLine
, Integer
> countMap
= new HashMap
<>();
713 InputLine currentInput
= null;
714 if (rootInputLine
.childrenInputs
!= null && rootInputLine
.childrenInputs
.size() > 0) {
715 currentInput
= rootInputLine
.childrenInputs
.get(0);
716 countMap
.put(currentInput
, 0);
718 rawPos
+= length
+ 1; // +1 for \n
719 while (scanner
.hasNext()) {
720 line
= scanner
.next();
721 length
= line
.length();
722 log
= line
.replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
723 boolean processed
= false;
724 if (currentInput
== null) {
725 for (InputLine input
: definition
.inputs
) {
727 matcher
= input
.getPattern().matcher(log
);
728 } catch (PatternSyntaxException e
) {
731 if (matcher
.matches()) {
736 if (countMap
.get(currentInput
) >= currentInput
.getMinCount()) {
737 List
<InputLine
> nextInputs
= currentInput
.getNextInputs(countMap
);
738 if (nextInputs
.size() == 0 || nextInputs
.get(nextInputs
.size() - 1).getMinCount() == 0) {
739 for (InputLine input
: definition
.inputs
) {
741 matcher
= input
.getPattern().matcher(log
);
742 } catch (PatternSyntaxException e
) {
745 if (matcher
.matches()) {
750 for (InputLine input
: nextInputs
) {
752 matcher
= input
.getPattern().matcher(log
);
753 } catch (PatternSyntaxException e
) {
756 if (matcher
.matches()) {
757 inputText
.setStyleRange(new StyleRange(rawPos
, length
,
758 COLOR_BLACK
, COLOR_LIGHT_YELLOW
, SWT
.ITALIC
));
759 currentInput
= input
;
760 updatePreviewLine(currentInput
, matcher
, data
, rawPos
, rootLineMatches
);
761 if (countMap
.get(currentInput
) == null) {
762 countMap
.put(currentInput
, 1);
764 countMap
.put(currentInput
, countMap
.get(currentInput
) + 1);
766 Iterator
<InputLine
> iter
= countMap
.keySet().iterator();
767 while (iter
.hasNext()) {
768 InputLine inputLine
= iter
.next();
769 if (inputLine
.level
> currentInput
.level
) {
773 if (currentInput
.childrenInputs
!= null && currentInput
.childrenInputs
.size() > 0) {
774 currentInput
= currentInput
.childrenInputs
.get(0);
775 countMap
.put(currentInput
, 0);
777 if (countMap
.get(currentInput
) >= currentInput
.getMaxCount()) {
778 if (currentInput
.getNextInputs(countMap
).size() > 0) {
779 currentInput
= currentInput
.getNextInputs(countMap
).get(0);
780 if (countMap
.get(currentInput
) == null) {
781 countMap
.put(currentInput
, 0);
783 iter
= countMap
.keySet().iterator();
784 while (iter
.hasNext()) {
785 InputLine inputLine
= iter
.next();
786 if (inputLine
.level
> currentInput
.level
) {
800 if (!processed
&& currentInput
!= null) {
803 matcher
= currentInput
.getPattern().matcher(log
);
804 } catch (PatternSyntaxException e
) {
806 if (matcher
!= null && matcher
.matches()) {
807 inputText
.setStyleRange(new StyleRange(rawPos
, length
,
808 COLOR_BLACK
, COLOR_LIGHT_YELLOW
, SWT
.ITALIC
));
809 updatePreviewLine(currentInput
, matcher
, data
, rawPos
, rootLineMatches
);
810 countMap
.put(currentInput
, countMap
.get(currentInput
) + 1);
811 if (currentInput
.childrenInputs
!= null && currentInput
.childrenInputs
.size() > 0) {
812 currentInput
= currentInput
.childrenInputs
.get(0);
813 countMap
.put(currentInput
, 0);
815 if (countMap
.get(currentInput
) >= currentInput
.getMaxCount()) {
816 if (currentInput
.getNextInputs(countMap
).size() > 0) {
817 currentInput
= currentInput
.getNextInputs(countMap
).get(0);
818 if (countMap
.get(currentInput
) == null) {
819 countMap
.put(currentInput
, 0);
821 Iterator
<InputLine
> iter
= countMap
.keySet().iterator();
822 while (iter
.hasNext()) {
823 InputLine inputLine
= iter
.next();
824 if (inputLine
.level
> currentInput
.level
) {
836 rawPos
+= length
+ 1; // +1 for \n
842 rawPos
+= length
+ 1; // +1 for \n
847 if (rootLineMatches
== 1) {
848 firstEntryTimeStamp
= data
.get(CustomTraceDefinition
.TAG_TIMESTAMP
);
849 firstEntryTimeStampInputFormat
= timeStampFormat
;
851 if (firstEntryTimeStamp
== null) {
852 timestampPreviewText
.setText(Messages
.CustomTxtParserInputWizardPage_noTimestampGroup
);
853 if (selectedLine
!= null) {
854 for (InputGroup group
: selectedLine
.inputs
) {
855 if (group
.tagCombo
.getText().equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
856 timestampPreviewText
.setText(Messages
.CustomTxtParserInputWizardPage_noMatchingTimestamp
);
863 TmfTimestampFormat timestampFormat
= new TmfTimestampFormat(firstEntryTimeStampInputFormat
);
864 long timestamp
= timestampFormat
.parseValue(firstEntryTimeStamp
);
865 timestampFormat
= new TmfTimestampFormat(timestampOutputFormatText
.getText().trim());
866 timestampPreviewText
.setText(timestampFormat
.format(timestamp
));
867 } catch (ParseException e
) {
868 timestampPreviewText
.setText("*parse exception* [" + firstEntryTimeStamp
+ "] <> [" + firstEntryTimeStampInputFormat
+ "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
869 } catch (IllegalArgumentException e
) {
870 timestampPreviewText
.setText("*parse exception* [Illegal Argument: " + e
.getMessage() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
877 private void updatePreviewLine(InputLine line
, Matcher matcher
, Map
<String
, String
> data
, int rawPos
, int rootLineMatches
) {
878 for (int i
= 0; i
< line
.columns
.size(); i
++) {
879 InputData input
= line
.columns
.get(i
);
880 if (i
< matcher
.groupCount() && matcher
.group(i
+ 1) != null) {
881 if (line
.parentInput
== null) {
882 inputText
.setStyleRange(new StyleRange(rawPos
+ matcher
.start(i
+ 1), matcher
.end(i
+ 1) - matcher
.start(i
+ 1),
883 COLOR_BLACK
, COLOR_GREEN
, SWT
.BOLD
));
885 inputText
.setStyleRange(new StyleRange(rawPos
+ matcher
.start(i
+ 1), matcher
.end(i
+ 1) - matcher
.start(i
+ 1),
886 COLOR_BLACK
, COLOR_LIGHT_GREEN
, SWT
.BOLD
));
888 String value
= matcher
.group(i
+ 1).trim();
889 if (selectedLine
!= null && selectedLine
.inputLine
.equals(line
) && rootLineMatches
== 1 &&
890 selectedLine
.inputs
.get(i
).previewText
.getText().equals(Messages
.CustomTxtParserInputWizardPage_noMatchingLine
)) {
891 selectedLine
.inputs
.get(i
).previewText
.setText(value
);
893 if (value
.length() == 0) {
896 if (input
.action
== CustomTraceDefinition
.ACTION_SET
) {
897 data
.put(input
.name
, value
);
898 if (input
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
899 timeStampFormat
= input
.format
;
901 } else if (input
.action
== CustomTraceDefinition
.ACTION_APPEND
) {
902 String s
= data
.get(input
.name
);
904 data
.put(input
.name
, s
+ value
);
906 data
.put(input
.name
, value
);
908 if (input
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
909 if (timeStampFormat
!= null) {
910 timeStampFormat
+= input
.format
;
912 timeStampFormat
= input
.format
;
915 } else if (input
.action
== CustomTraceDefinition
.ACTION_APPEND_WITH_SEPARATOR
) {
916 String s
= data
.get(input
.name
);
918 data
.put(input
.name
, s
+ " | " + value
); //$NON-NLS-1$
920 data
.put(input
.name
, value
);
922 if (input
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
923 if (timeStampFormat
!= null) {
924 timeStampFormat
+= " | " + input
.format
; //$NON-NLS-1$
926 timeStampFormat
= input
.format
;
931 if (selectedLine
!= null && selectedLine
.inputLine
.equals(line
) && rootLineMatches
== 1) {
932 if (selectedLine
.inputs
.get(i
).previewText
.getText().equals(Messages
.CustomTxtParserInputWizardPage_noMatchingLine
)) {
933 selectedLine
.inputs
.get(i
).previewText
.setText(Messages
.CustomTxtParserInputWizardPage_noMatchingGroup
);
938 // highlight the matching groups that have no corresponponding input
939 for (int i
= line
.columns
.size(); i
< matcher
.groupCount(); i
++) {
940 if (matcher
.group(i
+ 1) != null) {
941 if (line
.parentInput
== null) {
942 inputText
.setStyleRange(new StyleRange(rawPos
+ matcher
.start(i
+ 1), matcher
.end(i
+ 1) - matcher
.start(i
+ 1),
943 COLOR_BLACK
, COLOR_MAGENTA
));
945 inputText
.setStyleRange(new StyleRange(rawPos
+ matcher
.start(i
+ 1), matcher
.end(i
+ 1) - matcher
.start(i
+ 1),
946 COLOR_BLACK
, COLOR_LIGHT_MAGENTA
));
952 private void openHelpShell(String url
) {
953 if (helpBrowser
!= null && !helpBrowser
.isDisposed()) {
954 helpBrowser
.getShell().setActive();
955 if (!helpBrowser
.getUrl().equals(url
)) {
956 helpBrowser
.setUrl(url
);
960 final Shell helpShell
= new Shell(getShell(), SWT
.SHELL_TRIM
);
961 helpShell
.setLayout(new FillLayout());
962 helpBrowser
= new Browser(helpShell
, SWT
.NONE
);
963 helpBrowser
.addTitleListener(new TitleListener() {
965 public void changed(TitleEvent event
) {
966 helpShell
.setText(event
.title
);
969 Rectangle r
= container
.getBounds();
970 Point p
= container
.toDisplay(r
.x
, r
.y
);
971 Rectangle trim
= helpShell
.computeTrim(p
.x
+ (r
.width
- 750) / 2, p
.y
+ (r
.height
- 400) / 2, 750, 400);
972 helpShell
.setBounds(trim
);
974 helpBrowser
.setUrl(url
);
977 private void openLegend() {
978 final String cg
= Messages
.CustomTxtParserInputWizardPage_capturedGroup
;
979 final String ucg
= Messages
.CustomTxtParserInputWizardPage_unidentifiedCaptureGroup
;
980 final String ut
= Messages
.CustomTxtParserInputWizardPage_uncapturedText
;
982 String line1
= Messages
.CustomTxtParserInputWizardPage_nonMatchingLine
;
983 int line2start
= line1start
+ line1
.length();
984 String line2
= Messages
.CustomTxtParserInputWizardPage_matchingRootLine
+ ' ' + cg
+ ' ' + ucg
+ ' ' + ut
+ " \n"; //$NON-NLS-1$
985 int line3start
= line2start
+ line2
.length();
986 String line3
= Messages
.CustomTxtParserInputWizardPage_matchingOtherLine
+ ' ' + cg
+ ' ' + ucg
+ ' ' + ut
+ " \n"; //$NON-NLS-1$
987 int line4start
= line3start
+ line3
.length();
988 String line4
= Messages
.CustomTxtParserInputWizardPage_matchingOtherLine
+ ' ' + cg
+ ' ' + ucg
+ ' ' + ut
+ " \n"; //$NON-NLS-1$
989 int line5start
= line4start
+ line4
.length();
990 String line5
= Messages
.CustomTxtParserInputWizardPage_nonMatchingLine
;
991 int line6start
= line5start
+ line5
.length();
992 String line6
= Messages
.CustomTxtParserInputWizardPage_matchingRootLine
+ cg
+ ' ' + ucg
+ ' ' + ut
+ " \n"; //$NON-NLS-1$
994 final Shell legendShell
= new Shell(getShell(), SWT
.DIALOG_TRIM
);
995 legendShell
.setLayout(new FillLayout());
996 StyledText legendText
= new StyledText(legendShell
, SWT
.MULTI
);
997 legendText
.setFont(fixedFont
);
998 legendText
.setText(line1
+ line2
+ line3
+ line4
+ line5
+ line6
);
999 legendText
.setStyleRange(new StyleRange(line2start
, line2
.length(), COLOR_BLACK
, COLOR_YELLOW
, SWT
.ITALIC
));
1000 legendText
.setStyleRange(new StyleRange(line3start
, line3
.length(), COLOR_BLACK
, COLOR_LIGHT_YELLOW
, SWT
.ITALIC
));
1001 legendText
.setStyleRange(new StyleRange(line4start
, line4
.length(), COLOR_BLACK
, COLOR_LIGHT_YELLOW
, SWT
.ITALIC
));
1002 legendText
.setStyleRange(new StyleRange(line6start
, line6
.length(), COLOR_BLACK
, COLOR_YELLOW
, SWT
.ITALIC
));
1003 legendText
.setStyleRange(new StyleRange(line2start
+ line2
.indexOf(cg
), cg
.length(), COLOR_BLACK
, COLOR_GREEN
, SWT
.BOLD
));
1004 legendText
.setStyleRange(new StyleRange(line2start
+ line2
.indexOf(ucg
), ucg
.length(), COLOR_BLACK
, COLOR_MAGENTA
));
1005 legendText
.setStyleRange(new StyleRange(line3start
+ line3
.indexOf(cg
), cg
.length(), COLOR_BLACK
, COLOR_LIGHT_GREEN
, SWT
.BOLD
));
1006 legendText
.setStyleRange(new StyleRange(line3start
+ line3
.indexOf(ucg
), ucg
.length(), COLOR_BLACK
, COLOR_LIGHT_MAGENTA
));
1007 legendText
.setStyleRange(new StyleRange(line4start
+ line4
.indexOf(cg
), cg
.length(), COLOR_BLACK
, COLOR_LIGHT_GREEN
, SWT
.BOLD
));
1008 legendText
.setStyleRange(new StyleRange(line4start
+ line4
.indexOf(ucg
), ucg
.length(), COLOR_BLACK
, COLOR_LIGHT_MAGENTA
));
1009 legendText
.setStyleRange(new StyleRange(line6start
+ line6
.indexOf(cg
), cg
.length(), COLOR_BLACK
, COLOR_GREEN
, SWT
.BOLD
));
1010 legendText
.setStyleRange(new StyleRange(line6start
+ line6
.indexOf(ucg
), ucg
.length(), COLOR_BLACK
, COLOR_MAGENTA
));
1011 legendShell
.setText(Messages
.CustomTxtParserInputWizardPage_previewLegend
);
1016 private class UpdateListener
implements ModifyListener
, SelectionListener
{
1019 public void modifyText(ModifyEvent e
) {
1025 public void widgetDefaultSelected(SelectionEvent e
) {
1031 public void widgetSelected(SelectionEvent e
) {
1038 private class Line
{
1039 private static final String INFINITY_STRING
= "\u221E"; //$NON-NLS-1$
1040 private InputLine inputLine
;
1041 private Group group
;
1042 private Composite labelComposite
;
1043 private Text regexText
;
1044 private Composite cardinalityContainer
;
1045 private Combo cardinalityCombo
;
1046 private Label cardinalityMinLabel
;
1047 private Text cardinalityMinText
;
1048 private Label cardinalityMaxLabel
;
1049 private Text cardinalityMaxText
;
1050 private Button infiniteButton
;
1051 private List
<InputGroup
> inputs
= new ArrayList
<>();
1052 private Button addGroupButton
;
1053 private Label addGroupLabel
;
1055 public Line(Composite parent
, String name
, InputLine inputLine
) {
1056 this.inputLine
= inputLine
;
1058 group
= new Group(parent
, SWT
.NONE
);
1059 group
.setText(name
);
1060 group
.setLayout(new GridLayout(2, false));
1061 group
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1063 labelComposite
= new Composite(group
, SWT
.FILL
);
1064 GridLayout labelLayout
= new GridLayout(1, false);
1065 labelLayout
.marginWidth
= 0;
1066 labelLayout
.marginHeight
= 0;
1067 labelComposite
.setLayout(labelLayout
);
1068 labelComposite
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1070 Label label
= new Label(labelComposite
, SWT
.NULL
);
1071 label
.setText(Messages
.CustomTxtParserInputWizardPage_regularExpression
);
1073 Composite regexContainer
= new Composite(group
, SWT
.NONE
);
1074 GridLayout regexLayout
= new GridLayout(2, false);
1075 regexLayout
.marginHeight
= 0;
1076 regexLayout
.marginWidth
= 0;
1077 regexContainer
.setLayout(regexLayout
);
1078 regexContainer
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1080 regexText
= new Text(regexContainer
, SWT
.BORDER
| SWT
.SINGLE
);
1081 GridData gd
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
1083 regexText
.setLayoutData(gd
);
1084 regexText
.setText(inputLine
.getRegex());
1085 regexText
.addModifyListener(updateListener
);
1087 Button regexHelpButton
= new Button(regexContainer
, SWT
.PUSH
);
1088 regexHelpButton
.setImage(HELP_IMAGE
);
1089 regexHelpButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_regularExpressionHelp
);
1090 regexHelpButton
.addSelectionListener(new SelectionAdapter() {
1092 public void widgetSelected(SelectionEvent e
) {
1093 openHelpShell(PATTERN_URL
);
1097 label
= new Label(group
, SWT
.NONE
);
1098 label
.setText(Messages
.CustomTxtParserInputWizardPage_cardinality
);
1099 label
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1101 cardinalityContainer
= new Composite(group
, SWT
.NONE
);
1102 GridLayout cardinalityLayout
= new GridLayout(6, false);
1103 cardinalityLayout
.marginHeight
= 0;
1104 cardinalityLayout
.marginWidth
= 0;
1105 cardinalityContainer
.setLayout(cardinalityLayout
);
1106 cardinalityContainer
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1108 cardinalityCombo
= new Combo(cardinalityContainer
, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
1109 cardinalityCombo
.setItems(new String
[] {
1110 Cardinality
.ZERO_OR_MORE
.toString(),
1111 Cardinality
.ONE_OR_MORE
.toString(),
1112 Cardinality
.ZERO_OR_ONE
.toString(),
1113 Cardinality
.ONE
.toString(), "(?,?)" }); //$NON-NLS-1$
1114 cardinalityCombo
.addSelectionListener(new SelectionListener() {
1116 public void widgetDefaultSelected(SelectionEvent e
) {
1120 public void widgetSelected(SelectionEvent e
) {
1121 switch (cardinalityCombo
.getSelectionIndex()) {
1123 cardinalityMinLabel
.setVisible(true);
1124 cardinalityMinText
.setVisible(true);
1125 cardinalityMaxLabel
.setVisible(true);
1126 cardinalityMaxText
.setVisible(true);
1127 infiniteButton
.setVisible(true);
1130 cardinalityMinLabel
.setVisible(false);
1131 cardinalityMinText
.setVisible(false);
1132 cardinalityMaxLabel
.setVisible(false);
1133 cardinalityMaxText
.setVisible(false);
1134 infiniteButton
.setVisible(false);
1137 cardinalityContainer
.layout();
1143 cardinalityMinLabel
= new Label(cardinalityContainer
, SWT
.NONE
);
1144 cardinalityMinLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1145 cardinalityMinLabel
.setText(Messages
.CustomTxtParserInputWizardPage_min
);
1146 cardinalityMinLabel
.setVisible(false);
1148 cardinalityMinText
= new Text(cardinalityContainer
, SWT
.BORDER
| SWT
.SINGLE
);
1149 gd
= new GridData(SWT
.CENTER
, SWT
.CENTER
, false, false);
1151 cardinalityMinText
.setLayoutData(gd
);
1152 cardinalityMinText
.setVisible(false);
1154 cardinalityMaxLabel
= new Label(cardinalityContainer
, SWT
.NONE
);
1155 cardinalityMaxLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1156 cardinalityMaxLabel
.setText(Messages
.CustomTxtParserInputWizardPage_max
);
1157 cardinalityMaxLabel
.setVisible(false);
1159 cardinalityMaxText
= new Text(cardinalityContainer
, SWT
.BORDER
| SWT
.SINGLE
);
1160 gd
= new GridData(SWT
.CENTER
, SWT
.CENTER
, false, false);
1162 cardinalityMaxText
.setLayoutData(gd
);
1163 cardinalityMaxText
.setVisible(false);
1165 infiniteButton
= new Button(cardinalityContainer
, SWT
.PUSH
);
1166 infiniteButton
.setText(INFINITY_STRING
);
1167 infiniteButton
.setVisible(false);
1168 infiniteButton
.addSelectionListener(new SelectionAdapter() {
1170 public void widgetSelected(SelectionEvent e
) {
1171 cardinalityMaxText
.setText(INFINITY_STRING
);
1175 if (inputLine
.cardinality
.equals(Cardinality
.ZERO_OR_MORE
)) {
1176 cardinalityCombo
.select(0);
1177 } else if (inputLine
.cardinality
.equals(Cardinality
.ONE_OR_MORE
)) {
1178 cardinalityCombo
.select(1);
1179 } else if (inputLine
.cardinality
.equals(Cardinality
.ZERO_OR_ONE
)) {
1180 cardinalityCombo
.select(2);
1181 } else if (inputLine
.cardinality
.equals(Cardinality
.ONE
)) {
1182 cardinalityCombo
.select(3);
1184 cardinalityCombo
.select(4);
1185 cardinalityMinLabel
.setVisible(true);
1186 cardinalityMinText
.setVisible(true);
1187 if (inputLine
.getMinCount() >= 0) {
1188 cardinalityMinText
.setText(Integer
.toString(inputLine
.getMinCount()));
1190 cardinalityMaxLabel
.setVisible(true);
1191 cardinalityMaxText
.setVisible(true);
1192 if (inputLine
.getMaxCount() == Cardinality
.INF
) {
1193 cardinalityMaxText
.setText(INFINITY_STRING
);
1194 } else if (inputLine
.getMaxCount() >= 0) {
1195 cardinalityMaxText
.setText(Integer
.toString(inputLine
.getMaxCount()));
1197 infiniteButton
.setVisible(true);
1200 VerifyListener digitsListener
= new VerifyListener() {
1202 public void verifyText(VerifyEvent e
) {
1203 if (e
.text
.equals(INFINITY_STRING
)) {
1204 e
.doit
= e
.widget
== cardinalityMaxText
&& e
.start
== 0 && e
.end
== ((Text
) e
.widget
).getText().length();
1206 if (((Text
) e
.widget
).getText().equals(INFINITY_STRING
)) {
1207 e
.doit
= e
.start
== 0 && e
.end
== ((Text
) e
.widget
).getText().length();
1209 for (int i
= 0; i
< e
.text
.length(); i
++) {
1210 if (!Character
.isDigit(e
.text
.charAt(i
))) {
1219 cardinalityMinText
.addModifyListener(updateListener
);
1220 cardinalityMaxText
.addModifyListener(updateListener
);
1221 cardinalityMinText
.addVerifyListener(digitsListener
);
1222 cardinalityMaxText
.addVerifyListener(digitsListener
);
1224 if (inputLine
.columns
!= null) {
1225 for (InputData inputData
: inputLine
.columns
) {
1226 InputGroup inputGroup
= new InputGroup(group
, this, inputs
.size() + 1);
1227 if (inputData
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1228 inputGroup
.tagCombo
.select(0);
1229 inputGroup
.tagText
.setText(inputData
.format
);
1230 inputGroup
.tagLabel
.setText(Messages
.CustomTxtParserInputWizardPage_format
);
1231 inputGroup
.tagLabel
.setVisible(true);
1232 inputGroup
.tagText
.setVisible(true);
1233 inputGroup
.tagText
.addModifyListener(updateListener
);
1234 } else if (inputData
.name
.equals(CustomTraceDefinition
.TAG_MESSAGE
)) {
1235 inputGroup
.tagCombo
.select(1);
1237 inputGroup
.tagCombo
.select(2);
1238 inputGroup
.tagText
.setText(inputData
.name
);
1239 inputGroup
.tagLabel
.setText(Messages
.CustomTxtParserInputWizardPage_name
);
1240 inputGroup
.tagLabel
.setVisible(true);
1241 inputGroup
.tagText
.setVisible(true);
1242 inputGroup
.tagText
.addModifyListener(updateListener
);
1244 inputGroup
.actionCombo
.select(inputData
.action
);
1245 inputs
.add(inputGroup
);
1249 createAddGroupButton();
1252 private void createAddGroupButton() {
1253 addGroupButton
= new Button(group
, SWT
.PUSH
);
1254 addGroupButton
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1255 addGroupButton
.setImage(ADD_IMAGE
);
1256 addGroupButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_addGroup
);
1257 addGroupButton
.addSelectionListener(new SelectionAdapter() {
1259 public void widgetSelected(SelectionEvent e
) {
1260 removeAddGroupButton();
1261 inputs
.add(new InputGroup(group
, Line
.this, inputs
.size() + 1));
1262 createAddGroupButton();
1263 lineContainer
.layout();
1264 lineScrolledComposite
.setMinSize(lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
1265 group
.getParent().layout();
1271 addGroupLabel
= new Label(group
, SWT
.NULL
);
1272 addGroupLabel
.setText(Messages
.CustomTxtParserInputWizardPage_newGroup
);
1275 private void removeAddGroupButton() {
1276 addGroupButton
.dispose();
1277 addGroupLabel
.dispose();
1280 private void removeInput(int inputNumber
) {
1281 int nb
= inputNumber
;
1282 if (--nb
< inputs
.size()) {
1283 inputs
.remove(nb
).dispose();
1284 for (int i
= nb
; i
< inputs
.size(); i
++) {
1285 inputs
.get(i
).setInputNumber(i
+ 1);
1287 lineContainer
.layout();
1288 lineScrolledComposite
.setMinSize(lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
1289 group
.getParent().layout();
1293 private void dispose() {
1297 private void extractInputs() {
1298 inputLine
.setRegex(selectedLine
.regexText
.getText());
1299 switch (cardinalityCombo
.getSelectionIndex()) {
1301 inputLine
.cardinality
= Cardinality
.ZERO_OR_MORE
;
1304 inputLine
.cardinality
= Cardinality
.ONE_OR_MORE
;
1307 inputLine
.cardinality
= Cardinality
.ZERO_OR_ONE
;
1310 inputLine
.cardinality
= Cardinality
.ONE
;
1316 min
= Integer
.parseInt(cardinalityMinText
.getText());
1317 } catch (NumberFormatException e
) {
1321 if (cardinalityMaxText
.getText().equals(INFINITY_STRING
)) {
1322 max
= Cardinality
.INF
;
1324 max
= Integer
.parseInt(cardinalityMaxText
.getText());
1326 } catch (NumberFormatException e
) {
1329 inputLine
.cardinality
= new Cardinality(min
, max
);
1332 inputLine
.cardinality
= Cardinality
.ZERO_OR_MORE
;
1335 inputLine
.columns
= new ArrayList
<>(inputs
.size());
1336 for (int i
= 0; i
< inputs
.size(); i
++) {
1337 InputGroup grp
= inputs
.get(i
);
1338 InputData inputData
= new InputData();
1339 if (grp
.tagCombo
.getText().equals(CustomTraceDefinition
.TAG_OTHER
)) {
1340 inputData
.name
= grp
.tagText
.getText().trim();
1342 inputData
.name
= grp
.tagCombo
.getText();
1343 if (grp
.tagCombo
.getText().equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1344 inputData
.format
= grp
.tagText
.getText().trim();
1347 inputData
.action
= grp
.actionCombo
.getSelectionIndex();
1348 inputLine
.columns
.add(inputData
);
1353 private class InputGroup
{
1355 private int inputNumber
;
1357 // children of parent (must be disposed)
1358 private Composite labelComposite
;
1359 private Composite tagComposite
;
1360 private Label previewLabel
;
1361 private Text previewText
;
1363 // children of labelComposite
1364 private Label inputLabel
;
1366 // children of tagComposite
1367 private Combo tagCombo
;
1368 private Label tagLabel
;
1369 private Text tagText
;
1370 private Combo actionCombo
;
1372 public InputGroup(Composite parent
, Line line
, int inputNumber
) {
1374 this.inputNumber
= inputNumber
;
1376 labelComposite
= new Composite(parent
, SWT
.FILL
);
1377 GridLayout labelLayout
= new GridLayout(2, false);
1378 labelLayout
.marginWidth
= 0;
1379 labelLayout
.marginHeight
= 0;
1380 labelComposite
.setLayout(labelLayout
);
1381 labelComposite
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1383 Button deleteButton
= new Button(labelComposite
, SWT
.PUSH
);
1384 deleteButton
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1385 deleteButton
.setImage(DELETE_IMAGE
);
1386 deleteButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_removeGroup
);
1387 deleteButton
.addSelectionListener(new SelectionAdapter() {
1389 public void widgetSelected(SelectionEvent e
) {
1390 InputGroup
.this.line
.removeInput(InputGroup
.this.inputNumber
);
1396 inputLabel
= new Label(labelComposite
, SWT
.NULL
);
1397 inputLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1398 inputLabel
.setText(NLS
.bind(Messages
.CustomTxtParserInputWizardPage_group
, inputNumber
));
1400 tagComposite
= new Composite(parent
, SWT
.FILL
);
1401 GridLayout tagLayout
= new GridLayout(4, false);
1402 tagLayout
.marginWidth
= 0;
1403 tagLayout
.marginHeight
= 0;
1404 tagComposite
.setLayout(tagLayout
);
1405 tagComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1407 tagCombo
= new Combo(tagComposite
, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
1408 tagCombo
.setItems(new String
[] { CustomTraceDefinition
.TAG_TIMESTAMP
,
1409 CustomTraceDefinition
.TAG_MESSAGE
,
1410 CustomTraceDefinition
.TAG_OTHER
});
1412 tagCombo
.addSelectionListener(new SelectionListener() {
1414 public void widgetDefaultSelected(SelectionEvent e
) {
1418 public void widgetSelected(SelectionEvent e
) {
1419 tagText
.removeModifyListener(updateListener
);
1420 switch (tagCombo
.getSelectionIndex()) {
1421 case 0: // Time Stamp
1422 tagLabel
.setText(Messages
.CustomTxtParserInputWizardPage_format
);
1423 tagLabel
.setVisible(true);
1424 tagText
.setVisible(true);
1425 tagText
.addModifyListener(updateListener
);
1428 tagLabel
.setVisible(false);
1429 tagText
.setVisible(false);
1432 tagLabel
.setText(Messages
.CustomTxtParserInputWizardPage_name
);
1433 tagLabel
.setVisible(true);
1434 tagText
.setVisible(true);
1435 tagText
.addModifyListener(updateListener
);
1438 tagLabel
.setVisible(false);
1439 tagText
.setVisible(false);
1444 tagComposite
.layout();
1450 tagLabel
= new Label(tagComposite
, SWT
.NULL
);
1451 tagLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1452 tagLabel
.setVisible(false);
1454 tagText
= new Text(tagComposite
, SWT
.BORDER
| SWT
.SINGLE
);
1455 GridData gd
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
1457 tagText
.setLayoutData(gd
);
1458 tagText
.setVisible(false);
1460 actionCombo
= new Combo(tagComposite
, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
1461 actionCombo
.setItems(new String
[] { Messages
.CustomTxtParserInputWizardPage_set
, Messages
.CustomTxtParserInputWizardPage_append
, Messages
.CustomTxtParserInputWizardPage_appendWith
});
1462 actionCombo
.select(0);
1463 actionCombo
.addSelectionListener(updateListener
);
1465 previewLabel
= new Label(parent
, SWT
.NULL
);
1466 previewLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1467 previewLabel
.setText(Messages
.CustomTxtParserInputWizardPage_preview
);
1469 previewText
= new Text(parent
, SWT
.BORDER
| SWT
.SINGLE
| SWT
.READ_ONLY
);
1470 gd
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
1472 previewText
.setLayoutData(gd
);
1473 previewText
.setText(Messages
.CustomTxtParserInputWizardPage_noMatch
);
1474 previewText
.setBackground(COLOR_WIDGET_BACKGROUND
);
1477 private void dispose() {
1478 labelComposite
.dispose();
1479 tagComposite
.dispose();
1480 previewLabel
.dispose();
1481 previewText
.dispose();
1484 private void setInputNumber(int inputNumber
) {
1485 this.inputNumber
= inputNumber
;
1486 inputLabel
.setText(NLS
.bind(Messages
.CustomTxtParserInputWizardPage_group
, inputNumber
));
1487 labelComposite
.layout();
1491 private void validate() {
1493 definition
.categoryName
= categoryText
.getText().trim();
1494 definition
.definitionName
= logtypeText
.getText().trim();
1495 definition
.timeStampOutputFormat
= timestampOutputFormatText
.getText().trim();
1497 if (selectedLine
!= null) {
1498 selectedLine
.extractInputs();
1499 treeViewer
.refresh();
1502 StringBuffer errors
= new StringBuffer();
1504 if (definition
.categoryName
.length() == 0) {
1505 errors
.append("Enter a category for the new trace type. "); //$NON-NLS-1$
1506 categoryText
.setBackground(COLOR_LIGHT_RED
);
1507 } else if (definition
.definitionName
.length() == 0) {
1508 errors
.append("Enter a name for the new trace type. "); //$NON-NLS-1$
1509 logtypeText
.setBackground(COLOR_LIGHT_RED
);
1511 categoryText
.setBackground(COLOR_TEXT_BACKGROUND
);
1512 logtypeText
.setBackground(COLOR_TEXT_BACKGROUND
);
1513 if (definition
.categoryName
.indexOf(':') != -1) {
1514 errors
.append("Invalid character ':' in category. "); //$NON-NLS-1$
1515 categoryText
.setBackground(COLOR_LIGHT_RED
);
1517 if (definition
.definitionName
.indexOf(':') != -1) {
1518 errors
.append("Invalid character ':' in trace type. "); //$NON-NLS-1$
1519 logtypeText
.setBackground(COLOR_LIGHT_RED
);
1521 for (TraceTypeHelper helper
: TmfTraceType
.getTraceTypeHelpers()) {
1522 if (definition
.categoryName
.equals(helper
.getCategoryName()) &&
1523 definition
.definitionName
.equals(helper
.getName()) &&
1524 (editDefinitionName
== null || !editDefinitionName
.equals(definition
.definitionName
)) &&
1525 (editCategoryName
== null || !editCategoryName
.equals(definition
.categoryName
))) {
1526 errors
.append("The trace type name already exists. "); //$NON-NLS-1$
1527 logtypeText
.setBackground(COLOR_LIGHT_RED
);
1533 timestampFound
= false;
1534 for (int i
= 0; i
< definition
.inputs
.size(); i
++) {
1536 InputLine inputLine
= definition
.inputs
.get(i
);
1537 String name
= Integer
.toString(i
+ 1);
1538 errors
.append(validateLine(inputLine
, name
));
1540 if (timestampFound
) {
1541 if (definition
.timeStampOutputFormat
.length() == 0) {
1542 errors
.append("Enter the output format for the Time Stamp field. "); //$NON-NLS-1$
1543 timestampOutputFormatText
.setBackground(COLOR_LIGHT_RED
);
1546 new TmfTimestampFormat(definition
.timeStampOutputFormat
);
1547 timestampOutputFormatText
.setBackground(COLOR_TEXT_BACKGROUND
);
1548 } catch (IllegalArgumentException e
) {
1549 errors
.append("Enter a valid output format for the Time Stamp field [" + e
.getMessage() + "]."); //$NON-NLS-1$ //$NON-NLS-2$
1550 timestampOutputFormatText
.setBackground(COLOR_LIGHT_RED
);
1555 timestampOutputFormatText
.setBackground(COLOR_TEXT_BACKGROUND
);
1558 if (errors
.length() == 0) {
1559 setDescription(defaultDescription
);
1560 setPageComplete(true);
1562 setDescription(errors
.toString());
1563 setPageComplete(false);
1568 * Validate an input line.
1571 * The line to clean up
1573 * The name of the line
1574 * @return The cleaned up line
1576 public StringBuffer
validateLine(InputLine inputLine
, String name
) {
1577 StringBuffer errors
= new StringBuffer();
1579 if (selectedLine
!= null && selectedLine
.inputLine
.equals(inputLine
)) {
1580 line
= selectedLine
;
1583 Pattern
.compile(inputLine
.getRegex());
1585 line
.regexText
.setBackground(COLOR_TEXT_BACKGROUND
);
1587 } catch (PatternSyntaxException e
) {
1588 errors
.append("Enter a valid regular expression (Line " + name
+ "). "); //$NON-NLS-1$ //$NON-NLS-2$
1590 line
.regexText
.setBackground(COLOR_LIGHT_RED
);
1593 if (inputLine
.getMinCount() == -1) {
1594 errors
.append("Enter a minimum value for cardinality (Line " + name
+ "). "); //$NON-NLS-1$ //$NON-NLS-2$
1596 line
.cardinalityMinText
.setBackground(COLOR_LIGHT_RED
);
1600 line
.cardinalityMinText
.setBackground(COLOR_TEXT_BACKGROUND
);
1603 if (inputLine
.getMaxCount() == -1) {
1604 errors
.append("Enter a maximum value for cardinality (Line " + name
+ "). "); //$NON-NLS-1$ //$NON-NLS-2$
1606 line
.cardinalityMaxText
.setBackground(COLOR_LIGHT_RED
);
1608 } else if (inputLine
.getMinCount() > inputLine
.getMaxCount()) {
1609 errors
.append("Enter correct (min <= max) values for cardinality (Line " + name
+ "). "); //$NON-NLS-1$ //$NON-NLS-2$
1611 line
.cardinalityMinText
.setBackground(COLOR_LIGHT_RED
);
1614 line
.cardinalityMaxText
.setBackground(COLOR_LIGHT_RED
);
1618 line
.cardinalityMaxText
.setBackground(COLOR_TEXT_BACKGROUND
);
1621 for (int i
= 0; inputLine
.columns
!= null && i
< inputLine
.columns
.size(); i
++) {
1622 InputData inputData
= inputLine
.columns
.get(i
);
1623 InputGroup group
= null;
1625 group
= line
.inputs
.get(i
);
1627 if (inputData
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1628 timestampFound
= true;
1629 if (inputData
.format
.length() == 0) {
1630 errors
.append("Enter the input format for the Time Stamp (Line " + name
+ " Group " + (i
+ 1) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1631 if (group
!= null) {
1632 group
.tagText
.setBackground(COLOR_LIGHT_RED
);
1636 new TmfTimestampFormat(inputData
.format
);
1637 if (group
!= null) {
1638 group
.tagText
.setBackground(COLOR_TEXT_BACKGROUND
);
1640 } catch (IllegalArgumentException e
) {
1641 errors
.append("Enter a valid input format for the Time Stamp (Line " + name
+ " Group " + (i
+ 1) + ") [" + e
.getMessage() + "]. "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
1642 if (group
!= null) {
1643 group
.tagText
.setBackground(COLOR_LIGHT_RED
);
1647 } else if (inputData
.name
.length() == 0) {
1648 errors
.append("Enter a name for the data group (Line " + name
+ " Group " + (i
+ 1) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1649 if (group
!= null) {
1650 group
.tagText
.setBackground(COLOR_LIGHT_RED
);
1653 if (group
!= null) {
1654 group
.tagText
.setBackground(COLOR_TEXT_BACKGROUND
);
1658 for (int i
= 0; inputLine
.childrenInputs
!= null && i
< inputLine
.childrenInputs
.size(); i
++) {
1659 errors
.append(validateLine(inputLine
.childrenInputs
.get(i
), name
+ "." + (i
+ 1))); //$NON-NLS-1$
1665 * Get the trace definition.
1667 * @return The trace definition
1669 public CustomTxtTraceDefinition
getDefinition() {
1674 * Get the raw text of the input.
1676 * @return The raw input text
1678 public char[] getInputText() {
1679 return inputText
.getText().toCharArray();