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 static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
17 import java
.io
.BufferedReader
;
18 import java
.io
.IOException
;
19 import java
.io
.InputStreamReader
;
21 import java
.text
.ParseException
;
22 import java
.util
.ArrayList
;
23 import java
.util
.Arrays
;
24 import java
.util
.HashMap
;
25 import java
.util
.Iterator
;
26 import java
.util
.List
;
28 import java
.util
.Scanner
;
29 import java
.util
.regex
.Matcher
;
30 import java
.util
.regex
.Pattern
;
31 import java
.util
.regex
.PatternSyntaxException
;
33 import org
.eclipse
.core
.resources
.IFile
;
34 import org
.eclipse
.core
.runtime
.CoreException
;
35 import org
.eclipse
.core
.runtime
.FileLocator
;
36 import org
.eclipse
.core
.runtime
.IPath
;
37 import org
.eclipse
.core
.runtime
.Path
;
38 import org
.eclipse
.core
.runtime
.Platform
;
39 import org
.eclipse
.jface
.viewers
.ColumnLabelProvider
;
40 import org
.eclipse
.jface
.viewers
.ISelection
;
41 import org
.eclipse
.jface
.viewers
.ISelectionChangedListener
;
42 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
43 import org
.eclipse
.jface
.viewers
.ITreeContentProvider
;
44 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
45 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
46 import org
.eclipse
.jface
.viewers
.TreeViewer
;
47 import org
.eclipse
.jface
.viewers
.Viewer
;
48 import org
.eclipse
.jface
.wizard
.WizardPage
;
49 import org
.eclipse
.osgi
.util
.NLS
;
50 import org
.eclipse
.swt
.SWT
;
51 import org
.eclipse
.swt
.browser
.Browser
;
52 import org
.eclipse
.swt
.browser
.TitleEvent
;
53 import org
.eclipse
.swt
.browser
.TitleListener
;
54 import org
.eclipse
.swt
.custom
.SashForm
;
55 import org
.eclipse
.swt
.custom
.ScrolledComposite
;
56 import org
.eclipse
.swt
.custom
.StyleRange
;
57 import org
.eclipse
.swt
.custom
.StyledText
;
58 import org
.eclipse
.swt
.events
.ModifyEvent
;
59 import org
.eclipse
.swt
.events
.ModifyListener
;
60 import org
.eclipse
.swt
.events
.SelectionAdapter
;
61 import org
.eclipse
.swt
.events
.SelectionEvent
;
62 import org
.eclipse
.swt
.events
.SelectionListener
;
63 import org
.eclipse
.swt
.events
.VerifyEvent
;
64 import org
.eclipse
.swt
.events
.VerifyListener
;
65 import org
.eclipse
.swt
.graphics
.Color
;
66 import org
.eclipse
.swt
.graphics
.Font
;
67 import org
.eclipse
.swt
.graphics
.FontData
;
68 import org
.eclipse
.swt
.graphics
.Image
;
69 import org
.eclipse
.swt
.graphics
.Point
;
70 import org
.eclipse
.swt
.graphics
.Rectangle
;
71 import org
.eclipse
.swt
.layout
.FillLayout
;
72 import org
.eclipse
.swt
.layout
.GridData
;
73 import org
.eclipse
.swt
.layout
.GridLayout
;
74 import org
.eclipse
.swt
.widgets
.Button
;
75 import org
.eclipse
.swt
.widgets
.Combo
;
76 import org
.eclipse
.swt
.widgets
.Composite
;
77 import org
.eclipse
.swt
.widgets
.Display
;
78 import org
.eclipse
.swt
.widgets
.Group
;
79 import org
.eclipse
.swt
.widgets
.Label
;
80 import org
.eclipse
.swt
.widgets
.Shell
;
81 import org
.eclipse
.swt
.widgets
.Text
;
82 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Activator
;
83 import org
.eclipse
.tracecompass
.internal
.tmf
.ui
.Messages
;
84 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTraceDefinition
;
85 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTxtTraceDefinition
;
86 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTxtTraceDefinition
.Cardinality
;
87 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTxtTraceDefinition
.InputData
;
88 import org
.eclipse
.tracecompass
.tmf
.core
.parsers
.custom
.CustomTxtTraceDefinition
.InputLine
;
89 import org
.eclipse
.tracecompass
.tmf
.core
.project
.model
.TmfTraceType
;
90 import org
.eclipse
.tracecompass
.tmf
.core
.project
.model
.TraceTypeHelper
;
91 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimestampFormat
;
92 import org
.osgi
.framework
.Bundle
;
95 * Input wizard page for custom text parsers.
97 * @author Patrick Tasse
99 public class CustomTxtParserInputWizardPage
extends WizardPage
{
101 private static final String DEFAULT_REGEX
= "\\s*(.*\\S)"; //$NON-NLS-1$
102 private static final String DEFAULT_TIMESTAMP_FORMAT
= "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$
103 private static final String TIMESTAMP_FORMAT_BUNDLE
= "org.eclipse.tracecompass.doc.user"; //$NON-NLS-1$
104 private static final String TIMESTAMP_FORMAT_PATH
= "reference/api/org/eclipse/tracecompass/tmf/core/timestamp/TmfTimestampFormat.html"; //$NON-NLS-1$
105 private static final String PATTERN_URL
= "http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#sum"; //$NON-NLS-1$
106 private static final Image LINE_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/line_icon.gif"); //$NON-NLS-1$
107 private static final Image ADD_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$
108 private static final Image ADD_NEXT_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/addnext_button.gif"); //$NON-NLS-1$
109 private static final Image ADD_CHILD_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/addchild_button.gif"); //$NON-NLS-1$
110 private static final Image DELETE_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/delete_button.gif"); //$NON-NLS-1$
111 private static final Image MOVE_UP_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/moveup_button.gif"); //$NON-NLS-1$
112 private static final Image MOVE_DOWN_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/movedown_button.gif"); //$NON-NLS-1$
113 private static final Image HELP_IMAGE
= Activator
.getDefault().getImageFromPath("/icons/elcl16/help_button.gif"); //$NON-NLS-1$
114 private static final Color COLOR_BLACK
= Display
.getDefault().getSystemColor(SWT
.COLOR_BLACK
);
115 private static final Color COLOR_LIGHT_GREEN
= new Color(Display
.getDefault(), 192, 255, 192);
116 private static final Color COLOR_GREEN
= Display
.getDefault().getSystemColor(SWT
.COLOR_GREEN
);
117 private static final Color COLOR_LIGHT_YELLOW
= new Color(Display
.getDefault(), 255, 255, 192);
118 private static final Color COLOR_YELLOW
= Display
.getDefault().getSystemColor(SWT
.COLOR_YELLOW
);
119 private static final Color COLOR_LIGHT_MAGENTA
= new Color(Display
.getDefault(), 255, 192, 255);
120 private static final Color COLOR_MAGENTA
= Display
.getDefault().getSystemColor(SWT
.COLOR_MAGENTA
);
121 private static final Color COLOR_LIGHT_RED
= new Color(Display
.getDefault(), 255, 192, 192);
122 private static final Color COLOR_TEXT_BACKGROUND
= Display
.getDefault().getSystemColor(SWT
.COLOR_WHITE
);
123 private static final Color COLOR_WIDGET_BACKGROUND
= Display
.getDefault().getSystemColor(SWT
.COLOR_WIDGET_BACKGROUND
);
125 private final ISelection selection
;
126 private CustomTxtTraceDefinition definition
;
127 private String editCategoryName
;
128 private String editDefinitionName
;
129 private String defaultDescription
;
130 private Line selectedLine
;
131 private Composite container
;
132 private Text categoryText
;
133 private Text logtypeText
;
134 private Text timestampOutputFormatText
;
135 private Text timestampPreviewText
;
136 private ScrolledComposite lineScrolledComposite
;
137 private TreeViewer treeViewer
;
138 private Composite lineContainer
;
139 private StyledText inputText
;
140 private Font fixedFont
;
141 private UpdateListener updateListener
;
142 private Browser helpBrowser
;
144 // variables used recursively through line traversal
145 private String timeStampFormat
;
146 private boolean timestampFound
;
152 * The Selection object
154 * The trace definition
156 protected CustomTxtParserInputWizardPage(ISelection selection
,
157 CustomTxtTraceDefinition definition
) {
158 super("CustomParserWizardPage"); //$NON-NLS-1$
159 if (definition
== null) {
160 setTitle(Messages
.CustomTxtParserInputWizardPage_titleNew
);
161 defaultDescription
= Messages
.CustomTxtParserInputWizardPage_descriptionNew
;
163 setTitle(Messages
.CustomTxtParserInputWizardPage_titleEdit
);
164 defaultDescription
= Messages
.CustomTxtParserInputWizardPage_desccriptionEdit
;
166 setDescription(defaultDescription
);
167 this.selection
= selection
;
168 this.definition
= definition
;
169 if (definition
!= null) {
170 this.editCategoryName
= definition
.categoryName
;
171 this.editDefinitionName
= definition
.definitionName
;
176 public void createControl(Composite parent
) {
177 container
= new Composite(parent
, SWT
.NULL
);
178 container
.setLayout(new GridLayout());
180 updateListener
= new UpdateListener();
182 Composite headerComposite
= new Composite(container
, SWT
.FILL
);
183 GridLayout headerLayout
= new GridLayout(5, false);
184 headerLayout
.marginHeight
= 0;
185 headerLayout
.marginWidth
= 0;
186 headerComposite
.setLayout(headerLayout
);
187 headerComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
189 Label categoryLabel
= new Label(headerComposite
, SWT
.NULL
);
190 categoryLabel
.setText(Messages
.CustomTxtParserInputWizardPage_category
);
192 categoryText
= new Text(headerComposite
, SWT
.BORDER
| SWT
.SINGLE
);
193 categoryText
.setLayoutData(new GridData(120, SWT
.DEFAULT
));
195 Label timestampFormatLabel
= new Label(headerComposite
, SWT
.NULL
);
196 timestampFormatLabel
.setText(Messages
.CustomTxtParserInputWizardPage_timestampFormat
);
198 timestampOutputFormatText
= new Text(headerComposite
, SWT
.BORDER
| SWT
.SINGLE
);
199 timestampOutputFormatText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
200 timestampOutputFormatText
.setText(DEFAULT_TIMESTAMP_FORMAT
);
202 Button timeStampFormatHelpButton
= new Button(headerComposite
, SWT
.PUSH
);
203 timeStampFormatHelpButton
.setImage(HELP_IMAGE
);
204 timeStampFormatHelpButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_timestampFormatHelp
);
205 timeStampFormatHelpButton
.addSelectionListener(new SelectionAdapter() {
207 public void widgetSelected(SelectionEvent e
) {
208 Bundle plugin
= Platform
.getBundle(TIMESTAMP_FORMAT_BUNDLE
);
209 IPath path
= new Path(TIMESTAMP_FORMAT_PATH
);
210 URL fileURL
= FileLocator
.find(plugin
, path
, null);
212 URL pageURL
= FileLocator
.toFileURL(fileURL
);
213 openHelpShell(pageURL
.toString());
214 } catch (IOException e1
) {
219 Label logtypeLabel
= new Label(headerComposite
, SWT
.NULL
);
220 logtypeLabel
.setText(Messages
.CustomTxtParserInputWizardPage_logType
);
222 logtypeText
= new Text(headerComposite
, SWT
.BORDER
| SWT
.SINGLE
);
223 logtypeText
.setLayoutData(new GridData(120, SWT
.DEFAULT
));
224 logtypeText
.setFocus();
226 Label timestampPreviewLabel
= new Label(headerComposite
, SWT
.NULL
);
227 timestampPreviewLabel
.setText(Messages
.CustomTxtParserInputWizardPage_preview
);
229 timestampPreviewText
= new Text(headerComposite
, SWT
.BORDER
| SWT
.SINGLE
| SWT
.READ_ONLY
);
230 timestampPreviewText
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false, 2, 1));
231 timestampPreviewText
.setText(Messages
.CustomTxtParserInputWizardPage_noMatchingTimestamp
);
233 Composite buttonBar
= new Composite(container
, SWT
.NONE
);
234 GridLayout buttonBarLayout
= new GridLayout(5, false);
235 buttonBarLayout
.marginHeight
= 0;
236 buttonBarLayout
.marginWidth
= 0;
237 buttonBar
.setLayout(buttonBarLayout
);
239 Button removeButton
= new Button(buttonBar
, SWT
.PUSH
);
240 removeButton
.setImage(DELETE_IMAGE
);
241 removeButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_removeLine
);
242 removeButton
.addSelectionListener(new SelectionAdapter() {
244 public void widgetSelected(SelectionEvent e
) {
245 if (treeViewer
.getSelection().isEmpty() || selectedLine
== null) {
249 InputLine inputLine
= (InputLine
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
250 if (inputLine
.parentInput
== null) {
251 definition
.inputs
.remove(inputLine
);
253 inputLine
.parentInput
.childrenInputs
.remove(inputLine
);
255 treeViewer
.refresh();
260 Button addNextButton
= new Button(buttonBar
, SWT
.PUSH
);
261 addNextButton
.setImage(ADD_NEXT_IMAGE
);
262 addNextButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_addNextLine
);
263 addNextButton
.addSelectionListener(new SelectionAdapter() {
265 public void widgetSelected(SelectionEvent e
) {
266 InputLine inputLine
= new InputLine(Cardinality
.ZERO_OR_MORE
, "", null); //$NON-NLS-1$
267 if (((List
<?
>) treeViewer
.getInput()).size() == 0) {
268 definition
.inputs
.add(inputLine
);
269 } else if (treeViewer
.getSelection().isEmpty()) {
272 InputLine previousInputLine
= (InputLine
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
273 if (previousInputLine
.parentInput
== null) {
274 for (int i
= 0; i
< definition
.inputs
.size(); i
++) {
275 if (definition
.inputs
.get(i
).equals(previousInputLine
)) {
276 definition
.inputs
.add(i
+ 1, inputLine
);
280 previousInputLine
.addNext(inputLine
);
283 treeViewer
.refresh();
284 treeViewer
.setSelection(new StructuredSelection(inputLine
), true);
287 Button addChildButton
= new Button(buttonBar
, SWT
.PUSH
);
288 addChildButton
.setImage(ADD_CHILD_IMAGE
);
289 addChildButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_addChildLine
);
290 addChildButton
.addSelectionListener(new SelectionAdapter() {
292 public void widgetSelected(SelectionEvent e
) {
293 InputLine inputLine
= new InputLine(Cardinality
.ZERO_OR_MORE
, "", null); //$NON-NLS-1$
294 if (((List
<?
>) treeViewer
.getInput()).size() == 0) {
295 definition
.inputs
.add(inputLine
);
296 } else if (treeViewer
.getSelection().isEmpty()) {
299 InputLine parentInputLine
= (InputLine
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
300 parentInputLine
.addChild(inputLine
);
302 treeViewer
.refresh();
303 treeViewer
.setSelection(new StructuredSelection(inputLine
), true);
306 Button moveUpButton
= new Button(buttonBar
, SWT
.PUSH
);
307 moveUpButton
.setImage(MOVE_UP_IMAGE
);
308 moveUpButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_moveUp
);
309 moveUpButton
.addSelectionListener(new SelectionAdapter() {
311 public void widgetSelected(SelectionEvent e
) {
312 if (treeViewer
.getSelection().isEmpty()) {
315 InputLine inputLine
= (InputLine
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
316 if (inputLine
.parentInput
== null) {
317 for (int i
= 1; i
< definition
.inputs
.size(); i
++) {
318 if (definition
.inputs
.get(i
).equals(inputLine
)) {
319 definition
.inputs
.add(i
- 1, definition
.inputs
.remove(i
));
326 treeViewer
.refresh();
331 Button moveDownButton
= new Button(buttonBar
, SWT
.PUSH
);
332 moveDownButton
.setImage(MOVE_DOWN_IMAGE
);
333 moveDownButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_moveDown
);
334 moveDownButton
.addSelectionListener(new SelectionAdapter() {
336 public void widgetSelected(SelectionEvent e
) {
337 if (treeViewer
.getSelection().isEmpty()) {
340 InputLine inputLine
= (InputLine
) ((IStructuredSelection
) treeViewer
.getSelection()).getFirstElement();
341 if (inputLine
.parentInput
== null) {
342 for (int i
= 0; i
< definition
.inputs
.size() - 1; i
++) {
343 if (definition
.inputs
.get(i
).equals(inputLine
)) {
344 definition
.inputs
.add(i
+ 1, definition
.inputs
.remove(i
));
349 inputLine
.moveDown();
351 treeViewer
.refresh();
357 SashForm vSash
= new SashForm(container
, SWT
.VERTICAL
);
358 vSash
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
359 vSash
.setBackground(vSash
.getDisplay().getSystemColor(SWT
.COLOR_GRAY
));
361 SashForm hSash
= new SashForm(vSash
, SWT
.HORIZONTAL
);
362 hSash
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
364 ScrolledComposite treeScrolledComposite
= new ScrolledComposite(hSash
, SWT
.V_SCROLL
| SWT
.H_SCROLL
);
365 GridData gd
= new GridData(SWT
.FILL
, SWT
.FILL
, true, true);
368 treeScrolledComposite
.setLayoutData(gd
);
369 Composite treeContainer
= new Composite(treeScrolledComposite
, SWT
.NONE
);
370 treeContainer
.setLayout(new FillLayout());
371 treeScrolledComposite
.setContent(treeContainer
);
372 treeScrolledComposite
.setExpandHorizontal(true);
373 treeScrolledComposite
.setExpandVertical(true);
375 treeViewer
= new TreeViewer(treeContainer
, SWT
.SINGLE
| SWT
.BORDER
);
376 treeViewer
.setContentProvider(new InputLineTreeNodeContentProvider());
377 treeViewer
.setLabelProvider(new InputLineTreeLabelProvider());
378 treeViewer
.addSelectionChangedListener(new InputLineTreeSelectionChangedListener());
379 treeContainer
.layout();
381 treeScrolledComposite
.setMinSize(treeContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, treeContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
);
383 lineScrolledComposite
= new ScrolledComposite(hSash
, SWT
.V_SCROLL
);
384 lineScrolledComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.FILL
, true, true));
385 lineContainer
= new Composite(lineScrolledComposite
, SWT
.NONE
);
386 GridLayout linesLayout
= new GridLayout();
387 linesLayout
.marginHeight
= 1;
388 linesLayout
.marginWidth
= 0;
389 lineContainer
.setLayout(linesLayout
);
390 lineScrolledComposite
.setContent(lineContainer
);
391 lineScrolledComposite
.setExpandHorizontal(true);
392 lineScrolledComposite
.setExpandVertical(true);
394 if (definition
== null) {
395 definition
= new CustomTxtTraceDefinition();
396 definition
.inputs
.add(new InputLine(Cardinality
.ZERO_OR_MORE
, DEFAULT_REGEX
,
397 Arrays
.asList(new InputData(CustomTraceDefinition
.TAG_MESSAGE
, CustomTraceDefinition
.ACTION_SET
))));
399 loadDefinition(definition
);
400 treeViewer
.expandAll();
401 lineContainer
.layout();
403 categoryText
.addModifyListener(updateListener
);
404 logtypeText
.addModifyListener(updateListener
);
405 timestampOutputFormatText
.addModifyListener(updateListener
);
407 lineScrolledComposite
.setMinSize(lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
409 hSash
.setWeights(new int[] { 1, 2 });
411 Composite sashBottom
= new Composite(vSash
, SWT
.NONE
);
412 GridLayout sashBottomLayout
= new GridLayout(3, false);
413 sashBottomLayout
.marginHeight
= 0;
414 sashBottomLayout
.marginWidth
= 0;
415 sashBottom
.setLayout(sashBottomLayout
);
417 Label previewLabel
= new Label(sashBottom
, SWT
.NULL
);
418 previewLabel
.setText(Messages
.CustomTxtParserInputWizardPage_previewInput
);
419 previewLabel
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
421 Button highlightAllButton
= new Button(sashBottom
, SWT
.PUSH
);
422 highlightAllButton
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
423 highlightAllButton
.setText(Messages
.CustomTxtParserInputWizardPage_highlightAll
);
424 highlightAllButton
.addSelectionListener(new SelectionAdapter() {
426 public void widgetSelected(SelectionEvent e
) {
427 updatePreviews(true);
431 Button legendButton
= new Button(sashBottom
, SWT
.PUSH
);
432 legendButton
.setImage(HELP_IMAGE
);
433 legendButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_previewLegend
);
434 legendButton
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
435 legendButton
.addSelectionListener(new SelectionAdapter() {
437 public void widgetSelected(SelectionEvent e
) {
442 inputText
= new StyledText(sashBottom
, SWT
.MULTI
| SWT
.V_SCROLL
| SWT
.H_SCROLL
);
443 if (fixedFont
== null) {
444 if (System
.getProperty("os.name").contains("Windows")) { //$NON-NLS-1$ //$NON-NLS-2$
445 fixedFont
= new Font(Display
.getCurrent(), new FontData("Courier New", 10, SWT
.NORMAL
)); //$NON-NLS-1$
447 fixedFont
= new Font(Display
.getCurrent(), new FontData("Monospace", 10, SWT
.NORMAL
)); //$NON-NLS-1$
450 inputText
.setFont(fixedFont
);
451 gd
= new GridData(SWT
.FILL
, SWT
.FILL
, true, true, 3, 1);
452 gd
.heightHint
= inputText
.computeSize(SWT
.DEFAULT
, inputText
.getLineHeight() * 4).y
;
454 inputText
.setLayoutData(gd
);
455 inputText
.setText(getSelectionText());
456 inputText
.addModifyListener(updateListener
);
458 vSash
.setWeights(new int[] { hSash
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
, sashBottom
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
});
460 setControl(container
);
466 private static class InputLineTreeNodeContentProvider
implements ITreeContentProvider
{
469 public Object
[] getElements(Object inputElement
) {
470 return ((List
<?
>) inputElement
).toArray();
474 public Object
[] getChildren(Object parentElement
) {
475 InputLine inputLine
= (InputLine
) parentElement
;
476 if (inputLine
.childrenInputs
== null) {
477 return new InputLine
[0];
479 return inputLine
.childrenInputs
.toArray();
483 public boolean hasChildren(Object element
) {
484 InputLine inputLine
= (InputLine
) element
;
485 return (inputLine
.childrenInputs
!= null && inputLine
.childrenInputs
.size() > 0);
489 public void dispose() {
493 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
497 public Object
getParent(Object element
) {
498 InputLine inputLine
= (InputLine
) element
;
499 return inputLine
.parentInput
;
503 private class InputLineTreeLabelProvider
extends ColumnLabelProvider
{
506 public Image
getImage(Object element
) {
511 public String
getText(Object element
) {
512 InputLine inputLine
= (InputLine
) element
;
513 if (inputLine
.parentInput
== null) {
514 return "Root Line " + getName(inputLine
) + " " + inputLine
.cardinality
.toString() + " : " + inputLine
.getRegex(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
516 return "Line " + getName(inputLine
) + " " + inputLine
.cardinality
.toString() + " : " + inputLine
.getRegex(); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
520 private class InputLineTreeSelectionChangedListener
implements ISelectionChangedListener
{
522 public void selectionChanged(SelectionChangedEvent event
) {
523 if (selectedLine
!= null) {
524 selectedLine
.dispose();
526 if (!(event
.getSelection().isEmpty()) && event
.getSelection() instanceof IStructuredSelection
) {
527 IStructuredSelection sel
= (IStructuredSelection
) event
.getSelection();
528 InputLine inputLine
= (InputLine
) sel
.getFirstElement();
529 selectedLine
= new Line(lineContainer
, getName(inputLine
), inputLine
);
530 lineContainer
.layout();
531 lineScrolledComposite
.setMinSize(lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
540 public void dispose() {
541 if (fixedFont
!= null) {
548 private void loadDefinition(CustomTxtTraceDefinition def
) {
549 categoryText
.setText(def
.categoryName
);
550 logtypeText
.setText(def
.definitionName
);
551 timestampOutputFormatText
.setText(def
.timeStampOutputFormat
);
552 treeViewer
.setInput(def
.inputs
);
553 if (def
.inputs
.size() > 0) {
554 InputLine inputLine
= def
.inputs
.get(0);
555 treeViewer
.setSelection(new StructuredSelection(inputLine
));
559 private String
getName(InputLine inputLine
) {
560 if (inputLine
.parentInput
== null) {
561 return Integer
.toString(definition
.inputs
.indexOf(inputLine
) + 1);
563 return getName(inputLine
.parentInput
) + "." + Integer
.toString(inputLine
.parentInput
.childrenInputs
.indexOf(inputLine
) + 1); //$NON-NLS-1$
567 * Get the global list of input names.
569 * @return The list of input names
571 public List
<String
> getInputNames() {
572 List
<String
> inputs
= new ArrayList
<>();
573 for (InputLine inputLine
: definition
.inputs
) {
574 for (String inputName
: getInputNames(inputLine
)) {
575 if (!inputs
.contains(inputName
)) {
576 inputs
.add(inputName
);
584 * Get the list of input names for the given input line.
588 * @return The list of input names
590 public List
<String
> getInputNames(InputLine inputLine
) {
591 List
<String
> inputs
= new ArrayList
<>();
592 if (inputLine
.columns
!= null) {
593 for (InputData inputData
: inputLine
.columns
) {
594 String inputName
= inputData
.name
;
595 if (!inputs
.contains(inputName
)) {
596 inputs
.add(inputName
);
600 if (inputLine
.childrenInputs
!= null) {
601 for (InputLine childInputLine
: inputLine
.childrenInputs
) {
602 for (String inputName
: getInputNames(childInputLine
)) {
603 if (!inputs
.contains(inputName
)) {
604 inputs
.add(inputName
);
612 private void removeLine() {
613 selectedLine
.dispose();
615 lineContainer
.layout();
616 lineScrolledComposite
.setMinSize(lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
620 private String
getSelectionText() {
621 if (this.selection
instanceof IStructuredSelection
) {
622 Object sel
= ((IStructuredSelection
) this.selection
).getFirstElement();
623 if (sel
instanceof IFile
) {
624 IFile file
= (IFile
) sel
;
625 BufferedReader reader
= null;
627 reader
= new BufferedReader(new InputStreamReader(file
.getContents()));
628 StringBuilder sb
= new StringBuilder();
630 while ((line
= reader
.readLine()) != null) {
631 sb
.append(line
+ "\n"); //$NON-NLS-1$
633 return sb
.toString();
634 } catch (CoreException e
) {
635 return ""; //$NON-NLS-1$
636 } catch (IOException e
) {
637 return ""; //$NON-NLS-1$
639 if (reader
!= null) {
642 } catch (IOException e
) {
648 return ""; //$NON-NLS-1$
651 private void updatePreviews() {
652 updatePreviews(false);
655 private void updatePreviews(boolean updateAll
) {
656 if (inputText
== null) {
657 // early update during construction
660 inputText
.setStyleRanges(new StyleRange
[] {});
662 try (Scanner scanner
= new Scanner(inputText
.getText());) {
663 scanner
.useDelimiter("\n"); //$NON-NLS-1$
666 // skip starting delimiters
667 String skip
= scanner
.findWithinHorizon("\\A\n+", 0); //$NON-NLS-1$
669 rawPos
+= skip
.length();
672 timeStampFormat
= null;
673 if (selectedLine
!= null) {
674 for (InputGroup input
: selectedLine
.inputs
) {
675 input
.previewText
.setText(Messages
.CustomTxtParserInputWizardPage_noMathcingLine
);
679 Map
<String
, String
> data
= new HashMap
<>();
680 int rootLineMatches
= 0;
681 String firstEntryTimeStamp
= null;
682 String firstEntryTimeStampInputFormat
= null;
684 boolean lineIsNull
= true; // needed because of JDT bug with continue at label
685 event
: while (scanner
.hasNext() || !lineIsNull
) {
686 if (rootLineMatches
> 0 && !updateAll
) {
690 line
= scanner
.next();
693 int length
= line
.length();
694 String log
= line
.replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
695 for (InputLine rootInputLine
: definition
.inputs
) {
698 pattern
= rootInputLine
.getPattern();
699 } catch (PatternSyntaxException e
) {
702 Matcher matcher
= pattern
.matcher(log
);
703 if (matcher
.matches()) {
705 inputText
.setStyleRange(new StyleRange(rawPos
, length
,
706 COLOR_BLACK
, COLOR_YELLOW
, SWT
.ITALIC
));
707 data
= new HashMap
<>();
708 timeStampFormat
= null;
709 updatePreviewLine(rootInputLine
, matcher
, data
, rawPos
, rootLineMatches
);
710 if (rootLineMatches
== 1) {
711 firstEntryTimeStamp
= data
.get(CustomTraceDefinition
.TAG_TIMESTAMP
);
712 firstEntryTimeStampInputFormat
= timeStampFormat
;
714 HashMap
<InputLine
, Integer
> countMap
= new HashMap
<>();
715 InputLine currentInput
= null;
716 if (rootInputLine
.childrenInputs
!= null && rootInputLine
.childrenInputs
.size() > 0) {
717 currentInput
= rootInputLine
.childrenInputs
.get(0);
718 countMap
.put(currentInput
, 0);
720 rawPos
+= length
+ 1; // +1 for \n
721 while (scanner
.hasNext()) {
722 line
= scanner
.next();
723 length
= line
.length();
724 log
= line
.replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
725 boolean processed
= false;
726 if (currentInput
== null) {
727 for (InputLine input
: definition
.inputs
) {
729 matcher
= input
.getPattern().matcher(log
);
730 } catch (PatternSyntaxException e
) {
733 if (matcher
.matches()) {
738 if (checkNotNull(countMap
.get(currentInput
)) >= currentInput
.getMinCount()) {
739 List
<InputLine
> nextInputs
= currentInput
.getNextInputs(countMap
);
740 if (nextInputs
.size() == 0 || nextInputs
.get(nextInputs
.size() - 1).getMinCount() == 0) {
741 for (InputLine input
: definition
.inputs
) {
743 matcher
= input
.getPattern().matcher(log
);
744 } catch (PatternSyntaxException e
) {
747 if (matcher
.matches()) {
752 for (InputLine input
: nextInputs
) {
754 matcher
= input
.getPattern().matcher(log
);
755 } catch (PatternSyntaxException e
) {
758 if (matcher
.matches()) {
759 inputText
.setStyleRange(new StyleRange(rawPos
, length
,
760 COLOR_BLACK
, COLOR_LIGHT_YELLOW
, SWT
.ITALIC
));
761 currentInput
= input
;
762 updatePreviewLine(currentInput
, matcher
, data
, rawPos
, rootLineMatches
);
763 if (countMap
.get(currentInput
) == null) {
764 countMap
.put(currentInput
, 1);
766 countMap
.put(currentInput
, checkNotNull(countMap
.get(currentInput
)) + 1);
768 Iterator
<InputLine
> iter
= countMap
.keySet().iterator();
769 while (iter
.hasNext()) {
770 InputLine inputLine
= iter
.next();
771 if (inputLine
.level
> currentInput
.level
) {
775 if (currentInput
.childrenInputs
!= null && currentInput
.childrenInputs
.size() > 0) {
776 currentInput
= currentInput
.childrenInputs
.get(0);
777 countMap
.put(currentInput
, 0);
779 if (checkNotNull(countMap
.get(currentInput
)) >= currentInput
.getMaxCount()) {
780 if (currentInput
.getNextInputs(countMap
).size() > 0) {
781 currentInput
= currentInput
.getNextInputs(countMap
).get(0);
782 if (countMap
.get(currentInput
) == null) {
783 countMap
.put(currentInput
, 0);
785 iter
= countMap
.keySet().iterator();
786 while (iter
.hasNext()) {
787 InputLine inputLine
= iter
.next();
788 if (inputLine
.level
> currentInput
.level
) {
802 if (!processed
&& currentInput
!= null) {
805 matcher
= currentInput
.getPattern().matcher(log
);
806 } catch (PatternSyntaxException e
) {
808 if (matcher
!= null && matcher
.matches()) {
809 inputText
.setStyleRange(new StyleRange(rawPos
, length
,
810 COLOR_BLACK
, COLOR_LIGHT_YELLOW
, SWT
.ITALIC
));
811 updatePreviewLine(currentInput
, matcher
, data
, rawPos
, rootLineMatches
);
812 countMap
.put(currentInput
, checkNotNull(countMap
.get(currentInput
)) + 1);
813 if (currentInput
.childrenInputs
!= null && currentInput
.childrenInputs
.size() > 0) {
814 currentInput
= currentInput
.childrenInputs
.get(0);
815 countMap
.put(currentInput
, 0);
817 if (checkNotNull(countMap
.get(currentInput
)) >= currentInput
.getMaxCount()) {
818 if (currentInput
.getNextInputs(countMap
).size() > 0) {
819 currentInput
= currentInput
.getNextInputs(countMap
).get(0);
820 if (countMap
.get(currentInput
) == null) {
821 countMap
.put(currentInput
, 0);
823 Iterator
<InputLine
> iter
= countMap
.keySet().iterator();
824 while (iter
.hasNext()) {
825 InputLine inputLine
= iter
.next();
826 if (inputLine
.level
> currentInput
.level
) {
838 rawPos
+= length
+ 1; // +1 for \n
844 rawPos
+= length
+ 1; // +1 for \n
849 if (rootLineMatches
== 1) {
850 firstEntryTimeStamp
= data
.get(CustomTraceDefinition
.TAG_TIMESTAMP
);
851 firstEntryTimeStampInputFormat
= timeStampFormat
;
853 if (firstEntryTimeStamp
== null) {
854 timestampPreviewText
.setText(Messages
.CustomTxtParserInputWizardPage_noTimestampGroup
);
855 if (selectedLine
!= null) {
856 for (InputGroup group
: selectedLine
.inputs
) {
857 if (group
.tagCombo
.getText().equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
858 timestampPreviewText
.setText(Messages
.CustomTxtParserInputWizardPage_noMatchingTimestamp
);
865 TmfTimestampFormat timestampFormat
= new TmfTimestampFormat(firstEntryTimeStampInputFormat
);
866 long timestamp
= timestampFormat
.parseValue(firstEntryTimeStamp
);
867 timestampFormat
= new TmfTimestampFormat(timestampOutputFormatText
.getText().trim());
868 timestampPreviewText
.setText(timestampFormat
.format(timestamp
));
869 } catch (ParseException e
) {
870 timestampPreviewText
.setText("*parse exception* [" + firstEntryTimeStamp
+ "] <> [" + firstEntryTimeStampInputFormat
+ "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
871 } catch (IllegalArgumentException e
) {
872 timestampPreviewText
.setText("*parse exception* [Illegal Argument: " + e
.getMessage() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
879 private void updatePreviewLine(InputLine line
, Matcher matcher
, Map
<String
, String
> data
, int rawPos
, int rootLineMatches
) {
880 for (int i
= 0; i
< line
.columns
.size(); i
++) {
881 InputData input
= line
.columns
.get(i
);
882 if (i
< matcher
.groupCount() && matcher
.group(i
+ 1) != null) {
883 if (line
.parentInput
== null) {
884 inputText
.setStyleRange(new StyleRange(rawPos
+ matcher
.start(i
+ 1), matcher
.end(i
+ 1) - matcher
.start(i
+ 1),
885 COLOR_BLACK
, COLOR_GREEN
, SWT
.BOLD
));
887 inputText
.setStyleRange(new StyleRange(rawPos
+ matcher
.start(i
+ 1), matcher
.end(i
+ 1) - matcher
.start(i
+ 1),
888 COLOR_BLACK
, COLOR_LIGHT_GREEN
, SWT
.BOLD
));
890 String value
= matcher
.group(i
+ 1).trim();
891 if (selectedLine
!= null && selectedLine
.inputLine
.equals(line
) && rootLineMatches
== 1 &&
892 selectedLine
.inputs
.get(i
).previewText
.getText().equals(Messages
.CustomTxtParserInputWizardPage_noMatchingLine
)) {
893 selectedLine
.inputs
.get(i
).previewText
.setText(value
);
895 if (value
.length() == 0) {
898 if (input
.action
== CustomTraceDefinition
.ACTION_SET
) {
899 data
.put(input
.name
, value
);
900 if (input
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
901 timeStampFormat
= input
.format
;
903 } else if (input
.action
== CustomTraceDefinition
.ACTION_APPEND
) {
904 String s
= data
.get(input
.name
);
906 data
.put(input
.name
, s
+ value
);
908 data
.put(input
.name
, value
);
910 if (input
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
911 if (timeStampFormat
!= null) {
912 timeStampFormat
+= input
.format
;
914 timeStampFormat
= input
.format
;
917 } else if (input
.action
== CustomTraceDefinition
.ACTION_APPEND_WITH_SEPARATOR
) {
918 String s
= data
.get(input
.name
);
920 data
.put(input
.name
, s
+ " | " + value
); //$NON-NLS-1$
922 data
.put(input
.name
, value
);
924 if (input
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
925 if (timeStampFormat
!= null) {
926 timeStampFormat
+= " | " + input
.format
; //$NON-NLS-1$
928 timeStampFormat
= input
.format
;
933 if (selectedLine
!= null && selectedLine
.inputLine
.equals(line
) && rootLineMatches
== 1) {
934 if (selectedLine
.inputs
.get(i
).previewText
.getText().equals(Messages
.CustomTxtParserInputWizardPage_noMatchingLine
)) {
935 selectedLine
.inputs
.get(i
).previewText
.setText(Messages
.CustomTxtParserInputWizardPage_noMatchingGroup
);
940 // highlight the matching groups that have no corresponponding input
941 for (int i
= line
.columns
.size(); i
< matcher
.groupCount(); i
++) {
942 if (matcher
.group(i
+ 1) != null) {
943 if (line
.parentInput
== null) {
944 inputText
.setStyleRange(new StyleRange(rawPos
+ matcher
.start(i
+ 1), matcher
.end(i
+ 1) - matcher
.start(i
+ 1),
945 COLOR_BLACK
, COLOR_MAGENTA
));
947 inputText
.setStyleRange(new StyleRange(rawPos
+ matcher
.start(i
+ 1), matcher
.end(i
+ 1) - matcher
.start(i
+ 1),
948 COLOR_BLACK
, COLOR_LIGHT_MAGENTA
));
954 private void openHelpShell(String url
) {
955 if (helpBrowser
!= null && !helpBrowser
.isDisposed()) {
956 helpBrowser
.getShell().setActive();
957 if (!helpBrowser
.getUrl().equals(url
)) {
958 helpBrowser
.setUrl(url
);
962 final Shell helpShell
= new Shell(getShell(), SWT
.SHELL_TRIM
);
963 helpShell
.setLayout(new FillLayout());
964 helpBrowser
= new Browser(helpShell
, SWT
.NONE
);
965 helpBrowser
.addTitleListener(new TitleListener() {
967 public void changed(TitleEvent event
) {
968 helpShell
.setText(event
.title
);
971 Rectangle r
= container
.getBounds();
972 Point p
= container
.toDisplay(r
.x
, r
.y
);
973 Rectangle trim
= helpShell
.computeTrim(p
.x
+ (r
.width
- 750) / 2, p
.y
+ (r
.height
- 400) / 2, 750, 400);
974 helpShell
.setBounds(trim
);
976 helpBrowser
.setUrl(url
);
979 private void openLegend() {
980 final String cg
= Messages
.CustomTxtParserInputWizardPage_capturedGroup
;
981 final String ucg
= Messages
.CustomTxtParserInputWizardPage_unidentifiedCaptureGroup
;
982 final String ut
= Messages
.CustomTxtParserInputWizardPage_uncapturedText
;
984 String line1
= Messages
.CustomTxtParserInputWizardPage_nonMatchingLine
;
985 int line2start
= line1start
+ line1
.length();
986 String line2
= Messages
.CustomTxtParserInputWizardPage_matchingRootLine
+ ' ' + cg
+ ' ' + ucg
+ ' ' + ut
+ " \n"; //$NON-NLS-1$
987 int line3start
= line2start
+ line2
.length();
988 String line3
= Messages
.CustomTxtParserInputWizardPage_matchingOtherLine
+ ' ' + cg
+ ' ' + ucg
+ ' ' + ut
+ " \n"; //$NON-NLS-1$
989 int line4start
= line3start
+ line3
.length();
990 String line4
= Messages
.CustomTxtParserInputWizardPage_matchingOtherLine
+ ' ' + cg
+ ' ' + ucg
+ ' ' + ut
+ " \n"; //$NON-NLS-1$
991 int line5start
= line4start
+ line4
.length();
992 String line5
= Messages
.CustomTxtParserInputWizardPage_nonMatchingLine
;
993 int line6start
= line5start
+ line5
.length();
994 String line6
= Messages
.CustomTxtParserInputWizardPage_matchingRootLine
+ cg
+ ' ' + ucg
+ ' ' + ut
+ " \n"; //$NON-NLS-1$
996 final Shell legendShell
= new Shell(getShell(), SWT
.DIALOG_TRIM
);
997 legendShell
.setLayout(new FillLayout());
998 StyledText legendText
= new StyledText(legendShell
, SWT
.MULTI
);
999 legendText
.setFont(fixedFont
);
1000 legendText
.setText(line1
+ line2
+ line3
+ line4
+ line5
+ line6
);
1001 legendText
.setStyleRange(new StyleRange(line2start
, line2
.length(), COLOR_BLACK
, COLOR_YELLOW
, SWT
.ITALIC
));
1002 legendText
.setStyleRange(new StyleRange(line3start
, line3
.length(), COLOR_BLACK
, COLOR_LIGHT_YELLOW
, SWT
.ITALIC
));
1003 legendText
.setStyleRange(new StyleRange(line4start
, line4
.length(), COLOR_BLACK
, COLOR_LIGHT_YELLOW
, SWT
.ITALIC
));
1004 legendText
.setStyleRange(new StyleRange(line6start
, line6
.length(), COLOR_BLACK
, COLOR_YELLOW
, SWT
.ITALIC
));
1005 legendText
.setStyleRange(new StyleRange(line2start
+ line2
.indexOf(cg
), cg
.length(), COLOR_BLACK
, COLOR_GREEN
, SWT
.BOLD
));
1006 legendText
.setStyleRange(new StyleRange(line2start
+ line2
.indexOf(ucg
), ucg
.length(), COLOR_BLACK
, COLOR_MAGENTA
));
1007 legendText
.setStyleRange(new StyleRange(line3start
+ line3
.indexOf(cg
), cg
.length(), COLOR_BLACK
, COLOR_LIGHT_GREEN
, SWT
.BOLD
));
1008 legendText
.setStyleRange(new StyleRange(line3start
+ line3
.indexOf(ucg
), ucg
.length(), COLOR_BLACK
, COLOR_LIGHT_MAGENTA
));
1009 legendText
.setStyleRange(new StyleRange(line4start
+ line4
.indexOf(cg
), cg
.length(), COLOR_BLACK
, COLOR_LIGHT_GREEN
, SWT
.BOLD
));
1010 legendText
.setStyleRange(new StyleRange(line4start
+ line4
.indexOf(ucg
), ucg
.length(), COLOR_BLACK
, COLOR_LIGHT_MAGENTA
));
1011 legendText
.setStyleRange(new StyleRange(line6start
+ line6
.indexOf(cg
), cg
.length(), COLOR_BLACK
, COLOR_GREEN
, SWT
.BOLD
));
1012 legendText
.setStyleRange(new StyleRange(line6start
+ line6
.indexOf(ucg
), ucg
.length(), COLOR_BLACK
, COLOR_MAGENTA
));
1013 legendShell
.setText(Messages
.CustomTxtParserInputWizardPage_previewLegend
);
1018 private class UpdateListener
implements ModifyListener
, SelectionListener
{
1021 public void modifyText(ModifyEvent e
) {
1027 public void widgetDefaultSelected(SelectionEvent e
) {
1033 public void widgetSelected(SelectionEvent e
) {
1040 private class Line
{
1041 private static final String INFINITY_STRING
= "\u221E"; //$NON-NLS-1$
1042 private InputLine inputLine
;
1043 private Group group
;
1044 private Composite labelComposite
;
1045 private Text regexText
;
1046 private Composite cardinalityContainer
;
1047 private Combo cardinalityCombo
;
1048 private Label cardinalityMinLabel
;
1049 private Text cardinalityMinText
;
1050 private Label cardinalityMaxLabel
;
1051 private Text cardinalityMaxText
;
1052 private Button infiniteButton
;
1053 private List
<InputGroup
> inputs
= new ArrayList
<>();
1054 private Button addGroupButton
;
1055 private Label addGroupLabel
;
1057 public Line(Composite parent
, String name
, InputLine inputLine
) {
1058 this.inputLine
= inputLine
;
1060 group
= new Group(parent
, SWT
.NONE
);
1061 group
.setText(name
);
1062 group
.setLayout(new GridLayout(2, false));
1063 group
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1065 labelComposite
= new Composite(group
, SWT
.FILL
);
1066 GridLayout labelLayout
= new GridLayout(1, false);
1067 labelLayout
.marginWidth
= 0;
1068 labelLayout
.marginHeight
= 0;
1069 labelComposite
.setLayout(labelLayout
);
1070 labelComposite
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1072 Label label
= new Label(labelComposite
, SWT
.NULL
);
1073 label
.setText(Messages
.CustomTxtParserInputWizardPage_regularExpression
);
1075 Composite regexContainer
= new Composite(group
, SWT
.NONE
);
1076 GridLayout regexLayout
= new GridLayout(2, false);
1077 regexLayout
.marginHeight
= 0;
1078 regexLayout
.marginWidth
= 0;
1079 regexContainer
.setLayout(regexLayout
);
1080 regexContainer
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1082 regexText
= new Text(regexContainer
, SWT
.BORDER
| SWT
.SINGLE
);
1083 GridData gd
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
1085 regexText
.setLayoutData(gd
);
1086 regexText
.setText(inputLine
.getRegex());
1087 regexText
.addModifyListener(updateListener
);
1089 Button regexHelpButton
= new Button(regexContainer
, SWT
.PUSH
);
1090 regexHelpButton
.setImage(HELP_IMAGE
);
1091 regexHelpButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_regularExpressionHelp
);
1092 regexHelpButton
.addSelectionListener(new SelectionAdapter() {
1094 public void widgetSelected(SelectionEvent e
) {
1095 openHelpShell(PATTERN_URL
);
1099 label
= new Label(group
, SWT
.NONE
);
1100 label
.setText(Messages
.CustomTxtParserInputWizardPage_cardinality
);
1101 label
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1103 cardinalityContainer
= new Composite(group
, SWT
.NONE
);
1104 GridLayout cardinalityLayout
= new GridLayout(6, false);
1105 cardinalityLayout
.marginHeight
= 0;
1106 cardinalityLayout
.marginWidth
= 0;
1107 cardinalityContainer
.setLayout(cardinalityLayout
);
1108 cardinalityContainer
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1110 cardinalityCombo
= new Combo(cardinalityContainer
, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
1111 cardinalityCombo
.setItems(new String
[] {
1112 Cardinality
.ZERO_OR_MORE
.toString(),
1113 Cardinality
.ONE_OR_MORE
.toString(),
1114 Cardinality
.ZERO_OR_ONE
.toString(),
1115 Cardinality
.ONE
.toString(), "(?,?)" }); //$NON-NLS-1$
1116 cardinalityCombo
.addSelectionListener(new SelectionListener() {
1118 public void widgetDefaultSelected(SelectionEvent e
) {
1122 public void widgetSelected(SelectionEvent e
) {
1123 switch (cardinalityCombo
.getSelectionIndex()) {
1125 cardinalityMinLabel
.setVisible(true);
1126 cardinalityMinText
.setVisible(true);
1127 cardinalityMaxLabel
.setVisible(true);
1128 cardinalityMaxText
.setVisible(true);
1129 infiniteButton
.setVisible(true);
1132 cardinalityMinLabel
.setVisible(false);
1133 cardinalityMinText
.setVisible(false);
1134 cardinalityMaxLabel
.setVisible(false);
1135 cardinalityMaxText
.setVisible(false);
1136 infiniteButton
.setVisible(false);
1139 cardinalityContainer
.layout();
1145 cardinalityMinLabel
= new Label(cardinalityContainer
, SWT
.NONE
);
1146 cardinalityMinLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1147 cardinalityMinLabel
.setText(Messages
.CustomTxtParserInputWizardPage_min
);
1148 cardinalityMinLabel
.setVisible(false);
1150 cardinalityMinText
= new Text(cardinalityContainer
, SWT
.BORDER
| SWT
.SINGLE
);
1151 gd
= new GridData(SWT
.CENTER
, SWT
.CENTER
, false, false);
1153 cardinalityMinText
.setLayoutData(gd
);
1154 cardinalityMinText
.setVisible(false);
1156 cardinalityMaxLabel
= new Label(cardinalityContainer
, SWT
.NONE
);
1157 cardinalityMaxLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1158 cardinalityMaxLabel
.setText(Messages
.CustomTxtParserInputWizardPage_max
);
1159 cardinalityMaxLabel
.setVisible(false);
1161 cardinalityMaxText
= new Text(cardinalityContainer
, SWT
.BORDER
| SWT
.SINGLE
);
1162 gd
= new GridData(SWT
.CENTER
, SWT
.CENTER
, false, false);
1164 cardinalityMaxText
.setLayoutData(gd
);
1165 cardinalityMaxText
.setVisible(false);
1167 infiniteButton
= new Button(cardinalityContainer
, SWT
.PUSH
);
1168 infiniteButton
.setText(INFINITY_STRING
);
1169 infiniteButton
.setVisible(false);
1170 infiniteButton
.addSelectionListener(new SelectionAdapter() {
1172 public void widgetSelected(SelectionEvent e
) {
1173 cardinalityMaxText
.setText(INFINITY_STRING
);
1177 if (inputLine
.cardinality
.equals(Cardinality
.ZERO_OR_MORE
)) {
1178 cardinalityCombo
.select(0);
1179 } else if (inputLine
.cardinality
.equals(Cardinality
.ONE_OR_MORE
)) {
1180 cardinalityCombo
.select(1);
1181 } else if (inputLine
.cardinality
.equals(Cardinality
.ZERO_OR_ONE
)) {
1182 cardinalityCombo
.select(2);
1183 } else if (inputLine
.cardinality
.equals(Cardinality
.ONE
)) {
1184 cardinalityCombo
.select(3);
1186 cardinalityCombo
.select(4);
1187 cardinalityMinLabel
.setVisible(true);
1188 cardinalityMinText
.setVisible(true);
1189 if (inputLine
.getMinCount() >= 0) {
1190 cardinalityMinText
.setText(Integer
.toString(inputLine
.getMinCount()));
1192 cardinalityMaxLabel
.setVisible(true);
1193 cardinalityMaxText
.setVisible(true);
1194 if (inputLine
.getMaxCount() == Cardinality
.INF
) {
1195 cardinalityMaxText
.setText(INFINITY_STRING
);
1196 } else if (inputLine
.getMaxCount() >= 0) {
1197 cardinalityMaxText
.setText(Integer
.toString(inputLine
.getMaxCount()));
1199 infiniteButton
.setVisible(true);
1202 VerifyListener digitsListener
= new VerifyListener() {
1204 public void verifyText(VerifyEvent e
) {
1205 if (e
.text
.equals(INFINITY_STRING
)) {
1206 e
.doit
= e
.widget
== cardinalityMaxText
&& e
.start
== 0 && e
.end
== ((Text
) e
.widget
).getText().length();
1208 if (((Text
) e
.widget
).getText().equals(INFINITY_STRING
)) {
1209 e
.doit
= e
.start
== 0 && e
.end
== ((Text
) e
.widget
).getText().length();
1211 for (int i
= 0; i
< e
.text
.length(); i
++) {
1212 if (!Character
.isDigit(e
.text
.charAt(i
))) {
1221 cardinalityMinText
.addModifyListener(updateListener
);
1222 cardinalityMaxText
.addModifyListener(updateListener
);
1223 cardinalityMinText
.addVerifyListener(digitsListener
);
1224 cardinalityMaxText
.addVerifyListener(digitsListener
);
1226 if (inputLine
.columns
!= null) {
1227 for (InputData inputData
: inputLine
.columns
) {
1228 InputGroup inputGroup
= new InputGroup(group
, this, inputs
.size() + 1);
1229 if (inputData
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1230 inputGroup
.tagCombo
.select(0);
1231 inputGroup
.tagText
.setText(inputData
.format
);
1232 inputGroup
.tagLabel
.setText(Messages
.CustomTxtParserInputWizardPage_format
);
1233 inputGroup
.tagLabel
.setVisible(true);
1234 inputGroup
.tagText
.setVisible(true);
1235 inputGroup
.tagText
.addModifyListener(updateListener
);
1236 } else if (inputData
.name
.equals(CustomTraceDefinition
.TAG_MESSAGE
)) {
1237 inputGroup
.tagCombo
.select(1);
1239 inputGroup
.tagCombo
.select(2);
1240 inputGroup
.tagText
.setText(inputData
.name
);
1241 inputGroup
.tagLabel
.setText(Messages
.CustomTxtParserInputWizardPage_name
);
1242 inputGroup
.tagLabel
.setVisible(true);
1243 inputGroup
.tagText
.setVisible(true);
1244 inputGroup
.tagText
.addModifyListener(updateListener
);
1246 inputGroup
.actionCombo
.select(inputData
.action
);
1247 inputs
.add(inputGroup
);
1251 createAddGroupButton();
1254 private void createAddGroupButton() {
1255 addGroupButton
= new Button(group
, SWT
.PUSH
);
1256 addGroupButton
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1257 addGroupButton
.setImage(ADD_IMAGE
);
1258 addGroupButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_addGroup
);
1259 addGroupButton
.addSelectionListener(new SelectionAdapter() {
1261 public void widgetSelected(SelectionEvent e
) {
1262 removeAddGroupButton();
1263 inputs
.add(new InputGroup(group
, Line
.this, inputs
.size() + 1));
1264 createAddGroupButton();
1265 lineContainer
.layout();
1266 lineScrolledComposite
.setMinSize(lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
1267 group
.getParent().layout();
1273 addGroupLabel
= new Label(group
, SWT
.NULL
);
1274 addGroupLabel
.setText(Messages
.CustomTxtParserInputWizardPage_newGroup
);
1277 private void removeAddGroupButton() {
1278 addGroupButton
.dispose();
1279 addGroupLabel
.dispose();
1282 private void removeInput(int inputNumber
) {
1283 int nb
= inputNumber
;
1284 if (--nb
< inputs
.size()) {
1285 inputs
.remove(nb
).dispose();
1286 for (int i
= nb
; i
< inputs
.size(); i
++) {
1287 inputs
.get(i
).setInputNumber(i
+ 1);
1289 lineContainer
.layout();
1290 lineScrolledComposite
.setMinSize(lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
1291 group
.getParent().layout();
1295 private void dispose() {
1299 private void extractInputs() {
1300 inputLine
.setRegex(selectedLine
.regexText
.getText());
1301 switch (cardinalityCombo
.getSelectionIndex()) {
1303 inputLine
.cardinality
= Cardinality
.ZERO_OR_MORE
;
1306 inputLine
.cardinality
= Cardinality
.ONE_OR_MORE
;
1309 inputLine
.cardinality
= Cardinality
.ZERO_OR_ONE
;
1312 inputLine
.cardinality
= Cardinality
.ONE
;
1318 min
= Integer
.parseInt(cardinalityMinText
.getText());
1319 } catch (NumberFormatException e
) {
1323 if (cardinalityMaxText
.getText().equals(INFINITY_STRING
)) {
1324 max
= Cardinality
.INF
;
1326 max
= Integer
.parseInt(cardinalityMaxText
.getText());
1328 } catch (NumberFormatException e
) {
1331 inputLine
.cardinality
= new Cardinality(min
, max
);
1334 inputLine
.cardinality
= Cardinality
.ZERO_OR_MORE
;
1337 inputLine
.columns
= new ArrayList
<>(inputs
.size());
1338 for (int i
= 0; i
< inputs
.size(); i
++) {
1339 InputGroup grp
= inputs
.get(i
);
1340 InputData inputData
= new InputData();
1341 if (grp
.tagCombo
.getText().equals(CustomTraceDefinition
.TAG_OTHER
)) {
1342 inputData
.name
= grp
.tagText
.getText().trim();
1344 inputData
.name
= grp
.tagCombo
.getText();
1345 if (grp
.tagCombo
.getText().equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1346 inputData
.format
= grp
.tagText
.getText().trim();
1349 inputData
.action
= grp
.actionCombo
.getSelectionIndex();
1350 inputLine
.columns
.add(inputData
);
1355 private class InputGroup
{
1357 private int inputNumber
;
1359 // children of parent (must be disposed)
1360 private Composite labelComposite
;
1361 private Composite tagComposite
;
1362 private Label previewLabel
;
1363 private Text previewText
;
1365 // children of labelComposite
1366 private Label inputLabel
;
1368 // children of tagComposite
1369 private Combo tagCombo
;
1370 private Label tagLabel
;
1371 private Text tagText
;
1372 private Combo actionCombo
;
1374 public InputGroup(Composite parent
, Line line
, int inputNumber
) {
1376 this.inputNumber
= inputNumber
;
1378 labelComposite
= new Composite(parent
, SWT
.FILL
);
1379 GridLayout labelLayout
= new GridLayout(2, false);
1380 labelLayout
.marginWidth
= 0;
1381 labelLayout
.marginHeight
= 0;
1382 labelComposite
.setLayout(labelLayout
);
1383 labelComposite
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1385 Button deleteButton
= new Button(labelComposite
, SWT
.PUSH
);
1386 deleteButton
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1387 deleteButton
.setImage(DELETE_IMAGE
);
1388 deleteButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_removeGroup
);
1389 deleteButton
.addSelectionListener(new SelectionAdapter() {
1391 public void widgetSelected(SelectionEvent e
) {
1392 InputGroup
.this.line
.removeInput(InputGroup
.this.inputNumber
);
1398 inputLabel
= new Label(labelComposite
, SWT
.NULL
);
1399 inputLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1400 inputLabel
.setText(NLS
.bind(Messages
.CustomTxtParserInputWizardPage_group
, inputNumber
));
1402 tagComposite
= new Composite(parent
, SWT
.FILL
);
1403 GridLayout tagLayout
= new GridLayout(4, false);
1404 tagLayout
.marginWidth
= 0;
1405 tagLayout
.marginHeight
= 0;
1406 tagComposite
.setLayout(tagLayout
);
1407 tagComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1409 tagCombo
= new Combo(tagComposite
, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
1410 tagCombo
.setItems(new String
[] { CustomTraceDefinition
.TAG_TIMESTAMP
,
1411 CustomTraceDefinition
.TAG_MESSAGE
,
1412 CustomTraceDefinition
.TAG_OTHER
});
1414 tagCombo
.addSelectionListener(new SelectionListener() {
1416 public void widgetDefaultSelected(SelectionEvent e
) {
1420 public void widgetSelected(SelectionEvent e
) {
1421 tagText
.removeModifyListener(updateListener
);
1422 switch (tagCombo
.getSelectionIndex()) {
1423 case 0: // Time Stamp
1424 tagLabel
.setText(Messages
.CustomTxtParserInputWizardPage_format
);
1425 tagLabel
.setVisible(true);
1426 tagText
.setVisible(true);
1427 tagText
.addModifyListener(updateListener
);
1430 tagLabel
.setVisible(false);
1431 tagText
.setVisible(false);
1434 tagLabel
.setText(Messages
.CustomTxtParserInputWizardPage_name
);
1435 tagLabel
.setVisible(true);
1436 tagText
.setVisible(true);
1437 tagText
.addModifyListener(updateListener
);
1440 tagLabel
.setVisible(false);
1441 tagText
.setVisible(false);
1446 tagComposite
.layout();
1452 tagLabel
= new Label(tagComposite
, SWT
.NULL
);
1453 tagLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1454 tagLabel
.setVisible(false);
1456 tagText
= new Text(tagComposite
, SWT
.BORDER
| SWT
.SINGLE
);
1457 GridData gd
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
1459 tagText
.setLayoutData(gd
);
1460 tagText
.setVisible(false);
1462 actionCombo
= new Combo(tagComposite
, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
1463 actionCombo
.setItems(new String
[] { Messages
.CustomTxtParserInputWizardPage_set
, Messages
.CustomTxtParserInputWizardPage_append
, Messages
.CustomTxtParserInputWizardPage_appendWith
});
1464 actionCombo
.select(0);
1465 actionCombo
.addSelectionListener(updateListener
);
1467 previewLabel
= new Label(parent
, SWT
.NULL
);
1468 previewLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1469 previewLabel
.setText(Messages
.CustomTxtParserInputWizardPage_preview
);
1471 previewText
= new Text(parent
, SWT
.BORDER
| SWT
.SINGLE
| SWT
.READ_ONLY
);
1472 gd
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
1474 previewText
.setLayoutData(gd
);
1475 previewText
.setText(Messages
.CustomTxtParserInputWizardPage_noMatch
);
1476 previewText
.setBackground(COLOR_WIDGET_BACKGROUND
);
1479 private void dispose() {
1480 labelComposite
.dispose();
1481 tagComposite
.dispose();
1482 previewLabel
.dispose();
1483 previewText
.dispose();
1486 private void setInputNumber(int inputNumber
) {
1487 this.inputNumber
= inputNumber
;
1488 inputLabel
.setText(NLS
.bind(Messages
.CustomTxtParserInputWizardPage_group
, inputNumber
));
1489 labelComposite
.layout();
1493 private void validate() {
1495 definition
.categoryName
= categoryText
.getText().trim();
1496 definition
.definitionName
= logtypeText
.getText().trim();
1497 definition
.timeStampOutputFormat
= timestampOutputFormatText
.getText().trim();
1499 if (selectedLine
!= null) {
1500 selectedLine
.extractInputs();
1501 treeViewer
.refresh();
1504 StringBuffer errors
= new StringBuffer();
1506 if (definition
.categoryName
.length() == 0) {
1507 errors
.append("Enter a category for the new trace type. "); //$NON-NLS-1$
1508 categoryText
.setBackground(COLOR_LIGHT_RED
);
1509 } else if (definition
.definitionName
.length() == 0) {
1510 errors
.append("Enter a name for the new trace type. "); //$NON-NLS-1$
1511 logtypeText
.setBackground(COLOR_LIGHT_RED
);
1513 categoryText
.setBackground(COLOR_TEXT_BACKGROUND
);
1514 logtypeText
.setBackground(COLOR_TEXT_BACKGROUND
);
1515 if (definition
.categoryName
.indexOf(':') != -1) {
1516 errors
.append("Invalid character ':' in category. "); //$NON-NLS-1$
1517 categoryText
.setBackground(COLOR_LIGHT_RED
);
1519 if (definition
.definitionName
.indexOf(':') != -1) {
1520 errors
.append("Invalid character ':' in trace type. "); //$NON-NLS-1$
1521 logtypeText
.setBackground(COLOR_LIGHT_RED
);
1523 for (TraceTypeHelper helper
: TmfTraceType
.getTraceTypeHelpers()) {
1524 if (definition
.categoryName
.equals(helper
.getCategoryName()) &&
1525 definition
.definitionName
.equals(helper
.getName()) &&
1526 (editDefinitionName
== null || !editDefinitionName
.equals(definition
.definitionName
)) &&
1527 (editCategoryName
== null || !editCategoryName
.equals(definition
.categoryName
))) {
1528 errors
.append("The trace type name already exists. "); //$NON-NLS-1$
1529 logtypeText
.setBackground(COLOR_LIGHT_RED
);
1535 timestampFound
= false;
1536 for (int i
= 0; i
< definition
.inputs
.size(); i
++) {
1538 InputLine inputLine
= definition
.inputs
.get(i
);
1539 String name
= Integer
.toString(i
+ 1);
1540 errors
.append(validateLine(inputLine
, name
));
1542 if (timestampFound
) {
1543 if (definition
.timeStampOutputFormat
.length() == 0) {
1544 errors
.append("Enter the output format for the Time Stamp field. "); //$NON-NLS-1$
1545 timestampOutputFormatText
.setBackground(COLOR_LIGHT_RED
);
1548 new TmfTimestampFormat(definition
.timeStampOutputFormat
);
1549 timestampOutputFormatText
.setBackground(COLOR_TEXT_BACKGROUND
);
1550 } catch (IllegalArgumentException e
) {
1551 errors
.append("Enter a valid output format for the Time Stamp field [" + e
.getMessage() + "]."); //$NON-NLS-1$ //$NON-NLS-2$
1552 timestampOutputFormatText
.setBackground(COLOR_LIGHT_RED
);
1557 timestampOutputFormatText
.setBackground(COLOR_TEXT_BACKGROUND
);
1560 if (errors
.length() == 0) {
1561 setDescription(defaultDescription
);
1562 setPageComplete(true);
1564 setDescription(errors
.toString());
1565 setPageComplete(false);
1570 * Validate an input line.
1573 * The line to clean up
1575 * The name of the line
1576 * @return The cleaned up line
1578 public StringBuffer
validateLine(InputLine inputLine
, String name
) {
1579 StringBuffer errors
= new StringBuffer();
1581 if (selectedLine
!= null && selectedLine
.inputLine
.equals(inputLine
)) {
1582 line
= selectedLine
;
1585 Pattern
.compile(inputLine
.getRegex());
1587 line
.regexText
.setBackground(COLOR_TEXT_BACKGROUND
);
1589 } catch (PatternSyntaxException e
) {
1590 errors
.append("Enter a valid regular expression (Line " + name
+ "). "); //$NON-NLS-1$ //$NON-NLS-2$
1592 line
.regexText
.setBackground(COLOR_LIGHT_RED
);
1595 if (inputLine
.getMinCount() == -1) {
1596 errors
.append("Enter a minimum value for cardinality (Line " + name
+ "). "); //$NON-NLS-1$ //$NON-NLS-2$
1598 line
.cardinalityMinText
.setBackground(COLOR_LIGHT_RED
);
1602 line
.cardinalityMinText
.setBackground(COLOR_TEXT_BACKGROUND
);
1605 if (inputLine
.getMaxCount() == -1) {
1606 errors
.append("Enter a maximum value for cardinality (Line " + name
+ "). "); //$NON-NLS-1$ //$NON-NLS-2$
1608 line
.cardinalityMaxText
.setBackground(COLOR_LIGHT_RED
);
1610 } else if (inputLine
.getMinCount() > inputLine
.getMaxCount()) {
1611 errors
.append("Enter correct (min <= max) values for cardinality (Line " + name
+ "). "); //$NON-NLS-1$ //$NON-NLS-2$
1613 line
.cardinalityMinText
.setBackground(COLOR_LIGHT_RED
);
1616 line
.cardinalityMaxText
.setBackground(COLOR_LIGHT_RED
);
1620 line
.cardinalityMaxText
.setBackground(COLOR_TEXT_BACKGROUND
);
1623 for (int i
= 0; inputLine
.columns
!= null && i
< inputLine
.columns
.size(); i
++) {
1624 InputData inputData
= inputLine
.columns
.get(i
);
1625 InputGroup group
= null;
1627 group
= line
.inputs
.get(i
);
1629 if (inputData
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1630 timestampFound
= true;
1631 if (inputData
.format
.length() == 0) {
1632 errors
.append("Enter the input format for the Time Stamp (Line " + name
+ " Group " + (i
+ 1) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1633 if (group
!= null) {
1634 group
.tagText
.setBackground(COLOR_LIGHT_RED
);
1638 new TmfTimestampFormat(inputData
.format
);
1639 if (group
!= null) {
1640 group
.tagText
.setBackground(COLOR_TEXT_BACKGROUND
);
1642 } catch (IllegalArgumentException e
) {
1643 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$
1644 if (group
!= null) {
1645 group
.tagText
.setBackground(COLOR_LIGHT_RED
);
1649 } else if (inputData
.name
.length() == 0) {
1650 errors
.append("Enter a name for the data group (Line " + name
+ " Group " + (i
+ 1) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1651 if (group
!= null) {
1652 group
.tagText
.setBackground(COLOR_LIGHT_RED
);
1655 if (group
!= null) {
1656 group
.tagText
.setBackground(COLOR_TEXT_BACKGROUND
);
1660 for (int i
= 0; inputLine
.childrenInputs
!= null && i
< inputLine
.childrenInputs
.size(); i
++) {
1661 errors
.append(validateLine(inputLine
.childrenInputs
.get(i
), name
+ "." + (i
+ 1))); //$NON-NLS-1$
1667 * Get the trace definition.
1669 * @return The trace definition
1671 public CustomTxtTraceDefinition
getDefinition() {
1676 * Get the raw text of the input.
1678 * @return The raw input text
1680 public char[] getInputText() {
1681 return inputText
.getText().toCharArray();