Skip to content

Commit 086875a

Browse files
authored
Merge pull request #352 from alyssaruth/show-error
Remove deprecated showError
2 parents 4f3b0b8 + 40599ce commit 086875a

86 files changed

Lines changed: 581 additions & 671 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎src/main/kotlin/dartzee/bean/AbstractDartzeeRuleSelector.kt‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ abstract class AbstractDartzeeRuleSelector<BaseRuleType : AbstractDartzeeRule>(v
5252

5353
fun getSelection() = comboBoxRuleType.selectedItemTyped()
5454

55-
fun setSelected(selected: Boolean) {
56-
cbDesc.isSelected = selected
57-
}
58-
5955
open fun populate(rule: BaseRuleType?) {
6056
if (rule != null) {
6157
val item = comboBoxRuleType.findByConcreteClass(rule.javaClass)!!
@@ -72,7 +68,7 @@ abstract class AbstractDartzeeRuleSelector<BaseRuleType : AbstractDartzeeRule>(v
7268
fun valid(): Boolean {
7369
val errorStr = getSelection().validate()
7470
if (errorStr.isNotEmpty()) {
75-
DialogUtil.showErrorOLD("$desc: $errorStr")
71+
DialogUtil.showError("$desc: $errorStr")
7672
return false
7773
}
7874

‎src/main/kotlin/dartzee/bean/ScrollTableDartsGame.kt‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@ class ScrollTableDartsGame(linkColumnName: String = "Game", testId: String = "")
1313
val gameId = GameEntity.getGameId(localId)
1414
gameId?.let { gameLauncher.loadAndDisplayGame(gameId) }
1515
} else {
16-
DialogUtil.showErrorOLD(
17-
"It isn't possible to display individual games from a simulation."
18-
)
16+
DialogUtil.showError("It isn't possible to display individual games from a simulation.")
1917
}
2018
}
2119

‎src/main/kotlin/dartzee/core/bean/DateFilterPanel.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package dartzee.core.bean
22

33
import com.github.lgooddatepicker.components.DatePicker
44
import com.github.lgooddatepicker.components.DatePickerSettings
5-
import dartzee.core.util.DialogUtil.showErrorOLD
5+
import dartzee.core.util.DialogUtil.showError
66
import java.sql.Timestamp
77
import java.text.SimpleDateFormat
88
import javax.swing.JLabel
@@ -32,7 +32,7 @@ class DateFilterPanel : JPanel() {
3232
}
3333

3434
if (getDtFrom().isAfter(getDtTo())) {
35-
showErrorOLD("The 'date from' cannot be after the 'date to'")
35+
showError("The 'date from' cannot be after the 'date to'")
3636
return false
3737
}
3838

‎src/main/kotlin/dartzee/core/util/DialogUtil.kt‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,6 @@ object DialogUtil {
3939
logDialogClosed("CustomError", null)
4040
}
4141

42-
@Deprecated("Use showError")
43-
fun showErrorOLD(errorText: String) {
44-
logDialogShown("Error", "Error", errorText)
45-
dialogFactory.showError(errorText)
46-
logDialogClosed("Error", null)
47-
}
48-
4942
fun showError(errorText: String, parent: Component? = ScreenCache.mainScreen) {
5043
dismissLoadingDialog()
5144

‎src/main/kotlin/dartzee/core/util/IMessageDialogFactory.kt‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@ import java.awt.Component
44
import java.io.File
55

66
interface IMessageDialogFactory {
7-
fun showError(text: String)
8-
97
fun showOption(title: String, message: String, options: List<String>): String?
108

119
fun <K> showInput(title: String, message: String, options: Array<K>?, defaultOption: K?): K?

‎src/main/kotlin/dartzee/core/util/MessageDialogFactory.kt‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,6 @@ class MessageDialogFactory : IMessageDialogFactory {
2323
defaultOption,
2424
) as K?
2525

26-
override fun showError(text: String) {
27-
JOptionPane.showMessageDialog(null, text, "Error", JOptionPane.ERROR_MESSAGE)
28-
}
29-
3026
override fun showOption(title: String, message: String, options: List<String>): String? {
3127
val typedArray = options.toTypedArray()
3228
val selection =

‎src/main/kotlin/dartzee/db/sanity/AbstractSanityCheckFinalScore.kt‎

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
package dartzee.db.sanity
22

3+
import dartzee.core.util.TableUtil.DefaultModel
34
import dartzee.db.ParticipantEntity
45
import dartzee.game.GameType
56
import dartzee.utils.InjectedThings.mainDatabase
7+
import javax.swing.table.DefaultTableModel
68

79
abstract class AbstractSanityCheckFinalScore : ISanityCheck {
810
abstract val gameType: GameType
911

1012
abstract fun populateParticipantToFinalScoreTable(tempTable: String)
1113

12-
override fun runCheck(): List<AbstractSanityCheckResult> {
14+
override fun runCheck(): List<SanityCheckResult> {
1315
val tempTable =
1416
mainDatabase.createTempTable(
1517
"ParticipantToFinalScore_$gameType",
@@ -40,9 +42,49 @@ abstract class AbstractSanityCheckFinalScore : ISanityCheck {
4042

4143
// Add the sanity error
4244
if (hmParticipantToActualCount.isNotEmpty()) {
43-
return listOf(SanityCheckResultFinalScoreMismatch(gameType, hmParticipantToActualCount))
45+
return listOf(
46+
SanityCheckResultFinalScoreMismatch(
47+
gameType,
48+
buildResultsModel(hmParticipantToActualCount),
49+
)
50+
)
4451
}
4552

4653
return listOf()
4754
}
55+
56+
private fun buildResultsModel(
57+
hmParticipantToActualCount: Map<ParticipantEntity, Int>
58+
): DefaultTableModel {
59+
val model = DefaultModel()
60+
model.addColumn("ParticipantId")
61+
model.addColumn("PlayerId")
62+
model.addColumn("GameId")
63+
model.addColumn("DtLastUpdate")
64+
model.addColumn("FinalScore")
65+
model.addColumn("FinalScoreRAW")
66+
67+
val pts = hmParticipantToActualCount.keys
68+
for (pt in pts) {
69+
val participantId = pt.rowId
70+
val playerId = pt.playerId
71+
val gameId = pt.gameId
72+
val dtLastUpdate = pt.dtLastUpdate
73+
val finalScore = pt.finalScore
74+
val finalScoreRaw = hmParticipantToActualCount.getValue(pt)
75+
76+
val row =
77+
arrayOf<Any>(
78+
participantId,
79+
playerId,
80+
gameId,
81+
dtLastUpdate,
82+
finalScore,
83+
finalScoreRaw,
84+
)
85+
model.addRow(row)
86+
}
87+
88+
return model
89+
}
4890
}

‎src/main/kotlin/dartzee/db/sanity/DatabaseSanityCheck.kt‎

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ object DatabaseSanityCheck {
6262
val dlg = ProgressDialog.factory("Running Sanity Check", "checks remaining", checks.size)
6363
dlg.setVisibleLater()
6464

65-
val sanityErrors = mutableListOf<AbstractSanityCheckResult>()
65+
val sanityErrors = mutableListOf<SanityCheckResult>()
6666

6767
try {
6868
checks.forEach { check ->
@@ -79,7 +79,7 @@ object DatabaseSanityCheck {
7979
runOnEventThread { sanityCheckComplete(sanityErrors) }
8080
}
8181

82-
private fun sanityCheckComplete(sanityErrors: List<AbstractSanityCheckResult>) {
82+
private fun sanityCheckComplete(sanityErrors: List<SanityCheckResult>) {
8383
logger.info(
8484
CODE_SANITY_CHECK_COMPLETED,
8585
"Completed sanity check and found ${sanityErrors.size} issues",
@@ -88,8 +88,8 @@ object DatabaseSanityCheck {
8888
sanityErrors.forEach { error ->
8989
logger.info(
9090
CODE_SANITY_CHECK_RESULT,
91-
"${error.getCount()} ${error.getDescription()}",
92-
KEY_SANITY_DESCRIPTION to error.getDescription(),
91+
"${error.getCount()} ${error.description}",
92+
KEY_SANITY_DESCRIPTION to error.description,
9393
KEY_SANITY_COUNT to error.getCount(),
9494
)
9595
}
@@ -129,9 +129,7 @@ object DatabaseSanityCheck {
129129
}
130130
}
131131

132-
private fun buildResultsModel(
133-
sanityErrors: List<AbstractSanityCheckResult>
134-
): DefaultTableModel {
132+
private fun buildResultsModel(sanityErrors: List<SanityCheckResult>): DefaultTableModel {
135133
val model = DefaultModel()
136134
model.addColumn("Description")
137135
model.addColumn("Count")
@@ -140,19 +138,14 @@ object DatabaseSanityCheck {
140138

141139
for (result in sanityErrors) {
142140
val row =
143-
arrayOf<Any>(
144-
result.getDescription(),
145-
result.getCount(),
146-
"View Results >",
147-
"Auto-fix",
148-
)
141+
arrayOf<Any>(result.description, result.getCount(), "View Results >", "Auto-fix")
149142
model.addRow(row)
150143
}
151144

152145
return model
153146
}
154147

155-
private fun showResultsBreakdown(result: AbstractSanityCheckResult) {
148+
private fun showResultsBreakdown(result: SanityCheckResult) {
156149
val dlg = result.getResultsDialog()
157150
dlg.setSize(800, 600)
158151
dlg.setLocationRelativeTo(ScreenCache.mainScreen)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
package dartzee.db.sanity
22

33
interface ISanityCheck {
4-
fun runCheck(): List<AbstractSanityCheckResult>
4+
fun runCheck(): List<SanityCheckResult>
55
}

‎src/main/kotlin/dartzee/db/sanity/SanityCheckColumnsThatAllowDefaults.kt‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package dartzee.db.sanity
33
import dartzee.core.util.TableUtil
44

55
class SanityCheckColumnsThatAllowDefaults : ISanityCheck {
6-
override fun runCheck(): List<AbstractSanityCheckResult> {
6+
override fun runCheck(): List<SanityCheckResult> {
77
val model = TableUtil.DefaultModel()
88
model.addColumn("TableName")
99
model.addColumn("ColumnName")
@@ -12,7 +12,7 @@ class SanityCheckColumnsThatAllowDefaults : ISanityCheck {
1212
results.forEach { model.addRow(it) }
1313

1414
if (model.rowCount > 0) {
15-
return listOf(SanityCheckResultSimpleTableModel(model, "Columns that allow defaults"))
15+
return listOf(SanityCheckResult(model, "Columns that allow defaults"))
1616
}
1717

1818
return listOf()

0 commit comments

Comments
 (0)