Search in sources :

Example 6 with NetworkMapObject

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

the class ClusterTab method buildClusterMap.

/**
 * Build hierarchical cluster representation
 *
 * @return
 */
private NetworkMapPage buildClusterMap() {
    NetworkMapPage page = new NetworkMapPage(pluginId + id);
    long id = 1;
    page.addElement(new NetworkMapObject(id++, cluster.getObjectId()));
    for (AbstractObject o : cluster.getAllChilds(AbstractObject.OBJECT_NODE)) {
        page.addElement(new NetworkMapObject(id, o.getObjectId()));
        page.addLink(new NetworkMapLink(0, 1, id));
        addOwnedResources(page, id, o.getObjectId(), cluster.getResources());
        id++;
    }
    return page;
}
Also used : NetworkMapPage(org.netxms.client.maps.NetworkMapPage) AbstractObject(org.netxms.client.objects.AbstractObject) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 7 with NetworkMapObject

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

the class IPNeighbors method addSubnets.

/**
 * Add subnets connected by given node
 *
 * @param root
 * @param rootElementId
 */
private void addSubnets(AbstractObject root, long rootElementId) {
    for (long objectId : root.getParentIdList()) {
        AbstractObject object = session.findObjectById(objectId);
        if ((object != null) && (object instanceof Subnet)) {
            long elementId = mapPage.createElementId();
            mapPage.addElement(new NetworkMapObject(elementId, objectId));
            mapPage.addLink(new NetworkMapLink(NetworkMapLink.NORMAL, rootElementId, elementId));
            addNodesFromSubnet((Subnet) object, elementId, root.getObjectId());
        }
    }
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) Subnet(org.netxms.client.objects.Subnet) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 8 with NetworkMapObject

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

the class IPNeighbors method addNodesFromSubnet.

/**
 * Add nodes connected to given subnet to map
 * @param subnet Subnet object
 * @param rootNodeId ID of map's root node (used to prevent recursion)
 */
private void addNodesFromSubnet(Subnet subnet, long subnetElementId, long rootNodeId) {
    Iterator<Long> it = subnet.getChildren();
    while (it.hasNext()) {
        long objectId = it.next();
        if (objectId != rootNodeId) {
            AbstractObject object = session.findObjectById(objectId);
            if ((object != null) && (object instanceof Node)) {
                long elementId = mapPage.createElementId();
                mapPage.addElement(new NetworkMapObject(elementId, objectId));
                mapPage.addLink(new NetworkMapLink(NetworkMapLink.NORMAL, subnetElementId, elementId));
            }
        }
    }
    addDciToRequestList();
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) Node(org.netxms.client.objects.Node) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 9 with NetworkMapObject

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

the class NetworkMapWidget method enableObjectDoubleClick.

public void enableObjectDoubleClick() {
    registerDoubleClickHandlers();
    viewer.addDoubleClickListener(new IDoubleClickListener() {

        @Override
        public void doubleClick(DoubleClickEvent event) {
            IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
            if (selection.isEmpty() || !(selection.getFirstElement() instanceof NetworkMapObject))
                return;
            AbstractObject object = ConsoleSharedData.getSession().findObjectById(((NetworkMapObject) selection.getFirstElement()).getObjectId());
            if (object == null)
                return;
            for (DoubleClickHandlerData h : doubleClickHandlers) {
                if ((h.enabledFor == null) || (h.enabledFor.isInstance(object))) {
                    if (h.handler.onDoubleClick(object)) {
                        return;
                    }
                }
            }
            // Default behaviour
            openDrillDownObject(object);
        }
    });
}
Also used : IDoubleClickListener(org.eclipse.jface.viewers.IDoubleClickListener) AbstractObject(org.netxms.client.objects.AbstractObject) DoubleClickEvent(org.eclipse.jface.viewers.DoubleClickEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject)

Example 10 with NetworkMapObject

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

the class NXCSession method queryInternalConnectionTopology.

/**
 * Query internal connection 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 queryInternalConnectionTopology(final long nodeId) throws IOException, NXCException {
    NXCPMessage msg = newMessage(NXCPCodes.CMD_QUERY_INTERNAL_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() + ".InternalConnectionTopology");
    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)

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