Search in sources :

Example 1 with TrapConfigurationDialog

use of org.netxms.ui.eclipse.snmp.dialogs.TrapConfigurationDialog in project netxms by netxms.

the class SnmpTrapEditor method editTrap.

/**
 * Edit selected trap
 */
protected void editTrap() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() != 1)
        return;
    final SnmpTrap trap = (SnmpTrap) selection.getFirstElement();
    TrapConfigurationDialog dlg = new TrapConfigurationDialog(getViewSite().getShell(), trap);
    if (dlg.open() == Window.OK) {
        new ConsoleJob(Messages.get().SnmpTrapEditor_ModifyJob_Title, this, Activator.PLUGIN_ID, null) {

            @Override
            protected String getErrorMessage() {
                return Messages.get().SnmpTrapEditor_ModifyJob_Error;
            }

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                session.modifySnmpTrapConfiguration(trap);
            }
        }.start();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TrapConfigurationDialog(org.netxms.ui.eclipse.snmp.dialogs.TrapConfigurationDialog) SnmpTrap(org.netxms.client.snmp.SnmpTrap) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Example 2 with TrapConfigurationDialog

use of org.netxms.ui.eclipse.snmp.dialogs.TrapConfigurationDialog in project netxms by netxms.

the class SnmpTrapEditor method createTrap.

/**
 * Create new trap
 */
protected void createTrap() {
    final SnmpTrap trap = new SnmpTrap();
    // SYS_UNMATCHED_SNMP_TRAP
    trap.setEventCode(500);
    TrapConfigurationDialog dlg = new TrapConfigurationDialog(getViewSite().getShell(), trap);
    if (dlg.open() == Window.OK) {
        new ConsoleJob(Messages.get().SnmpTrapEditor_CreateJob_Title, this, Activator.PLUGIN_ID, null) {

            @Override
            protected String getErrorMessage() {
                return Messages.get().SnmpTrapEditor_CreateJob_Error;
            }

            @Override
            protected void runInternal(IProgressMonitor monitor) throws Exception {
                trap.setId(session.createSnmpTrapConfiguration());
                session.modifySnmpTrapConfiguration(trap);
            }
        }.start();
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) TrapConfigurationDialog(org.netxms.ui.eclipse.snmp.dialogs.TrapConfigurationDialog) SnmpTrap(org.netxms.client.snmp.SnmpTrap) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 SnmpTrap (org.netxms.client.snmp.SnmpTrap)2 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)2 TrapConfigurationDialog (org.netxms.ui.eclipse.snmp.dialogs.TrapConfigurationDialog)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1