Search in sources :

Example 36 with AbstractObject

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());
        }
    }
}
Also used : TabbedObjectView(org.netxms.ui.eclipse.objectview.views.TabbedObjectView) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException)

Example 37 with AbstractObject

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;
}
Also used : NXCSession(org.netxms.client.NXCSession) Alarm(org.netxms.client.events.Alarm) AbstractObject(org.netxms.client.objects.AbstractObject) ZoneMember(org.netxms.client.objects.ZoneMember) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 38 with AbstractObject

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;
}
Also used : Alarm(org.netxms.client.events.Alarm) AbstractObject(org.netxms.client.objects.AbstractObject) AbstractUserObject(org.netxms.client.users.AbstractUserObject) ZoneMember(org.netxms.client.objects.ZoneMember)

Example 39 with AbstractObject

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();
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject)

Example 40 with AbstractObject

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();
}
Also used : NXCSession(org.netxms.client.NXCSession) AbstractObject(org.netxms.client.objects.AbstractObject)

Aggregations

AbstractObject (org.netxms.client.objects.AbstractObject)216 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)55 NXCSession (org.netxms.client.NXCSession)51 AbstractNode (org.netxms.client.objects.AbstractNode)31 PartInitException (org.eclipse.ui.PartInitException)27 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)26 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)25 Cluster (org.netxms.client.objects.Cluster)22 ObjectSelectionDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)22 ArrayList (java.util.ArrayList)20 Node (org.netxms.client.objects.Node)20 GridData (org.eclipse.swt.layout.GridData)18 Composite (org.eclipse.swt.widgets.Composite)18 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)18 GridLayout (org.eclipse.swt.layout.GridLayout)15 Container (org.netxms.client.objects.Container)15 Interface (org.netxms.client.objects.Interface)12 Template (org.netxms.client.objects.Template)12 SelectionEvent (org.eclipse.swt.events.SelectionEvent)11 Point (org.eclipse.swt.graphics.Point)11