Search in sources :

Example 1 with DBTTaskRun

use of org.jkiss.dbeaver.model.task.DBTTaskRun in project dbeaver by serge-rider.

the class RecentTasksMenuContributor method fillContributionItems.

@Override
protected void fillContributionItems(final List<IContributionItem> menuItems) {
    DBPProject project = NavigatorUtils.getSelectedProject();
    if (project == null) {
        return;
    }
    DBTTask[] tasks = project.getTaskManager().getAllTasks();
    Arrays.sort(tasks, (o1, o2) -> {
        DBTTaskRun lr1 = o1.getLastRun();
        DBTTaskRun lr2 = o1.getLastRun();
        if (lr1 == lr2)
            return o1.getCreateTime().compareTo(o2.getCreateTime());
        else if (lr1 == null)
            return -1;
        else if (lr2 == null)
            return 1;
        else
            return lr1.getStartTime().compareTo(lr2.getStartTime());
    });
    for (int i = 0; i < tasks.length && i <= MAX_ITEMS; i++) {
        DBTTask task = tasks[i];
        DBPImage taskIcon = task.getType().getIcon();
        if (taskIcon == null)
            taskIcon = DBIcon.TREE_TASK;
        menuItems.add(ActionUtils.makeActionContribution(new Action(task.getName(), DBeaverIcons.getImageDescriptor(taskIcon)) {

            @Override
            public void run() {
                TaskHandlerRun.runTask(task);
            }
        }, false));
    }
}
Also used : DBTTaskRun(org.jkiss.dbeaver.model.task.DBTTaskRun) Action(org.eclipse.jface.action.Action) DBTTask(org.jkiss.dbeaver.model.task.DBTTask) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) DBPImage(org.jkiss.dbeaver.model.DBPImage)

Example 2 with DBTTaskRun

use of org.jkiss.dbeaver.model.task.DBTTaskRun in project dbeaver by dbeaver.

the class RecentTasksMenuContributor method fillContributionItems.

@Override
protected void fillContributionItems(final List<IContributionItem> menuItems) {
    DBPProject project = NavigatorUtils.getSelectedProject();
    if (project == null) {
        return;
    }
    DBTTask[] tasks = project.getTaskManager().getAllTasks();
    Arrays.sort(tasks, (o1, o2) -> {
        DBTTaskRun lr1 = o1.getLastRun();
        DBTTaskRun lr2 = o1.getLastRun();
        if (lr1 == lr2)
            return o1.getCreateTime().compareTo(o2.getCreateTime());
        else if (lr1 == null)
            return -1;
        else if (lr2 == null)
            return 1;
        else
            return lr1.getStartTime().compareTo(lr2.getStartTime());
    });
    for (int i = 0; i < tasks.length && i <= MAX_ITEMS; i++) {
        DBTTask task = tasks[i];
        DBPImage taskIcon = task.getType().getIcon();
        if (taskIcon == null)
            taskIcon = DBIcon.TREE_TASK;
        menuItems.add(ActionUtils.makeActionContribution(new Action(task.getName(), DBeaverIcons.getImageDescriptor(taskIcon)) {

            @Override
            public void run() {
                TaskHandlerRun.runTask(task);
            }
        }, false));
    }
}
Also used : DBTTaskRun(org.jkiss.dbeaver.model.task.DBTTaskRun) Action(org.eclipse.jface.action.Action) DBTTask(org.jkiss.dbeaver.model.task.DBTTask) DBPProject(org.jkiss.dbeaver.model.app.DBPProject) DBPImage(org.jkiss.dbeaver.model.DBPImage)

Aggregations

Action (org.eclipse.jface.action.Action)2 DBPImage (org.jkiss.dbeaver.model.DBPImage)2 DBPProject (org.jkiss.dbeaver.model.app.DBPProject)2 DBTTask (org.jkiss.dbeaver.model.task.DBTTask)2 DBTTaskRun (org.jkiss.dbeaver.model.task.DBTTaskRun)2