Search in sources :

Example 11 with NetworkMapObject

use of org.netxms.client.maps.elements.NetworkMapObject in project netxms by netxms.

the class NXCSession method queryLayer2Topology.

/**
 * Query layer 2 topology for node
 *
 * @param nodeId The node ID
 * @throws IOException  if socket I/O error occurs
 * @throws NXCException if NetXMS server returns an error or operation was timed out
 * @return The NetworkMapPage
 */
public NetworkMapPage queryLayer2Topology(final long nodeId) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_QUERY_L2_TOPOLOGY);
    msg.setFieldInt32(NXCPCodes.VID_OBJECT_ID, (int) nodeId);
    sendMessage(msg);
    final NXCPMessage response = waitForRCC(msg.getMessageId());
    int count = response.getFieldAsInt32(NXCPCodes.VID_NUM_OBJECTS);
    long[] idList = response.getFieldAsUInt32Array(NXCPCodes.VID_OBJECT_LIST);
    if (idList.length != count)
        throw new NXCException(RCC.INTERNAL_ERROR);
    NetworkMapPage page = new NetworkMapPage(msg.getMessageId() + ".L2Topology");
    for (int i = 0; i < count; i++) {
        page.addElement(new NetworkMapObject(page.createElementId(), idList[i]));
    }
    count = response.getFieldAsInt32(NXCPCodes.VID_NUM_LINKS);
    long varId = NXCPCodes.VID_OBJECT_LINKS_BASE;
    for (int i = 0; i < count; i++, varId += 3) {
        NetworkMapObject obj1 = page.findObjectElement(response.getFieldAsInt64(varId++));
        NetworkMapObject obj2 = page.findObjectElement(response.getFieldAsInt64(varId++));
        int type = response.getFieldAsInt32(varId++);
        String port1 = response.getFieldAsString(varId++);
        String port2 = response.getFieldAsString(varId++);
        String name = response.getFieldAsString(varId++);
        int flags = response.getFieldAsInt32(varId++);
        if ((obj1 != null) && (obj2 != null)) {
            page.addLink(new NetworkMapLink(name, type, obj1.getId(), obj2.getId(), port1, port2, flags));
        }
    }
    return page;
}
Also used : NetworkMapPage(org.netxms.client.maps.NetworkMapPage) NXCPMessage(org.netxms.base.NXCPMessage) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) ConnectionPoint(org.netxms.client.topology.ConnectionPoint) AccessPoint(org.netxms.client.objects.AccessPoint) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 12 with NetworkMapObject

use of org.netxms.client.maps.elements.NetworkMapObject in project netxms by netxms.

the class IPNeighbors method buildMapPage.

/**
 * Build map page
 */
protected void buildMapPage() {
    // $NON-NLS-1$
    mapPage = new NetworkMapPage(ID + "." + this.toString());
    long rootElementId = mapPage.createElementId();
    mapPage.addElement(new NetworkMapObject(rootElementId, rootObject.getObjectId()));
    addSubnets(rootObject, rootElementId);
    for (long objectId : rootObject.getChildIdList()) {
        AbstractObject object = session.findObjectById(objectId);
        if ((object != null) && (object instanceof VPNConnector)) {
            AbstractObject peer = session.findObjectById(((VPNConnector) object).getPeerGatewayId());
            if (peer != null) {
                long elementId = mapPage.createElementId();
                mapPage.addElement(new NetworkMapObject(elementId, peer.getObjectId()));
                NetworkMapLink link = new NetworkMapLink(NetworkMapLink.VPN, rootElementId, elementId);
                link.setName(object.getObjectName());
                mapPage.addLink(link);
                addSubnets(peer, elementId);
            }
        }
    }
    addDciToRequestList();
}
Also used : NetworkMapPage(org.netxms.client.maps.NetworkMapPage) AbstractObject(org.netxms.client.objects.AbstractObject) VPNConnector(org.netxms.client.objects.VPNConnector) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 13 with NetworkMapObject

use of org.netxms.client.maps.elements.NetworkMapObject 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 14 with NetworkMapObject

use of org.netxms.client.maps.elements.NetworkMapObject in project netxms by netxms.

the class ServiceDependency method buildMapPage.

/* (non-Javadoc)
	 * @see org.netxms.ui.eclipse.networkmaps.views.NetworkMap#buildMapPage()
	 */
@Override
protected void buildMapPage() {
    mapPage = new NetworkMapPage(ID + rootObject.getObjectId());
    long elementId = mapPage.createElementId();
    mapPage.addElement(new NetworkMapObject(elementId, rootObject.getObjectId()));
    addParentServices(rootObject, elementId);
    addDciToRequestList();
}
Also used : NetworkMapPage(org.netxms.client.maps.NetworkMapPage) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject)

Example 15 with NetworkMapObject

use of org.netxms.client.maps.elements.NetworkMapObject in project netxms by netxms.

the class MapContentProvider method inputChanged.

/* (non-Javadoc)
	 * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
	 */
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
    synchronized (cachedDciValues) {
        cachedDciValues.clear();
    }
    if (newInput instanceof NetworkMapPage) {
        page = (NetworkMapPage) newInput;
        synchronized (cachedDciValues) {
            for (NetworkMapElement e : page.getElements()) {
                if (e instanceof NetworkMapObject) {
                    long id = ((NetworkMapObject) e).getObjectId();
                    AbstractObject object = session.findObjectById(id);
                    if ((object != null) && (object instanceof AbstractNode)) {
                        cachedDciValues.put(id, null);
                    }
                }
            }
        }
    } else {
        page = null;
    }
}
Also used : NetworkMapPage(org.netxms.client.maps.NetworkMapPage) AbstractNode(org.netxms.client.objects.AbstractNode) NetworkMapElement(org.netxms.client.maps.elements.NetworkMapElement) AbstractObject(org.netxms.client.objects.AbstractObject) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject)

Aggregations

NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)21 NetworkMapLink (org.netxms.client.maps.NetworkMapLink)13 AbstractObject (org.netxms.client.objects.AbstractObject)13 NetworkMapPage (org.netxms.client.maps.NetworkMapPage)8 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 Cluster (org.netxms.client.objects.Cluster)3 Container (org.netxms.client.objects.Container)3 Node (org.netxms.client.objects.Node)3 NXCPMessage (org.netxms.base.NXCPMessage)2 AccessPoint (org.netxms.client.objects.AccessPoint)2 Condition (org.netxms.client.objects.Condition)2 ConnectionPoint (org.netxms.client.topology.ConnectionPoint)2 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 UUID (java.util.UUID)1 DoubleClickEvent (org.eclipse.jface.viewers.DoubleClickEvent)1 IDoubleClickListener (org.eclipse.jface.viewers.IDoubleClickListener)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 Image (org.eclipse.swt.graphics.Image)1 Point (org.eclipse.swt.graphics.Point)1