use of org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParserRule in project netxms by netxms.
the class LogParserEditor method buildParserXml.
/**
* Build parser XML from current builder state
*
* @return
*/
private String buildParserXml() {
if (!isSyslogParser) {
parser.setFile(labelFileName.getText());
parser.setEncoding((comboFileEncoding.getSelectionIndex() == 0) ? null : comboFileEncoding.getText());
}
parser.setProcessALL(checkProcessAll.getSelection());
parser.setTrace(spinerTrace.getSelection());
for (LogParserRule rule : parser.getRules()) rule.getEditor().save();
try {
return parser.createXml();
} catch (Exception e) {
e.printStackTrace();
// $NON-NLS-1$
return "<parser>\n</parser>";
}
}
use of org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParserRule in project netxms by netxms.
the class LogParserEditor method updateBuilderFromXml.
/**
* Update parser builder from XML
*
* @param xml
*/
private void updateBuilderFromXml(String xml) {
if (parser != null) {
for (LogParserRule rule : parser.getRules()) rule.getEditor().dispose();
}
try {
parser = LogParser.createFromXml(xml);
} catch (Exception e) {
e.printStackTrace();
MessageDialogHelper.openError(getShell(), Messages.get().LogParserEditor_Error, Messages.get().LogParserEditor_InvalidDefinition);
parser = new LogParser();
}
parser.setSyslogParser(isSyslogParser);
/* general */
if (!isSyslogParser) {
labelFileName.setText(parser.getFile());
comboFileEncoding.setText((parser.getEncoding() == null) ? "AUTO" : parser.getEncoding());
}
spinerTrace.setSelection(parser.getTrace() != null ? parser.getTrace() : 0);
checkProcessAll.setSelection(parser.getProcessALL());
/* rules */
for (LogParserRule rule : parser.getRules()) createRuleEditor(rule).moveAbove(addColumnLink);
/* macros */
macroList.setInput(parser.getMacros().entrySet().toArray());
form.reflow(true);
form.getParent().layout(true, true);
}
use of org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParserRule in project netxms by netxms.
the class LogParserEditor method addRule.
/**
* @param addColumnLink
*/
private void addRule() {
LogParserRule rule = new LogParserRule();
LogParserRuleEditor editor = createRuleEditor(rule);
editor.moveAbove(addColumnLink);
parser.getRules().add(rule);
form.reflow(true);
fireModifyListeners();
}
use of org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParserRule in project netxms by netxms.
the class LogParserEditor method createGeneralArea.
/**
* @param generalArea
*/
private void createGeneralArea(Composite generalArea) {
GridLayout layout = new GridLayout();
layout.makeColumnsEqualWidth = false;
layout.numColumns = 3;
generalArea.setLayout(layout);
if (!isSyslogParser) {
labelFileName = new LabeledText(generalArea, SWT.NONE);
labelFileName.setLabel("Parsing file path");
// $NON-NLS-1$
labelFileName.setText((parser.getFile() != null) ? parser.getFile() : "");
GridData gd = new GridData();
gd.grabExcessHorizontalSpace = true;
gd.horizontalAlignment = SWT.FILL;
labelFileName.setLayoutData(gd);
labelFileName.getTextControl().addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
fireModifyListeners();
for (LogParserRule rule : parser.getRules()) {
if (rule.getEditor() != null)
rule.getEditor().updateWindowsEventLogFields();
}
}
});
String[] items = { "AUTO", "ACP", "UTF-8", "UCS-2", "UCS-2LE", "UCS-2BE", "UCS-4", "UCS-4LE", "UCS-4BE" };
gd = new GridData();
comboFileEncoding = (Combo) WidgetHelper.createLabeledCombo(generalArea, SWT.BORDER | SWT.READ_ONLY, "Parsing file encoding", gd);
comboFileEncoding.setItems(items);
comboFileEncoding.select((parser.getEncoding() != null) ? Arrays.asList(items).indexOf(parser.getEncoding()) : 0);
comboFileEncoding.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
fireModifyListeners();
}
});
}
final WidgetFactory spinnerFactory = new WidgetFactory() {
@Override
public Control createControl(Composite parent, int style) {
return new Spinner(parent, style);
}
};
GridData gd = new GridData();
gd.horizontalAlignment = SWT.FILL;
spinerTrace = (Spinner) WidgetHelper.createLabeledControl(generalArea, SWT.BORDER, spinnerFactory, "Trace level", gd);
spinerTrace.setMinimum(0);
spinerTrace.setMaximum(9);
spinerTrace.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
fireModifyListeners();
}
});
spinerTrace.setSelection(parser.getTrace() != null ? parser.getTrace() : 0);
checkProcessAll = toolkit.createButton(generalArea, "Process all", SWT.CHECK);
checkProcessAll.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
fireModifyListeners();
}
});
}
Aggregations