use of org.netxms.client.maps.NetworkMapLink in project netxms by netxms.
the class MapLabelProvider method selfStyleConnection.
/*
* (non-Javadoc)
*
* @see
* org.eclipse.gef4.zest.core.viewers.ISelfStyleProvider#selfStyleConnection(java
* .lang.Object, org.eclipse.gef4.zest.core.widgets.GraphConnection)
*/
@Override
public void selfStyleConnection(Object element, GraphConnection connection) {
connection.setVisible(connectionsVisible);
NetworkMapLink link = (NetworkMapLink) connection.getData();
if (link.getType() == NetworkMapLink.VPN) {
connection.setLineStyle(Graphics.LINE_DOT);
}
if (link.hasConnectorName1() && connectionLabelsVisible) {
ConnectionEndpointLocator sourceEndpointLocator = new ConnectionEndpointLocator(connection.getConnectionFigure(), false);
sourceEndpointLocator.setVDistance(0);
final Label label = new ConnectorLabel(link.getConnectorName1());
label.setFont(fontLabel);
connection.getConnectionFigure().add(label, sourceEndpointLocator);
}
if (link.hasConnectorName2() && connectionLabelsVisible) {
ConnectionEndpointLocator targetEndpointLocator = new ConnectionEndpointLocator(connection.getConnectionFigure(), true);
targetEndpointLocator.setVDistance(0);
final Label label = new ConnectorLabel(link.getConnectorName2());
label.setFont(fontLabel);
connection.getConnectionFigure().add(label, targetEndpointLocator);
}
if (showLinkDirection)
((PolylineConnection) connection.getConnectionFigure()).setSourceDecoration(new PolylineDecoration());
IFigure owner = ((PolylineConnection) connection.getConnectionFigure()).getTargetAnchor().getOwner();
((PolylineConnection) connection.getConnectionFigure()).setTargetAnchor(new MultiConnectionAnchor(owner, link));
owner = ((PolylineConnection) connection.getConnectionFigure()).getSourceAnchor().getOwner();
((PolylineConnection) connection.getConnectionFigure()).setSourceAnchor(new MultiConnectionAnchor(owner, link));
boolean hasDciData = link.hasDciData();
boolean hasName = link.hasName();
if (link.getStatusObject() != null && link.getStatusObject().size() != 0) {
ObjectStatus status = ObjectStatus.UNKNOWN;
for (Long id : link.getStatusObject()) {
AbstractObject object = session.findObjectById(id);
if (object != null) {
ObjectStatus s = object.getStatus();
if ((s.compareTo(ObjectStatus.UNKNOWN) < 0) && ((status.compareTo(s) < 0) || (status == ObjectStatus.UNKNOWN))) {
status = s;
if (status == ObjectStatus.CRITICAL)
break;
}
}
}
connection.setLineColor(StatusDisplayInfo.getStatusColor(status));
} else if (link.getColor() >= 0) {
connection.setLineColor(colors.create(ColorConverter.rgbFromInt(link.getColor())));
} else if (link.getType() == NetworkMapLink.AGENT_TUNEL) {
connection.setLineColor(COLOR_AGENT_TUNNEL);
} else if (link.getType() == NetworkMapLink.AGENT_PROXY) {
connection.setLineColor(COLOR_AGENT_PROXY);
} else if (link.getType() == NetworkMapLink.ICMP_PROXY) {
connection.setLineColor(COLOR_ICMP_PROXY);
} else if (link.getType() == NetworkMapLink.SNMP_PROXY) {
connection.setLineColor(COLOR_SNMP_PROXY);
} else if (link.getType() == NetworkMapLink.SSH_PROXY) {
connection.setLineColor(COLOR_SSH_PROXY);
} else if (link.getType() == NetworkMapLink.ZONE_PROXY) {
connection.setLineColor(COLOR_ZONE_PROXY);
} else if (defaultLinkColor != null) {
connection.setLineColor(defaultLinkColor);
}
if ((hasName || hasDciData) && connectionLabelsVisible) {
MultiLabelConnectionLocator nameLocator = new MultiLabelConnectionLocator(connection.getConnectionFigure(), link);
// $NON-NLS-1$
String labelString = "";
if (hasName)
labelString += link.getName();
if (hasName && hasDciData)
// $NON-NLS-1$
labelString += "\n";
if (hasDciData) {
labelString += dciValueProvider.getDciDataAsString(link);
}
final Label label;
if (link.getType() == NetworkMapLink.AGENT_TUNEL || link.getType() == NetworkMapLink.AGENT_PROXY || link.getType() == NetworkMapLink.ICMP_PROXY || link.getType() == NetworkMapLink.SNMP_PROXY || link.getType() == NetworkMapLink.SSH_PROXY || link.getType() == NetworkMapLink.ZONE_PROXY)
label = new ConnectorLabel(labelString, connection.getLineColor());
else
label = new ConnectorLabel(labelString);
label.setFont(fontLabel);
connection.getConnectionFigure().add(label, nameLocator);
}
switch(link.getRouting()) {
case NetworkMapLink.ROUTING_DIRECT:
connection.setRouter(ConnectionRouter.NULL);
break;
case NetworkMapLink.ROUTING_MANHATTAN:
connection.setRouter(manhattanRouter);
break;
case NetworkMapLink.ROUTING_BENDPOINTS:
connection.setRouter(bendpointRouter);
// $NON-NLS-1$
connection.setData("ROUTER", bendpointRouter);
Object bp = getConnectionPoints(link);
bendpointRouter.setConstraint(connection.getConnectionFigure(), bp);
connection.getConnectionFigure().setRoutingConstraint(bp);
break;
default:
connection.setRouter(null);
break;
}
connection.setLineWidth(2);
}
use of org.netxms.client.maps.NetworkMapLink 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.NetworkMapLink 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.NetworkMapLink 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;
}
use of org.netxms.client.maps.NetworkMapLink 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;
}
Aggregations