Search in sources :

Example 1 with NetworkMapObject

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

the class AbstractNetworkMapView method transformSelection.

/**
 * Transform viewer's selection to form usable by another plugins by extracting NetXMS objects from map elements.
 *
 * @param viewerSelection viewer's selection
 * @return selection containing only NetXMS objects
 */
@SuppressWarnings("rawtypes")
private IStructuredSelection transformSelection(ISelection viewerSelection) {
    IStructuredSelection selection = (IStructuredSelection) viewerSelection;
    if (selection.isEmpty())
        return selection;
    List<Object> objects = new ArrayList<Object>();
    Iterator it = selection.iterator();
    while (it.hasNext()) {
        Object element = it.next();
        if (element instanceof NetworkMapObject) {
            AbstractObject object = session.findObjectById(((NetworkMapObject) element).getObjectId());
            if (object != null) {
                objects.add(object);
            } else {
                // Fix for issue NX-24
                // If object not found, add map element to selection
                // This will allow removal of unknown objects from map
                objects.add(element);
            }
        } else if (isSelectableElement(element)) {
            objects.add(element);
        }
    }
    return new StructuredSelection(objects.toArray());
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject)

Example 2 with NetworkMapObject

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

the class AbstractNetworkMapView method onObjectChange.

/**
 * Called by session listener when NetXMS object was changed.
 *
 * @param object changed NetXMS object
 */
protected void onObjectChange(final AbstractObject object) {
    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);
        addDciToRequestList();
    }
    if (object.getObjectId() == rootObject.getObjectId())
        rootObject = object;
}
Also used : NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 3 with NetworkMapObject

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

the class PredefinedMap method linkSelectedObjects.

/**
 * Link currently selected objects
 */
private void linkSelectedObjects() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() != 2)
        return;
    Object[] objects = selection.toArray();
    long id1 = ((NetworkMapObject) objects[0]).getId();
    long id2 = ((NetworkMapObject) objects[1]).getId();
    mapPage.addLink(new NetworkMapLink(NetworkMapLink.NORMAL, id1, id2));
    saveMap();
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 4 with NetworkMapObject

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

the class PredefinedMap method addObjectsFromList.

/**
 * Add objects from list to map
 *
 * @param list
 *           object list
 */
private void addObjectsFromList(List<AbstractObject> list, Point location) {
    int added = 0;
    for (AbstractObject object : list) {
        if (mapPage.findObjectElement(object.getObjectId()) == null) {
            final NetworkMapObject mapObject = new NetworkMapObject(mapPage.createElementId(), object.getObjectId());
            if (location != null)
                mapObject.setLocation(location.x, location.y);
            else
                mapObject.setLocation(40, 40);
            mapPage.addElement(mapObject);
            added++;
        }
    }
    if (added > 0) {
        saveMap();
    }
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) Point(org.eclipse.swt.graphics.Point)

Example 5 with NetworkMapObject

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

the class ServiceDependency method addParentServices.

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

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