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;
}
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());
}
}
}
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();
}
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);
}
});
}
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;
}
Aggregations