Search in sources :

Example 16 with NetworkMapObject

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

the class NetworkMapWidget method onObjectChange.

/**
 * Called by session listener when NetXMS object was changed.
 *
 * @param object changed NetXMS object
 */
private void onObjectChange(final AbstractObject object) {
    if (mapPage == null)
        return;
    NetworkMapObject element = mapPage.findObjectElement(object.getObjectId());
    if (element != null)
        viewer.refresh(element, true);
    List<NetworkMapLink> links = mapPage.findLinksWithStatusObject(object.getObjectId());
    if (links != null)
        for (NetworkMapLink l : links) viewer.refresh(l);
}
Also used : NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 17 with NetworkMapObject

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

the class ServiceComponents method addServiceComponents.

/**
 * Add parent services for given object
 *
 * @param object
 */
private void addServiceComponents(AbstractObject object, long parentElementId) {
    Iterator<Long> it = object.getChildren();
    while (it.hasNext()) {
        long objectId = it.next();
        AbstractObject child = session.findObjectById(objectId);
        if ((child != null) && ((child instanceof Container) || (child instanceof Cluster) || (child instanceof Node) || (child instanceof Condition))) {
            long elementId = mapPage.createElementId();
            mapPage.addElement(new NetworkMapObject(elementId, objectId));
            mapPage.addLink(new NetworkMapLink(NetworkMapLink.NORMAL, parentElementId, elementId));
            addServiceComponents(child, elementId);
        }
    }
}
Also used : Condition(org.netxms.client.objects.Condition) Container(org.netxms.client.objects.Container) AbstractObject(org.netxms.client.objects.AbstractObject) Node(org.netxms.client.objects.Node) Cluster(org.netxms.client.objects.Cluster) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 18 with NetworkMapObject

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

the class ServiceComponents 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()));
    addServiceComponents(rootObject, elementId);
    addDciToRequestList();
}
Also used : NetworkMapPage(org.netxms.client.maps.NetworkMapPage) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject)

Example 19 with NetworkMapObject

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

the class VlanMap method collectVlanInfo.

/**
 * Recursively collect VLAN information starting from given node
 *
 * @param page map page
 * @param root root node
 * @throws Exception
 * @throws NXCException
 */
private long collectVlanInfo(NetworkMapPage page, Node root) throws Exception {
    if (page.findObjectElement(root.getObjectId()) != null)
        return -1;
    long rootElementId = mapPage.createElementId();
    page.addElement(new NetworkMapObject(rootElementId, root.getObjectId()));
    List<VlanInfo> vlans = session.getVlans(root.getObjectId());
    for (VlanInfo vlan : vlans) {
        if (vlan.getVlanId() == vlanId) {
            Port[] ports = vlan.getPorts();
            for (Port port : ports) {
                processVlanPort(page, root, port, rootElementId);
            }
            break;
        }
    }
    return rootElementId;
}
Also used : Port(org.netxms.client.topology.Port) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) VlanInfo(org.netxms.client.topology.VlanInfo)

Example 20 with NetworkMapObject

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

the class MapLabelProvider method getImage.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.jface.viewers.LabelProvider#getImage(java.lang.Object)
	 */
@Override
public Image getImage(Object element) {
    if (element instanceof NetworkMapObject) {
        AbstractObject object = session.findObjectById(((NetworkMapObject) element).getObjectId());
        if (object != null) {
            // First, check if object has custom map image set
            final UUID objectImageGuid = object.getImage();
            if (objectImageGuid != null && !objectImageGuid.equals(NXCommon.EMPTY_GUID)) {
                return ImageProvider.getInstance(viewer.getControl().getDisplay()).getImage(objectImageGuid);
            }
            // Try registered network map image providers
            Image img = MapImageProvidersManager.getInstance().getMapImage(object);
            if (img != null)
                return img;
            // Use built-in image as last resort
            switch(object.getObjectClass()) {
                case AbstractObject.OBJECT_NODE:
                    if ((((Node) object).getCapabilities() & Node.NC_IS_BRIDGE) != 0)
                        return imgNodeSwitch;
                    if ((((Node) object).getCapabilities() & Node.NC_IS_ROUTER) != 0)
                        return imgNodeRouter;
                    if ((((Node) object).getCapabilities() & Node.NC_IS_PRINTER) != 0)
                        return imgNodePrinter;
                    if (// $NON-NLS-1$
                    ((Node) object).getPlatformName().startsWith("windows"))
                        return imgNodeWindows;
                    if (// $NON-NLS-1$
                    ((Node) object).getPlatformName().startsWith("Linux"))
                        return imgNodeLinux;
                    if (// $NON-NLS-1$
                    ((Node) object).getPlatformName().startsWith("FreeBSD"))
                        return imgNodeFreeBSD;
                    return imgNodeGeneric;
                case AbstractObject.OBJECT_SUBNET:
                    return imgSubnet;
                case AbstractObject.OBJECT_CONTAINER:
                    return imgService;
                case AbstractObject.OBJECT_CLUSTER:
                    return imgCluster;
                case AbstractObject.OBJECT_ACCESSPOINT:
                    return imgAccessPoint;
                case AbstractObject.OBJECT_NETWORKMAP:
                    return imgNetMap;
                case AbstractObject.OBJECT_INTERFACE:
                    return imgInterface;
                default:
                    return imgOther;
            }
        } else {
            return imgUnknown;
        }
    } else if (element instanceof NetworkMapResource) {
        return imgResCluster;
    }
    return null;
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) NetworkMapResource(org.netxms.client.maps.elements.NetworkMapResource) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) UUID(java.util.UUID) NetworkMapDCIImage(org.netxms.client.maps.elements.NetworkMapDCIImage) Image(org.eclipse.swt.graphics.Image)

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