Search in sources :

Example 11 with AbstractNode

use of org.netxms.client.objects.AbstractNode in project netxms by netxms.

the class ShowObjectSnmpTrapLog method execute.

/* (non-Javadoc)
    * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
    */
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
    ISelection selection = window.getActivePage().getSelection();
    if ((selection == null) || !(selection instanceof IStructuredSelection) || selection.isEmpty())
        return null;
    ColumnFilter cf = new ColumnFilter();
    cf.setOperation(ColumnFilterSetOperation.OR);
    for (Object o : ((IStructuredSelection) selection).toList()) {
        if (!(o instanceof AbstractObject))
            continue;
        cf.addSubFilter(new ColumnFilter((o instanceof AbstractNode) ? ColumnFilterType.EQUALS : ColumnFilterType.CHILDOF, ((AbstractObject) o).getObjectId()));
    }
    try {
        // $NON-NLS-1$
        LogViewer view = (LogViewer) window.getActivePage().showView(LogViewer.ID, "SnmpTrapLog", IWorkbenchPage.VIEW_ACTIVATE);
        LogFilter filter = new LogFilter();
        // $NON-NLS-1$
        filter.setColumnFilter("object_id", cf);
        List<OrderingColumn> orderingColumns = new ArrayList<OrderingColumn>(1);
        // $NON-NLS-1$
        orderingColumns.add(new OrderingColumn("trap_timestamp", Messages.get().ShowObjectSnmpTrapLog_Time, true));
        filter.setOrderingColumns(orderingColumns);
        view.queryWithFilter(filter);
    } catch (PartInitException e) {
        MessageDialogHelper.openError(window.getShell(), Messages.get().ShowObjectSnmpTrapLog_Error, String.format(Messages.get().ShowObjectSnmpTrapLog_ErrorOpenLogViewer, e.getMessage()));
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) AbstractNode(org.netxms.client.objects.AbstractNode) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ColumnFilter(org.netxms.client.log.ColumnFilter) AbstractObject(org.netxms.client.objects.AbstractObject) ISelection(org.eclipse.jface.viewers.ISelection) AbstractObject(org.netxms.client.objects.AbstractObject) LogViewer(org.netxms.ui.eclipse.logviewer.views.LogViewer) PartInitException(org.eclipse.ui.PartInitException) OrderingColumn(org.netxms.client.log.OrderingColumn) LogFilter(org.netxms.client.log.LogFilter)

Example 12 with AbstractNode

use of org.netxms.client.objects.AbstractNode in project netxms by netxms.

the class IPAddressSelector method setNode.

/**
 * Set node for which list of IP addresses will be displayed.
 *
 * @param nodeId node ID
 */
public void setNode(long nodeId) {
    AbstractObject object = session.findObjectById(nodeId);
    if (object instanceof AbstractNode) {
        node = (AbstractNode) object;
        address = node.getPrimaryIP().getAddress();
        setText((address != null) ? address.getHostAddress() : "");
    } else {
        node = null;
        setText(Messages.get().IPAddressSelector_None);
    }
}
Also used : AbstractNode(org.netxms.client.objects.AbstractNode) AbstractObject(org.netxms.client.objects.AbstractObject)

Example 13 with AbstractNode

use of org.netxms.client.objects.AbstractNode in project netxms by netxms.

the class ObjectSearchResultLabelProvider method getColumnText.

/* (non-Javadoc)
    * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
    */
@Override
public String getColumnText(Object element, int columnIndex) {
    if (!(element instanceof AbstractObject))
        return null;
    AbstractObject object = (AbstractObject) element;
    switch(columnIndex) {
        case ObjectFinder.COL_CLASS:
            return object.getObjectClassName();
        case ObjectFinder.COL_ID:
            return Long.toString(object.getObjectId());
        case ObjectFinder.COL_IP_ADDRESS:
            if (object instanceof AbstractNode) {
                InetAddressEx addr = ((AbstractNode) object).getPrimaryIP();
                return addr.isValidUnicastAddress() ? addr.getHostAddress() : null;
            }
            if (object instanceof AccessPoint) {
                InetAddressEx addr = ((AccessPoint) object).getIpAddress();
                return addr.isValidUnicastAddress() ? addr.getHostAddress() : null;
            }
            if (object instanceof Interface) {
                return ((Interface) object).getIpAddressListAsString();
            }
            return null;
        case ObjectFinder.COL_NAME:
            return wbLabelProvider.getText(element);
        case ObjectFinder.COL_PARENT:
            return getParentNames((AbstractObject) element);
        case ObjectFinder.COL_ZONE:
            if (object instanceof AbstractNode) {
                long zoneId = ((AbstractNode) object).getZoneId();
                Zone zone = ConsoleSharedData.getSession().findZone(zoneId);
                return (zone != null) ? zone.getObjectName() + " (" + Long.toString(zoneId) + ")" : Long.toString(zoneId);
            } else if (object instanceof Interface) {
                long zoneId = ((Interface) object).getZoneId();
                Zone zone = ConsoleSharedData.getSession().findZone(zoneId);
                return (zone != null) ? zone.getObjectName() + " (" + Long.toString(zoneId) + ")" : Long.toString(zoneId);
            }
            return null;
    }
    return null;
}
Also used : AbstractNode(org.netxms.client.objects.AbstractNode) InetAddressEx(org.netxms.base.InetAddressEx) Zone(org.netxms.client.objects.Zone) AbstractObject(org.netxms.client.objects.AbstractObject) AccessPoint(org.netxms.client.objects.AccessPoint) Interface(org.netxms.client.objects.Interface)

Example 14 with AbstractNode

use of org.netxms.client.objects.AbstractNode in project netxms by netxms.

the class BindObjectTo method selectionChanged.

/**
 * @see IActionDelegate#selectionChanged(IAction, ISelection)
 */
public void selectionChanged(IAction action, ISelection selection) {
    if ((selection instanceof IStructuredSelection) && (((IStructuredSelection) selection).size() > 0)) {
        objects = new HashSet<Long>();
        for (Object o : ((IStructuredSelection) selection).toList()) {
            if ((o instanceof AbstractNode) || (o instanceof Subnet) || (o instanceof MobileDevice) || (o instanceof Rack) || (o instanceof Cluster) || (o instanceof Sensor))
                objects.add(((AbstractObject) o).getObjectId());
        }
    } else {
        action.setEnabled(false);
        objects = null;
    }
}
Also used : Rack(org.netxms.client.objects.Rack) MobileDevice(org.netxms.client.objects.MobileDevice) AbstractNode(org.netxms.client.objects.AbstractNode) AbstractObject(org.netxms.client.objects.AbstractObject) Cluster(org.netxms.client.objects.Cluster) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) Subnet(org.netxms.client.objects.Subnet) Sensor(org.netxms.client.objects.Sensor)

Example 15 with AbstractNode

use of org.netxms.client.objects.AbstractNode 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;
}
Also used : NXCSession(org.netxms.client.NXCSession) AbstractNode(org.netxms.client.objects.AbstractNode) Cluster(org.netxms.client.objects.Cluster) ServiceRoot(org.netxms.client.objects.ServiceRoot) Container(org.netxms.client.objects.Container) AbstractObject(org.netxms.client.objects.AbstractObject) Alarm(org.netxms.client.events.Alarm) ObjectWrapper(org.netxms.ui.eclipse.objects.ObjectWrapper) AbstractObject(org.netxms.client.objects.AbstractObject) ObjectContext(org.netxms.ui.eclipse.objects.ObjectContext) Subnet(org.netxms.client.objects.Subnet) HashSet(java.util.HashSet)

Aggregations

AbstractNode (org.netxms.client.objects.AbstractNode)47 AbstractObject (org.netxms.client.objects.AbstractObject)27 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 NXCSession (org.netxms.client.NXCSession)13 ArrayList (java.util.ArrayList)12 Cluster (org.netxms.client.objects.Cluster)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 Composite (org.eclipse.swt.widgets.Composite)6 PartInitException (org.eclipse.ui.PartInitException)6 MobileDevice (org.netxms.client.objects.MobileDevice)6 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)6 NXCException (org.netxms.client.NXCException)5 Interface (org.netxms.client.objects.Interface)5 Sensor (org.netxms.client.objects.Sensor)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 DataCollectionItem (org.netxms.client.datacollection.DataCollectionItem)4 Subnet (org.netxms.client.objects.Subnet)4 ISelection (org.eclipse.jface.viewers.ISelection)3