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);
}
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);
}
}
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());
}
}
}
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);
}
}
}
}
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);
}
}
}
}
Aggregations