Search in sources :

Example 51 with AbstractObject

use of org.netxms.client.objects.AbstractObject 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 52 with AbstractObject

use of org.netxms.client.objects.AbstractObject 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 53 with AbstractObject

use of org.netxms.client.objects.AbstractObject 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 54 with AbstractObject

use of org.netxms.client.objects.AbstractObject 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)

Example 55 with AbstractObject

use of org.netxms.client.objects.AbstractObject in project netxms by netxms.

the class MapLabelProvider method selfStyleConnection.

/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.gef4.zest.core.viewers.ISelfStyleProvider#selfStyleConnection(java
	 * .lang.Object, org.eclipse.gef4.zest.core.widgets.GraphConnection)
	 */
@Override
public void selfStyleConnection(Object element, GraphConnection connection) {
    connection.setVisible(connectionsVisible);
    NetworkMapLink link = (NetworkMapLink) connection.getData();
    if (link.getType() == NetworkMapLink.VPN) {
        connection.setLineStyle(Graphics.LINE_DOT);
    }
    if (link.hasConnectorName1() && connectionLabelsVisible) {
        ConnectionEndpointLocator sourceEndpointLocator = new ConnectionEndpointLocator(connection.getConnectionFigure(), false);
        sourceEndpointLocator.setVDistance(0);
        final Label label = new ConnectorLabel(link.getConnectorName1());
        label.setFont(fontLabel);
        connection.getConnectionFigure().add(label, sourceEndpointLocator);
    }
    if (link.hasConnectorName2() && connectionLabelsVisible) {
        ConnectionEndpointLocator targetEndpointLocator = new ConnectionEndpointLocator(connection.getConnectionFigure(), true);
        targetEndpointLocator.setVDistance(0);
        final Label label = new ConnectorLabel(link.getConnectorName2());
        label.setFont(fontLabel);
        connection.getConnectionFigure().add(label, targetEndpointLocator);
    }
    if (showLinkDirection)
        ((PolylineConnection) connection.getConnectionFigure()).setSourceDecoration(new PolylineDecoration());
    IFigure owner = ((PolylineConnection) connection.getConnectionFigure()).getTargetAnchor().getOwner();
    ((PolylineConnection) connection.getConnectionFigure()).setTargetAnchor(new MultiConnectionAnchor(owner, link));
    owner = ((PolylineConnection) connection.getConnectionFigure()).getSourceAnchor().getOwner();
    ((PolylineConnection) connection.getConnectionFigure()).setSourceAnchor(new MultiConnectionAnchor(owner, link));
    boolean hasDciData = link.hasDciData();
    boolean hasName = link.hasName();
    if (link.getStatusObject() != null && link.getStatusObject().size() != 0) {
        ObjectStatus status = ObjectStatus.UNKNOWN;
        for (Long id : link.getStatusObject()) {
            AbstractObject object = session.findObjectById(id);
            if (object != null) {
                ObjectStatus s = object.getStatus();
                if ((s.compareTo(ObjectStatus.UNKNOWN) < 0) && ((status.compareTo(s) < 0) || (status == ObjectStatus.UNKNOWN))) {
                    status = s;
                    if (status == ObjectStatus.CRITICAL)
                        break;
                }
            }
        }
        connection.setLineColor(StatusDisplayInfo.getStatusColor(status));
    } else if (link.getColor() >= 0) {
        connection.setLineColor(colors.create(ColorConverter.rgbFromInt(link.getColor())));
    } else if (link.getType() == NetworkMapLink.AGENT_TUNEL) {
        connection.setLineColor(COLOR_AGENT_TUNNEL);
    } else if (link.getType() == NetworkMapLink.AGENT_PROXY) {
        connection.setLineColor(COLOR_AGENT_PROXY);
    } else if (link.getType() == NetworkMapLink.ICMP_PROXY) {
        connection.setLineColor(COLOR_ICMP_PROXY);
    } else if (link.getType() == NetworkMapLink.SNMP_PROXY) {
        connection.setLineColor(COLOR_SNMP_PROXY);
    } else if (link.getType() == NetworkMapLink.SSH_PROXY) {
        connection.setLineColor(COLOR_SSH_PROXY);
    } else if (link.getType() == NetworkMapLink.ZONE_PROXY) {
        connection.setLineColor(COLOR_ZONE_PROXY);
    } else if (defaultLinkColor != null) {
        connection.setLineColor(defaultLinkColor);
    }
    if ((hasName || hasDciData) && connectionLabelsVisible) {
        MultiLabelConnectionLocator nameLocator = new MultiLabelConnectionLocator(connection.getConnectionFigure(), link);
        // $NON-NLS-1$
        String labelString = "";
        if (hasName)
            labelString += link.getName();
        if (hasName && hasDciData)
            // $NON-NLS-1$
            labelString += "\n";
        if (hasDciData) {
            labelString += dciValueProvider.getDciDataAsString(link);
        }
        final Label label;
        if (link.getType() == NetworkMapLink.AGENT_TUNEL || link.getType() == NetworkMapLink.AGENT_PROXY || link.getType() == NetworkMapLink.ICMP_PROXY || link.getType() == NetworkMapLink.SNMP_PROXY || link.getType() == NetworkMapLink.SSH_PROXY || link.getType() == NetworkMapLink.ZONE_PROXY)
            label = new ConnectorLabel(labelString, connection.getLineColor());
        else
            label = new ConnectorLabel(labelString);
        label.setFont(fontLabel);
        connection.getConnectionFigure().add(label, nameLocator);
    }
    switch(link.getRouting()) {
        case NetworkMapLink.ROUTING_DIRECT:
            connection.setRouter(ConnectionRouter.NULL);
            break;
        case NetworkMapLink.ROUTING_MANHATTAN:
            connection.setRouter(manhattanRouter);
            break;
        case NetworkMapLink.ROUTING_BENDPOINTS:
            connection.setRouter(bendpointRouter);
            // $NON-NLS-1$
            connection.setData("ROUTER", bendpointRouter);
            Object bp = getConnectionPoints(link);
            bendpointRouter.setConstraint(connection.getConnectionFigure(), bp);
            connection.getConnectionFigure().setRoutingConstraint(bp);
            break;
        default:
            connection.setRouter(null);
            break;
    }
    connection.setLineWidth(2);
}
Also used : Label(org.eclipse.draw2d.Label) PolylineDecoration(org.eclipse.draw2d.PolylineDecoration) PolylineConnection(org.eclipse.draw2d.PolylineConnection) ObjectStatus(org.netxms.client.constants.ObjectStatus) AbstractObject(org.netxms.client.objects.AbstractObject) ConnectionEndpointLocator(org.eclipse.draw2d.ConnectionEndpointLocator) AbstractObject(org.netxms.client.objects.AbstractObject) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) UnknownObject(org.netxms.client.objects.UnknownObject) NetworkMapLink(org.netxms.client.maps.NetworkMapLink) IFigure(org.eclipse.draw2d.IFigure)

Aggregations

AbstractObject (org.netxms.client.objects.AbstractObject)216 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)55 NXCSession (org.netxms.client.NXCSession)51 AbstractNode (org.netxms.client.objects.AbstractNode)31 PartInitException (org.eclipse.ui.PartInitException)27 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)26 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)25 Cluster (org.netxms.client.objects.Cluster)22 ObjectSelectionDialog (org.netxms.ui.eclipse.objectbrowser.dialogs.ObjectSelectionDialog)22 ArrayList (java.util.ArrayList)20 Node (org.netxms.client.objects.Node)20 GridData (org.eclipse.swt.layout.GridData)18 Composite (org.eclipse.swt.widgets.Composite)18 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)18 GridLayout (org.eclipse.swt.layout.GridLayout)15 Container (org.netxms.client.objects.Container)15 Interface (org.netxms.client.objects.Interface)12 Template (org.netxms.client.objects.Template)12 SelectionEvent (org.eclipse.swt.events.SelectionEvent)11 Point (org.eclipse.swt.graphics.Point)11