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/8/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) {
634 return sb
.toString();
635 } catch (CoreException e
) {
636 return ""; //$NON-NLS-1$
637 } catch (IOException e
) {
638 return ""; //$NON-NLS-1$
640 if (reader
!= null) {
643 } catch (IOException e
) {
649 return ""; //$NON-NLS-1$
652 private void updatePreviews() {
653 updatePreviews(false);
656 private void updatePreviews(boolean updateAll
) {
657 if (inputText
== null) {
658 // early update during construction
661 inputText
.setStyleRanges(new StyleRange
[] {});
663 try (Scanner scanner
= new Scanner(inputText
.getText());) {
664 scanner
.useDelimiter("\n"); //$NON-NLS-1$
667 // skip starting delimiters
668 String skip
= scanner
.findWithinHorizon("\\A\n+", 0); //$NON-NLS-1$
670 rawPos
+= skip
.length();
673 timeStampFormat
= null;
674 if (selectedLine
!= null) {
675 for (InputGroup input
: selectedLine
.inputs
) {
676 input
.previewText
.setText(Messages
.CustomTxtParserInputWizardPage_noMathcingLine
);
680 Map
<String
, String
> data
= new HashMap
<>();
681 int rootLineMatches
= 0;
682 String firstEntryTimeStamp
= null;
683 String firstEntryTimeStampInputFormat
= null;
685 boolean lineIsNull
= true; // needed because of JDT bug with continue at label
686 event
: while (scanner
.hasNext() || !lineIsNull
) {
687 if (rootLineMatches
> 0 && !updateAll
) {
691 line
= scanner
.next();
694 int length
= line
.length();
695 String log
= line
.replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
696 for (InputLine rootInputLine
: definition
.inputs
) {
699 pattern
= rootInputLine
.getPattern();
700 } catch (PatternSyntaxException e
) {
703 Matcher matcher
= pattern
.matcher(log
);
704 if (matcher
.matches()) {
706 inputText
.setStyleRange(new StyleRange(rawPos
, length
,
707 COLOR_BLACK
, COLOR_YELLOW
, SWT
.ITALIC
));
708 data
= new HashMap
<>();
709 timeStampFormat
= null;
710 updatePreviewLine(rootInputLine
, matcher
, data
, rawPos
, rootLineMatches
);
711 if (rootLineMatches
== 1) {
712 firstEntryTimeStamp
= data
.get(CustomTraceDefinition
.TAG_TIMESTAMP
);
713 firstEntryTimeStampInputFormat
= timeStampFormat
;
715 HashMap
<InputLine
, Integer
> countMap
= new HashMap
<>();
716 InputLine currentInput
= null;
717 if (rootInputLine
.childrenInputs
!= null && rootInputLine
.childrenInputs
.size() > 0) {
718 currentInput
= rootInputLine
.childrenInputs
.get(0);
719 countMap
.put(currentInput
, 0);
721 rawPos
+= length
+ 1; // +1 for \n
722 while (scanner
.hasNext()) {
723 line
= scanner
.next();
724 length
= line
.length();
725 log
= line
.replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
726 boolean processed
= false;
727 if (currentInput
== null) {
728 for (InputLine input
: definition
.inputs
) {
730 matcher
= input
.getPattern().matcher(log
);
731 } catch (PatternSyntaxException e
) {
734 if (matcher
.matches()) {
739 if (checkNotNull(countMap
.get(currentInput
)) >= currentInput
.getMinCount()) {
740 List
<InputLine
> nextInputs
= currentInput
.getNextInputs(countMap
);
741 if (nextInputs
.size() == 0 || nextInputs
.get(nextInputs
.size() - 1).getMinCount() == 0) {
742 for (InputLine input
: definition
.inputs
) {
744 matcher
= input
.getPattern().matcher(log
);
745 } catch (PatternSyntaxException e
) {
748 if (matcher
.matches()) {
753 for (InputLine input
: nextInputs
) {
755 matcher
= input
.getPattern().matcher(log
);
756 } catch (PatternSyntaxException e
) {
759 if (matcher
.matches()) {
760 inputText
.setStyleRange(new StyleRange(rawPos
, length
,
761 COLOR_BLACK
, COLOR_LIGHT_YELLOW
, SWT
.ITALIC
));
762 currentInput
= input
;
763 updatePreviewLine(currentInput
, matcher
, data
, rawPos
, rootLineMatches
);
764 if (countMap
.get(currentInput
) == null) {
765 countMap
.put(currentInput
, 1);
767 countMap
.put(currentInput
, checkNotNull(countMap
.get(currentInput
)) + 1);
769 Iterator
<InputLine
> iter
= countMap
.keySet().iterator();
770 while (iter
.hasNext()) {
771 InputLine inputLine
= iter
.next();
772 if (inputLine
.level
> currentInput
.level
) {
776 if (currentInput
.childrenInputs
!= null && currentInput
.childrenInputs
.size() > 0) {
777 currentInput
= currentInput
.childrenInputs
.get(0);
778 countMap
.put(currentInput
, 0);
780 if (checkNotNull(countMap
.get(currentInput
)) >= currentInput
.getMaxCount()) {
781 if (currentInput
.getNextInputs(countMap
).size() > 0) {
782 currentInput
= currentInput
.getNextInputs(countMap
).get(0);
783 if (countMap
.get(currentInput
) == null) {
784 countMap
.put(currentInput
, 0);
786 iter
= countMap
.keySet().iterator();
787 while (iter
.hasNext()) {
788 InputLine inputLine
= iter
.next();
789 if (inputLine
.level
> currentInput
.level
) {
803 if (!processed
&& currentInput
!= null) {
806 matcher
= currentInput
.getPattern().matcher(log
);
807 } catch (PatternSyntaxException e
) {
809 if (matcher
!= null && matcher
.matches()) {
810 inputText
.setStyleRange(new StyleRange(rawPos
, length
,
811 COLOR_BLACK
, COLOR_LIGHT_YELLOW
, SWT
.ITALIC
));
812 updatePreviewLine(currentInput
, matcher
, data
, rawPos
, rootLineMatches
);
813 countMap
.put(currentInput
, checkNotNull(countMap
.get(currentInput
)) + 1);
814 if (currentInput
.childrenInputs
!= null && currentInput
.childrenInputs
.size() > 0) {
815 currentInput
= currentInput
.childrenInputs
.get(0);
816 countMap
.put(currentInput
, 0);
818 if (checkNotNull(countMap
.get(currentInput
)) >= currentInput
.getMaxCount()) {
819 if (currentInput
.getNextInputs(countMap
).size() > 0) {
820 currentInput
= currentInput
.getNextInputs(countMap
).get(0);
821 if (countMap
.get(currentInput
) == null) {
822 countMap
.put(currentInput
, 0);
824 Iterator
<InputLine
> iter
= countMap
.keySet().iterator();
825 while (iter
.hasNext()) {
826 InputLine inputLine
= iter
.next();
827 if (inputLine
.level
> currentInput
.level
) {
839 rawPos
+= length
+ 1; // +1 for \n
845 rawPos
+= length
+ 1; // +1 for \n
850 if (rootLineMatches
== 1) {
851 firstEntryTimeStamp
= data
.get(CustomTraceDefinition
.TAG_TIMESTAMP
);
852 firstEntryTimeStampInputFormat
= timeStampFormat
;
854 if (firstEntryTimeStamp
== null) {
855 timestampPreviewText
.setText(Messages
.CustomTxtParserInputWizardPage_noTimestampGroup
);
856 if (selectedLine
!= null) {
857 for (InputGroup group
: selectedLine
.inputs
) {
858 if (group
.tagCombo
.getText().equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
859 timestampPreviewText
.setText(Messages
.CustomTxtParserInputWizardPage_noMatchingTimestamp
);
866 TmfTimestampFormat timestampFormat
= new TmfTimestampFormat(firstEntryTimeStampInputFormat
);
867 long timestamp
= timestampFormat
.parseValue(firstEntryTimeStamp
);
868 timestampFormat
= new TmfTimestampFormat(timestampOutputFormatText
.getText().trim());
869 timestampPreviewText
.setText(timestampFormat
.format(timestamp
));
870 } catch (ParseException e
) {
871 timestampPreviewText
.setText("*parse exception* [" + firstEntryTimeStamp
+ "] <> [" + firstEntryTimeStampInputFormat
+ "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
872 } catch (IllegalArgumentException e
) {
873 timestampPreviewText
.setText("*parse exception* [Illegal Argument: " + e
.getMessage() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
880 private void updatePreviewLine(InputLine line
, Matcher matcher
, Map
<String
, String
> data
, int rawPos
, int rootLineMatches
) {
881 for (int i
= 0; i
< line
.columns
.size(); i
++) {
882 InputData input
= line
.columns
.get(i
);
883 if (i
< matcher
.groupCount() && matcher
.group(i
+ 1) != null) {
884 if (line
.parentInput
== null) {
885 inputText
.setStyleRange(new StyleRange(rawPos
+ matcher
.start(i
+ 1), matcher
.end(i
+ 1) - matcher
.start(i
+ 1),
886 COLOR_BLACK
, COLOR_GREEN
, SWT
.BOLD
));
888 inputText
.setStyleRange(new StyleRange(rawPos
+ matcher
.start(i
+ 1), matcher
.end(i
+ 1) - matcher
.start(i
+ 1),
889 COLOR_BLACK
, COLOR_LIGHT_GREEN
, SWT
.BOLD
));
891 String value
= matcher
.group(i
+ 1).trim();
892 if (selectedLine
!= null && selectedLine
.inputLine
.equals(line
) && rootLineMatches
== 1 &&
893 selectedLine
.inputs
.get(i
).previewText
.getText().equals(Messages
.CustomTxtParserInputWizardPage_noMatchingLine
)) {
894 selectedLine
.inputs
.get(i
).previewText
.setText(value
);
896 if (value
.length() == 0) {
899 if (input
.action
== CustomTraceDefinition
.ACTION_SET
) {
900 data
.put(input
.name
, value
);
901 if (input
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
902 timeStampFormat
= input
.format
;
904 } else if (input
.action
== CustomTraceDefinition
.ACTION_APPEND
) {
905 String s
= data
.get(input
.name
);
907 data
.put(input
.name
, s
+ value
);
909 data
.put(input
.name
, value
);
911 if (input
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
912 if (timeStampFormat
!= null) {
913 timeStampFormat
+= input
.format
;
915 timeStampFormat
= input
.format
;
918 } else if (input
.action
== CustomTraceDefinition
.ACTION_APPEND_WITH_SEPARATOR
) {
919 String s
= data
.get(input
.name
);
921 data
.put(input
.name
, s
+ " | " + value
); //$NON-NLS-1$
923 data
.put(input
.name
, value
);
925 if (input
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
926 if (timeStampFormat
!= null) {
927 timeStampFormat
+= " | " + input
.format
; //$NON-NLS-1$
929 timeStampFormat
= input
.format
;
934 if (selectedLine
!= null && selectedLine
.inputLine
.equals(line
) && rootLineMatches
== 1) {
935 if (selectedLine
.inputs
.get(i
).previewText
.getText().equals(Messages
.CustomTxtParserInputWizardPage_noMatchingLine
)) {
936 selectedLine
.inputs
.get(i
).previewText
.setText(Messages
.CustomTxtParserInputWizardPage_noMatchingGroup
);
941 // highlight the matching groups that have no corresponponding input
942 for (int i
= line
.columns
.size(); i
< matcher
.groupCount(); i
++) {
943 if (matcher
.group(i
+ 1) != null) {
944 if (line
.parentInput
== null) {
945 inputText
.setStyleRange(new StyleRange(rawPos
+ matcher
.start(i
+ 1), matcher
.end(i
+ 1) - matcher
.start(i
+ 1),
946 COLOR_BLACK
, COLOR_MAGENTA
));
948 inputText
.setStyleRange(new StyleRange(rawPos
+ matcher
.start(i
+ 1), matcher
.end(i
+ 1) - matcher
.start(i
+ 1),
949 COLOR_BLACK
, COLOR_LIGHT_MAGENTA
));
955 private void openHelpShell(String url
) {
956 if (helpBrowser
!= null && !helpBrowser
.isDisposed()) {
957 helpBrowser
.getShell().setActive();
958 if (!helpBrowser
.getUrl().equals(url
)) {
959 helpBrowser
.setUrl(url
);
963 final Shell helpShell
= new Shell(getShell(), SWT
.SHELL_TRIM
);
964 helpShell
.setLayout(new FillLayout());
965 helpBrowser
= new Browser(helpShell
, SWT
.NONE
);
966 helpBrowser
.addTitleListener(new TitleListener() {
968 public void changed(TitleEvent event
) {
969 helpShell
.setText(event
.title
);
972 Rectangle r
= container
.getBounds();
973 Point p
= container
.toDisplay(r
.x
, r
.y
);
974 Rectangle trim
= helpShell
.computeTrim(p
.x
+ (r
.width
- 750) / 2, p
.y
+ (r
.height
- 400) / 2, 750, 400);
975 helpShell
.setBounds(trim
);
977 helpBrowser
.setUrl(url
);
980 private void openLegend() {
981 final String cg
= Messages
.CustomTxtParserInputWizardPage_capturedGroup
;
982 final String ucg
= Messages
.CustomTxtParserInputWizardPage_unidentifiedCaptureGroup
;
983 final String ut
= Messages
.CustomTxtParserInputWizardPage_uncapturedText
;
985 String line1
= Messages
.CustomTxtParserInputWizardPage_nonMatchingLine
;
986 int line2start
= line1start
+ line1
.length();
987 String line2
= Messages
.CustomTxtParserInputWizardPage_matchingRootLine
+ ' ' + cg
+ ' ' + ucg
+ ' ' + ut
+ " \n"; //$NON-NLS-1$
988 int line3start
= line2start
+ line2
.length();
989 String line3
= Messages
.CustomTxtParserInputWizardPage_matchingOtherLine
+ ' ' + cg
+ ' ' + ucg
+ ' ' + ut
+ " \n"; //$NON-NLS-1$
990 int line4start
= line3start
+ line3
.length();
991 String line4
= Messages
.CustomTxtParserInputWizardPage_matchingOtherLine
+ ' ' + cg
+ ' ' + ucg
+ ' ' + ut
+ " \n"; //$NON-NLS-1$
992 int line5start
= line4start
+ line4
.length();
993 String line5
= Messages
.CustomTxtParserInputWizardPage_nonMatchingLine
;
994 int line6start
= line5start
+ line5
.length();
995 String line6
= Messages
.CustomTxtParserInputWizardPage_matchingRootLine
+ cg
+ ' ' + ucg
+ ' ' + ut
+ " \n"; //$NON-NLS-1$
997 final Shell legendShell
= new Shell(getShell(), SWT
.DIALOG_TRIM
);
998 legendShell
.setLayout(new FillLayout());
999 StyledText legendText
= new StyledText(legendShell
, SWT
.MULTI
);
1000 legendText
.setFont(fixedFont
);
1001 legendText
.setText(line1
+ line2
+ line3
+ line4
+ line5
+ line6
);
1002 legendText
.setStyleRange(new StyleRange(line2start
, line2
.length(), COLOR_BLACK
, COLOR_YELLOW
, SWT
.ITALIC
));
1003 legendText
.setStyleRange(new StyleRange(line3start
, line3
.length(), COLOR_BLACK
, COLOR_LIGHT_YELLOW
, SWT
.ITALIC
));
1004 legendText
.setStyleRange(new StyleRange(line4start
, line4
.length(), COLOR_BLACK
, COLOR_LIGHT_YELLOW
, SWT
.ITALIC
));
1005 legendText
.setStyleRange(new StyleRange(line6start
, line6
.length(), COLOR_BLACK
, COLOR_YELLOW
, SWT
.ITALIC
));
1006 legendText
.setStyleRange(new StyleRange(line2start
+ line2
.indexOf(cg
), cg
.length(), COLOR_BLACK
, COLOR_GREEN
, SWT
.BOLD
));
1007 legendText
.setStyleRange(new StyleRange(line2start
+ line2
.indexOf(ucg
), ucg
.length(), COLOR_BLACK
, COLOR_MAGENTA
));
1008 legendText
.setStyleRange(new StyleRange(line3start
+ line3
.indexOf(cg
), cg
.length(), COLOR_BLACK
, COLOR_LIGHT_GREEN
, SWT
.BOLD
));
1009 legendText
.setStyleRange(new StyleRange(line3start
+ line3
.indexOf(ucg
), ucg
.length(), COLOR_BLACK
, COLOR_LIGHT_MAGENTA
));
1010 legendText
.setStyleRange(new StyleRange(line4start
+ line4
.indexOf(cg
), cg
.length(), COLOR_BLACK
, COLOR_LIGHT_GREEN
, SWT
.BOLD
));
1011 legendText
.setStyleRange(new StyleRange(line4start
+ line4
.indexOf(ucg
), ucg
.length(), COLOR_BLACK
, COLOR_LIGHT_MAGENTA
));
1012 legendText
.setStyleRange(new StyleRange(line6start
+ line6
.indexOf(cg
), cg
.length(), COLOR_BLACK
, COLOR_GREEN
, SWT
.BOLD
));
1013 legendText
.setStyleRange(new StyleRange(line6start
+ line6
.indexOf(ucg
), ucg
.length(), COLOR_BLACK
, COLOR_MAGENTA
));
1014 legendShell
.setText(Messages
.CustomTxtParserInputWizardPage_previewLegend
);
1019 private class UpdateListener
implements ModifyListener
, SelectionListener
{
1022 public void modifyText(ModifyEvent e
) {
1028 public void widgetDefaultSelected(SelectionEvent e
) {
1034 public void widgetSelected(SelectionEvent e
) {
1041 private class Line
{
1042 private static final String INFINITY_STRING
= "\u221E"; //$NON-NLS-1$
1043 private InputLine inputLine
;
1044 private Group group
;
1045 private Composite labelComposite
;
1046 private Text regexText
;
1047 private Composite cardinalityContainer
;
1048 private Combo cardinalityCombo
;
1049 private Label cardinalityMinLabel
;
1050 private Text cardinalityMinText
;
1051 private Label cardinalityMaxLabel
;
1052 private Text cardinalityMaxText
;
1053 private Button infiniteButton
;
1054 private List
<InputGroup
> inputs
= new ArrayList
<>();
1055 private Button addGroupButton
;
1056 private Label addGroupLabel
;
1058 public Line(Composite parent
, String name
, InputLine inputLine
) {
1059 this.inputLine
= inputLine
;
1061 group
= new Group(parent
, SWT
.NONE
);
1062 group
.setText(name
);
1063 group
.setLayout(new GridLayout(2, false));
1064 group
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1066 labelComposite
= new Composite(group
, SWT
.FILL
);
1067 GridLayout labelLayout
= new GridLayout(1, false);
1068 labelLayout
.marginWidth
= 0;
1069 labelLayout
.marginHeight
= 0;
1070 labelComposite
.setLayout(labelLayout
);
1071 labelComposite
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1073 Label label
= new Label(labelComposite
, SWT
.NULL
);
1074 label
.setText(Messages
.CustomTxtParserInputWizardPage_regularExpression
);
1076 Composite regexContainer
= new Composite(group
, SWT
.NONE
);
1077 GridLayout regexLayout
= new GridLayout(2, false);
1078 regexLayout
.marginHeight
= 0;
1079 regexLayout
.marginWidth
= 0;
1080 regexContainer
.setLayout(regexLayout
);
1081 regexContainer
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1083 regexText
= new Text(regexContainer
, SWT
.BORDER
| SWT
.SINGLE
);
1084 GridData gd
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
1086 regexText
.setLayoutData(gd
);
1087 regexText
.setText(inputLine
.getRegex());
1088 regexText
.addModifyListener(updateListener
);
1090 Button regexHelpButton
= new Button(regexContainer
, SWT
.PUSH
);
1091 regexHelpButton
.setImage(HELP_IMAGE
);
1092 regexHelpButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_regularExpressionHelp
);
1093 regexHelpButton
.addSelectionListener(new SelectionAdapter() {
1095 public void widgetSelected(SelectionEvent e
) {
1096 openHelpShell(PATTERN_URL
);
1100 label
= new Label(group
, SWT
.NONE
);
1101 label
.setText(Messages
.CustomTxtParserInputWizardPage_cardinality
);
1102 label
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1104 cardinalityContainer
= new Composite(group
, SWT
.NONE
);
1105 GridLayout cardinalityLayout
= new GridLayout(6, false);
1106 cardinalityLayout
.marginHeight
= 0;
1107 cardinalityLayout
.marginWidth
= 0;
1108 cardinalityContainer
.setLayout(cardinalityLayout
);
1109 cardinalityContainer
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1111 cardinalityCombo
= new Combo(cardinalityContainer
, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
1112 cardinalityCombo
.setItems(new String
[] {
1113 Cardinality
.ZERO_OR_MORE
.toString(),
1114 Cardinality
.ONE_OR_MORE
.toString(),
1115 Cardinality
.ZERO_OR_ONE
.toString(),
1116 Cardinality
.ONE
.toString(), "(?,?)" }); //$NON-NLS-1$
1117 cardinalityCombo
.addSelectionListener(new SelectionListener() {
1119 public void widgetDefaultSelected(SelectionEvent e
) {
1123 public void widgetSelected(SelectionEvent e
) {
1124 switch (cardinalityCombo
.getSelectionIndex()) {
1126 cardinalityMinLabel
.setVisible(true);
1127 cardinalityMinText
.setVisible(true);
1128 cardinalityMaxLabel
.setVisible(true);
1129 cardinalityMaxText
.setVisible(true);
1130 infiniteButton
.setVisible(true);
1133 cardinalityMinLabel
.setVisible(false);
1134 cardinalityMinText
.setVisible(false);
1135 cardinalityMaxLabel
.setVisible(false);
1136 cardinalityMaxText
.setVisible(false);
1137 infiniteButton
.setVisible(false);
1140 cardinalityContainer
.layout();
1146 cardinalityMinLabel
= new Label(cardinalityContainer
, SWT
.NONE
);
1147 cardinalityMinLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1148 cardinalityMinLabel
.setText(Messages
.CustomTxtParserInputWizardPage_min
);
1149 cardinalityMinLabel
.setVisible(false);
1151 cardinalityMinText
= new Text(cardinalityContainer
, SWT
.BORDER
| SWT
.SINGLE
);
1152 gd
= new GridData(SWT
.CENTER
, SWT
.CENTER
, false, false);
1154 cardinalityMinText
.setLayoutData(gd
);
1155 cardinalityMinText
.setVisible(false);
1157 cardinalityMaxLabel
= new Label(cardinalityContainer
, SWT
.NONE
);
1158 cardinalityMaxLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1159 cardinalityMaxLabel
.setText(Messages
.CustomTxtParserInputWizardPage_max
);
1160 cardinalityMaxLabel
.setVisible(false);
1162 cardinalityMaxText
= new Text(cardinalityContainer
, SWT
.BORDER
| SWT
.SINGLE
);
1163 gd
= new GridData(SWT
.CENTER
, SWT
.CENTER
, false, false);
1165 cardinalityMaxText
.setLayoutData(gd
);
1166 cardinalityMaxText
.setVisible(false);
1168 infiniteButton
= new Button(cardinalityContainer
, SWT
.PUSH
);
1169 infiniteButton
.setText(INFINITY_STRING
);
1170 infiniteButton
.setVisible(false);
1171 infiniteButton
.addSelectionListener(new SelectionAdapter() {
1173 public void widgetSelected(SelectionEvent e
) {
1174 cardinalityMaxText
.setText(INFINITY_STRING
);
1178 if (inputLine
.cardinality
.equals(Cardinality
.ZERO_OR_MORE
)) {
1179 cardinalityCombo
.select(0);
1180 } else if (inputLine
.cardinality
.equals(Cardinality
.ONE_OR_MORE
)) {
1181 cardinalityCombo
.select(1);
1182 } else if (inputLine
.cardinality
.equals(Cardinality
.ZERO_OR_ONE
)) {
1183 cardinalityCombo
.select(2);
1184 } else if (inputLine
.cardinality
.equals(Cardinality
.ONE
)) {
1185 cardinalityCombo
.select(3);
1187 cardinalityCombo
.select(4);
1188 cardinalityMinLabel
.setVisible(true);
1189 cardinalityMinText
.setVisible(true);
1190 if (inputLine
.getMinCount() >= 0) {
1191 cardinalityMinText
.setText(Integer
.toString(inputLine
.getMinCount()));
1193 cardinalityMaxLabel
.setVisible(true);
1194 cardinalityMaxText
.setVisible(true);
1195 if (inputLine
.getMaxCount() == Cardinality
.INF
) {
1196 cardinalityMaxText
.setText(INFINITY_STRING
);
1197 } else if (inputLine
.getMaxCount() >= 0) {
1198 cardinalityMaxText
.setText(Integer
.toString(inputLine
.getMaxCount()));
1200 infiniteButton
.setVisible(true);
1203 VerifyListener digitsListener
= new VerifyListener() {
1205 public void verifyText(VerifyEvent e
) {
1206 if (e
.text
.equals(INFINITY_STRING
)) {
1207 e
.doit
= e
.widget
== cardinalityMaxText
&& e
.start
== 0 && e
.end
== ((Text
) e
.widget
).getText().length();
1209 if (((Text
) e
.widget
).getText().equals(INFINITY_STRING
)) {
1210 e
.doit
= e
.start
== 0 && e
.end
== ((Text
) e
.widget
).getText().length();
1212 for (int i
= 0; i
< e
.text
.length(); i
++) {
1213 if (!Character
.isDigit(e
.text
.charAt(i
))) {
1222 cardinalityMinText
.addModifyListener(updateListener
);
1223 cardinalityMaxText
.addModifyListener(updateListener
);
1224 cardinalityMinText
.addVerifyListener(digitsListener
);
1225 cardinalityMaxText
.addVerifyListener(digitsListener
);
1227 if (inputLine
.columns
!= null) {
1228 for (InputData inputData
: inputLine
.columns
) {
1229 InputGroup inputGroup
= new InputGroup(group
, this, inputs
.size() + 1);
1230 if (inputData
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1231 inputGroup
.tagCombo
.select(0);
1232 inputGroup
.tagText
.setText(inputData
.format
);
1233 inputGroup
.tagLabel
.setText(Messages
.CustomTxtParserInputWizardPage_format
);
1234 inputGroup
.tagLabel
.setVisible(true);
1235 inputGroup
.tagText
.setVisible(true);
1236 inputGroup
.tagText
.addModifyListener(updateListener
);
1237 } else if (inputData
.name
.equals(CustomTraceDefinition
.TAG_EVENT_TYPE
)) {
1238 inputGroup
.tagCombo
.select(1);
1239 } else if (inputData
.name
.equals(CustomTraceDefinition
.TAG_MESSAGE
)) {
1240 inputGroup
.tagCombo
.select(2);
1242 inputGroup
.tagCombo
.select(3);
1243 inputGroup
.tagText
.setText(inputData
.name
);
1244 inputGroup
.tagLabel
.setText(Messages
.CustomTxtParserInputWizardPage_name
);
1245 inputGroup
.tagLabel
.setVisible(true);
1246 inputGroup
.tagText
.setVisible(true);
1247 inputGroup
.tagText
.addModifyListener(updateListener
);
1249 inputGroup
.actionCombo
.select(inputData
.action
);
1250 inputs
.add(inputGroup
);
1254 createAddGroupButton();
1257 private void createAddGroupButton() {
1258 addGroupButton
= new Button(group
, SWT
.PUSH
);
1259 addGroupButton
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1260 addGroupButton
.setImage(ADD_IMAGE
);
1261 addGroupButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_addGroup
);
1262 addGroupButton
.addSelectionListener(new SelectionAdapter() {
1264 public void widgetSelected(SelectionEvent e
) {
1265 removeAddGroupButton();
1266 inputs
.add(new InputGroup(group
, Line
.this, inputs
.size() + 1));
1267 createAddGroupButton();
1268 lineContainer
.layout();
1269 lineScrolledComposite
.setMinSize(lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
1270 group
.getParent().layout();
1276 addGroupLabel
= new Label(group
, SWT
.NULL
);
1277 addGroupLabel
.setText(Messages
.CustomTxtParserInputWizardPage_newGroup
);
1280 private void removeAddGroupButton() {
1281 addGroupButton
.dispose();
1282 addGroupLabel
.dispose();
1285 private void removeInput(int inputNumber
) {
1286 int nb
= inputNumber
;
1287 if (--nb
< inputs
.size()) {
1288 inputs
.remove(nb
).dispose();
1289 for (int i
= nb
; i
< inputs
.size(); i
++) {
1290 inputs
.get(i
).setInputNumber(i
+ 1);
1292 lineContainer
.layout();
1293 lineScrolledComposite
.setMinSize(lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).x
, lineContainer
.computeSize(SWT
.DEFAULT
, SWT
.DEFAULT
).y
- 1);
1294 group
.getParent().layout();
1298 private void dispose() {
1302 private void extractInputs() {
1303 inputLine
.setRegex(selectedLine
.regexText
.getText());
1304 switch (cardinalityCombo
.getSelectionIndex()) {
1306 inputLine
.cardinality
= Cardinality
.ZERO_OR_MORE
;
1309 inputLine
.cardinality
= Cardinality
.ONE_OR_MORE
;
1312 inputLine
.cardinality
= Cardinality
.ZERO_OR_ONE
;
1315 inputLine
.cardinality
= Cardinality
.ONE
;
1321 min
= Integer
.parseInt(cardinalityMinText
.getText());
1322 } catch (NumberFormatException e
) {
1326 if (cardinalityMaxText
.getText().equals(INFINITY_STRING
)) {
1327 max
= Cardinality
.INF
;
1329 max
= Integer
.parseInt(cardinalityMaxText
.getText());
1331 } catch (NumberFormatException e
) {
1334 inputLine
.cardinality
= new Cardinality(min
, max
);
1337 inputLine
.cardinality
= Cardinality
.ZERO_OR_MORE
;
1340 inputLine
.columns
= new ArrayList
<>(inputs
.size());
1341 for (int i
= 0; i
< inputs
.size(); i
++) {
1342 InputGroup grp
= inputs
.get(i
);
1343 InputData inputData
= new InputData();
1344 if (grp
.tagCombo
.getText().equals(CustomTraceDefinition
.TAG_OTHER
)) {
1345 inputData
.name
= grp
.tagText
.getText().trim();
1347 inputData
.name
= grp
.tagCombo
.getText();
1348 if (grp
.tagCombo
.getText().equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1349 inputData
.format
= grp
.tagText
.getText().trim();
1352 inputData
.action
= grp
.actionCombo
.getSelectionIndex();
1353 inputLine
.columns
.add(inputData
);
1358 private class InputGroup
{
1360 private int inputNumber
;
1362 // children of parent (must be disposed)
1363 private Composite labelComposite
;
1364 private Composite tagComposite
;
1365 private Label previewLabel
;
1366 private Text previewText
;
1368 // children of labelComposite
1369 private Label inputLabel
;
1371 // children of tagComposite
1372 private Combo tagCombo
;
1373 private Label tagLabel
;
1374 private Text tagText
;
1375 private Combo actionCombo
;
1377 public InputGroup(Composite parent
, Line line
, int inputNumber
) {
1379 this.inputNumber
= inputNumber
;
1381 labelComposite
= new Composite(parent
, SWT
.FILL
);
1382 GridLayout labelLayout
= new GridLayout(2, false);
1383 labelLayout
.marginWidth
= 0;
1384 labelLayout
.marginHeight
= 0;
1385 labelComposite
.setLayout(labelLayout
);
1386 labelComposite
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1388 Button deleteButton
= new Button(labelComposite
, SWT
.PUSH
);
1389 deleteButton
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1390 deleteButton
.setImage(DELETE_IMAGE
);
1391 deleteButton
.setToolTipText(Messages
.CustomTxtParserInputWizardPage_removeGroup
);
1392 deleteButton
.addSelectionListener(new SelectionAdapter() {
1394 public void widgetSelected(SelectionEvent e
) {
1395 InputGroup
.this.line
.removeInput(InputGroup
.this.inputNumber
);
1401 inputLabel
= new Label(labelComposite
, SWT
.NULL
);
1402 inputLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1403 inputLabel
.setText(NLS
.bind(Messages
.CustomTxtParserInputWizardPage_group
, inputNumber
));
1405 tagComposite
= new Composite(parent
, SWT
.FILL
);
1406 GridLayout tagLayout
= new GridLayout(4, false);
1407 tagLayout
.marginWidth
= 0;
1408 tagLayout
.marginHeight
= 0;
1409 tagComposite
.setLayout(tagLayout
);
1410 tagComposite
.setLayoutData(new GridData(SWT
.FILL
, SWT
.CENTER
, true, false));
1412 tagCombo
= new Combo(tagComposite
, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
1413 tagCombo
.setItems(new String
[] { CustomTraceDefinition
.TAG_TIMESTAMP
,
1414 CustomTraceDefinition
.TAG_EVENT_TYPE
,
1415 CustomTraceDefinition
.TAG_MESSAGE
,
1416 CustomTraceDefinition
.TAG_OTHER
});
1418 tagCombo
.addSelectionListener(new SelectionListener() {
1420 public void widgetDefaultSelected(SelectionEvent e
) {
1424 public void widgetSelected(SelectionEvent e
) {
1425 tagText
.removeModifyListener(updateListener
);
1426 switch (tagCombo
.getSelectionIndex()) {
1427 case 0: // Time Stamp
1428 tagLabel
.setText(Messages
.CustomTxtParserInputWizardPage_format
);
1429 tagLabel
.setVisible(true);
1430 tagText
.setVisible(true);
1431 tagText
.addModifyListener(updateListener
);
1433 case 1: // Event type
1434 tagLabel
.setVisible(false);
1435 tagText
.setVisible(false);
1438 tagLabel
.setVisible(false);
1439 tagText
.setVisible(false);
1442 tagLabel
.setText(Messages
.CustomTxtParserInputWizardPage_name
);
1443 tagLabel
.setVisible(true);
1444 tagText
.setVisible(true);
1445 tagText
.addModifyListener(updateListener
);
1450 tagComposite
.layout();
1456 tagLabel
= new Label(tagComposite
, SWT
.NULL
);
1457 tagLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1458 tagLabel
.setVisible(false);
1460 tagText
= new Text(tagComposite
, SWT
.BORDER
| SWT
.SINGLE
);
1461 GridData gd
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
1463 tagText
.setLayoutData(gd
);
1464 tagText
.setVisible(false);
1466 actionCombo
= new Combo(tagComposite
, SWT
.DROP_DOWN
| SWT
.READ_ONLY
);
1467 actionCombo
.setItems(new String
[] { Messages
.CustomTxtParserInputWizardPage_set
, Messages
.CustomTxtParserInputWizardPage_append
, Messages
.CustomTxtParserInputWizardPage_appendWith
});
1468 actionCombo
.select(0);
1469 actionCombo
.addSelectionListener(updateListener
);
1471 previewLabel
= new Label(parent
, SWT
.NULL
);
1472 previewLabel
.setLayoutData(new GridData(SWT
.RIGHT
, SWT
.CENTER
, false, false));
1473 previewLabel
.setText(Messages
.CustomTxtParserInputWizardPage_preview
);
1475 previewText
= new Text(parent
, SWT
.BORDER
| SWT
.SINGLE
| SWT
.READ_ONLY
);
1476 gd
= new GridData(SWT
.FILL
, SWT
.CENTER
, true, false);
1478 previewText
.setLayoutData(gd
);
1479 previewText
.setText(Messages
.CustomTxtParserInputWizardPage_noMatch
);
1480 previewText
.setBackground(COLOR_WIDGET_BACKGROUND
);
1483 private void dispose() {
1484 labelComposite
.dispose();
1485 tagComposite
.dispose();
1486 previewLabel
.dispose();
1487 previewText
.dispose();
1490 private void setInputNumber(int inputNumber
) {
1491 this.inputNumber
= inputNumber
;
1492 inputLabel
.setText(NLS
.bind(Messages
.CustomTxtParserInputWizardPage_group
, inputNumber
));
1493 labelComposite
.layout();
1497 private void validate() {
1499 definition
.categoryName
= categoryText
.getText().trim();
1500 definition
.definitionName
= logtypeText
.getText().trim();
1501 definition
.timeStampOutputFormat
= timestampOutputFormatText
.getText().trim();
1503 if (selectedLine
!= null) {
1504 selectedLine
.extractInputs();
1505 treeViewer
.refresh();
1508 StringBuffer errors
= new StringBuffer();
1510 if (definition
.categoryName
.length() == 0) {
1511 errors
.append("Enter a category for the new trace type. "); //$NON-NLS-1$
1512 categoryText
.setBackground(COLOR_LIGHT_RED
);
1513 } else if (definition
.definitionName
.length() == 0) {
1514 errors
.append("Enter a name for the new trace type. "); //$NON-NLS-1$
1515 logtypeText
.setBackground(COLOR_LIGHT_RED
);
1517 categoryText
.setBackground(COLOR_TEXT_BACKGROUND
);
1518 logtypeText
.setBackground(COLOR_TEXT_BACKGROUND
);
1519 if (definition
.categoryName
.indexOf(':') != -1) {
1520 errors
.append("Invalid character ':' in category. "); //$NON-NLS-1$
1521 categoryText
.setBackground(COLOR_LIGHT_RED
);
1523 if (definition
.definitionName
.indexOf(':') != -1) {
1524 errors
.append("Invalid character ':' in trace type. "); //$NON-NLS-1$
1525 logtypeText
.setBackground(COLOR_LIGHT_RED
);
1527 for (TraceTypeHelper helper
: TmfTraceType
.getTraceTypeHelpers()) {
1528 if (definition
.categoryName
.equals(helper
.getCategoryName()) &&
1529 definition
.definitionName
.equals(helper
.getName()) &&
1530 (editDefinitionName
== null || !editDefinitionName
.equals(definition
.definitionName
)) &&
1531 (editCategoryName
== null || !editCategoryName
.equals(definition
.categoryName
))) {
1532 errors
.append("The trace type name already exists. "); //$NON-NLS-1$
1533 logtypeText
.setBackground(COLOR_LIGHT_RED
);
1539 timestampFound
= false;
1540 for (int i
= 0; i
< definition
.inputs
.size(); i
++) {
1542 InputLine inputLine
= definition
.inputs
.get(i
);
1543 String name
= Integer
.toString(i
+ 1);
1544 errors
.append(validateLine(inputLine
, name
));
1546 if (timestampFound
) {
1547 if (definition
.timeStampOutputFormat
.length() == 0) {
1548 errors
.append("Enter the output format for the Time Stamp field. "); //$NON-NLS-1$
1549 timestampOutputFormatText
.setBackground(COLOR_LIGHT_RED
);
1552 new TmfTimestampFormat(definition
.timeStampOutputFormat
);
1553 timestampOutputFormatText
.setBackground(COLOR_TEXT_BACKGROUND
);
1554 } catch (IllegalArgumentException e
) {
1555 errors
.append("Enter a valid output format for the Time Stamp field [" + e
.getMessage() + "]."); //$NON-NLS-1$ //$NON-NLS-2$
1556 timestampOutputFormatText
.setBackground(COLOR_LIGHT_RED
);
1561 timestampOutputFormatText
.setBackground(COLOR_TEXT_BACKGROUND
);
1564 if (errors
.length() == 0) {
1565 setDescription(defaultDescription
);
1566 setPageComplete(true);
1568 setDescription(errors
.toString());
1569 setPageComplete(false);
1574 * Validate an input line.
1577 * The line to clean up
1579 * The name of the line
1580 * @return The cleaned up line
1582 public StringBuffer
validateLine(InputLine inputLine
, String name
) {
1583 StringBuffer errors
= new StringBuffer();
1585 if (selectedLine
!= null && selectedLine
.inputLine
.equals(inputLine
)) {
1586 line
= selectedLine
;
1589 Pattern
.compile(inputLine
.getRegex());
1591 line
.regexText
.setBackground(COLOR_TEXT_BACKGROUND
);
1593 } catch (PatternSyntaxException e
) {
1594 errors
.append("Enter a valid regular expression (Line " + name
+ "). "); //$NON-NLS-1$ //$NON-NLS-2$
1596 line
.regexText
.setBackground(COLOR_LIGHT_RED
);
1599 if (inputLine
.getMinCount() == -1) {
1600 errors
.append("Enter a minimum value for cardinality (Line " + name
+ "). "); //$NON-NLS-1$ //$NON-NLS-2$
1602 line
.cardinalityMinText
.setBackground(COLOR_LIGHT_RED
);
1606 line
.cardinalityMinText
.setBackground(COLOR_TEXT_BACKGROUND
);
1609 if (inputLine
.getMaxCount() == -1) {
1610 errors
.append("Enter a maximum value for cardinality (Line " + name
+ "). "); //$NON-NLS-1$ //$NON-NLS-2$
1612 line
.cardinalityMaxText
.setBackground(COLOR_LIGHT_RED
);
1614 } else if (inputLine
.getMinCount() > inputLine
.getMaxCount()) {
1615 errors
.append("Enter correct (min <= max) values for cardinality (Line " + name
+ "). "); //$NON-NLS-1$ //$NON-NLS-2$
1617 line
.cardinalityMinText
.setBackground(COLOR_LIGHT_RED
);
1620 line
.cardinalityMaxText
.setBackground(COLOR_LIGHT_RED
);
1624 line
.cardinalityMaxText
.setBackground(COLOR_TEXT_BACKGROUND
);
1627 for (int i
= 0; inputLine
.columns
!= null && i
< inputLine
.columns
.size(); i
++) {
1628 InputData inputData
= inputLine
.columns
.get(i
);
1629 InputGroup group
= null;
1631 group
= line
.inputs
.get(i
);
1633 if (inputData
.name
.equals(CustomTraceDefinition
.TAG_TIMESTAMP
)) {
1634 timestampFound
= true;
1635 if (inputData
.format
.length() == 0) {
1636 errors
.append("Enter the input format for the Time Stamp (Line " + name
+ " Group " + (i
+ 1) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1637 if (group
!= null) {
1638 group
.tagText
.setBackground(COLOR_LIGHT_RED
);
1642 new TmfTimestampFormat(inputData
.format
);
1643 if (group
!= null) {
1644 group
.tagText
.setBackground(COLOR_TEXT_BACKGROUND
);
1646 } catch (IllegalArgumentException e
) {
1647 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$
1648 if (group
!= null) {
1649 group
.tagText
.setBackground(COLOR_LIGHT_RED
);
1653 } else if (inputData
.name
.length() == 0) {
1654 errors
.append("Enter a name for the data group (Line " + name
+ " Group " + (i
+ 1) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
1655 if (group
!= null) {
1656 group
.tagText
.setBackground(COLOR_LIGHT_RED
);
1659 if (group
!= null) {
1660 group
.tagText
.setBackground(COLOR_TEXT_BACKGROUND
);
1664 for (int i
= 0; inputLine
.childrenInputs
!= null && i
< inputLine
.childrenInputs
.size(); i
++) {
1665 errors
.append(validateLine(inputLine
.childrenInputs
.get(i
), name
+ "." + (i
+ 1))); //$NON-NLS-1$
1671 * Get the trace definition.
1673 * @return The trace definition
1675 public CustomTxtTraceDefinition
getDefinition() {
1680 * Get the raw text of the input.
1682 * @return The raw input text
1684 public char[] getInputText() {
1685 return inputText
.getText().toCharArray();