Search in sources :

Example 21 with NetworkMapLink

use of org.netxms.client.maps.NetworkMapLink in project netxms by netxms.

the class IPRouteMap method getRoute.

/**
 * Get route between objects and build map page
 *
 * @throws Exception
 */
private void getRoute(Display display) throws Exception {
    final NetworkPath path = session.getNetworkPath(rootObject.getObjectId(), targetObject.getObjectId());
    // $NON-NLS-1$ //$NON-NLS-2$
    final NetworkMapPage page = new NetworkMapPage(ID + "@" + rootObject.getObjectName() + "@" + targetObject.getObjectName());
    long prevElementId = 0;
    HopInfo prevHop = null;
    for (final HopInfo h : path.getPath()) {
        final long elementId = page.createElementId();
        page.addElement(new NetworkMapObject(elementId, h.getNodeId()));
        if (prevElementId != 0) {
            NetworkMapLink link = new NetworkMapLink(prevHop.isVpn() ? NetworkMapLink.VPN : NetworkMapLink.NORMAL, prevElementId, elementId);
            if (!prevHop.getName().isEmpty())
                link.setName(prevHop.getName());
            page.addLink(link);
        }
        prevElementId = elementId;
        prevHop = h;
    }
    replaceMapPage(page, display);
}
Also used : HopInfo(org.netxms.client.topology.HopInfo) NetworkMapPage(org.netxms.client.maps.NetworkMapPage) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink) NetworkPath(org.netxms.client.topology.NetworkPath)

Example 22 with NetworkMapLink

use of org.netxms.client.maps.NetworkMapLink in project netxms by netxms.

the class NetworkMapWidget method onObjectChange.

/**
 * Called by session listener when NetXMS object was changed.
 *
 * @param object changed NetXMS object
 */
private void onObjectChange(final AbstractObject object) {
    if (mapPage == null)
        return;
    NetworkMapObject element = mapPage.findObjectElement(object.getObjectId());
    if (element != null)
        viewer.refresh(element, true);
    List<NetworkMapLink> links = mapPage.findLinksWithStatusObject(object.getObjectId());
    if (links != null)
        for (NetworkMapLink l : links) viewer.refresh(l);
}
Also used : NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 23 with NetworkMapLink

use of org.netxms.client.maps.NetworkMapLink in project netxms by netxms.

the class NetworkMapWidget method addDciToRequestList.

/**
 * Goes thought all links and trys to add to request list required DCIs.
 */
protected void addDciToRequestList() {
    Collection<NetworkMapLink> linkList = mapPage.getLinks();
    for (NetworkMapLink item : linkList) {
        if (item.hasDciData()) {
            for (SingleDciConfig value : item.getDciAsList()) {
                if (value.type == SingleDciConfig.ITEM) {
                    dciValueProvider.addDci(value.getNodeId(), value.dciId, mapPage);
                } else {
                    dciValueProvider.addDci(value.getNodeId(), value.dciId, value.column, value.instance, mapPage);
                }
            }
        }
    }
    Collection<NetworkMapElement> mapElements = mapPage.getElements();
    for (NetworkMapElement element : mapElements) {
        if (element instanceof NetworkMapDCIContainer) {
            NetworkMapDCIContainer item = (NetworkMapDCIContainer) element;
            if (item.hasDciData()) {
                for (SingleDciConfig value : item.getObjectDCIArray()) {
                    if (value.type == SingleDciConfig.ITEM) {
                        dciValueProvider.addDci(value.getNodeId(), value.dciId, mapPage);
                    } else {
                        dciValueProvider.addDci(value.getNodeId(), value.dciId, value.column, value.instance, mapPage);
                    }
                }
            }
        }
        if (element instanceof NetworkMapDCIImage) {
            NetworkMapDCIImage item = (NetworkMapDCIImage) element;
            DCIImageConfiguration config = item.getImageOptions();
            SingleDciConfig value = config.getDci();
            if (value.type == SingleDciConfig.ITEM) {
                dciValueProvider.addDci(value.getNodeId(), value.dciId, mapPage);
            } else {
                dciValueProvider.addDci(value.getNodeId(), value.dciId, value.column, value.instance, mapPage);
            }
        }
    }
}
Also used : NetworkMapDCIImage(org.netxms.client.maps.elements.NetworkMapDCIImage) NetworkMapElement(org.netxms.client.maps.elements.NetworkMapElement) DCIImageConfiguration(org.netxms.client.maps.configs.DCIImageConfiguration) NetworkMapDCIContainer(org.netxms.client.maps.elements.NetworkMapDCIContainer) NetworkMapLink(org.netxms.client.maps.NetworkMapLink) SingleDciConfig(org.netxms.client.maps.configs.SingleDciConfig)

Example 24 with NetworkMapLink

use of org.netxms.client.maps.NetworkMapLink in project netxms by netxms.

the class ServiceComponents method addServiceComponents.

/**
 * Add parent services for given object
 *
 * @param object
 */
private void addServiceComponents(AbstractObject object, long parentElementId) {
    Iterator<Long> it = object.getChildren();
    while (it.hasNext()) {
        long objectId = it.next();
        AbstractObject child = session.findObjectById(objectId);
        if ((child != null) && ((child instanceof Container) || (child instanceof Cluster) || (child instanceof Node) || (child instanceof Condition))) {
            long elementId = mapPage.createElementId();
            mapPage.addElement(new NetworkMapObject(elementId, objectId));
            mapPage.addLink(new NetworkMapLink(NetworkMapLink.NORMAL, parentElementId, elementId));
            addServiceComponents(child, elementId);
        }
    }
}
Also used : Condition(org.netxms.client.objects.Condition) Container(org.netxms.client.objects.Container) AbstractObject(org.netxms.client.objects.AbstractObject) Node(org.netxms.client.objects.Node) Cluster(org.netxms.client.objects.Cluster) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 25 with NetworkMapLink

use of org.netxms.client.maps.NetworkMapLink in project netxms by netxms.

the class VlanMap method processVlanPort.

/**
 * Process single member port of VLAN. Will add connected switch on other site to the map.
 *
 * @param page
 * @param root
 * @param port
 * @throws Exception
 */
private void processVlanPort(NetworkMapPage page, Node root, Port port, long rootElementId) throws Exception {
    Interface iface = (Interface) session.findObjectById(port.getObjectId(), Interface.class);
    if (iface != null) {
        Node peerNode = (Node) session.findObjectById(iface.getPeerNodeId(), Node.class);
        if ((peerNode != null) && ((peerNode.getCapabilities() & Node.NC_IS_BRIDGE) != 0)) {
            try {
                long nodeElementId = collectVlanInfo(page, peerNode);
                if (nodeElementId != -1) {
                    Interface peerIf = (Interface) session.findObjectById(iface.getPeerInterfaceId(), Interface.class);
                    page.addLink(new NetworkMapLink(null, NetworkMapLink.NORMAL, rootElementId, nodeElementId, iface.getObjectName(), (peerIf != null) ? peerIf.getObjectName() : "???", // $NON-NLS-1$ //$NON-NLS-2$
                    0));
                }
            } catch (NXCException e) {
            // Ignore NetXMS errors for remote bridges
            }
        }
    }
}
Also used : Node(org.netxms.client.objects.Node) Interface(org.netxms.client.objects.Interface) NetworkMapLink(org.netxms.client.maps.NetworkMapLink) NXCException(org.netxms.client.NXCException)

Aggregations

NetworkMapLink (org.netxms.client.maps.NetworkMapLink)27 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)16 AbstractObject (org.netxms.client.objects.AbstractObject)12 NetworkMapPage (org.netxms.client.maps.NetworkMapPage)6 NetworkMapElement (org.netxms.client.maps.elements.NetworkMapElement)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 NXCPMessage (org.netxms.base.NXCPMessage)3 AccessPoint (org.netxms.client.objects.AccessPoint)3 Cluster (org.netxms.client.objects.Cluster)3 Container (org.netxms.client.objects.Container)3 Node (org.netxms.client.objects.Node)3 CoreException (org.eclipse.core.runtime.CoreException)2 Point (org.eclipse.draw2d.geometry.Point)2 PartInitException (org.eclipse.ui.PartInitException)2 ObjectStatus (org.netxms.client.constants.ObjectStatus)2 DCIImageConfiguration (org.netxms.client.maps.configs.DCIImageConfiguration)2 SingleDciConfig (org.netxms.client.maps.configs.SingleDciConfig)2 NetworkMapDCIContainer (org.netxms.client.maps.elements.NetworkMapDCIContainer)2 NetworkMapDCIImage (org.netxms.client.maps.elements.NetworkMapDCIImage)2 ClusterResource (org.netxms.client.objects.ClusterResource)2