Search in sources :

Example 1 with TaskSeverity

use of eu.esdihumboldt.hale.common.tasks.TaskType.TaskSeverity in project hale by halestudio.

the class TaskDescriptionLabelProvider method getNodeLevel.

/**
 * Get the given node's severity level
 *
 * @param node the node
 *
 * @return the severity level or <code>null</code>
 */
private TaskSeverity getNodeLevel(MapTreeNode<?, ?> node) {
    TaskSeverity level = null;
    TreeNode[] children = node.getChildren();
    for (TreeNode child : children) {
        if (child instanceof DefaultTreeNode) {
            // child is task node
            DefaultTreeNode childNode = (DefaultTreeNode) child;
            Object tmp = childNode.getValue();
            // get value
            Object value;
            if (tmp.getClass().isArray()) {
                value = ((Object[]) tmp)[index];
            } else {
                value = tmp;
            }
            // determine level
            if (value instanceof ResolvedTask) {
                ResolvedTask<?> task = (ResolvedTask<?>) value;
                if (task.isOpen()) {
                    // only inspect open tasks
                    level = TaskSeverity.max(level, task.getSeverityLevel());
                }
            }
        } else if (child instanceof MapTreeNode<?, ?>) {
            // child is map node
            MapTreeNode<?, ?> childNode = (MapTreeNode<?, ?>) child;
            TaskSeverity childLevel = getNodeLevel(childNode);
            level = TaskSeverity.max(level, childLevel);
        }
    }
    return level;
}
Also used : TaskSeverity(eu.esdihumboldt.hale.common.tasks.TaskType.TaskSeverity) TreeNode(org.eclipse.jface.viewers.TreeNode) MapTreeNode(eu.esdihumboldt.hale.ui.util.tree.MapTreeNode) DefaultTreeNode(eu.esdihumboldt.hale.ui.util.tree.DefaultTreeNode) DefaultTreeNode(eu.esdihumboldt.hale.ui.util.tree.DefaultTreeNode) ResolvedTask(eu.esdihumboldt.hale.common.tasks.ResolvedTask) MapTreeNode(eu.esdihumboldt.hale.ui.util.tree.MapTreeNode)

Aggregations

ResolvedTask (eu.esdihumboldt.hale.common.tasks.ResolvedTask)1 TaskSeverity (eu.esdihumboldt.hale.common.tasks.TaskType.TaskSeverity)1 DefaultTreeNode (eu.esdihumboldt.hale.ui.util.tree.DefaultTreeNode)1 MapTreeNode (eu.esdihumboldt.hale.ui.util.tree.MapTreeNode)1 TreeNode (org.eclipse.jface.viewers.TreeNode)1