Search in sources :

Example 1 with NetworkMapResource

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

the class ClusterTab method addOwnedResources.

/**
 * @param id
 * @param objectId
 * @param resources
 */
private void addOwnedResources(NetworkMapPage page, long rootElementId, long objectId, List<ClusterResource> resources) {
    long elementId = rootElementId * 100000;
    for (ClusterResource r : resources) {
        if (r.getCurrentOwner() == objectId) {
            page.addElement(new NetworkMapResource(elementId, NetworkMapResource.CLUSTER_RESOURCE, r));
            page.addLink(new NetworkMapLink(0, rootElementId, elementId));
            elementId++;
        }
    }
}
Also used : NetworkMapResource(org.netxms.client.maps.elements.NetworkMapResource) NetworkMapLink(org.netxms.client.maps.NetworkMapLink) ClusterResource(org.netxms.client.objects.ClusterResource)

Example 2 with NetworkMapResource

use of org.netxms.client.maps.elements.NetworkMapResource 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

NetworkMapResource (org.netxms.client.maps.elements.NetworkMapResource)2 UUID (java.util.UUID)1 Image (org.eclipse.swt.graphics.Image)1 NetworkMapLink (org.netxms.client.maps.NetworkMapLink)1 NetworkMapDCIImage (org.netxms.client.maps.elements.NetworkMapDCIImage)1 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)1 AbstractObject (org.netxms.client.objects.AbstractObject)1 ClusterResource (org.netxms.client.objects.ClusterResource)1