Search in sources :

Example 1 with RerunTimeDialog

use of org.netxms.ui.eclipse.serverconfig.dialogs.RerunTimeDialog in project netxms by netxms.

the class ScheduledTaskView method rescheduleTask.

/**
 * Reschedule task
 */
protected void rescheduleTask() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() != 1)
        return;
    final ScheduledTask origin = (ScheduledTask) selection.toList().get(0);
    final RerunTimeDialog dialog = new RerunTimeDialog(getSite().getShell(), origin.getExecutionTime());
    if (dialog.open() != Window.OK)
        return;
    new ConsoleJob("Reschedule task", null, Activator.PLUGIN_ID, null) {

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            origin.setExecutionTime(dialog.getRerunDate());
            origin.setFlags(origin.getFlags() & ~ScheduledTask.EXECUTED);
            session.updateSchedule(origin);
        }

        @Override
        protected String getErrorMessage() {
            return "Cannot reschedule tasks";
        }
    }.start();
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) RerunTimeDialog(org.netxms.ui.eclipse.serverconfig.dialogs.RerunTimeDialog) ScheduledTask(org.netxms.client.ScheduledTask) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) ConsoleJob(org.netxms.ui.eclipse.jobs.ConsoleJob) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 PartInitException (org.eclipse.ui.PartInitException)1 ScheduledTask (org.netxms.client.ScheduledTask)1 ConsoleJob (org.netxms.ui.eclipse.jobs.ConsoleJob)1 RerunTimeDialog (org.netxms.ui.eclipse.serverconfig.dialogs.RerunTimeDialog)1