Search in sources :

Example 26 with AbstractNode

use of org.netxms.client.objects.AbstractNode in project netxms by netxms.

the class ShowRadioInterfaces method selectionChanged.

/* (non-Javadoc)
	 * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
	 */
@Override
public void selectionChanged(IAction action, ISelection selection) {
    if ((selection instanceof IStructuredSelection) && (((IStructuredSelection) selection).size() == 1)) {
        Object obj = ((IStructuredSelection) selection).getFirstElement();
        if ((obj instanceof AbstractNode) && ((AbstractNode) obj).isWirelessController()) {
            action.setEnabled(true);
            objectId = ((AbstractObject) obj).getObjectId();
        } else {
            action.setEnabled(false);
            objectId = 0;
        }
    } else {
        action.setEnabled(false);
        objectId = 0;
    }
}
Also used : AbstractNode(org.netxms.client.objects.AbstractNode) AbstractObject(org.netxms.client.objects.AbstractObject) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 27 with AbstractNode

use of org.netxms.client.objects.AbstractNode in project netxms by netxms.

the class ExpansionTest method testNodeAndAlarmExpanssion.

public void testNodeAndAlarmExpanssion() throws Exception {
    final NXCSession session = connect();
    session.syncObjects();
    final AbstractNode object = (AbstractNode) session.findObjectById(TestConstants.NODE_ID);
    final Map<Long, Alarm> alarms = session.getAlarms();
    final Map<String, String> inputValues = new HashMap<String, String>();
    final Alarm alarm = alarms.values().iterator().next();
    inputValues.put("Key1", "Value1");
    inputValues.put("Key2", "Value2");
    final List<String> stringsToExpand = new ArrayList<String>();
    stringsToExpand.add("%%%a%A");
    stringsToExpand.add("%g%I");
    stringsToExpand.add("%K%n%U");
    stringsToExpand.add("%(Key1)%(Key2)");
    final List<String> expandedStrings = session.substitureMacross(new ObjectContextBase(object, alarm), stringsToExpand, inputValues);
    assertEquals("%" + object.getPrimaryIP().getHostAddress().toString() + alarm.getMessage(), expandedStrings.get(0));
    assertEquals(object.getGuid().toString() + object.getObjectId(), expandedStrings.get(1));
    assertEquals(alarm.getKey() + object.getObjectName() + session.getUserName(), expandedStrings.get(2));
    session.disconnect();
}
Also used : AbstractNode(org.netxms.client.objects.AbstractNode) HashMap(java.util.HashMap) ObjectContextBase(org.netxms.client.objecttools.ObjectContextBase) Alarm(org.netxms.client.events.Alarm) ArrayList(java.util.ArrayList)

Example 28 with AbstractNode

use of org.netxms.client.objects.AbstractNode in project netxms by netxms.

the class CreateSnmpDci method createDci.

/**
 * @param session
 * @param value
 * @param description
 * @param pollingInterval
 * @param retentionTime
 * @param deltaCalculation
 * @param lockRequired
 * @throws Exception
 */
private static void createDci(NXCSession session, SnmpValue value, String description, int pollingInterval, int retentionTime, int deltaCalculation, Map<Long, Boolean> lockRequired) throws Exception {
    AbstractNode node = (AbstractNode) session.findObjectById(value.getNodeId(), AbstractNode.class);
    if (node == null)
        throw new NXCException(RCC.INTERNAL_ERROR);
    DataCollectionConfiguration dcc;
    if (lockRequired.get(node.getObjectId())) {
        dcc = session.openDataCollectionConfiguration(node.getObjectId());
    } else {
        dcc = new DataCollectionConfiguration(session, node.getObjectId());
    }
    final DataCollectionItem dci = (DataCollectionItem) dcc.findItem(dcc.createItem(null), DataCollectionItem.class);
    dci.setPollingInterval(pollingInterval);
    dci.setRetentionTime(retentionTime);
    dci.setOrigin(DataCollectionItem.SNMP);
    dci.setDataType(dciTypeFromAsnType(value.getType()));
    dci.setStatus(DataCollectionItem.ACTIVE);
    dci.setDescription(description);
    dci.setDeltaCalculation(deltaCalculation);
    dci.setName(value.getName());
    dcc.modifyObject(dci);
    if (lockRequired.get(node.getObjectId())) {
        dcc.close();
    }
}
Also used : AbstractNode(org.netxms.client.objects.AbstractNode) DataCollectionItem(org.netxms.client.datacollection.DataCollectionItem) NXCException(org.netxms.client.NXCException) DataCollectionConfiguration(org.netxms.client.datacollection.DataCollectionConfiguration)

Example 29 with AbstractNode

use of org.netxms.client.objects.AbstractNode in project netxms by netxms.

the class ShowObjectEvents 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, "EventLog", IWorkbenchPage.VIEW_ACTIVATE);
        LogFilter filter = new LogFilter();
        // $NON-NLS-1$
        filter.setColumnFilter("event_source", cf);
        List<OrderingColumn> orderingColumns = new ArrayList<OrderingColumn>(1);
        // $NON-NLS-1$
        orderingColumns.add(new OrderingColumn("event_timestamp", Messages.get().ShowObjectEvents_Time, true));
        filter.setOrderingColumns(orderingColumns);
        view.queryWithFilter(filter);
    } catch (PartInitException e) {
        MessageDialogHelper.openError(window.getShell(), Messages.get().ShowObjectEvents_Error, String.format(Messages.get().ShowObjectEvents_CannotOpenLogViewer, e.getMessage()));
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) AbstractNode(org.netxms.client.objects.AbstractNode) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ColumnFilter(org.netxms.client.log.ColumnFilter) AbstractObject(org.netxms.client.objects.AbstractObject) ISelection(org.eclipse.jface.viewers.ISelection) AbstractObject(org.netxms.client.objects.AbstractObject) LogViewer(org.netxms.ui.eclipse.logviewer.views.LogViewer) PartInitException(org.eclipse.ui.PartInitException) OrderingColumn(org.netxms.client.log.OrderingColumn) LogFilter(org.netxms.client.log.LogFilter)

Example 30 with AbstractNode

use of org.netxms.client.objects.AbstractNode in project netxms by netxms.

the class ShowObjectSyslog 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, "syslog", IWorkbenchPage.VIEW_ACTIVATE);
        LogFilter filter = new LogFilter();
        // $NON-NLS-1$
        filter.setColumnFilter("source_object_id", cf);
        List<OrderingColumn> orderingColumns = new ArrayList<OrderingColumn>(1);
        // $NON-NLS-1$
        orderingColumns.add(new OrderingColumn("msg_timestamp", Messages.get().ShowObjectSyslog_Time, true));
        filter.setOrderingColumns(orderingColumns);
        view.queryWithFilter(filter);
    } catch (PartInitException e) {
        MessageDialogHelper.openError(window.getShell(), Messages.get().ShowObjectSyslog_Error, String.format(Messages.get().ShowObjectSyslog_ErrorOpenLogViewer, e.getMessage()));
    }
    return null;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) AbstractNode(org.netxms.client.objects.AbstractNode) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ColumnFilter(org.netxms.client.log.ColumnFilter) AbstractObject(org.netxms.client.objects.AbstractObject) ISelection(org.eclipse.jface.viewers.ISelection) AbstractObject(org.netxms.client.objects.AbstractObject) LogViewer(org.netxms.ui.eclipse.logviewer.views.LogViewer) PartInitException(org.eclipse.ui.PartInitException) OrderingColumn(org.netxms.client.log.OrderingColumn) LogFilter(org.netxms.client.log.LogFilter)

Aggregations

AbstractNode (org.netxms.client.objects.AbstractNode)47 AbstractObject (org.netxms.client.objects.AbstractObject)27 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)14 NXCSession (org.netxms.client.NXCSession)13 ArrayList (java.util.ArrayList)12 Cluster (org.netxms.client.objects.Cluster)9 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 Composite (org.eclipse.swt.widgets.Composite)6 PartInitException (org.eclipse.ui.PartInitException)6 MobileDevice (org.netxms.client.objects.MobileDevice)6 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)6 NXCException (org.netxms.client.NXCException)5 Interface (org.netxms.client.objects.Interface)5 Sensor (org.netxms.client.objects.Sensor)5 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 DataCollectionItem (org.netxms.client.datacollection.DataCollectionItem)4 Subnet (org.netxms.client.objects.Subnet)4 ISelection (org.eclipse.jface.viewers.ISelection)3