Search in sources :

Example 1 with WrappedTask

use of net.sf.mzmine.taskcontrol.impl.WrappedTask in project mzmine2 by mzmine.

the class TaskProgressTable method actionPerformed.

/**
 * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
 */
public void actionPerformed(ActionEvent event) {
    TaskControllerImpl taskController = (TaskControllerImpl) MZmineCore.getTaskController();
    WrappedTask[] currentQueue = taskController.getTaskQueue().getQueueSnapshot();
    Task selectedTask = null;
    int selectedRow = taskTable.getSelectedRow();
    if ((selectedRow < currentQueue.length) && (selectedRow >= 0))
        selectedTask = currentQueue[selectedRow].getActualTask();
    Object src = event.getSource();
    if (src == cancelTaskMenuItem) {
        if (selectedTask == null)
            return;
        TaskStatus status = selectedTask.getStatus();
        if ((status == TaskStatus.WAITING) || (status == TaskStatus.PROCESSING)) {
            selectedTask.cancel();
        }
    }
    if (src == cancelAllMenuItem) {
        for (WrappedTask wrappedTask : currentQueue) {
            Task task = wrappedTask.getActualTask();
            TaskStatus status = task.getStatus();
            if ((status == TaskStatus.WAITING) || (status == TaskStatus.PROCESSING)) {
                task.cancel();
            }
        }
    }
    if (src == highPriorityMenuItem) {
        if (selectedTask == null)
            return;
        taskController.setTaskPriority(selectedTask, TaskPriority.HIGH);
    }
    if (src == normalPriorityMenuItem) {
        if (selectedTask == null)
            return;
        taskController.setTaskPriority(selectedTask, TaskPriority.NORMAL);
    }
}
Also used : WrappedTask(net.sf.mzmine.taskcontrol.impl.WrappedTask) Task(net.sf.mzmine.taskcontrol.Task) WrappedTask(net.sf.mzmine.taskcontrol.impl.WrappedTask) TaskStatus(net.sf.mzmine.taskcontrol.TaskStatus) TaskControllerImpl(net.sf.mzmine.taskcontrol.impl.TaskControllerImpl)

Aggregations

Task (net.sf.mzmine.taskcontrol.Task)1 TaskStatus (net.sf.mzmine.taskcontrol.TaskStatus)1 TaskControllerImpl (net.sf.mzmine.taskcontrol.impl.TaskControllerImpl)1 WrappedTask (net.sf.mzmine.taskcontrol.impl.WrappedTask)1