use of org.netxms.client.events.Alarm in project netxms by netxms.
the class AlarmComparator 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;
switch(// $NON-NLS-1$
(Integer) sortColumn.getData("ID")) {
case AlarmList.COLUMN_SEVERITY:
rc = ((Alarm) e1).getCurrentSeverity().compareTo(((Alarm) e2).getCurrentSeverity());
break;
case AlarmList.COLUMN_STATE:
rc = Integer.signum(((Alarm) e1).getState() - ((Alarm) e2).getState());
break;
case AlarmList.COLUMN_SOURCE:
AbstractObject obj1 = ConsoleSharedData.getSession().findObjectById(((Alarm) e1).getSourceObjectId());
AbstractObject obj2 = ConsoleSharedData.getSession().findObjectById(((Alarm) e2).getSourceObjectId());
String name1 = (obj1 != null) ? obj1.getObjectName() : Messages.get().AlarmComparator_Unknown;
String name2 = (obj2 != null) ? obj2.getObjectName() : Messages.get().AlarmComparator_Unknown;
rc = name1.compareToIgnoreCase(name2);
break;
case AlarmList.COLUMN_MESSAGE:
rc = ((Alarm) e1).getMessage().compareToIgnoreCase(((Alarm) e2).getMessage());
break;
case AlarmList.COLUMN_COUNT:
rc = Integer.signum(((Alarm) e1).getRepeatCount() - ((Alarm) e2).getRepeatCount());
break;
case AlarmList.COLUMN_CREATED:
rc = ((Alarm) e1).getCreationTime().compareTo(((Alarm) e2).getCreationTime());
break;
case AlarmList.COLUMN_LASTCHANGE:
rc = ((Alarm) e1).getLastChangeTime().compareTo(((Alarm) e2).getLastChangeTime());
break;
case AlarmList.COLUMN_ZONE:
NXCSession session = ConsoleSharedData.getSession();
if (session.isZoningEnabled()) {
ZoneMember o1 = session.findObjectById(((Alarm) e1).getSourceObjectId(), ZoneMember.class);
ZoneMember o2 = session.findObjectById(((Alarm) e2).getSourceObjectId(), ZoneMember.class);
String n1 = (o1 != null) ? o1.getZoneName() : "";
String n2 = (o2 != null) ? o2.getZoneName() : "";
rc = n1.compareToIgnoreCase(n2);
} else {
rc = 0;
}
break;
default:
rc = 0;
break;
}
int dir = ((TableViewer) viewer).getTable().getSortDirection();
return (dir == SWT.UP) ? rc : -rc;
}
use of org.netxms.client.events.Alarm in project netxms by netxms.
the class AlarmListLabelProvider method getColumnText.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
@Override
public String getColumnText(Object element, int columnIndex) {
switch((Integer) viewer.getTable().getColumn(columnIndex).getData("ID")) {
case AlarmList.COLUMN_SEVERITY:
return StatusDisplayInfo.getStatusText(((Alarm) element).getCurrentSeverity());
case AlarmList.COLUMN_STATE:
int time = ((Alarm) element).getAckTime();
// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
String timeString = time > 0 ? " (" + RegionalSettings.getDateTimeFormat().format(System.currentTimeMillis() + (time * 1000)) + ")" : "";
return stateText[((Alarm) element).getState()] + timeString;
case AlarmList.COLUMN_SOURCE:
AbstractObject object = session.findObjectById(((Alarm) element).getSourceObjectId());
// $NON-NLS-1$ //$NON-NLS-2$
return (object != null) ? object.getObjectName() : ("[" + Long.toString(((Alarm) element).getSourceObjectId()) + "]");
case AlarmList.COLUMN_ZONE:
if (session.isZoningEnabled()) {
ZoneMember zm = session.findObjectById(((Alarm) element).getSourceObjectId(), ZoneMember.class);
return (zm != null) ? zm.getZoneName() : "";
}
return "";
case AlarmList.COLUMN_MESSAGE:
return ((Alarm) element).getMessage();
case AlarmList.COLUMN_COUNT:
return Integer.toString(((Alarm) element).getRepeatCount());
case AlarmList.COLUMN_COMMENTS:
return (((Alarm) element).getCommentsCount() > 0) ? Integer.toString(((Alarm) element).getCommentsCount()) : null;
case AlarmList.COLUMN_ACK_BY:
if (((Alarm) element).getState() == Alarm.STATE_OUTSTANDING)
return null;
long userId = (((Alarm) element).getState() == Alarm.STATE_ACKNOWLEDGED) ? ((Alarm) element).getAckByUser() : ((Alarm) element).getResolvedByUser();
AbstractUserObject user = session.findUserDBObjectById(userId);
// $NON-NLS-1$ //$NON-NLS-2$
return (user != null) ? user.getName() : ("[" + Long.toString(((Alarm) element).getAckByUser()) + "]");
case AlarmList.COLUMN_CREATED:
return RegionalSettings.getDateTimeFormat().format(((Alarm) element).getCreationTime());
case AlarmList.COLUMN_LASTCHANGE:
return RegionalSettings.getDateTimeFormat().format(((Alarm) element).getLastChangeTime());
case AlarmList.COLUMN_HELPDESK_REF:
switch(((Alarm) element).getHelpdeskState()) {
case Alarm.HELPDESK_STATE_OPEN:
return ((Alarm) element).getHelpdeskReference();
case Alarm.HELPDESK_STATE_CLOSED:
return ((Alarm) element).getHelpdeskReference() + Messages.get().AlarmListLabelProvider_Closed;
}
return null;
}
return null;
}
use of org.netxms.client.events.Alarm in project netxms by netxms.
the class AlarmLogViewer method fillContextMenu.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.logviewer.views.LogViewer#fillContextMenu(org.eclipse.jface.action.IMenuManager)
*/
@Override
protected void fillContextMenu(final IMenuManager mgr) {
super.fillContextMenu(mgr);
IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
if (// selection.size() == 0 && session.isHelpdeskLinkActive())
true) {
try {
Alarm alarm = session.getAlarm(Long.parseLong(((TableRow) selection.getFirstElement()).get(0).getValue()));
if (alarm.getHelpdeskState() == Alarm.HELPDESK_STATE_IGNORED)
mgr.add(actionCreateIssue);
else {
mgr.add(actionShowIssue);
if ((session.getUserSystemRights() & UserAccessRights.SYSTEM_ACCESS_UNLINK_ISSUES) != 0)
mgr.add(actionUnlinkIssue);
}
} catch (NumberFormatException | ArrayIndexOutOfBoundsException | IOException | NXCException e) {
Activator.logError("Error finding alarm", e);
}
}
}
use of org.netxms.client.events.Alarm in project netxms by netxms.
the class ObjectToolsDynamicMenu method buildNodeSet.
/**
* Build node set from selection
*
* @param selection
* @return
*/
private Set<ObjectContext> buildNodeSet(IStructuredSelection selection) {
final Set<ObjectContext> nodes = new HashSet<ObjectContext>();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
for (Object o : selection.toList()) {
if (o instanceof AbstractNode) {
nodes.add(new ObjectContext((AbstractNode) o, null));
} else if ((o instanceof Container) || (o instanceof ServiceRoot) || (o instanceof Subnet) || (o instanceof Cluster)) {
for (AbstractObject n : ((AbstractObject) o).getAllChilds(AbstractObject.OBJECT_NODE)) nodes.add(new ObjectContext((AbstractNode) n, null));
} else if (o instanceof Alarm) {
AbstractNode n = (AbstractNode) session.findObjectById(((Alarm) o).getSourceObjectId(), AbstractNode.class);
if (n != null)
nodes.add(new ObjectContext(n, (Alarm) o));
} else if (o instanceof ObjectWrapper) {
AbstractObject n = ((ObjectWrapper) o).getObject();
if ((n != null) && (n instanceof AbstractNode))
nodes.add(new ObjectContext((AbstractNode) n, null));
}
}
return nodes;
}
use of org.netxms.client.events.Alarm in project netxms by netxms.
the class AlarmsFragment method handleItemSelection.
/**
* Handles menu item selection for both Option and Context menus
* @param item Menu item to handle
* @return true if menu has been properly handled
*/
private boolean handleItemSelection(MenuItem item) {
switch(item.getItemId()) {
case R.id.sort_severity_asc:
setNewSort(item, AlarmListAdapter.SORT_SEVERITY_ASC);
return true;
case R.id.sort_severity_desc:
setNewSort(item, AlarmListAdapter.SORT_SEVERITY_DESC);
return true;
case R.id.sort_date_asc:
setNewSort(item, AlarmListAdapter.SORT_DATE_ASC);
return true;
case R.id.sort_date_desc:
setNewSort(item, AlarmListAdapter.SORT_DATE_DESC);
return true;
case R.id.sort_name_asc:
setNewSort(item, AlarmListAdapter.SORT_NAME_ASC);
return true;
case R.id.sort_name_desc:
setNewSort(item, AlarmListAdapter.SORT_NAME_DESC);
return true;
case R.id.selectall:
selectAll(true);
return true;
case R.id.unselectall:
selectAll(false);
return true;
case R.id.acknowledge:
adapter.doAction(AlarmListAdapter.ACKNOWLEDGE, getAlarmsSelection(item));
selectAll(false);
return true;
case R.id.sticky_acknowledge:
adapter.doAction(AlarmListAdapter.STICKY_ACKNOWLEDGE, getAlarmsSelection(item));
selectAll(false);
return true;
case R.id.resolve:
adapter.doAction(AlarmListAdapter.RESOLVE, getAlarmsSelection(item));
selectAll(false);
return true;
case R.id.terminate:
adapter.doAction(AlarmListAdapter.TERMINATE, getAlarmsSelection(item));
selectAll(false);
return true;
case R.id.viewlastvalues:
if (service != null) {
Alarm al = (Alarm) adapter.getItem(lastPosition);
if (al != null) {
AbstractObject object = service.findObjectById(al.getSourceObjectId());
if (object != null) {
Intent newIntent = new Intent(getActivity(), NodeInfoFragment.class);
newIntent.putExtra("objectId", object.getObjectId());
newIntent.putExtra("tabId", NodeInfoFragment.TAB_LAST_VALUES_ID);
startActivity(newIntent);
}
}
}
return true;
}
return false;
}
Aggregations