Commit 41149f26 authored by Jens Korinth's avatar Jens Korinth
Browse files

Show result of tasks in task panel

* added bool field "Successful"
* added color highlights for successful and failed, too
parent 023033c4
...@@ -26,7 +26,8 @@ class QueuePanel( ...@@ -26,7 +26,8 @@ class QueuePanel(
t.description, t.description,
t.queued map (_dateFormat.format(_)) getOrElse "", t.queued map (_dateFormat.format(_)) getOrElse "",
t.started map (_dateFormat.format(_)) getOrElse "", t.started map (_dateFormat.format(_)) getOrElse "",
t.completed map (_dateFormat.format(_)) getOrElse "" t.completed map (_dateFormat.format(_)) getOrElse "",
t.result
) )
private def tasksToTable(tasks: Seq[Task]): Array[Array[Any]] = private def tasksToTable(tasks: Seq[Task]): Array[Array[Any]] =
...@@ -34,7 +35,7 @@ class QueuePanel( ...@@ -34,7 +35,7 @@ class QueuePanel(
private def mkTable(tasks: Seq[Task]): Table = new Table( private def mkTable(tasks: Seq[Task]): Table = new Table(
tasksToTable(tasks), tasksToTable(tasks),
Seq("Task", "Queued at", "Started at", "Completed at") Seq("Task", "Queued at", "Started at", "Completed at", "Successful")
) { ) {
selection.elementMode = scala.swing.Table.ElementMode.Row selection.elementMode = scala.swing.Table.ElementMode.Row
val m = model val m = model
...@@ -46,6 +47,24 @@ class QueuePanel( ...@@ -46,6 +47,24 @@ class QueuePanel(
override def getColumnName(col: Int): String = m.getColumnName(col) override def getColumnName(col: Int): String = m.getColumnName(col)
} }
// highlight unsuccessful rows
import javax.swing.table._, javax.swing._
private final val cr = new DefaultTableCellRenderer {
override def getTableCellRendererComponent(table: JTable, value: Any, isSelected: Boolean, hasFocus: Boolean,
row: Int, col: Int): JComponent = {
val r = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, col)
if (tasks(row).completed.nonEmpty) {
if (!tasks(row).result) {
setBackground(DefaultColors.toSeq(3))
} else {
setBackground(DefaultColors.toSeq(2))
}
}
this
}
}
peer.setDefaultRenderer(classOf[Object], cr)
// auto-resize columns // auto-resize columns
val cols = 0 until peer.getColumnCount() map { i => (i, peer.getColumnModel().getColumn(i)) } val cols = 0 until peer.getColumnCount() map { i => (i, peer.getColumnModel().getColumn(i)) }
cols foreach { case (cidx, col) => col.setPreferredWidth(if (cidx == 0) 800 else 150) } cols foreach { case (cidx, col) => col.setPreferredWidth(if (cidx == 0) 800 else 150) }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment