Skip to content

Commit

Permalink
[GP-202] feat: add clear button to clear done list
Browse files Browse the repository at this point in the history
  • Loading branch information
gon-song committed Apr 18, 2024
1 parent d2dd94f commit a5a8d81
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pluginGroup = com.github.gon2gon2.mdtdd
pluginName = mdtdd
pluginRepositoryUrl = https://github.com/gon2gon2/mdtdd
# SemVer format -> https://semver.org
pluginVersion = 0.1.0
pluginVersion = 0.2.0

# Supported build number ranges and IntelliJ Platform versions -> https://plugins.jetbrains.com/docs/intellij/build-number-ranges.html
pluginSinceBuild = 223
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,12 @@ class CustomListModel(private val backingList: MutableList<String>) : AbstractLi
fireIntervalRemoved(this, index, index)
}
}

fun clearList() {
val oldSize = backingList.size
backingList.clear()
if (oldSize > 0) {
fireIntervalRemoved(this, 0, oldSize - 1)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import javax.swing.JTextField


class TodoListPanel(
todoList: MutableList<String>,
doneList: MutableList<String>,
todoList: MutableList<String>,
doneList: MutableList<String>,
) {
val panel = JPanel()

Expand All @@ -27,6 +27,7 @@ class TodoListPanel(
private val addButton = JButton("Add")
private val doneButton = JButton("Done")
private val removeButton = JButton("Remove")
private val clearButton = JButton("Clear")

init {
setupUI()
Expand All @@ -42,6 +43,7 @@ class TodoListPanel(
panel.add(addButton)
panel.add(doneButton)
panel.add(removeButton)
panel.add(clearButton)
}

private fun setupActions() {
Expand All @@ -67,5 +69,9 @@ class TodoListPanel(
todoListModel.removeElementAt(selectedIndex)
}
}

clearButton.addActionListener {
doneListModel.clearList()
}
}
}

0 comments on commit a5a8d81

Please sign in to comment.