* The regex matcher to use
*/
public void processGroups(InputLine input, Matcher matcher) {
+ if (input.eventType != null) {
+ fData.put(CustomTraceDefinition.TAG_EVENT_TYPE, input.eventType);
+ }
if (input.columns == null) {
return;
}
private static final String MIN_ATTRIBUTE = Messages.CustomTxtTraceDefinition_min;
private static final String MAX_ATTRIBUTE = Messages.CustomTxtTraceDefinition_max;
private static final String REGEX_ELEMENT = Messages.CustomTxtTraceDefinition_regEx;
+ private static final String EVENT_TYPE_ELEMENT = Messages.CustomTxtTraceDefinition_eventType;
private static final String INPUT_DATA_ELEMENT = Messages.CustomTxtTraceDefinition_inputData;
private static final String ACTION_ATTRIBUTE = Messages.CustomTxtTraceDefinition_action;
private static final String FORMAT_ATTRIBUTE = Messages.CustomTxtTraceDefinition_format;
/** Children of this line (if one "event" spans many lines) */
public List<InputLine> childrenInputs;
+ /** Event type associated with this line
+ * @since 2.1*/
+ public String eventType;
+
private String regex;
private Pattern pattern;
inputLineElement.appendChild(regexElement);
regexElement.appendChild(doc.createTextNode(inputLine.regex));
+ if (inputLine.eventType != null) {
+ Element eventTypeElement = doc.createElement(EVENT_TYPE_ELEMENT);
+ inputLineElement.appendChild(eventTypeElement);
+ eventTypeElement.appendChild(doc.createTextNode(inputLine.eventType));
+ }
+
if (inputLine.columns != null) {
for (InputData inputData : inputLine.columns) {
Element inputDataElement = doc.createElement(INPUT_DATA_ELEMENT);
} else if (nodeName.equals(REGEX_ELEMENT)) {
Element regexElement = (Element) node;
inputLine.regex = regexElement.getTextContent();
+ } else if (nodeName.equals(EVENT_TYPE_ELEMENT)) {
+ Element eventTypeElement = (Element) node;
+ inputLine.eventType = eventTypeElement.getTextContent();
} else if (nodeName.equals(INPUT_DATA_ELEMENT)) {
Element inputDataElement = (Element) node;
InputData inputData = new InputData();
/** Child elements */
private List<CustomXmlInputElement> fChildElements;
+ /** Event type associated with this input element */
+ private String fEventType;
+
/**
* Default (empty) constructor
*/
fInputName = inputName;
}
+ /**
+ * @return the eventType, or null
+ * @since 2.1
+ */
+ public String getEventType() {
+ return fEventType;
+ }
+
+ /**
+ * @param eventType
+ * the eventType to set, or null
+ * @since 2.1
+ */
+ public void setEventType(String eventType) {
+ fEventType = eventType;
+ }
+
/**
* @return the inputAction
*/
}
private void parseElement(final Element element, final CustomXmlEvent event, final CustomXmlInputElement inputElement) {
+ String eventType = inputElement.getEventType();
+ if (eventType != null && event.getType() instanceof CustomEventType) {
+ ((CustomEventType) event.getType()).setName(eventType);
+ }
if (inputElement.getInputName() != null && !inputElement.getInputName().equals(CustomXmlTraceDefinition.TAG_IGNORE)) {
event.parseInput(parseElement(element, new StringBuffer()).toString(), inputElement.getInputName(), inputElement.getInputAction(), inputElement.getInputFormat());
}
private static final String CATEGORY_ATTRIBUTE = Messages.CustomXmlTraceDefinition_category;
private static final String NAME_ATTRIBUTE = Messages.CustomXmlTraceDefinition_name;
private static final String LOG_ENTRY_ATTRIBUTE = Messages.CustomXmlTraceDefinition_logEntry;
+ private static final String EVENT_TYPE_ATTRIBUTE = Messages.CustomXmlTraceDefinition_eventType;
private static final String TIME_STAMP_OUTPUT_FORMAT_ELEMENT = Messages.CustomXmlTraceDefinition_timestampOutputFormat;
private static final String INPUT_ELEMENT_ELEMENT = Messages.CustomXmlTraceDefinition_inputElement;
private static final String ATTRIBUTE_ELEMENT = Messages.CustomXmlTraceDefinition_attribute;
inputElementElement.setAttribute(LOG_ENTRY_ATTRIBUTE, Boolean.toString(inputElement.isLogEntry()));
}
+ if (inputElement.getEventType() != null) {
+ inputElementElement.setAttribute(EVENT_TYPE_ATTRIBUTE, inputElement.getEventType());
+ }
+
if (inputElement.getParentElement() != null) {
Element inputDataElement = doc.createElement(INPUT_DATA_ELEMENT);
inputElementElement.appendChild(inputDataElement);
CustomXmlInputElement inputElement = new CustomXmlInputElement();
inputElement.setElementName(inputElementElement.getAttribute(NAME_ATTRIBUTE));
inputElement.setLogEntry((Boolean.toString(true).equals(inputElementElement.getAttribute(LOG_ENTRY_ATTRIBUTE))) ? true : false);
+ String eventType = inputElementElement.getAttribute(EVENT_TYPE_ATTRIBUTE);
+ inputElement.setEventType(eventType.isEmpty() ? null : eventType);
NodeList nodeList = inputElementElement.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
public static String CustomTxtTraceDefinition_category;
public static String CustomTxtTraceDefinition_definition;
public static String CustomTxtTraceDefinition_definitionRootElement;
+ /** @since 2.1 */
+ public static String CustomTxtTraceDefinition_eventType;
public static String CustomTxtTraceDefinition_format;
public static String CustomTxtTraceDefinition_inputData;
public static String CustomTxtTraceDefinition_inputLine;
public static String CustomXmlTraceDefinition_category;
public static String CustomXmlTraceDefinition_definition;
public static String CustomXmlTraceDefinition_definitionRootElement;
+ /** @since 2.1 */
+ public static String CustomXmlTraceDefinition_eventType;
public static String CustomXmlTraceDefinition_format;
public static String CustomXmlTraceDefinition_ignoreTag;
public static String CustomXmlTraceDefinition_inputData;
CustomTxtTraceDefinition_category=category
CustomTxtTraceDefinition_definition=Definition
CustomTxtTraceDefinition_definitionRootElement=CustomTxtTraceDefinitionList
+CustomTxtTraceDefinition_eventType=EventType
CustomTxtTraceDefinition_format=format
CustomTxtTraceDefinition_inputData=InputData
CustomTxtTraceDefinition_inputLine=InputLine
CustomXmlTraceDefinition_category=category
CustomXmlTraceDefinition_definition=Definition
CustomXmlTraceDefinition_definitionRootElement=CustomXMLTraceDefinitionList
+CustomXmlTraceDefinition_eventType=eventtype
CustomXmlTraceDefinition_format=format
CustomXmlTraceDefinition_ignoreTag=Ignore
CustomXmlTraceDefinition_inputData=InputData
public static String CustomTxtParserInputWizardPage_category;
public static String CustomTxtParserInputWizardPage_desccriptionEdit;
public static String CustomTxtParserInputWizardPage_descriptionNew;
+ public static String CustomTxtParserInputWizardPage_eventType;
public static String CustomTxtParserInputWizardPage_format;
public static String CustomTxtParserInputWizardPage_group;
public static String CustomTxtParserInputWizardPage_highlightAll;
public static String CustomTxtParserOutputWizardPage_moveBefore;
public static String CustomTxtParserOutputWizardPage_visible;
public static String CustomXmlParserInputWizardPage_emptyCategoryError;
+ public static String CustomXmlParserInputWizardPage_emptyEventTypeError;
public static String CustomXmlParserInputWizardPage_emptyLogTypeError;
public static String CustomXmlParserInputWizardPage_invalidCategoryError;
public static String CustomXmlParserInputWizardPage_invalidLogTypeError;
###############################################################################
-# Copyright (c) 2013, 2015 Ericsson
+# Copyright (c) 2013, 2016 Ericsson
#
# All rights reserved. This program and the accompanying materials
# are made available under the terms of the Eclipse Public License v1.0
CustomTxtParserInputWizardPage_category=Category:
CustomTxtParserInputWizardPage_desccriptionEdit=Edit an existing custom parser for text trace files
CustomTxtParserInputWizardPage_descriptionNew=Create a new custom parser for text trace files
+CustomTxtParserInputWizardPage_eventType=Event type:
CustomTxtParserInputWizardPage_format=format:
CustomTxtParserInputWizardPage_group=Group {0}:
CustomTxtParserInputWizardPage_highlightAll=Highlight All
CustomTxtParserOutputWizardPage_moveBefore=Move Before
CustomTxtParserOutputWizardPage_visible=Visible
CustomXmlParserInputWizardPage_emptyCategoryError=Enter a category for the new trace type.
+CustomXmlParserInputWizardPage_emptyEventTypeError=Enter the event type for the element (Element {0}).
CustomXmlParserInputWizardPage_emptyLogTypeError=Enter a name for the new trace type.
CustomXmlParserInputWizardPage_invalidCategoryError=Invalid character ':' in category.
CustomXmlParserInputWizardPage_invalidLogTypeError=Invalid character ':' in trace type.
private Label cardinalityMaxLabel;
private Text cardinalityMaxText;
private Button infiniteButton;
+ private Button eventTypeButton;
+ private Text eventTypeText;
private List<InputGroup> inputs = new ArrayList<>();
private Button addGroupButton;
private Label addGroupLabel;
cardinalityMinText.addVerifyListener(digitsListener);
cardinalityMaxText.addVerifyListener(digitsListener);
+ eventTypeButton = new Button(group, SWT.CHECK);
+ eventTypeButton.setText(Messages.CustomTxtParserInputWizardPage_eventType);
+ eventTypeButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+ eventTypeButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (eventTypeButton.getSelection()) {
+ eventTypeText.setEnabled(true);
+ } else {
+ eventTypeText.setEnabled(false);
+ }
+ }
+ });
+ eventTypeButton.addSelectionListener(updateListener);
+
+ eventTypeText = new Text(group, SWT.BORDER | SWT.SINGLE);
+ gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ gd.widthHint = 0;
+ eventTypeText.setLayoutData(gd);
+ if (inputLine.eventType != null) {
+ eventTypeText.setText(inputLine.eventType);
+ eventTypeButton.setSelection(true);
+ } else {
+ eventTypeText.setEnabled(false);
+ eventTypeButton.setSelection(false);
+ }
+ eventTypeText.addModifyListener(updateListener);
+
+
if (inputLine.columns != null) {
for (InputData inputData : inputLine.columns) {
InputGroup inputGroup = new InputGroup(group, this, inputs.size() + 1);
private void extractInputs() {
inputLine.setRegex(selectedLine.regexText.getText());
+ inputLine.eventType = selectedLine.eventTypeButton.getSelection() ? selectedLine.eventTypeText.getText().trim() : null;
switch (cardinalityCombo.getSelectionIndex()) {
case 0:
inputLine.cardinality = Cardinality.ZERO_OR_MORE;
line.cardinalityMaxText.setBackground(COLOR_TEXT_BACKGROUND);
}
}
+ if (inputLine.eventType != null && inputLine.eventType.trim().isEmpty()) {
+ errors.append("Enter the event type (Line " + name + "). "); //$NON-NLS-1$ //$NON-NLS-2$
+ if (line != null) {
+ line.eventTypeText.setBackground(COLOR_LIGHT_RED);
+ }
+ } else {
+ if (line != null) {
+ line.eventTypeText.setBackground(COLOR_TEXT_BACKGROUND);
+ }
+ }
for (int i = 0; inputLine.columns != null && i < inputLine.columns.size(); i++) {
InputData inputData = inputLine.columns.get(i);
InputGroup group = null;
private Label previewLabel;
private Text previewText;
private Button logEntryButton;
+ private Button eventTypeButton;
+ private Text eventTypeText;
private Label fillerLabel;
private Composite addAttributeComposite;
private Button addAttributeButton;
tagText.setText(inputElement.getInputName());
tagText.addModifyListener(updateListener);
}
+
+ eventTypeButton = new Button(group, SWT.CHECK);
+ eventTypeButton.setText(Messages.CustomTxtParserInputWizardPage_eventType);
+ eventTypeButton.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
+ eventTypeButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ if (eventTypeButton.getSelection()) {
+ eventTypeText.setEnabled(true);
+ } else {
+ eventTypeText.setEnabled(false);
+ }
+ }
+ });
+ eventTypeButton.addSelectionListener(updateListener);
+
+ eventTypeText = new Text(group, SWT.BORDER | SWT.SINGLE);
+ gd = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ gd.widthHint = 0;
+ eventTypeText.setLayoutData(gd);
+ if (inputElement.getEventType() != null) {
+ eventTypeText.setText(inputElement.getEventType());
+ eventTypeButton.setSelection(true);
+ } else {
+ eventTypeText.setEnabled(false);
+ eventTypeButton.setSelection(false);
+ }
+ eventTypeText.addModifyListener(updateListener);
}
if (inputElement.getAttributes() != null) {
inputElement.setElementName(elementNameText.getText().trim());
if (inputElement.getParentElement() != null) {
inputElement.setLogEntry(logEntryButton.getSelection());
+ inputElement.setEventType(eventTypeButton.getSelection() ? eventTypeText.getText().trim() : null);
if (tagCombo.getText().equals(CustomTraceDefinition.TAG_OTHER)) {
inputElement.setInputName(tagText.getText().trim());
} else {
elementNode.tagText.setBackground(COLOR_TEXT_BACKGROUND);
}
}
+ if (inputElement.getEventType() != null && inputElement.getEventType().trim().isEmpty()) {
+ errors.add(NLS.bind(Messages.CustomXmlParserInputWizardPage_emptyEventTypeError, getName(inputElement)));
+ if (elementNode != null) {
+ elementNode.eventTypeText.setBackground(COLOR_LIGHT_RED);
+ }
+ } else {
+ if (elementNode != null) {
+ elementNode.eventTypeText.setBackground(COLOR_TEXT_BACKGROUND);
+ }
+ }
}
if (inputElement.getAttributes() != null) {
if (elementNode != null) {