Skip to content

Commit 4e492c0

Browse files
committed
Show a warning indicating 8.3 gwbks are not correctly processed
1 parent 7775ff0 commit 4e492c0

File tree

1 file changed

+19
-1
lines changed
  • src/main/kotlin/io/github/inductiveautomation/kindling/zip/views/gwbk

1 file changed

+19
-1
lines changed

src/main/kotlin/io/github/inductiveautomation/kindling/zip/views/gwbk/GwbkStatsView.kt

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.github.inductiveautomation.kindling.zip.views.gwbk
22

33
import com.formdev.flatlaf.extras.FlatSVGIcon
4+
import io.github.inductiveautomation.kindling.MainPanel
45
import io.github.inductiveautomation.kindling.statistics.GatewayBackup
56
import io.github.inductiveautomation.kindling.statistics.Statistic
67
import io.github.inductiveautomation.kindling.statistics.StatisticCalculator
@@ -27,6 +28,7 @@ import javax.swing.JPopupMenu
2728
import javax.swing.SwingConstants
2829
import javax.swing.UIManager
2930
import javax.swing.border.LineBorder
31+
import kotlin.io.path.exists
3032
import kotlin.io.path.extension
3133

3234
class GwbkStatsView(
@@ -42,6 +44,9 @@ class GwbkStatsView(
4244
private val gatewayBackup = GatewayBackup(path)
4345

4446
init {
47+
if (gatewayBackup.configDirectory.exists()) {
48+
add(eightThreeWarning(), "wrap")
49+
}
4550
add(MetaStatistics.Calculator renderedWith MetaStatisticsRenderer(), "growx, wrap")
4651
add(ProjectStatistics.Calculator renderedWith ProjectStatisticsRenderer(), "growx, sg")
4752
add(DatabaseStatistics.Calculator renderedWith DatabaseStatisticsRenderer(), "growx, sg")
@@ -64,7 +69,12 @@ class GwbkStatsView(
6469
add(throbber, "push, grow, span")
6570

6671
BACKGROUND.launch {
67-
val statistic = calculate(gatewayBackup)
72+
val statistic: T? = try {
73+
calculate(gatewayBackup)
74+
} catch (e: Exception) {
75+
MainPanel.LOGGER.error("Error calculating statistic", e)
76+
null
77+
}
6878
EDT_SCOPE.launch {
6979
if (statistic == null) {
7080
this@GwbkStatsView.remove(this@apply)
@@ -84,6 +94,14 @@ class GwbkStatsView(
8494
}
8595
}
8696

97+
private fun eightThreeWarning(): JLabel = JLabel(
98+
"8.3 Backups are not yet processed correctly",
99+
FlatSVGIcon("icons/bx-error.svg"),
100+
SwingConstants.CENTER,
101+
).apply {
102+
putClientProperty("FlatLaf.styleClass", "h2")
103+
}
104+
87105
companion object {
88106
private val BACKGROUND = CoroutineScope(SupervisorJob() + Dispatchers.IO)
89107

0 commit comments

Comments
 (0)