Search in sources :

Example 1 with ScheduledTaskEditor

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

the class ScheduledTaskView method editTask.

/**
 * Edit selected task
 */
protected void editTask() {
    IStructuredSelection selection = (IStructuredSelection) viewer.getSelection();
    if (selection.size() != 1)
        return;
    final ScheduledTask origin = (ScheduledTask) selection.toList().get(0);
    new ConsoleJob("Update scheduled task", null, Activator.PLUGIN_ID, null) {

        private ScheduledTask task = null;

        @Override
        protected void runInternal(IProgressMonitor monitor) throws Exception {
            final List<String> taskList = session.listScheduleCallbacks();
            getDisplay().syncExec(new Runnable() {

                @Override
                public void run() {
                    ScheduledTaskEditor dialog = new ScheduledTaskEditor(getSite().getShell(), origin, taskList);
                    if (dialog.open() == Window.OK) {
                        task = dialog.getScheduledTask();
                    }
                }
            });
            if (task != null)
                session.updateSchedule(task);
        }

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

Aggregations

ArrayList (java.util.ArrayList)1 List (java.util.List)1 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 ScheduledTaskEditor (org.netxms.ui.eclipse.serverconfig.dialogs.ScheduledTaskEditor)1