Search in sources :

Example 21 with EventObject

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

the class ExportFileBuilder method addRules.

/**
 * Add rules to list
 */
private void addRules() {
    RuleSelectionDialog dlg = new RuleSelectionDialog(getSite().getShell(), rulesCache);
    if (dlg.open() == Window.OK) {
        final Set<Long> eventCodes = new HashSet<Long>();
        for (EventProcessingPolicyRule r : dlg.getSelectedRules()) {
            rules.put(r.getRuleNumber(), r);
            for (Long e : r.getEvents()) {
                if (e >= 100000) {
                    eventCodes.add(e);
                }
            }
        }
        ruleViewer.setInput(rules.values().toArray());
        setModified();
        if (eventCodes.size() > 0) {
            for (EventObject o : session.findMultipleEventObjects(eventCodes.toArray(new Long[eventCodes.size()]))) {
                events.put(o.getCode(), o);
            }
            eventViewer.setInput(events.values().toArray());
        }
        ;
    }
}
Also used : EventProcessingPolicyRule(org.netxms.client.events.EventProcessingPolicyRule) RuleSelectionDialog(org.netxms.ui.eclipse.epp.dialogs.RuleSelectionDialog) EventObject(org.netxms.client.events.EventObject) HashSet(java.util.HashSet)

Example 22 with EventObject

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

the class ExportFileBuilder method addEvents.

/**
 * Add events to list
 */
private void addEvents() {
    EventSelectionDialog dlg = new EventSelectionDialog(getSite().getShell(), true);
    dlg.enableMultiSelection(true);
    if (dlg.open() == Window.OK) {
        for (EventObject t : dlg.getSelectedEvents()) {
            if (t instanceof EventGroup)
                addEventGroups((EventGroup) t);
            else
                events.put(t.getCode(), t);
        }
        eventViewer.setInput(events.values().toArray());
        setModified();
    }
}
Also used : EventObject(org.netxms.client.events.EventObject) EventGroup(org.netxms.client.events.EventGroup) EventSelectionDialog(org.netxms.ui.eclipse.eventmanager.dialogs.EventSelectionDialog)

Example 23 with EventObject

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

the class SnmpTrapComparator method compare.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.ViewerComparator#compare(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
	 */
@Override
public int compare(Viewer viewer, Object e1, Object e2) {
    TableColumn sortColumn = ((TableViewer) viewer).getTable().getSortColumn();
    if (sortColumn == null)
        return 0;
    int rc;
    SnmpTrap trap1 = (SnmpTrap) e1;
    SnmpTrap trap2 = (SnmpTrap) e2;
    switch(// $NON-NLS-1$
    (Integer) sortColumn.getData("ID")) {
        case SelectSnmpTrapDialog.COLUMN_OID:
            rc = trap1.getObjectId().compareTo(trap2.getObjectId());
            break;
        case SelectSnmpTrapDialog.COLUMN_EVENT:
            EventObject evo1 = session.findEventObjectByCode(trap1.getEventCode());
            EventObject evo2 = session.findEventObjectByCode(trap2.getEventCode());
            // $NON-NLS-1$ //$NON-NLS-2$
            String name1 = (evo1 != null) ? evo1.getName() : ("[" + Integer.toString(trap1.getEventCode()) + "]");
            // $NON-NLS-1$ //$NON-NLS-2$
            String name2 = (evo2 != null) ? evo2.getName() : ("[" + Integer.toString(trap2.getEventCode()) + "]");
            rc = name1.compareToIgnoreCase(name2);
            break;
        case SelectSnmpTrapDialog.COLUMN_DESCRIPTION:
            rc = trap1.getDescription().compareToIgnoreCase(trap2.getDescription());
            break;
        default:
            rc = 0;
            break;
    }
    int dir = ((TableViewer) viewer).getTable().getSortDirection();
    return (dir == SWT.UP) ? rc : -rc;
}
Also used : SnmpTrap(org.netxms.client.snmp.SnmpTrap) TableColumn(org.eclipse.swt.widgets.TableColumn) EventObject(org.netxms.client.events.EventObject)

Example 24 with EventObject

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

the class EventFieldEditor method selectEvent.

/**
 * Select event
 */
private void selectEvent() {
    EventSelectionDialog dlg = new EventSelectionDialog(getShell(), false);
    dlg.enableMultiSelection(false);
    if (dlg.open() == Window.OK) {
        EventObject[] events = dlg.getSelectedEvents();
        if (events.length > 0) {
            eventCode = events[0].getCode();
            text.setText(events[0].getName());
            if (events[0] instanceof EventTemplate)
                text.setImage(StatusDisplayInfo.getStatusImage(((EventTemplate) events[0]).getSeverity()));
        } else {
            eventCode = 0;
            text.setText(EMPTY_SELECTION_TEXT);
            text.setImage(null);
        }
    }
}
Also used : EventTemplate(org.netxms.client.events.EventTemplate) EventObject(org.netxms.client.events.EventObject) EventSelectionDialog(org.netxms.ui.eclipse.eventmanager.dialogs.EventSelectionDialog)

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