use of org.netxms.client.objects.AbstractObject in project netxms by netxms.
the class AlarmList method showObjectDetails.
/**
* Show details for selected object
*/
private void showObjectDetails() {
IStructuredSelection selection = (IStructuredSelection) alarmViewer.getSelection();
if (selection.size() != 1)
return;
AbstractObject object = session.findObjectById(((Alarm) selection.getFirstElement()).getSourceObjectId());
if (object != null) {
try {
TabbedObjectView view = (TabbedObjectView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(TabbedObjectView.ID);
view.setObject(object);
} catch (PartInitException e) {
MessageDialogHelper.openError(getShell(), Messages.get().AlarmList_Error, Messages.get().AlarmList_OpenDetailsError + e.getLocalizedMessage());
}
}
}
use of org.netxms.client.objects.AbstractObject 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.objects.AbstractObject 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.objects.AbstractObject in project netxms by netxms.
the class ObjectStatusChartElement method refreshData.
/* (non-Javadoc)
* @see org.netxms.ui.eclipse.dashboard.widgets.ComparisonChartElement#refreshData(org.netxms.ui.eclipse.dashboard.widgets.internal.DashboardDciInfo[])
*/
@Override
protected void refreshData(ChartDciConfig[] dciList) {
int[] objectCount = new int[6];
Arrays.fill(objectCount, 0);
AbstractObject root = session.findObjectById(config.getRootObject());
if (root != null)
collectData(objectCount, root);
for (int i = 0; i < objectCount.length; i++) chart.updateParameter(i, objectCount[i], false);
chart.refresh();
}
use of org.netxms.client.objects.AbstractObject in project netxms by netxms.
the class StatusIndicatorElement method refreshData.
/**
* Refresh element content
*/
protected void refreshData() {
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
final AbstractObject object = session.findObjectById(config.getObjectId());
if (object != null) {
status = object.getStatus();
} else {
status = ObjectStatus.UNKNOWN;
}
canvas.redraw();
}
Aggregations