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