Skip to content

Commit

Permalink
feat: support sftp status (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
hstyi authored Feb 24, 2025
1 parent ef9caf2 commit 84b4827
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/main/kotlin/app/termora/transport/FileTransportPanel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,18 @@ class FileTransportPanel(
deleteAll.isEnabled = transportManager.getTransports().isNotEmpty()
}

popupMenu.addSeparator()

popupMenu.add(I18n.getString("termora.transport.jobs.table.status")).addActionListener {
val last = transports.last()
OptionPane.showMessageDialog(
SwingUtilities.getWindowAncestor(this),
if (last.state == TransportState.Failed && last.stateText.isNotBlank()) last.stateText
else tableModel.formatStatus(last.state),
messageType = if (last.state == TransportState.Failed) JOptionPane.ERROR_MESSAGE else JOptionPane.INFORMATION_MESSAGE
)
}

popupMenu.show(table, event.x, event.y)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class FileTransportTableModel(transportManager: TransportManager) : DefaultTable
}
}

private fun formatStatus(state: TransportState): String {
fun formatStatus(state: TransportState): String {
return when (state) {
TransportState.Transporting -> I18n.getString("termora.transport.sftp.status.transporting")
TransportState.Waiting -> I18n.getString("termora.transport.sftp.status.waiting")
Expand Down
4 changes: 4 additions & 0 deletions src/main/kotlin/app/termora/transport/Transport.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package app.termora.transport
import app.termora.Disposable
import org.apache.commons.io.IOUtils
import org.apache.commons.lang3.ObjectUtils
import org.apache.commons.lang3.StringUtils
import org.apache.commons.lang3.exception.ExceptionUtils
import org.apache.commons.net.io.CopyStreamEvent
import org.apache.commons.net.io.CopyStreamListener
import org.apache.commons.net.io.Util
Expand Down Expand Up @@ -47,6 +49,7 @@ abstract class Transport(
field = value
listeners.forEach { it.onTransportChanged(this) }
}
var stateText: String = StringUtils.EMPTY

// 0 - 1
var progress = 0.0
Expand Down Expand Up @@ -186,6 +189,7 @@ class FileTransport(
log.error(e.message, e)
}
state = TransportState.Failed
stateText = ExceptionUtils.getRootCauseMessage(e)
} finally {
counter.clear()
}
Expand Down

0 comments on commit 84b4827

Please sign in to comment.