show tooltips on some download states

java-i2p-warning
Zlatin Balevsky 2022-08-29 09:22:35 +01:00
parent 0a87cb182b
commit d19bff6ab2
No known key found for this signature in database
GPG Key ID: A72832072D525E41
3 changed files with 49 additions and 1 deletions

View File

@ -808,6 +808,10 @@ TOOLTIP_DOWNLOAD_PAUSE=Pause the selected downloads
TOOLTIP_DOWNLOAD_CANCEL=Cancel the selected downloads
TOOLTIP_DOWNLOAD_PREVIEW=Preview the selected downloads
TOOLTIP_DOWNLOAD_CLEAR_DONE=Remove finished and failed downloads from list
TOOLTIP_DOWNLOAD_STATE_HASHLIST=Fetching hash list, download will start shortly
TOOLTIP_DOWNLOAD_STATE_FAILED=Download failed, MuWire will retry
TOOLTIP_DOWNLOAD_STATE_REJECTED=Slot limit on the uploader reached, MuWIre will retry
TOOLTIP_DOWNLOAD_STATE_HOPELESS=Download cannot complete, MuWire will not retry
### Tooltips for the Library tab
TOOLTIP_LIBRARY_TREE=View your shared files as a tree

View File

@ -285,7 +285,7 @@ class MainFrameView {
downloadsTable = table(id : "downloads-table", autoCreateRowSorter : true, rowHeight : rowHeight) {
tableModel(list: model.downloads) {
closureColumn(header: trans("NAME"), preferredWidth: 300, type: String, read : {row -> HTMLSanitizer.sanitize(row.downloader.file.getName())})
closureColumn(header: trans("STATUS"), preferredWidth: 50, type: String, read : {row -> trans(row.downloader.getCurrentState().name())})
closureColumn(header: trans("STATUS"), preferredWidth: 50, type: Downloader.DownloadState, read : { row -> row.downloader.getCurrentState()})
closureColumn(header: trans("PROGRESS"), preferredWidth: 70, type: Downloader, read: { row -> row.downloader })
closureColumn(header: trans("SPEED"), preferredWidth: 50, type:String, read :{row ->
formatSize(row.downloader.speed(),"B_SEC")
@ -1003,6 +1003,7 @@ class MainFrameView {
centerRenderer.setHorizontalAlignment(JLabel.CENTER)
downloadsTable.setDefaultRenderer(Integer.class, centerRenderer)
downloadsTable.setDefaultRenderer(Downloader.class, new DownloadProgressRenderer())
downloadsTable.setDefaultRenderer(Downloader.DownloadState.class, new DownloadStateRenderer())
downloadsTable.rowSorter.addRowSorterListener({ evt -> lastDownloadSortEvent = evt })
downloadsTable.rowSorter.setSortsOnUpdates(true)

View File

@ -0,0 +1,43 @@
package com.muwire.gui
import com.muwire.core.download.Downloader
import javax.swing.JComponent
import javax.swing.JTable
import javax.swing.table.DefaultTableCellRenderer
import static com.muwire.gui.Translator.trans
class DownloadStateRenderer extends DefaultTableCellRenderer {
@Override
JComponent getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column)
if (value == null)
return this //TODO investigate
Downloader.DownloadState state = (Downloader.DownloadState) value
setText(trans(state.name()))
String tooltipKey = null
switch(state) {
case Downloader.DownloadState.HASHLIST : tooltipKey = "TOOLTIP_DOWNLOAD_STATE_HASHLIST"; break
case Downloader.DownloadState.FAILED : tooltipKey = "TOOLTIP_DOWNLOAD_STATE_FAILED"; break
case Downloader.DownloadState.REJECTED : tooltipKey = "TOOLTIP_DOWNLOAD_STATE_REJECTED"; break
case Downloader.DownloadState.HOPELESS : tooltipKey = "TOOLTIP_DOWNLOAD_STATE_HOPELESS"; break
}
if (tooltipKey != null)
setToolTipText(trans(tooltipKey))
if (isSelected) {
setForeground(table.getSelectionForeground())
setBackground(table.getSelectionBackground())
} else {
setForeground(table.getForeground())
setBackground(table.getBackground())
}
this
}
}