Mercurial > cgi-bin > hgweb.cgi > JpegWasher
changeset 19:39b977021ea1
Tool tips in case key and type cols truncate.
author | David Barts <n5jrn@me.com> |
---|---|
date | Sat, 11 Apr 2020 16:12:59 -0700 |
parents | 841f711c40bd |
children | 965435b85a69 |
files | build.xml src/name/blackcap/exifwasher/Misc.kt src/name/blackcap/exifwasher/ShowDialog.kt src/name/blackcap/exifwasher/WashDialog.kt |
diffstat | 4 files changed, 27 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/build.xml Sat Apr 11 15:01:23 2020 -0700 +++ b/build.xml Sat Apr 11 16:12:59 2020 -0700 @@ -113,7 +113,7 @@ <fx:deploy nativeBundles="@{type}" outdir="${basedir}" outfile="${app.name}" signBundle="false"> <fx:application mainClass="${app.entry}" name="${app.name}" toolkit="swing" - version="1.01"/> + version="1.02"/> <fx:info description="ExifWasher" title="${app.name}" vendor="David Barts <n5jrn@me.com>" copyright="© MMXX, David W. Barts">
--- a/src/name/blackcap/exifwasher/Misc.kt Sat Apr 11 15:01:23 2020 -0700 +++ b/src/name/blackcap/exifwasher/Misc.kt Sat Apr 11 16:12:59 2020 -0700 @@ -9,7 +9,9 @@ import java.awt.Font import java.awt.FontMetrics import java.awt.Graphics +import java.awt.Point import java.awt.Toolkit +import java.awt.event.MouseEvent import javax.swing.* import javax.swing.table.TableColumnModel import kotlin.annotation.* @@ -193,3 +195,25 @@ } preferredSize = Dimension(total, preferredSize.height) } + +/** + * A JTable for displaying metadata. Columns that might get harmfully + * truncated have tooltips when truncation happens. + */ +class JExifTable(rowData: Array<Array<out Any?>>, colNames: Array<out Any?>): JTable(rowData, colNames) { + override fun getToolTipText(e: MouseEvent): String? { + val pos = e.point + val col = columnAtPoint(pos) + if (!setOf("Key", "Type").contains(getColumnName(col))) { + return null + } + val contents = getValueAt(rowAtPoint(pos), col) as String? + if (contents == null) { + return null + } + val needed = graphics.fontMetrics.stringWidth(contents) + val actual = columnModel.getColumn(col).width + return if (needed > actual) contents else null + } +} +
--- a/src/name/blackcap/exifwasher/ShowDialog.kt Sat Apr 11 15:01:23 2020 -0700 +++ b/src/name/blackcap/exifwasher/ShowDialog.kt Sat Apr 11 16:12:59 2020 -0700 @@ -26,7 +26,7 @@ private val HEIGHT = 480 private val COLUMN_NAMES = arrayOf<String>("Key", "Type", "Value") - private val myTable = JTable(arrayOf<Array<Any>>(), COLUMN_NAMES).apply { + private val myTable = JExifTable(arrayOf<Array<out Any?>>(), COLUMN_NAMES).apply { autoCreateRowSorter = false border = BorderFactory.createLineBorder(Color.GRAY) gridColor = Color.GRAY
--- a/src/name/blackcap/exifwasher/WashDialog.kt Sat Apr 11 15:01:23 2020 -0700 +++ b/src/name/blackcap/exifwasher/WashDialog.kt Sat Apr 11 16:12:59 2020 -0700 @@ -28,7 +28,7 @@ private val HEIGHT = 480 private val COLUMN_NAMES = arrayOf<String>("Delete?", "Key", "Type", "Value") - private val myTable = JTable(arrayOf<Array<Any>>(), COLUMN_NAMES).apply { + private val myTable = JExifTable(arrayOf<Array<out Any?>>(), COLUMN_NAMES).apply { autoCreateRowSorter = false border = BorderFactory.createLineBorder(Color.GRAY) gridColor = Color.GRAY