ss: Move plugins to Trace Compass namespace
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / internal / tmf / ui / parsers / wizards / CustomTxtParserInputWizardPage.java
index 1b4195faa8e1eb83fe607db1dfa71b4ffa06a667..c34dc77f3c725b72224727281970671d9a3bd6cd 100644 (file)
@@ -51,7 +51,10 @@ import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTxtTraceDefinition;
 import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTxtTraceDefinition.Cardinality;
 import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTxtTraceDefinition.InputData;
 import org.eclipse.linuxtools.tmf.core.parsers.custom.CustomTxtTraceDefinition.InputLine;
+import org.eclipse.linuxtools.tmf.core.project.model.TmfTraceType;
+import org.eclipse.linuxtools.tmf.core.project.model.TraceTypeHelper;
 import org.eclipse.linuxtools.tmf.core.timestamp.TmfTimestampFormat;
+import org.eclipse.osgi.util.NLS;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.browser.Browser;
 import org.eclipse.swt.browser.TitleEvent;
@@ -119,10 +122,12 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
 
     private final ISelection selection;
     private CustomTxtTraceDefinition definition;
+    private String editCategoryName;
     private String editDefinitionName;
     private String defaultDescription;
     private Line selectedLine;
     private Composite container;
+    private Text categoryText;
     private Text logtypeText;
     private Text timestampOutputFormatText;
     private Text timestampPreviewText;
@@ -160,11 +165,12 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
         this.selection = selection;
         this.definition = definition;
         if (definition != null) {
+            this.editCategoryName = definition.categoryName;
             this.editDefinitionName = definition.definitionName;
         }
     }
 
-       @Override
+    @Override
     public void createControl(Composite parent) {
         container = new Composite(parent, SWT.NULL);
         container.setLayout(new GridLayout());
@@ -178,11 +184,11 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
         headerComposite.setLayout(headerLayout);
         headerComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
 
-        Label logtypeLabel = new Label(headerComposite, SWT.NULL);
-        logtypeLabel.setText(Messages.CustomTxtParserInputWizardPage_logType);
+        Label categoryLabel = new Label(headerComposite, SWT.NULL);
+        categoryLabel.setText(Messages.CustomTxtParserInputWizardPage_category);
 
-        logtypeText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);
-        logtypeText.setLayoutData(new GridData(120, SWT.DEFAULT));
+        categoryText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);
+        categoryText.setLayoutData(new GridData(120, SWT.DEFAULT));
 
         Label timestampFormatLabel = new Label(headerComposite, SWT.NULL);
         timestampFormatLabel.setText(Messages.CustomTxtParserInputWizardPage_timestampFormat);
@@ -208,8 +214,14 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
             }
         });
 
+        Label logtypeLabel = new Label(headerComposite, SWT.NULL);
+        logtypeLabel.setText(Messages.CustomTxtParserInputWizardPage_logType);
+
+        logtypeText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE);
+        logtypeText.setLayoutData(new GridData(120, SWT.DEFAULT));
+        logtypeText.setFocus();
+
         Label timestampPreviewLabel = new Label(headerComposite, SWT.NULL);
-        timestampPreviewLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 3, 1));
         timestampPreviewLabel.setText(Messages.CustomTxtParserInputWizardPage_preview);
 
         timestampPreviewText = new Text(headerComposite, SWT.BORDER | SWT.SINGLE | SWT.READ_ONLY);
@@ -247,7 +259,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
         addNextButton.setImage(ADD_NEXT_IMAGE);
         addNextButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_addNextLine);
         addNextButton.addSelectionListener(new SelectionAdapter() {
-               @Override
+            @Override
             public void widgetSelected(SelectionEvent e) {
                 InputLine inputLine = new InputLine(Cardinality.ZERO_OR_MORE, "", null); //$NON-NLS-1$
                 if (((List<?>) treeViewer.getInput()).size() == 0) {
@@ -302,7 +314,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                 if (inputLine.parentInput == null) {
                     for (int i = 1; i < definition.inputs.size(); i++) {
                         if (definition.inputs.get(i).equals(inputLine)) {
-                            definition.inputs.add(i - 1 , definition.inputs.remove(i));
+                            definition.inputs.add(i - 1, definition.inputs.remove(i));
                             break;
                         }
                     }
@@ -327,7 +339,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                 if (inputLine.parentInput == null) {
                     for (int i = 0; i < definition.inputs.size() - 1; i++) {
                         if (definition.inputs.get(i).equals(inputLine)) {
-                            definition.inputs.add(i + 1 , definition.inputs.remove(i));
+                            definition.inputs.add(i + 1, definition.inputs.remove(i));
                             break;
                         }
                     }
@@ -386,12 +398,13 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
         treeViewer.expandAll();
         lineContainer.layout();
 
+        categoryText.addModifyListener(updateListener);
         logtypeText.addModifyListener(updateListener);
         timestampOutputFormatText.addModifyListener(updateListener);
 
-        lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);
+        lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
 
-        hSash.setWeights(new int[] {1, 2});
+        hSash.setWeights(new int[] { 1, 2 });
 
         Composite sashBottom = new Composite(vSash, SWT.NONE);
         GridLayout sashBottomLayout = new GridLayout(3, false);
@@ -440,7 +453,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
         inputText.setText(getSelectionText());
         inputText.addModifyListener(updateListener);
 
-        vSash.setWeights(new int[] {hSash.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sashBottom.computeSize(SWT.DEFAULT, SWT.DEFAULT).y});
+        vSash.setWeights(new int[] { hSash.computeSize(SWT.DEFAULT, SWT.DEFAULT).y, sashBottom.computeSize(SWT.DEFAULT, SWT.DEFAULT).y });
 
         setControl(container);
 
@@ -531,6 +544,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
     }
 
     private void loadDefinition(CustomTxtTraceDefinition def) {
+        categoryText.setText(def.categoryName);
         logtypeText.setText(def.definitionName);
         timestampOutputFormatText.setText(def.timeStampOutputFormat);
         treeViewer.setInput(def.inputs);
@@ -542,9 +556,9 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
 
     private String getName(InputLine inputLine) {
         if (inputLine.parentInput == null) {
-            return Integer.toString(definition.inputs.indexOf(inputLine)+1);
+            return Integer.toString(definition.inputs.indexOf(inputLine) + 1);
         }
-        return getName(inputLine.parentInput) + "." + Integer.toString(inputLine.parentInput.childrenInputs.indexOf(inputLine)+1); //$NON-NLS-1$
+        return getName(inputLine.parentInput) + "." + Integer.toString(inputLine.parentInput.childrenInputs.indexOf(inputLine) + 1); //$NON-NLS-1$
     }
 
     /**
@@ -597,7 +611,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
         selectedLine.dispose();
         selectedLine = null;
         lineContainer.layout();
-        lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);
+        lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
         container.layout();
     }
 
@@ -605,7 +619,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
         if (this.selection instanceof IStructuredSelection) {
             Object sel = ((IStructuredSelection) this.selection).getFirstElement();
             if (sel instanceof IFile) {
-                IFile file = (IFile)sel;
+                IFile file = (IFile) sel;
                 BufferedReader reader = null;
                 try {
                     reader = new BufferedReader(new InputStreamReader(file.getContents()));
@@ -664,15 +678,18 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
             int rootLineMatches = 0;
             String firstEntryTimeStamp = null;
             String firstEntryTimeStampInputFormat = null;
-            String log = null;
-            event: while (scanner.hasNext()) {
+            String line = null;
+            boolean lineIsNull = true; // needed because of JDT bug with continue at label
+            event: while (scanner.hasNext() || !lineIsNull) {
                 if (rootLineMatches > 0 && !updateAll) {
                     break;
                 }
-                if (log == null) {
-                    log = scanner.next();
+                if (line == null) {
+                    line = scanner.next();
+                    lineIsNull = false;
                 }
-                int length = log.length();
+                int length = line.length();
+                String log = line.replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
                 for (InputLine rootInputLine : definition.inputs) {
                     Pattern pattern;
                     try {
@@ -681,7 +698,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                         continue;
                     }
                     Matcher matcher = pattern.matcher(log);
-                    if (matcher.find()) {
+                    if (matcher.matches()) {
                         rootLineMatches++;
                         inputText.setStyleRange(new StyleRange(rawPos, length,
                                 COLOR_BLACK, COLOR_YELLOW, SWT.ITALIC));
@@ -700,13 +717,18 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                         }
                         rawPos += length + 1; // +1 for \n
                         while (scanner.hasNext()) {
-                            log = scanner.next();
-                            length = log.length();
+                            line = scanner.next();
+                            length = line.length();
+                            log = line.replaceAll("\r", ""); //$NON-NLS-1$ //$NON-NLS-2$
                             boolean processed = false;
                             if (currentInput == null) {
                                 for (InputLine input : definition.inputs) {
-                                    matcher = input.getPattern().matcher(log);
-                                    if (matcher.find()) {
+                                    try {
+                                        matcher = input.getPattern().matcher(log);
+                                    } catch (PatternSyntaxException e) {
+                                        continue;
+                                    }
+                                    if (matcher.matches()) {
                                         continue event;
                                     }
                                 }
@@ -715,15 +737,23 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                                     List<InputLine> nextInputs = currentInput.getNextInputs(countMap);
                                     if (nextInputs.size() == 0 || nextInputs.get(nextInputs.size() - 1).getMinCount() == 0) {
                                         for (InputLine input : definition.inputs) {
-                                            matcher = input.getPattern().matcher(log);
-                                            if (matcher.find()) {
+                                            try {
+                                                matcher = input.getPattern().matcher(log);
+                                            } catch (PatternSyntaxException e) {
+                                                continue;
+                                            }
+                                            if (matcher.matches()) {
                                                 continue event;
                                             }
                                         }
                                     }
                                     for (InputLine input : nextInputs) {
-                                        matcher = input.getPattern().matcher(log);
-                                        if (matcher.find()) {
+                                        try {
+                                            matcher = input.getPattern().matcher(log);
+                                        } catch (PatternSyntaxException e) {
+                                            continue;
+                                        }
+                                        if (matcher.matches()) {
                                             inputText.setStyleRange(new StyleRange(rawPos, length,
                                                     COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));
                                             currentInput = input;
@@ -768,8 +798,12 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                                     }
                                 }
                                 if (!processed && currentInput != null) {
-                                    matcher = currentInput.getPattern().matcher(log);
-                                    if (matcher.find()) {
+                                    matcher = null;
+                                    try {
+                                        matcher = currentInput.getPattern().matcher(log);
+                                    } catch (PatternSyntaxException e) {
+                                    }
+                                    if (matcher != null && matcher.matches()) {
                                         inputText.setStyleRange(new StyleRange(rawPos, length,
                                                 COLOR_BLACK, COLOR_LIGHT_YELLOW, SWT.ITALIC));
                                         updatePreviewLine(currentInput, matcher, data, rawPos, rootLineMatches);
@@ -806,7 +840,8 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                     }
                 }
                 rawPos += length + 1; // +1 for \n
-                log = null;
+                line = null;
+                lineIsNull = true;
             }
 
             if (rootLineMatches == 1) {
@@ -832,7 +867,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                 } catch (ParseException e) {
                     timestampPreviewText.setText("*parse exception* [" + firstEntryTimeStamp + "] <> [" + firstEntryTimeStampInputFormat + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                 } catch (IllegalArgumentException e) {
-                    timestampPreviewText.setText("*parse exception* [Illegal Argument: " + e.getMessage()+ "]"); //$NON-NLS-1$ //$NON-NLS-2$
+                    timestampPreviewText.setText("*parse exception* [Illegal Argument: " + e.getMessage() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
                 }
 
             }
@@ -842,15 +877,15 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
     private void updatePreviewLine(InputLine line, Matcher matcher, Map<String, String> data, int rawPos, int rootLineMatches) {
         for (int i = 0; i < line.columns.size(); i++) {
             InputData input = line.columns.get(i);
-            if (i < matcher.groupCount() && matcher.group(i+1) != null) {
+            if (i < matcher.groupCount() && matcher.group(i + 1) != null) {
                 if (line.parentInput == null) {
-                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i+1), matcher.end(i+1) - matcher.start(i+1),
+                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i + 1), matcher.end(i + 1) - matcher.start(i + 1),
                             COLOR_BLACK, COLOR_GREEN, SWT.BOLD));
                 } else {
-                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i+1), matcher.end(i+1) - matcher.start(i+1),
+                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i + 1), matcher.end(i + 1) - matcher.start(i + 1),
                             COLOR_BLACK, COLOR_LIGHT_GREEN, SWT.BOLD));
                 }
-                String value = matcher.group(i+1).trim();
+                String value = matcher.group(i + 1).trim();
                 if (selectedLine != null && selectedLine.inputLine.equals(line) && rootLineMatches == 1 &&
                         selectedLine.inputs.get(i).previewText.getText().equals(Messages.CustomTxtParserInputWizardPage_noMatchingLine)) {
                     selectedLine.inputs.get(i).previewText.setText(value);
@@ -902,12 +937,12 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
         }
         // highlight the matching groups that have no corresponponding input
         for (int i = line.columns.size(); i < matcher.groupCount(); i++) {
-            if (matcher.group(i+1) != null) {
+            if (matcher.group(i + 1) != null) {
                 if (line.parentInput == null) {
-                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i+1), matcher.end(i+1) - matcher.start(i+1),
+                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i + 1), matcher.end(i + 1) - matcher.start(i + 1),
                             COLOR_BLACK, COLOR_MAGENTA));
                 } else {
-                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i+1), matcher.end(i+1) - matcher.start(i+1),
+                    inputText.setStyleRange(new StyleRange(rawPos + matcher.start(i + 1), matcher.end(i + 1) - matcher.start(i + 1),
                             COLOR_BLACK, COLOR_LIGHT_MAGENTA));
                 }
             }
@@ -946,11 +981,11 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
         int line1start = 0;
         String line1 = Messages.CustomTxtParserInputWizardPage_nonMatchingLine;
         int line2start = line1start + line1.length();
-        String line2 = Messages.CustomTxtParserInputWizardPage_matchingLineRoot + cg + ' ' + ucg + ' ' + ut + " \n";  //$NON-NLS-1$
+        String line2 = Messages.CustomTxtParserInputWizardPage_matchingRootLine + ' ' + cg + ' ' + ucg + ' ' + ut + " \n"; //$NON-NLS-1$
         int line3start = line2start + line2.length();
-        String line3 = Messages.CustomTxtParserInputWizardPage_matchingOtherLine + cg + ' ' + ucg + ' ' + ut + " \n"; //$NON-NLS-1$
+        String line3 = Messages.CustomTxtParserInputWizardPage_matchingOtherLine + ' '  + cg + ' ' + ucg + ' ' + ut + " \n"; //$NON-NLS-1$
         int line4start = line3start + line3.length();
-        String line4 = Messages.CustomTxtParserInputWizardPage_matchingOtherLine + cg + ' ' + ucg + ' ' + ut + " \n"; //$NON-NLS-1$
+        String line4 = Messages.CustomTxtParserInputWizardPage_matchingOtherLine + ' ' + cg + ' ' + ucg + ' ' + ut + " \n"; //$NON-NLS-1$
         int line5start = line4start + line4.length();
         String line5 = Messages.CustomTxtParserInputWizardPage_nonMatchingLine;
         int line6start = line5start + line5.length();
@@ -1075,11 +1110,11 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                     Cardinality.ZERO_OR_MORE.toString(),
                     Cardinality.ONE_OR_MORE.toString(),
                     Cardinality.ZERO_OR_ONE.toString(),
-                    Cardinality.ONE.toString(),
-                    "(?,?)"}); //$NON-NLS-1$
+                    Cardinality.ONE.toString(), "(?,?)" }); //$NON-NLS-1$
             cardinalityCombo.addSelectionListener(new SelectionListener() {
                 @Override
-                public void widgetDefaultSelected(SelectionEvent e) {}
+                public void widgetDefaultSelected(SelectionEvent e) {
+                }
 
                 @Override
                 public void widgetSelected(SelectionEvent e) {
@@ -1130,11 +1165,12 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
             infiniteButton = new Button(cardinalityContainer, SWT.PUSH);
             infiniteButton.setText(INFINITY_STRING);
             infiniteButton.setVisible(false);
-            infiniteButton.addSelectionListener(new SelectionAdapter(){
+            infiniteButton.addSelectionListener(new SelectionAdapter() {
                 @Override
                 public void widgetSelected(SelectionEvent e) {
                     cardinalityMaxText.setText(INFINITY_STRING);
-                }});
+                }
+            });
 
             if (inputLine.cardinality.equals(Cardinality.ZERO_OR_MORE)) {
                 cardinalityCombo.select(0);
@@ -1162,7 +1198,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
             }
 
             VerifyListener digitsListener = new VerifyListener() {
-               @Override
+                @Override
                 public void verifyText(VerifyEvent e) {
                     if (e.text.equals(INFINITY_STRING)) {
                         e.doit = e.widget == cardinalityMaxText && e.start == 0 && e.end == ((Text) e.widget).getText().length();
@@ -1177,7 +1213,8 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                             }
                         }
                     }
-                }};
+                }
+            };
 
             cardinalityMinText.addModifyListener(updateListener);
             cardinalityMaxText.addModifyListener(updateListener);
@@ -1186,7 +1223,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
 
             if (inputLine.columns != null) {
                 for (InputData inputData : inputLine.columns) {
-                    InputGroup inputGroup = new InputGroup(group, this, inputs.size()+1);
+                    InputGroup inputGroup = new InputGroup(group, this, inputs.size() + 1);
                     if (inputData.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
                         inputGroup.tagCombo.select(0);
                         inputGroup.tagText.setText(inputData.format);
@@ -1218,13 +1255,13 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
             addGroupButton.setImage(ADD_IMAGE);
             addGroupButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_addGroup);
             addGroupButton.addSelectionListener(new SelectionAdapter() {
-               @Override
+                @Override
                 public void widgetSelected(SelectionEvent e) {
                     removeAddGroupButton();
-                    inputs.add(new InputGroup(group, Line.this, inputs.size()+1));
+                    inputs.add(new InputGroup(group, Line.this, inputs.size() + 1));
                     createAddGroupButton();
                     lineContainer.layout();
-                    lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);
+                    lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
                     group.getParent().layout();
                     validate();
                     updatePreviews();
@@ -1245,10 +1282,10 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
             if (--nb < inputs.size()) {
                 inputs.remove(nb).dispose();
                 for (int i = nb; i < inputs.size(); i++) {
-                    inputs.get(i).setInputNumber(i+1);
+                    inputs.get(i).setInputNumber(i + 1);
                 }
                 lineContainer.layout();
-                lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y-1);
+                lineScrolledComposite.setMinSize(lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).x, lineContainer.computeSize(SWT.DEFAULT, SWT.DEFAULT).y - 1);
                 group.getParent().layout();
             }
         }
@@ -1272,8 +1309,9 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
             case 3:
                 inputLine.cardinality = Cardinality.ONE;
                 break;
-            case 4: //(?,?)
-                int min, max;
+            case 4: // (?,?)
+                int min,
+                max;
                 try {
                     min = Integer.parseInt(cardinalityMinText.getText());
                 } catch (NumberFormatException e) {
@@ -1347,7 +1385,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
             deleteButton.setImage(DELETE_IMAGE);
             deleteButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_removeGroup);
             deleteButton.addSelectionListener(new SelectionAdapter() {
-               @Override
+                @Override
                 public void widgetSelected(SelectionEvent e) {
                     InputGroup.this.line.removeInput(InputGroup.this.inputNumber);
                     validate();
@@ -1357,7 +1395,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
 
             inputLabel = new Label(labelComposite, SWT.NULL);
             inputLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
-            inputLabel.setText(Messages.CustomTxtParserInputWizardPage_group + inputNumber + ":"); //$NON-NLS-1$
+            inputLabel.setText(NLS.bind(Messages.CustomTxtParserInputWizardPage_group, inputNumber));
 
             tagComposite = new Composite(parent, SWT.FILL);
             GridLayout tagLayout = new GridLayout(4, false);
@@ -1367,34 +1405,36 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
             tagComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
 
             tagCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
-            tagCombo.setItems(new String[] {CustomTraceDefinition.TAG_TIMESTAMP,
-                                            CustomTraceDefinition.TAG_MESSAGE,
-                                            CustomTraceDefinition.TAG_OTHER});
+            tagCombo.setItems(new String[] { CustomTraceDefinition.TAG_TIMESTAMP,
+                    CustomTraceDefinition.TAG_MESSAGE,
+                    CustomTraceDefinition.TAG_OTHER });
             tagCombo.select(1);
-            tagCombo.addSelectionListener(new SelectionListener(){
-               @Override
-                public void widgetDefaultSelected(SelectionEvent e) {}
-               @Override
+            tagCombo.addSelectionListener(new SelectionListener() {
+                @Override
+                public void widgetDefaultSelected(SelectionEvent e) {
+                }
+
+                @Override
                 public void widgetSelected(SelectionEvent e) {
                     tagText.removeModifyListener(updateListener);
                     switch (tagCombo.getSelectionIndex()) {
-                    case 0: //Time Stamp
+                    case 0: // Time Stamp
                         tagLabel.setText(Messages.CustomTxtParserInputWizardPage_format);
                         tagLabel.setVisible(true);
                         tagText.setVisible(true);
                         tagText.addModifyListener(updateListener);
                         break;
-                    case 1: //Message
+                    case 1: // Message
                         tagLabel.setVisible(false);
                         tagText.setVisible(false);
                         break;
-                    case 2: //Other
+                    case 2: // Other
                         tagLabel.setText(Messages.CustomTxtParserInputWizardPage_name);
                         tagLabel.setVisible(true);
                         tagText.setVisible(true);
                         tagText.addModifyListener(updateListener);
                         break;
-                    case 3: //Continue
+                    case 3: // Continue
                         tagLabel.setVisible(false);
                         tagText.setVisible(false);
                         break;
@@ -1404,7 +1444,8 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                     tagComposite.layout();
                     validate();
                     updatePreviews();
-                }});
+                }
+            });
 
             tagLabel = new Label(tagComposite, SWT.NULL);
             tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
@@ -1417,7 +1458,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
             tagText.setVisible(false);
 
             actionCombo = new Combo(tagComposite, SWT.DROP_DOWN | SWT.READ_ONLY);
-            actionCombo.setItems(new String[] {Messages.CustomTxtParserInputWizardPage_set, Messages.CustomTxtParserInputWizardPage_append, Messages.CustomTxtParserInputWizardPage_appendWith});
+            actionCombo.setItems(new String[] { Messages.CustomTxtParserInputWizardPage_set, Messages.CustomTxtParserInputWizardPage_append, Messages.CustomTxtParserInputWizardPage_appendWith });
             actionCombo.select(0);
             actionCombo.addSelectionListener(updateListener);
 
@@ -1442,13 +1483,14 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
 
         private void setInputNumber(int inputNumber) {
             this.inputNumber = inputNumber;
-            inputLabel.setText(Messages.CustomTxtParserInputWizardPage_group + inputNumber + ":"); //$NON-NLS-1$
+            inputLabel.setText(NLS.bind(Messages.CustomTxtParserInputWizardPage_group, inputNumber));
             labelComposite.layout();
         }
     }
 
     private void validate() {
 
+        definition.categoryName = categoryText.getText().trim();
         definition.definitionName = logtypeText.getText().trim();
         definition.timeStampOutputFormat = timestampOutputFormatText.getText().trim();
 
@@ -1459,15 +1501,29 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
 
         StringBuffer errors = new StringBuffer();
 
-        if (definition.definitionName.length() == 0) {
-            errors.append("Enter a name for the new log type. "); //$NON-NLS-1$
+        if (definition.categoryName.length() == 0) {
+            errors.append("Enter a category for the new trace type. "); //$NON-NLS-1$
+            categoryText.setBackground(COLOR_LIGHT_RED);
+        } else if (definition.definitionName.length() == 0) {
+            errors.append("Enter a name for the new trace type. "); //$NON-NLS-1$
             logtypeText.setBackground(COLOR_LIGHT_RED);
         } else {
+            categoryText.setBackground(COLOR_TEXT_BACKGROUND);
             logtypeText.setBackground(COLOR_TEXT_BACKGROUND);
-            for (CustomTxtTraceDefinition def : CustomTxtTraceDefinition.loadAll()) {
-                if (definition.definitionName.equals(def.definitionName) &&
-                        (editDefinitionName == null || !editDefinitionName.equals(definition.definitionName))) {
-                    errors.append("The log type name already exists. "); //$NON-NLS-1$
+            if (definition.categoryName.indexOf(':') != -1) {
+                errors.append("Invalid character ':' in category. "); //$NON-NLS-1$
+                categoryText.setBackground(COLOR_LIGHT_RED);
+            }
+            if (definition.definitionName.indexOf(':') != -1) {
+                errors.append("Invalid character ':' in trace type. "); //$NON-NLS-1$
+                logtypeText.setBackground(COLOR_LIGHT_RED);
+            }
+            for (TraceTypeHelper helper : TmfTraceType.getTraceTypeHelpers()) {
+                if (definition.categoryName.equals(helper.getCategoryName()) &&
+                        definition.definitionName.equals(helper.getName()) &&
+                        (editDefinitionName == null || !editDefinitionName.equals(definition.definitionName)) &&
+                        (editCategoryName == null || !editCategoryName.equals(definition.categoryName))) {
+                    errors.append("The trace type name already exists. "); //$NON-NLS-1$
                     logtypeText.setBackground(COLOR_LIGHT_RED);
                     break;
                 }
@@ -1478,7 +1534,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
         for (int i = 0; i < definition.inputs.size(); i++) {
 
             InputLine inputLine = definition.inputs.get(i);
-            String name = Integer.toString(i+1);
+            String name = Integer.toString(i + 1);
             errors.append(validateLine(inputLine, name));
         }
         if (timestampFound) {
@@ -1529,13 +1585,13 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                 line.regexText.setBackground(COLOR_TEXT_BACKGROUND);
             }
         } catch (PatternSyntaxException e) {
-            errors.append("Enter a valid regular expression (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$
+            errors.append("Enter a valid regular expression (Line " + name + "). "); //$NON-NLS-1$ //$NON-NLS-2$
             if (line != null) {
                 line.regexText.setBackground(COLOR_LIGHT_RED);
             }
         }
         if (inputLine.getMinCount() == -1) {
-            errors.append("Enter a minimum value for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$
+            errors.append("Enter a minimum value for cardinality (Line " + name + "). "); //$NON-NLS-1$ //$NON-NLS-2$
             if (line != null) {
                 line.cardinalityMinText.setBackground(COLOR_LIGHT_RED);
             }
@@ -1545,12 +1601,12 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
             }
         }
         if (inputLine.getMaxCount() == -1) {
-            errors.append("Enter a maximum value for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$
+            errors.append("Enter a maximum value for cardinality (Line " + name + "). "); //$NON-NLS-1$ //$NON-NLS-2$
             if (line != null) {
                 line.cardinalityMaxText.setBackground(COLOR_LIGHT_RED);
             }
         } else if (inputLine.getMinCount() > inputLine.getMaxCount()) {
-            errors.append("Enter correct (min <= max) values for cardinality (Line "+name+"). "); //$NON-NLS-1$ //$NON-NLS-2$
+            errors.append("Enter correct (min <= max) values for cardinality (Line " + name + "). "); //$NON-NLS-1$ //$NON-NLS-2$
             if (line != null) {
                 line.cardinalityMinText.setBackground(COLOR_LIGHT_RED);
             }
@@ -1571,7 +1627,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
             if (inputData.name.equals(CustomTraceDefinition.TAG_TIMESTAMP)) {
                 timestampFound = true;
                 if (inputData.format.length() == 0) {
-                    errors.append("Enter the input format for the Time Stamp (Line "+name+" Group "+(i+1)+"). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                    errors.append("Enter the input format for the Time Stamp (Line " + name + " Group " + (i + 1) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                     if (group != null) {
                         group.tagText.setBackground(COLOR_LIGHT_RED);
                     }
@@ -1582,14 +1638,14 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
                             group.tagText.setBackground(COLOR_TEXT_BACKGROUND);
                         }
                     } catch (IllegalArgumentException e) {
-                        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$
+                        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$
                         if (group != null) {
                             group.tagText.setBackground(COLOR_LIGHT_RED);
                         }
                     }
                 }
             } else if (inputData.name.length() == 0) {
-                errors.append("Enter a name for the data group (Line "+name+" Group "+(i+1)+"). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+                errors.append("Enter a name for the data group (Line " + name + " Group " + (i + 1) + "). "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
                 if (group != null) {
                     group.tagText.setBackground(COLOR_LIGHT_RED);
                 }
@@ -1600,7 +1656,7 @@ public class CustomTxtParserInputWizardPage extends WizardPage {
             }
         }
         for (int i = 0; inputLine.childrenInputs != null && i < inputLine.childrenInputs.size(); i++) {
-            errors.append(validateLine(inputLine.childrenInputs.get(i), name+"."+(i+1))); //$NON-NLS-1$
+            errors.append(validateLine(inputLine.childrenInputs.get(i), name + "." + (i + 1))); //$NON-NLS-1$
         }
         return errors;
     }
This page took 0.051213 seconds and 5 git commands to generate.