Search in sources :

Example 11 with EventObject

use of org.netxms.client.events.EventObject in project netxms by netxms.

the class LogParserRuleEditor method createActionArea.

/**
 * Create action area
 */
private Composite createActionArea(Composite parent) {
    Composite area = new Composite(parent, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;
    area.setLayout(layout);
    long eventCode = 0;
    if (rule.getEvent() != null) {
        try {
            eventCode = Long.parseLong(rule.getEvent().getEvent());
        } catch (NumberFormatException e) {
            EventObject o = ((NXCSession) ConsoleSharedData.getSession()).findEventObjectByName(rule.getEvent().getEvent());
            if (o != null)
                eventCode = o.getCode();
        }
    }
    event = new EventSelector(area, SWT.NONE, true);
    toolkit.adapt(event);
    event.setLabel(Messages.get().LogParserRuleEditor_GenerateEvent);
    event.setEventCode(eventCode);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    event.setLayoutData(gd);
    event.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            eventParamCount.setEnabled(event.getEventCode() != 0);
            editor.fireModifyListeners();
        }
    });
    final WidgetFactory factory = new WidgetFactory() {

        @Override
        public Control createControl(Composite parent, int style) {
            return new Spinner(parent, style);
        }
    };
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    eventParamCount = (Spinner) WidgetHelper.createLabeledControl(area, SWT.BORDER, factory, Messages.get().LogParserRuleEditor_Parameters, gd);
    toolkit.adapt(eventParamCount);
    eventParamCount.setMinimum(0);
    eventParamCount.setMaximum(32);
    if (rule.getEvent() != null) {
        eventParamCount.setSelection(rule.getEvent().getParameterCount());
    } else {
        eventParamCount.setSelection(0);
        eventParamCount.setEnabled(false);
    }
    eventParamCount.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            editor.fireModifyListeners();
        }
    });
    final LogParserContext contextDefinition = rule.getContextDefinition();
    context = new LabeledText(area, SWT.NONE);
    toolkit.adapt(context);
    context.setLabel(Messages.get().LogParserRuleEditor_ChangeContext);
    // $NON-NLS-1$
    context.setText((contextDefinition != null) ? contextDefinition.getData() : "");
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    context.setLayoutData(gd);
    context.getTextControl().addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            boolean contextSet = !context.getText().trim().isEmpty();
            contextAction.setEnabled(contextSet);
            contextResetMode.setEnabled(contextSet && (contextAction.getSelectionIndex() == 0));
            editor.fireModifyListeners();
        }
    });
    final Composite contextOptions = new Composite(area, SWT.NONE);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    layout.makeColumnsEqualWidth = true;
    contextOptions.setLayout(layout);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 2;
    contextOptions.setLayoutData(gd);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    contextAction = WidgetHelper.createLabeledCombo(contextOptions, SWT.READ_ONLY, Messages.get().LogParserRuleEditor_ContextAction, gd);
    toolkit.adapt(contextAction);
    contextAction.add(Messages.get().LogParserRuleEditor_CtxActionActivate);
    contextAction.add(Messages.get().LogParserRuleEditor_CtxActionClear);
    if (contextDefinition != null) {
        contextAction.select(contextDefinition.getAction());
    } else {
        contextAction.select(0);
        contextAction.setEnabled(false);
    }
    contextAction.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            contextResetMode.setEnabled(contextAction.getSelectionIndex() == 0);
            editor.fireModifyListeners();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    contextResetMode = WidgetHelper.createLabeledCombo(contextOptions, SWT.READ_ONLY, Messages.get().LogParserRuleEditor_ContextResetMode, gd);
    toolkit.adapt(contextResetMode);
    contextResetMode.add(Messages.get().LogParserRuleEditor_CtxModeAuto);
    contextResetMode.add(Messages.get().LogParserRuleEditor_CtxModeManual);
    if (contextDefinition != null) {
        contextResetMode.select(contextDefinition.getReset());
        contextResetMode.setEnabled(contextDefinition.getAction() == 0);
    } else {
        contextResetMode.select(0);
        contextResetMode.setEnabled(false);
    }
    contextResetMode.addSelectionListener(new SelectionListener() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            editor.fireModifyListeners();
        }

        @Override
        public void widgetDefaultSelected(SelectionEvent e) {
            widgetSelected(e);
        }
    });
    checkboxBreak = toolkit.createButton(area, "Process all", SWT.CHECK);
    checkboxBreak.setText("Break");
    checkboxBreak.setSelection(rule.isBreakProcessing());
    return area;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) DashboardComposite(org.netxms.ui.eclipse.widgets.DashboardComposite) ModifyListener(org.eclipse.swt.events.ModifyListener) LabeledText(org.netxms.ui.eclipse.widgets.LabeledText) Spinner(org.eclipse.swt.widgets.Spinner) EventSelector(org.netxms.ui.eclipse.eventmanager.widgets.EventSelector) EventObject(org.netxms.client.events.EventObject) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) WidgetFactory(org.netxms.ui.eclipse.tools.WidgetFactory) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 12 with EventObject

use of org.netxms.client.events.EventObject in project netxms by netxms.

the class NXCSession method syncEventObjects.

/**
 * Synchronize event templates configuration. After call to this method
 * session object will maintain internal list of configured event templates.
 *
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public void syncEventObjects() throws IOException, NXCException {
    List<EventObject> objects = getEventObjects();
    synchronized (eventObjects) {
        eventObjects.clear();
        for (EventObject o : objects) {
            eventObjects.put(o.getCode(), o);
        }
        eventObjectsNeedSync = true;
    }
}
Also used : EventObject(org.netxms.client.events.EventObject)

Example 13 with EventObject

use of org.netxms.client.events.EventObject in project netxms by netxms.

the class NXCSession method getEventObjects.

/**
 * Get event objects from server
 *
 * @return List of configured event objects
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 */
public List<EventObject> getEventObjects() throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_LOAD_EVENT_DB);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_EVENTS);
    long base = NXCPCodes.VID_ELEMENT_LIST_BASE;
    ArrayList<EventObject> list = new ArrayList<EventObject>();
    for (int i = 0; i < count; i++) {
        list.add(EventObject.createFromMessage(response, base));
        base += 10;
    }
    return list;
}
Also used : NXCPMessage(org.netxms.base.NXCPMessage) ArrayList(java.util.ArrayList) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint) EventObject(org.netxms.client.events.EventObject)

Example 14 with EventObject

use of org.netxms.client.events.EventObject in project netxms by netxms.

the class EventConditionEditor method createContent.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.logviewer.widgets.ConditionEditor#createContent(org.eclipse.swt.widgets.Composite)
	 */
@Override
protected void createContent(Composite parent, ColumnFilter initialFilter) {
    Composite group = new Composite(this, SWT.NONE);
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.horizontalSpacing = WidgetHelper.INNER_SPACING;
    layout.numColumns = 2;
    group.setLayout(layout);
    GridData gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    group.setLayoutData(gd);
    objectName = new CLabel(group, SWT.NONE);
    toolkit.adapt(objectName);
    gd = new GridData();
    gd.horizontalAlignment = SWT.FILL;
    gd.grabExcessHorizontalSpace = true;
    gd.verticalAlignment = SWT.TOP;
    objectName.setLayoutData(gd);
    objectName.setText(EMPTY_SELECTION_TEXT);
    final ImageHyperlink selectionLink = toolkit.createImageHyperlink(group, SWT.NONE);
    selectionLink.setImage(SharedIcons.IMG_FIND);
    selectionLink.addHyperlinkListener(new HyperlinkAdapter() {

        @Override
        public void linkActivated(HyperlinkEvent e) {
            selectEvent();
        }
    });
    if ((initialFilter != null) && (initialFilter.getType() == ColumnFilterType.EQUALS)) {
        setSelectedOperation(initialFilter.isNegated() ? 1 : 0);
        eventCode = initialFilter.getNumericValue();
        EventObject o = ConsoleSharedData.getSession().findEventObjectByCode(eventCode);
        if (o != null && o instanceof EventObject) {
            objectName.setText(o.getName());
            objectName.setImage(labelProvider.getImage(o));
        } else {
            objectName.setImage(StatusDisplayInfo.getStatusImage(Severity.UNKNOWN));
            // $NON-NLS-1$ //$NON-NLS-2$
            objectName.setText("[" + eventCode + "]");
        }
    }
}
Also used : CLabel(org.eclipse.swt.custom.CLabel) GridLayout(org.eclipse.swt.layout.GridLayout) HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) GridData(org.eclipse.swt.layout.GridData) EventObject(org.netxms.client.events.EventObject) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 15 with EventObject

use of org.netxms.client.events.EventObject in project netxms by netxms.

the class EventObjectList method removeFromGroup.

/**
 * Remove event object from group
 */
@SuppressWarnings("unchecked")
protected void removeFromGroup() {
    ITreeSelection selection = (ITreeSelection) viewer.getSelection();
    List<EventObject> list = selection.toList();
    for (int i = 0; i < selection.size(); i++) {
        EventGroup parent = (EventGroup) selection.getPathsFor(list.get(i))[0].getParentPath().getLastSegment();
        EventObject child = list.get(i);
        parent.removeChild(child.getCode());
        modifyEventObject(parent, false);
    }
}
Also used : ITreeSelection(org.eclipse.jface.viewers.ITreeSelection) EventObject(org.netxms.client.events.EventObject) EventGroup(org.netxms.client.events.EventGroup)

Aggregations

EventObject (org.netxms.client.events.EventObject)24 EventTemplate (org.netxms.client.events.EventTemplate)6 EventSelectionDialog (org.netxms.ui.eclipse.eventmanager.dialogs.EventSelectionDialog)5 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 Composite (org.eclipse.swt.widgets.Composite)4 EventGroup (org.netxms.client.events.EventGroup)4 SnmpTrap (org.netxms.client.snmp.SnmpTrap)4 HashSet (java.util.HashSet)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 AbstractObject (org.netxms.client.objects.AbstractObject)3 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 ITreeSelection (org.eclipse.jface.viewers.ITreeSelection)2 CLabel (org.eclipse.swt.custom.CLabel)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 TableColumn (org.eclipse.swt.widgets.TableColumn)2