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