Search in sources :

Example 6 with NetworkMapElement

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

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

the class ExtendedGraphViewer method clearDecorationSelection.

/**
 * Clear selection on decoration layer
 */
private void clearDecorationSelection(boolean sendEvent) {
    if (selectedDecorations.size() == 0)
        return;
    for (NetworkMapElement d : selectedDecorations) {
        DecorationLayerAbstractFigure f = decorationFigures.get(d.getId());
        if (f != null)
            f.setSelected(false);
    }
    selectedDecorations.clear();
    if (sendEvent) {
        SelectionChangedEvent event = new SelectionChangedEvent(this, getSelection());
        fireSelectionChanged(event);
        firePostSelectionChanged(event);
    }
}
Also used : NetworkMapElement(org.netxms.client.maps.elements.NetworkMapElement) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent)

Example 8 with NetworkMapElement

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

the class ManualLayout method applyLayout.

/* (non-Javadoc)
	 * @see org.eclipse.gef4.zest.layouts.LayoutAlgorithm#applyLayout(boolean)
	 */
@Override
public void applyLayout(boolean clean) {
    EntityLayout[] entitiesToLayout = context.getEntities();
    for (int i = 0; i < entitiesToLayout.length; i++) {
        Item[] items = entitiesToLayout[i].getItems();
        if ((items.length > 0) && (items[0].getData() instanceof NetworkMapElement)) {
            NetworkMapElement mapObject = (NetworkMapElement) items[0].getData();
            entitiesToLayout[i].setLocation(mapObject.getX(), mapObject.getY());
        }
    }
}
Also used : Item(org.eclipse.swt.widgets.Item) EntityLayout(org.eclipse.gef4.zest.layouts.interfaces.EntityLayout) NetworkMapElement(org.netxms.client.maps.elements.NetworkMapElement)

Example 9 with NetworkMapElement

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

the class AbstractNetworkMapView method updateObjectPositions.

/**
 * Update stored object positions with actual positions read from graph control
 */
protected void updateObjectPositions() {
    Graph graph = viewer.getGraphControl();
    List<?> nodes = graph.getNodes();
    for (Object o : nodes) {
        if (o instanceof GraphNode) {
            Object data = ((GraphNode) o).getData();
            if (data instanceof NetworkMapElement) {
                Point loc = ((GraphNode) o).getLocation();
                Dimension size = ((GraphNode) o).getSize();
                ((NetworkMapElement) data).setLocation(loc.x + (size.width + 1) / 2, loc.y + (size.height + 1) / 2);
            }
        }
    }
}
Also used : Graph(org.eclipse.gef4.zest.core.widgets.Graph) NetworkMapElement(org.netxms.client.maps.elements.NetworkMapElement) NetworkMapObject(org.netxms.client.maps.elements.NetworkMapObject) AbstractObject(org.netxms.client.objects.AbstractObject) GraphNode(org.eclipse.gef4.zest.core.widgets.GraphNode) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension)

Example 10 with NetworkMapElement

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

the class AbstractNetworkMapView method addDciToRequestList.

/**
 * Goes thought all links and trys to add to request list required DCIs.
 */
protected void addDciToRequestList() {
    Collection<NetworkMapLink> linkList = mapPage.getLinks();
    for (NetworkMapLink item : linkList) {
        if (item.hasDciData()) {
            for (SingleDciConfig value : item.getDciAsList()) {
                if (value.type == SingleDciConfig.ITEM) {
                    dciValueProvider.addDci(value.getNodeId(), value.dciId, mapPage);
                } else {
                    dciValueProvider.addDci(value.getNodeId(), value.dciId, value.column, value.instance, mapPage);
                }
            }
        }
    }
    Collection<NetworkMapElement> mapElements = mapPage.getElements();
    for (NetworkMapElement element : mapElements) {
        if (element instanceof NetworkMapDCIContainer) {
            NetworkMapDCIContainer item = (NetworkMapDCIContainer) element;
            if (item.hasDciData()) {
                for (SingleDciConfig value : item.getObjectDCIArray()) {
                    if (value.type == SingleDciConfig.ITEM) {
                        dciValueProvider.addDci(value.getNodeId(), value.dciId, mapPage);
                    } else {
                        dciValueProvider.addDci(value.getNodeId(), value.dciId, value.column, value.instance, mapPage);
                    }
                }
            }
        }
        if (element instanceof NetworkMapDCIImage) {
            NetworkMapDCIImage item = (NetworkMapDCIImage) element;
            DCIImageConfiguration config = item.getImageOptions();
            SingleDciConfig value = config.getDci();
            if (value.type == SingleDciConfig.ITEM) {
                dciValueProvider.addDci(value.getNodeId(), value.dciId, mapPage);
            } else {
                dciValueProvider.addDci(value.getNodeId(), value.dciId, value.column, value.instance, mapPage);
            }
        }
    }
}
Also used : NetworkMapDCIImage(org.netxms.client.maps.elements.NetworkMapDCIImage) NetworkMapElement(org.netxms.client.maps.elements.NetworkMapElement) DCIImageConfiguration(org.netxms.client.maps.configs.DCIImageConfiguration) NetworkMapDCIContainer(org.netxms.client.maps.elements.NetworkMapDCIContainer) NetworkMapLink(org.netxms.client.maps.NetworkMapLink) SingleDciConfig(org.netxms.client.maps.configs.SingleDciConfig)

Aggregations

NetworkMapElement (org.netxms.client.maps.elements.NetworkMapElement)13 NetworkMapLink (org.netxms.client.maps.NetworkMapLink)6 NetworkMapObject (org.netxms.client.maps.elements.NetworkMapObject)5 AbstractObject (org.netxms.client.objects.AbstractObject)4 Point (org.eclipse.draw2d.geometry.Point)2 NetworkMapPage (org.netxms.client.maps.NetworkMapPage)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 HashSet (java.util.HashSet)1 Iterator (java.util.Iterator)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Dimension (org.eclipse.draw2d.geometry.Dimension)1 Graph (org.eclipse.gef4.zest.core.widgets.Graph)1 GraphNode (org.eclipse.gef4.zest.core.widgets.GraphNode)1 EntityLayout (org.eclipse.gef4.zest.layouts.interfaces.EntityLayout)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 Item (org.eclipse.swt.widgets.Item)1