diff --git a/gradle.properties b/gradle.properties index c6c41a7..f44b18b 100644 --- a/gradle.properties +++ b/gradle.properties @@ -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 diff --git a/src/main/kotlin/com/github/gon2gon2/mdtdd/view/todo/CustomListModel.kt b/src/main/kotlin/com/github/gon2gon2/mdtdd/view/todo/CustomListModel.kt index 79a5520..927470c 100644 --- a/src/main/kotlin/com/github/gon2gon2/mdtdd/view/todo/CustomListModel.kt +++ b/src/main/kotlin/com/github/gon2gon2/mdtdd/view/todo/CustomListModel.kt @@ -26,4 +26,12 @@ class CustomListModel(private val backingList: MutableList) : AbstractLi fireIntervalRemoved(this, index, index) } } + + fun clearList() { + val oldSize = backingList.size + backingList.clear() + if (oldSize > 0) { + fireIntervalRemoved(this, 0, oldSize - 1) + } + } } diff --git a/src/main/kotlin/com/github/gon2gon2/mdtdd/view/todo/TodoListPanel.kt b/src/main/kotlin/com/github/gon2gon2/mdtdd/view/todo/TodoListPanel.kt index 24d7afb..f57851b 100644 --- a/src/main/kotlin/com/github/gon2gon2/mdtdd/view/todo/TodoListPanel.kt +++ b/src/main/kotlin/com/github/gon2gon2/mdtdd/view/todo/TodoListPanel.kt @@ -10,8 +10,8 @@ import javax.swing.JTextField class TodoListPanel( - todoList: MutableList, - doneList: MutableList, + todoList: MutableList, + doneList: MutableList, ) { val panel = JPanel() @@ -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() @@ -42,6 +43,7 @@ class TodoListPanel( panel.add(addButton) panel.add(doneButton) panel.add(removeButton) + panel.add(clearButton) } private fun setupActions() { @@ -67,5 +69,9 @@ class TodoListPanel( todoListModel.removeElementAt(selectedIndex) } } + + clearButton.addActionListener { + doneListModel.clearList() + } } }