Search in sources :

Example 1 with SnmpObjectId

use of org.netxms.client.snmp.SnmpObjectId in project netxms by netxms.

the class GeneralTable method selectParameter.

/**
 * Select parameter
 */
private void selectParameter() {
    Dialog dlg;
    editor.setSourceNode(sourceNode.getObjectId());
    switch(origin.getSelectionIndex()) {
        case DataCollectionObject.AGENT:
            if (sourceNode.getObjectId() != 0)
                dlg = new SelectAgentParamDlg(getShell(), sourceNode.getObjectId(), origin.getSelectionIndex(), true);
            else
                dlg = new SelectAgentParamDlg(getShell(), dci.getNodeId(), origin.getSelectionIndex(), true);
            break;
        case DataCollectionObject.SNMP:
        case DataCollectionObject.CHECKPOINT_SNMP:
            SnmpObjectId oid;
            try {
                oid = SnmpObjectId.parseSnmpObjectId(parameter.getText());
            } catch (SnmpObjectIdFormatException e) {
                oid = null;
            }
            if (sourceNode.getObjectId() != 0)
                dlg = new SelectSnmpParamDlg(getShell(), oid, sourceNode.getObjectId());
            else
                dlg = new SelectSnmpParamDlg(getShell(), oid, dci.getNodeId());
            break;
        case DataCollectionItem.SCRIPT:
            dlg = new SelectParameterScriptDialog(getShell());
            break;
        default:
            dlg = null;
            break;
    }
    if ((dlg != null) && (dlg.open() == Window.OK)) {
        IParameterSelectionDialog pd = (IParameterSelectionDialog) dlg;
        description.setText(pd.getParameterDescription());
        parameter.setText(pd.getParameterName());
        editor.fireOnSelectTableListeners(origin.getSelectionIndex(), pd.getParameterName(), pd.getParameterDescription());
    }
}
Also used : SelectSnmpParamDlg(org.netxms.ui.eclipse.datacollection.dialogs.SelectSnmpParamDlg) SelectParameterScriptDialog(org.netxms.ui.eclipse.datacollection.dialogs.SelectParameterScriptDialog) DCIPropertyPageDialog(org.netxms.ui.eclipse.datacollection.propertypages.helpers.DCIPropertyPageDialog) IParameterSelectionDialog(org.netxms.ui.eclipse.datacollection.dialogs.IParameterSelectionDialog) Dialog(org.eclipse.jface.dialogs.Dialog) SnmpObjectIdFormatException(org.netxms.client.snmp.SnmpObjectIdFormatException) SelectAgentParamDlg(org.netxms.ui.eclipse.datacollection.dialogs.SelectAgentParamDlg) SnmpObjectId(org.netxms.client.snmp.SnmpObjectId) SelectParameterScriptDialog(org.netxms.ui.eclipse.datacollection.dialogs.SelectParameterScriptDialog) IParameterSelectionDialog(org.netxms.ui.eclipse.datacollection.dialogs.IParameterSelectionDialog)

Example 2 with SnmpObjectId

use of org.netxms.client.snmp.SnmpObjectId in project netxms by netxms.

the class MibSelectionDialog method doWalk.

/**
 * Do SNMP walk
 */
private void doWalk() {
    try {
        final SnmpObjectId root = SnmpObjectId.parseSnmpObjectId(oid.getText());
        MibWalkDialog dlg = new MibWalkDialog(getShell(), nodeId, root);
        if (dlg.open() == Window.OK) {
            SnmpValue v = dlg.getValue();
            if (v != null) {
                oid.setText(v.getName());
            }
        }
    } catch (SnmpObjectIdFormatException e) {
        MessageDialogHelper.openError(getShell(), Messages.get().MibSelectionDialog_Error, Messages.get().MibSelectionDialog_OIDParseError);
    }
}
Also used : SnmpValue(org.netxms.client.snmp.SnmpValue) SnmpObjectIdFormatException(org.netxms.client.snmp.SnmpObjectIdFormatException) SnmpObjectId(org.netxms.client.snmp.SnmpObjectId)

Example 3 with SnmpObjectId

use of org.netxms.client.snmp.SnmpObjectId in project netxms by netxms.

the class ParamMappingEditDialog method selectObjectId.

/**
 * Select OID using MIB selection dialog
 */
private void selectObjectId() {
    SnmpObjectId oid;
    try {
        oid = SnmpObjectId.parseSnmpObjectId(objectId.getText());
    } catch (SnmpObjectIdFormatException e) {
        oid = null;
    }
    MibSelectionDialog dlg = new MibSelectionDialog(getShell(), oid, 0);
    if (dlg.open() == Window.OK) {
        objectId.setText(dlg.getSelectedObjectId().toString());
        objectId.setFocus();
    }
}
Also used : SnmpObjectIdFormatException(org.netxms.client.snmp.SnmpObjectIdFormatException) SnmpObjectId(org.netxms.client.snmp.SnmpObjectId)

Example 4 with SnmpObjectId

use of org.netxms.client.snmp.SnmpObjectId in project netxms by netxms.

the class MibObjectDetails method setObject.

/**
 * Set MIB object to show
 *
 * @param object MIB object
 */
public void setObject(MibObject object) {
    if (object != null) {
        if ((oid != null) && updateObjectId) {
            SnmpObjectId objectId = object.getObjectId();
            // $NON-NLS-1$
            oid.setText((objectId != null) ? objectId.toString() : "");
        }
        if (oidText != null) {
            oidText.setText(object.getFullName());
        }
        description.setText(object.getDescription());
        textualConvention.setText(object.getTextualConvention());
        type.setText(SnmpConstants.getObjectTypeName(object.getType()));
        status.setText(SnmpConstants.getObjectStatusName(object.getStatus()));
        access.setText(SnmpConstants.getObjectAccessName(object.getAccess()));
    } else {
        if (oid != null)
            // $NON-NLS-1$
            oid.setText("");
        if (oidText != null)
            // $NON-NLS-1$
            oidText.setText("");
        // $NON-NLS-1$
        description.setText("");
        // $NON-NLS-1$
        textualConvention.setText("");
        // $NON-NLS-1$
        type.setText("");
        // $NON-NLS-1$
        status.setText("");
        // $NON-NLS-1$
        access.setText("");
    }
}
Also used : SnmpObjectId(org.netxms.client.snmp.SnmpObjectId)

Example 5 with SnmpObjectId

use of org.netxms.client.snmp.SnmpObjectId in project netxms by netxms.

the class SnmpTest method testSnmpObjectId.

public void testSnmpObjectId() throws Exception {
    // Test parse and equals
    final SnmpObjectId oid1 = new SnmpObjectId(new long[] { 1, 3, 6, 1, 2, 1, 1, 1, 0 });
    final SnmpObjectId oid2 = SnmpObjectId.parseSnmpObjectId(".1.3.6.1.2.1.1.1.0");
    assertEquals(oid1, oid2);
    // Test toString
    assertEquals(".1.3.6.1.2.1.1.1.0", oid1.toString());
    // Test format exception
    try {
        SnmpObjectId.parseSnmpObjectId(".1.2.bad.4");
        assertFalse(true);
    } catch (SnmpObjectIdFormatException e) {
        System.out.println("Bad OID format: " + e.getMessage());
    }
    try {
        SnmpObjectId.parseSnmpObjectId("1.2.3.4");
        assertFalse(true);
    } catch (SnmpObjectIdFormatException e) {
        System.out.println("Bad OID format: " + e.getMessage());
    }
    try {
        SnmpObjectId.parseSnmpObjectId(".");
        assertFalse(true);
    } catch (SnmpObjectIdFormatException e) {
        System.out.println("Bad OID format: " + e.getMessage());
    }
}
Also used : SnmpObjectIdFormatException(org.netxms.client.snmp.SnmpObjectIdFormatException) SnmpObjectId(org.netxms.client.snmp.SnmpObjectId)

Aggregations

SnmpObjectId (org.netxms.client.snmp.SnmpObjectId)11 SnmpObjectIdFormatException (org.netxms.client.snmp.SnmpObjectIdFormatException)8 Dialog (org.eclipse.jface.dialogs.Dialog)2 IParameterSelectionDialog (org.netxms.ui.eclipse.datacollection.dialogs.IParameterSelectionDialog)2 SelectAgentParamDlg (org.netxms.ui.eclipse.datacollection.dialogs.SelectAgentParamDlg)2 SelectParameterScriptDialog (org.netxms.ui.eclipse.datacollection.dialogs.SelectParameterScriptDialog)2 SelectSnmpParamDlg (org.netxms.ui.eclipse.datacollection.dialogs.SelectSnmpParamDlg)2 DCIPropertyPageDialog (org.netxms.ui.eclipse.datacollection.propertypages.helpers.DCIPropertyPageDialog)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 SelectionListener (org.eclipse.swt.events.SelectionListener)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 MibObject (org.netxms.client.snmp.MibObject)1 SnmpTrapParameterMapping (org.netxms.client.snmp.SnmpTrapParameterMapping)1 SnmpValue (org.netxms.client.snmp.SnmpValue)1 SelectInternalParamDlg (org.netxms.ui.eclipse.datacollection.dialogs.SelectInternalParamDlg)1