Search in sources :

Example 1 with AlarmStateChangeFailureDialog

use of org.netxms.ui.eclipse.alarmviewer.dialogs.AlarmStateChangeFailureDialog in project netxms by netxms.

the class AlarmList method terminateAlarms.

/**
 * Terminate selected alarms
 */
private void terminateAlarms() {
    IStructuredSelection selection = (IStructuredSelection) alarmViewer.getSelection();
    if (selection.isEmpty())
        return;
    final List<Long> alarmIds = new ArrayList<Long>(selection.size());
    for (Object o : selection.toList()) alarmIds.add(((Alarm) o).getId());
    new ConsoleJob(Messages.get().TerminateAlarm_JobTitle, viewPart, Activator.PLUGIN_ID, AlarmList.JOB_FAMILY) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final Map<Long, Integer> terminationFails = session.bulkTerminateAlarms(alarmIds);
            if (!terminationFails.isEmpty()) {
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        AlarmStateChangeFailureDialog dlg = new AlarmStateChangeFailureDialog(viewPart.getSite().getShell(), terminationFails);
                        if (dlg.open() == Window.OK) {
                            return;
                        }
                    }
                });
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().TerminateAlarm_ErrorMessage;
        }
    }.start();
}
Also used : ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException) AlarmStateChangeFailureDialog(org.netxms.ui.eclipse.alarmviewer.dialogs.AlarmStateChangeFailureDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Alarm(org.netxms.client.events.Alarm) AbstractObject(org.netxms.client.objects.AbstractObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Map(java.util.Map) HashMap(java.util.HashMap)

Example 2 with AlarmStateChangeFailureDialog

use of org.netxms.ui.eclipse.alarmviewer.dialogs.AlarmStateChangeFailureDialog in project netxms by netxms.

the class AlarmList method resolveAlarms.

/**
 * Resolve selected alarms
 */
private void resolveAlarms() {
    IStructuredSelection selection = (IStructuredSelection) alarmViewer.getSelection();
    if (selection.isEmpty())
        return;
    final List<Long> alarmIds = new ArrayList<Long>(selection.size());
    for (Object o : selection.toList()) alarmIds.add(((Alarm) o).getId());
    new ConsoleJob(Messages.get().AlarmList_Resolving, viewPart, Activator.PLUGIN_ID, AlarmList.JOB_FAMILY) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final Map<Long, Integer> resolveFails = session.bulkResolveAlarms(alarmIds);
            if (!resolveFails.isEmpty()) {
                runInUIThread(new Runnable() {

                    @Override
                    public void run() {
                        AlarmStateChangeFailureDialog dlg = new AlarmStateChangeFailureDialog(viewPart.getSite().getShell(), resolveFails);
                        if (dlg.open() == Window.OK) {
                            return;
                        }
                    }
                });
            }
        }

        @Override
        protected String getErrorMessage() {
            return Messages.get().AlarmList_CannotResoveAlarm;
        }
    }.start();
}
Also used : ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) PartInitException(org.eclipse.ui.PartInitException) AlarmStateChangeFailureDialog(org.netxms.ui.eclipse.alarmviewer.dialogs.AlarmStateChangeFailureDialog) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Alarm(org.netxms.client.events.Alarm) AbstractObject(org.netxms.client.objects.AbstractObject) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 PartInitException (org.eclipse.ui.PartInitException)2 Alarm (org.netxms.client.events.Alarm)2 AbstractObject (org.netxms.client.objects.AbstractObject)2 AlarmStateChangeFailureDialog (org.netxms.ui.eclipse.alarmviewer.dialogs.AlarmStateChangeFailureDialog)2 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)2