Search in sources :

Example 6 with NetworkMapLink

use of org.netxms.client.maps.NetworkMapLink in project netxms by netxms.

the class AbstractNetworkMapView method analyzeSelection.

/**
 * Tests if given selection contains only NetXMS objects
 *
 * @param selection
 * @return
 */
@SuppressWarnings("rawtypes")
private int analyzeSelection(IStructuredSelection selection) {
    if (selection.isEmpty())
        return SELECTION_EMPTY;
    Iterator it = selection.iterator();
    Object first = it.next();
    int type;
    Class firstClass;
    if (first instanceof AbstractObject) {
        type = SELECTION_OBJECTS;
        firstClass = AbstractObject.class;
    } else if (first instanceof NetworkMapElement) {
        type = SELECTION_ELEMENTS;
        firstClass = NetworkMapElement.class;
    } else if (first instanceof NetworkMapLink) {
        type = SELECTION_LINKS;
        firstClass = NetworkMapLink.class;
    } else {
        return SELECTION_MIXED;
    }
    while (it.hasNext()) {
        final Object o = it.next();
        if (!firstClass.isInstance(o))
            return SELECTION_MIXED;
    }
    return type;
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) NetworkMapElement(org.netxms.client.maps.elements.NetworkMapElement) Iterator(java.util.Iterator) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) AbstractObject(org.netxms.client.objects.AbstractObject) Point(org.eclipse.draw2d.geometry.Point) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 7 with NetworkMapLink

use of org.netxms.client.maps.NetworkMapLink 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 8 with NetworkMapLink

use of org.netxms.client.maps.NetworkMapLink in project netxms by netxms.

the class PredefinedMap method removeSelectedElements.

/**
 * Remove currently selected map elements
 */
private void removeSelectedElements() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (!MessageDialogHelper.openQuestion(getSite().getShell(), Messages.get().PredefinedMap_ConfirmRemoval, (selection.size() == 1) ? Messages.get().PredefinedMap_RemovalConfirmationSingular : Messages.get().PredefinedMap_RemovalConfirmationPlural))
        return;
    Object[] objects = selection.toArray();
    for (Object element : objects) {
        if (element instanceof AbstractObject) {
            mapPage.removeObjectElement(((AbstractObject) element).getObjectId());
        } else if (element instanceof NetworkMapElement) {
            mapPage.removeElement(((NetworkMapElement) element).getId());
        } else if (element instanceof NetworkMapLink) {
            mapPage.removeLink((NetworkMapLink) element);
        }
    }
    saveMap();
    // for some reason graph viewer does not clear selection
    // after all selected elements was removed, so we have to do it manually
    viewer.setSelection(StructuredSelection.EMPTY);
}
Also used : AbstractObject(org.netxms.client.objects.AbstractObject) NetworkMapElement(org.netxms.client.maps.elements.NetworkMapElement) AbstractObject(org.netxms.client.objects.AbstractObject) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Example 9 with NetworkMapLink

use of org.netxms.client.maps.NetworkMapLink 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)

Example 10 with NetworkMapLink

use of org.netxms.client.maps.NetworkMapLink in project netxms by netxms.

the class ClusterTab method buildClusterMap.

/**
 * Build hierarchical cluster representation
 *
 * @return
 */
private NetworkMapPage buildClusterMap() {
    NetworkMapPage page = new NetworkMapPage(pluginId + id);
    long id = 1;
    page.addElement(new NetworkMapObject(id++, cluster.getObjectId()));
    for (AbstractObject o : cluster.getAllChilds(AbstractObject.OBJECT_NODE)) {
        page.addElement(new NetworkMapObject(id, o.getObjectId()));
        page.addLink(new NetworkMapLink(0, 1, id));
        addOwnedResources(page, id, o.getObjectId(), cluster.getResources());
        id++;
    }
    return page;
}
Also used : NetworkMapPage(org.netxms.client.maps.NetworkMapPage) AbstractObject(org.netxms.client.objects.AbstractObject) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink)

Aggregations

NetworkMapLink (org.netxms.client.maps.NetworkMapLink)27 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)16 AbstractObject (org.netxms.client.objects.AbstractObject)12 NetworkMapPage (org.netxms.client.maps.NetworkMapPage)6 NetworkMapElement (org.netxms.client.maps.elements.NetworkMapElement)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)3 NXCPMessage (org.netxms.base.NXCPMessage)3 AccessPoint (org.netxms.client.objects.AccessPoint)3 Cluster (org.netxms.client.objects.Cluster)3 Container (org.netxms.client.objects.Container)3 Node (org.netxms.client.objects.Node)3 CoreException (org.eclipse.core.runtime.CoreException)2 Point (org.eclipse.draw2d.geometry.Point)2 PartInitException (org.eclipse.ui.PartInitException)2 ObjectStatus (org.netxms.client.constants.ObjectStatus)2 DCIImageConfiguration (org.netxms.client.maps.configs.DCIImageConfiguration)2 SingleDciConfig (org.netxms.client.maps.configs.SingleDciConfig)2 NetworkMapDCIContainer (org.netxms.client.maps.elements.NetworkMapDCIContainer)2 NetworkMapDCIImage (org.netxms.client.maps.elements.NetworkMapDCIImage)2 ClusterResource (org.netxms.client.objects.ClusterResource)2