Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set default rendering for dates to an ISO-8601 format #195

Merged
merged 1 commit into from
Sep 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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