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;
}
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();
}
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();
}
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());
}
;
}
}
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();
}
}
Aggregations