Search in sources :

Example 1 with LogParserRule

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>";
    }
}
Also used : LogParserRule(org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParserRule)

Example 2 with LogParserRule

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);
}
Also used : LogParserRule(org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParserRule) LogParser(org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParser)

Example 3 with LogParserRule

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();
}
Also used : LogParserRule(org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParserRule) LogParserRuleEditor(org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParserRuleEditor)

Example 4 with LogParserRule

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();
        }
    });
}
Also used : LogParserModifyListener(org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParserModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) Spinner(org.eclipse.swt.widgets.Spinner) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) LogParserRule(org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParserRule) WidgetFactory(org.netxms.ui.eclipse.tools.WidgetFactory) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Aggregations

LogParserRule (org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParserRule)4 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Spinner (org.eclipse.swt.widgets.Spinner)1 LogParser (org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParser)1 LogParserModifyListener (org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParserModifyListener)1 LogParserRuleEditor (org.netxms.ui.eclipse.serverconfig.widgets.helpers.LogParserRuleEditor)1 WidgetFactory (org.netxms.ui.eclipse.tools.WidgetFactory)1 LabeledText (org.netxms.ui.eclipse.widgets.LabeledText)1