import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
+import java.net.URL;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
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;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
+import org.osgi.framework.Bundle;
/**
* Input wizard page for custom text parsers.
private static final String DEFAULT_REGEX = "\\s*(.*\\S)"; //$NON-NLS-1$
private static final String DEFAULT_TIMESTAMP_FORMAT = "yyyy-MM-dd HH:mm:ss.SSS"; //$NON-NLS-1$
- private static final String SIMPLE_DATE_FORMAT_URL = "http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html#skip-navbar_top"; //$NON-NLS-1$
+ private static final String TIMESTAMP_FORMAT_BUNDLE = "org.eclipse.linuxtools.lttng.help"; //$NON-NLS-1$
+ private static final String TIMESTAMP_FORMAT_PATH = "reference/api/org/eclipse/linuxtools/tmf/core/timestamp/TmfTimestampFormat.html"; //$NON-NLS-1$
private static final String PATTERN_URL = "http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html#sum"; //$NON-NLS-1$
private static final Image LINE_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/line_icon.gif"); //$NON-NLS-1$
private static final Image ADD_IMAGE = Activator.getDefault().getImageFromPath("/icons/elcl16/add_button.gif"); //$NON-NLS-1$
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;
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());
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);
timestampOutputFormatText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
timestampOutputFormatText.setText(DEFAULT_TIMESTAMP_FORMAT);
- Button dateFormatHelpButton = new Button(headerComposite, SWT.PUSH);
- dateFormatHelpButton.setImage(HELP_IMAGE);
- dateFormatHelpButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_dateFormatHelp);
- dateFormatHelpButton.addSelectionListener(new SelectionAdapter() {
+ Button timeStampFormatHelpButton = new Button(headerComposite, SWT.PUSH);
+ timeStampFormatHelpButton.setImage(HELP_IMAGE);
+ timeStampFormatHelpButton.setToolTipText(Messages.CustomTxtParserInputWizardPage_timestampFormatHelp);
+ timeStampFormatHelpButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
- openHelpShell(SIMPLE_DATE_FORMAT_URL);
+ Bundle plugin = Platform.getBundle(TIMESTAMP_FORMAT_BUNDLE);
+ IPath path = new Path(TIMESTAMP_FORMAT_PATH);
+ URL fileURL = FileLocator.find(plugin, path, null);
+ try {
+ URL pageURL = FileLocator.toFileURL(fileURL);
+ openHelpShell(pageURL.toString());
+ } catch (IOException e1) {
+ }
}
});
+ 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);
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) {
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;
}
}
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;
}
}
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);
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);
}
private void loadDefinition(CustomTxtTraceDefinition def) {
+ categoryText.setText(def.categoryName);
logtypeText.setText(def.definitionName);
timestampOutputFormatText.setText(def.timeStampOutputFormat);
treeViewer.setInput(def.inputs);
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$
}
/**
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();
}
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()));
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 {
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));
}
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;
}
}
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;
}
}
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);
}
}
rawPos += length + 1; // +1 for \n
- log = null;
+ line = null;
+ lineIsNull = true;
}
if (rootLineMatches == 1) {
} 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$
}
}
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);
}
// 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));
}
}
helpShell.setText(event.title);
}
});
- helpBrowser.setBounds(0, 0, 600, 400);
- helpShell.pack();
+ Rectangle r = container.getBounds();
+ Point p = container.toDisplay(r.x, r.y);
+ Rectangle trim = helpShell.computeTrim(p.x + (r.width - 750) / 2, p.y + (r.height - 400) / 2, 750, 400);
+ helpShell.setBounds(trim);
helpShell.open();
helpBrowser.setUrl(url);
}
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();
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) {
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);
}
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();
}
}
}
- }};
+ }
+ };
cardinalityMinText.addModifyListener(updateListener);
cardinalityMaxText.addModifyListener(updateListener);
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);
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();
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();
}
}
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) {
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();
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);
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;
tagComposite.layout();
validate();
updatePreviews();
- }});
+ }
+ });
tagLabel = new Label(tagComposite, SWT.NULL);
tagLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
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);
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();
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;
}
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) {
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);
}
}
}
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);
}
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);
}
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);
}
}
}
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;
}