Search in sources :

Example 1 with NodeInfoWindow

use of org.opennms.features.topology.netutils.internal.NodeInfoWindow in project opennms by OpenNMS.

the class NodeInfoOperation method execute.

@Override
public void execute(final List<VertexRef> targets, final OperationContext operationContext) {
    try {
        String label = "";
        int nodeID = -1;
        if (targets != null) {
            for (final VertexRef target : targets) {
                final String labelValue = getLabelValue(operationContext, target);
                final Integer nodeValue = getNodeIdValue(operationContext, target);
                if (nodeValue != null && nodeValue > 0) {
                    label = labelValue == null ? "" : labelValue;
                    nodeID = nodeValue.intValue();
                    break;
                }
            }
        }
        final Node node = new Node(nodeID, null, label);
        final String url;
        if (node.getNodeID() >= 0) {
            url = getNodePageURL() + node.getNodeID();
        } else {
            url = getNodeListURL();
        }
        final URL fullUrl = new URL(getFullUrl(url));
        operationContext.getMainWindow().addWindow(new NodeInfoWindow(node, fullUrl));
    } catch (final Exception e) {
        if (e instanceof RuntimeException) {
            throw (RuntimeException) e;
        } else {
            throw new RuntimeException("Failed to create node window.", e);
        }
    }
}
Also used : Node(org.opennms.features.topology.netutils.internal.Node) NodeInfoWindow(org.opennms.features.topology.netutils.internal.NodeInfoWindow) VertexRef(org.opennms.features.topology.api.topo.VertexRef) URL(java.net.URL)

Aggregations

URL (java.net.URL)1 VertexRef (org.opennms.features.topology.api.topo.VertexRef)1 Node (org.opennms.features.topology.netutils.internal.Node)1 NodeInfoWindow (org.opennms.features.topology.netutils.internal.NodeInfoWindow)1