Skip to content

Commit

Permalink
kindling-174: Set default rendering for dates to an ISO-8601 format
Browse files Browse the repository at this point in the history
  • Loading branch information
paul-griffith committed Sep 18, 2024
1 parent 444f110 commit fcac215
Showing 1 changed file with 15 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import org.jdesktop.swingx.decorator.HighlightPredicate
import org.jdesktop.swingx.sort.SortController
import org.jdesktop.swingx.table.ColumnControlButton
import java.awt.Color
import java.text.SimpleDateFormat
import java.util.Date
import javax.swing.JComponent
import javax.swing.SortOrder
import javax.swing.UIManager
Expand Down Expand Up @@ -40,11 +42,6 @@ class ReifiedJXTable<T : TableModel>(
}
isColumnControlVisible = true

setDefaultRenderer<String>(
getText = { it },
getTooltip = { it },
)

setSortOrderCycle(SortOrder.ASCENDING, SortOrder.DESCENDING, SortOrder.UNSORTED)

// TODO header name as tooltip without breaking sorting
Expand All @@ -63,6 +60,19 @@ class ReifiedJXTable<T : TableModel>(
return ColumnControlButton(this, FlatSVGIcon("icons/bx-column.svg").derive(0.8F))
}

override fun createDefaultRenderers() {
super.createDefaultRenderers()

setDefaultRenderer<String>(
getText = { it },
getTooltip = { it },
)
val format = SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS")
setDefaultRenderer<Date>(
getText = { it?.let(format::format) },
)
}

@Suppress("UNCHECKED_CAST")
override fun getModel(): T = super.getModel() as T

Expand Down

0 comments on commit fcac215

Please sign in to comment.