use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class ShowObjectSnmpTrapLog method execute.
/* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
*/
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event);
ISelection selection = window.getActivePage().getSelection();
if ((selection == null) || !(selection instanceof IStructuredSelection) || selection.isEmpty())
return null;
ColumnFilter cf = new ColumnFilter();
cf.setOperation(ColumnFilterSetOperation.OR);
for (Object o : ((IStructuredSelection) selection).toList()) {
if (!(o instanceof AbstractObject))
continue;
cf.addSubFilter(new ColumnFilter((o instanceof AbstractNode) ? ColumnFilterType.EQUALS : ColumnFilterType.CHILDOF, ((AbstractObject) o).getObjectId()));
}
try {
// $NON-NLS-1$
LogViewer view = (LogViewer) window.getActivePage().showView(LogViewer.ID, "SnmpTrapLog", IWorkbenchPage.VIEW_ACTIVATE);
LogFilter filter = new LogFilter();
// $NON-NLS-1$
filter.setColumnFilter("object_id", cf);
List<OrderingColumn> orderingColumns = new ArrayList<OrderingColumn>(1);
// $NON-NLS-1$
orderingColumns.add(new OrderingColumn("trap_timestamp", Messages.get().ShowObjectSnmpTrapLog_Time, true));
filter.setOrderingColumns(orderingColumns);
view.queryWithFilter(filter);
} catch (PartInitException e) {
MessageDialogHelper.openError(window.getShell(), Messages.get().ShowObjectSnmpTrapLog_Error, String.format(Messages.get().ShowObjectSnmpTrapLog_ErrorOpenLogViewer, e.getMessage()));
}
return null;
}
use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class IPAddressSelector method setNode.
/**
* Set node for which list of IP addresses will be displayed.
*
* @param nodeId node ID
*/
public void setNode(long nodeId) {
AbstractObject object = session.findObjectById(nodeId);
if (object instanceof AbstractNode) {
node = (AbstractNode) object;
address = node.getPrimaryIP().getAddress();
setText((address != null) ? address.getHostAddress() : "");
} else {
node = null;
setText(Messages.get().IPAddressSelector_None);
}
}
use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class ObjectSearchResultLabelProvider method getColumnText.
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int)
*/
@Override
public String getColumnText(Object element, int columnIndex) {
if (!(element instanceof AbstractObject))
return null;
AbstractObject object = (AbstractObject) element;
switch(columnIndex) {
case ObjectFinder.COL_CLASS:
return object.getObjectClassName();
case ObjectFinder.COL_ID:
return Long.toString(object.getObjectId());
case ObjectFinder.COL_IP_ADDRESS:
if (object instanceof AbstractNode) {
InetAddressEx addr = ((AbstractNode) object).getPrimaryIP();
return addr.isValidUnicastAddress() ? addr.getHostAddress() : null;
}
if (object instanceof AccessPoint) {
InetAddressEx addr = ((AccessPoint) object).getIpAddress();
return addr.isValidUnicastAddress() ? addr.getHostAddress() : null;
}
if (object instanceof Interface) {
return ((Interface) object).getIpAddressListAsString();
}
return null;
case ObjectFinder.COL_NAME:
return wbLabelProvider.getText(element);
case ObjectFinder.COL_PARENT:
return getParentNames((AbstractObject) element);
case ObjectFinder.COL_ZONE:
if (object instanceof AbstractNode) {
long zoneId = ((AbstractNode) object).getZoneId();
Zone zone = ConsoleSharedData.getSession().findZone(zoneId);
return (zone != null) ? zone.getObjectName() + " (" + Long.toString(zoneId) + ")" : Long.toString(zoneId);
} else if (object instanceof Interface) {
long zoneId = ((Interface) object).getZoneId();
Zone zone = ConsoleSharedData.getSession().findZone(zoneId);
return (zone != null) ? zone.getObjectName() + " (" + Long.toString(zoneId) + ")" : Long.toString(zoneId);
}
return null;
}
return null;
}
use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class BindObjectTo method selectionChanged.
/**
* @see IActionDelegate#selectionChanged(IAction, ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
if ((selection instanceof IStructuredSelection) && (((IStructuredSelection) selection).size() > 0)) {
objects = new HashSet<Long>();
for (Object o : ((IStructuredSelection) selection).toList()) {
if ((o instanceof AbstractNode) || (o instanceof Subnet) || (o instanceof MobileDevice) || (o instanceof Rack) || (o instanceof Cluster) || (o instanceof Sensor))
objects.add(((AbstractObject) o).getObjectId());
}
} else {
action.setEnabled(false);
objects = null;
}
}
use of org.netxms.client.objects.AbstractNode in project netxms by netxms.
the class ObjectToolsDynamicMenu method buildNodeSet.
/**
* Build node set from selection
*
* @param selection
* @return
*/
private Set<ObjectContext> buildNodeSet(IStructuredSelection selection) {
final Set<ObjectContext> nodes = new HashSet<ObjectContext>();
final NXCSession session = (NXCSession) ConsoleSharedData.getSession();
for (Object o : selection.toList()) {
if (o instanceof AbstractNode) {
nodes.add(new ObjectContext((AbstractNode) o, null));
} else if ((o instanceof Container) || (o instanceof ServiceRoot) || (o instanceof Subnet) || (o instanceof Cluster)) {
for (AbstractObject n : ((AbstractObject) o).getAllChilds(AbstractObject.OBJECT_NODE)) nodes.add(new ObjectContext((AbstractNode) n, null));
} else if (o instanceof Alarm) {
AbstractNode n = (AbstractNode) session.findObjectById(((Alarm) o).getSourceObjectId(), AbstractNode.class);
if (n != null)
nodes.add(new ObjectContext(n, (Alarm) o));
} else if (o instanceof ObjectWrapper) {
AbstractObject n = ((ObjectWrapper) o).getObject();
if ((n != null) && (n instanceof AbstractNode))
nodes.add(new ObjectContext((AbstractNode) n, null));
}
}
return nodes;
}
Aggregations