Search in sources :

Example 6 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 SnmpTrapEditor.COLUMN_ID:
            rc = Long.signum(trap1.getId() - trap2.getId());
            break;
        case SnmpTrapEditor.COLUMN_TRAP_OID:
            rc = trap1.getObjectId().compareTo(trap2.getObjectId());
            break;
        case SnmpTrapEditor.COLUMN_EVENT:
            EventObject evo1 = session.findEventObjectByCode(trap1.getEventCode());
            EventObject evo2 = session.findEventObjectByCode(trap2.getEventCode());
            String name1 = (evo1 != null) ? evo1.getName() : Messages.get().SnmpTrapComparator_Unknown;
            String name2 = (evo2 != null) ? evo2.getName() : Messages.get().SnmpTrapComparator_Unknown;
            rc = name1.compareToIgnoreCase(name2);
            break;
        case SnmpTrapEditor.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 7 with EventObject

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

the class EventSelectionDialog method okPressed.

/* (non-Javadoc)
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
	 */
@SuppressWarnings("unchecked")
@Override
protected void okPressed() {
    final IStructuredSelection selection = (IStructuredSelection) eventObjectList.getViewer().getSelection();
    final List<EventObject> list = selection.toList();
    selectedEvents = list.toArray(new EventObject[list.size()]);
    super.okPressed();
}
Also used : IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) EventObject(org.netxms.client.events.EventObject)

Example 8 with EventObject

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

the class ExportFileBuilder method doExport.

/**
 * Do export operation and call completion handler when done
 *
 * @param completionHandler
 */
private void doExport(final ExportCompletionHandler completionHandler) {
    final long[] eventList = new long[events.size()];
    int i = 0;
    for (EventObject o : events.values()) eventList[i++] = o.getCode();
    final long[] templateList = new long[templates.size()];
    i = 0;
    for (Template t : templates.values()) templateList[i++] = t.getObjectId();
    final long[] trapList = new long[traps.size()];
    i = 0;
    for (SnmpTrap t : traps.values()) trapList[i++] = t.getId();
    final UUID[] ruleList = new UUID[rules.size()];
    i = 0;
    for (EventProcessingPolicyRule r : rules.values()) ruleList[i++] = r.getGuid();
    final long[] scriptList = new long[scripts.size()];
    i = 0;
    for (Script s : scripts.values()) scriptList[i++] = s.getId();
    final long[] toolList = new long[tools.size()];
    i = 0;
    for (ObjectTool t : tools.values()) toolList[i++] = t.getId();
    final long[] summaryTableList = new long[summaryTables.size()];
    i = 0;
    for (DciSummaryTableDescriptor t : summaryTables.values()) summaryTableList[i++] = t.getId();
    final long[] actionList = new long[actions.size()];
    i = 0;
    for (ServerAction a : actions.values()) actionList[i++] = a.getId();
    final String descriptionText = description.getText();
    new ConsoleJob(Messages.get().ExportFileBuilder_ExportJobName, this, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final String xml = session.exportConfiguration(descriptionText, eventList, trapList, templateList, ruleList, scriptList, toolList, summaryTableList, actionList);
            runInUIThread(new Runnable() {

                @Override
                public void run() {
                    completionHandler.exportCompleted(xml);
                }
            });
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().ExportFileBuilder_ExportJobError;
        }
    }.start();
}
Also used : EventProcessingPolicyRule(org.netxms.client.events.EventProcessingPolicyRule) Script(org.netxms.client.Script) SnmpTrap(org.netxms.client.snmp.SnmpTrap) EventObject(org.netxms.client.events.EventObject) DciSummaryTableDescriptor(org.netxms.client.datacollection.DciSummaryTableDescriptor) Template(org.netxms.client.objects.Template) EventTemplate(org.netxms.client.events.EventTemplate) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) UUID(java.util.UUID) ServerAction(org.netxms.client.ServerAction) ObjectTool(org.netxms.client.objecttools.ObjectTool)

Example 9 with EventObject

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

the class ExportFileBuilder method addTraps.

/**
 * Add traps to list
 */
private void addTraps() {
    SelectSnmpTrapDialog dlg = new SelectSnmpTrapDialog(getSite().getShell(), snmpTrapCache);
    if (dlg.open() == Window.OK) {
        final Set<Long> eventCodes = new HashSet<Long>();
        for (SnmpTrap t : dlg.getSelection()) {
            traps.put(t.getId(), t);
            if (t.getEventCode() >= 100000) {
                eventCodes.add((long) t.getEventCode());
            }
        }
        trapViewer.setInput(traps.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 : SelectSnmpTrapDialog(org.netxms.ui.eclipse.serverconfig.dialogs.SelectSnmpTrapDialog) SnmpTrap(org.netxms.client.snmp.SnmpTrap) EventObject(org.netxms.client.events.EventObject) HashSet(java.util.HashSet)

Example 10 with EventObject

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

the class ExportFileBuilder method addTemplates.

/**
 * Add templates to list
 */
private void addTemplates() {
    final ObjectSelectionDialog dlg = new ObjectSelectionDialog(getSite().getShell(), null, ObjectSelectionDialog.createTemplateSelectionFilter());
    dlg.enableMultiSelection(true);
    dlg.showFilterToolTip(false);
    if (dlg.open() == Window.OK) {
        final Set<Long> idList = new HashSet<Long>();
        for (AbstractObject o : dlg.getSelectedObjects()) {
            if (o instanceof TemplateGroup) {
                Set<AbstractObject> children = ((TemplateGroup) o).getAllChilds(AbstractObject.OBJECT_TEMPLATE);
                for (AbstractObject child : children) {
                    templates.put(((Template) child).getObjectId(), (Template) child);
                    idList.add(child.getObjectId());
                }
            } else if (o instanceof Template) {
                templates.put(((Template) o).getObjectId(), (Template) o);
                idList.add(o.getObjectId());
            }
        }
        templateViewer.setInput(templates.values().toArray());
        setModified();
        new ConsoleJob(Messages.get().ExportFileBuilder_ResolveJobName, this, Activator.PLUGIN_ID, null) {

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                final Set<Long> eventCodes = new HashSet<Long>();
                final Map<Long, Script> scriptList = new HashMap<Long, Script>();
                for (Long id : idList) {
                    long[] e = session.getDataCollectionEvents(id);
                    for (long c : e) {
                        if (c >= 100000)
                            eventCodes.add(c);
                    }
                    for (Script s : session.getDataCollectionScripts(id)) scriptList.put(s.getId(), s);
                }
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        for (EventObject e : session.findMultipleEventObjects(eventCodes.toArray(new Long[eventCodes.size()]))) {
                            events.put(e.getCode(), e);
                        }
                        eventViewer.setInput(events.values().toArray());
                        scripts.putAll(scriptList);
                        scriptViewer.setInput(scripts.values().toArray());
                    }
                });
            }

            @Override
            protected String getErrorMessage() {
                return null;
            }
        }.start();
    }
}
Also used : Script(org.netxms.client.Script) Set(java.util.Set) HashSet(java.util.HashSet) EventObject(org.netxms.client.events.EventObject) Template(org.netxms.client.objects.Template) EventTemplate(org.netxms.client.events.EventTemplate) ObjectSelectionDialog(org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TemplateGroup(org.netxms.client.objects.TemplateGroup) AbstractObject(org.netxms.client.objects.AbstractObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Map(java.util.Map) HashMap(java.util.HashMap) HashSet(java.util.HashSet)

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