generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[GP-176] todoList와 doneList가 편집기를 껐다 켜도 유지된다 (#20)
- Loading branch information
Showing
11 changed files
with
87 additions
and
118 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/kotlin/com/github/gon2gon2/mdtdd/MdtddToolWindowFactory.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 8 additions & 27 deletions
35
src/main/kotlin/com/github/gon2gon2/mdtdd/infra/TodoStateRepository.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,20 @@ | ||
package com.github.gon2gon2.mdtdd.infra | ||
|
||
import com.github.gon2gon2.mdtdd.services.TodoRepository | ||
import com.intellij.openapi.components.PersistentStateComponent | ||
import com.intellij.openapi.components.BaseState | ||
import com.intellij.openapi.components.Service | ||
import com.intellij.openapi.components.SimplePersistentStateComponent | ||
import com.intellij.openapi.components.State | ||
import com.intellij.openapi.components.Storage | ||
import com.intellij.util.xmlb.XmlSerializerUtil | ||
|
||
@Service(Service.Level.PROJECT) | ||
@State( | ||
name = "com.github.gon2gon2.mdtdd.TodoListState", | ||
name = "TodoListState", | ||
storages = [Storage("TodoList.xml")] | ||
) | ||
class TodoStateRepository : PersistentStateComponent<TodoStateRepository>, TodoRepository { | ||
private var todoList: MutableList<String> = mutableListOf() | ||
|
||
override fun add(todo: String) { | ||
todoList.add(todo) | ||
} | ||
|
||
override fun remove(todo: String) { | ||
todoList.remove(todo) | ||
} | ||
|
||
override fun remove(todoIndex: Int) { | ||
todoList.removeAt(todoIndex) | ||
class TodoStateRepository : SimplePersistentStateComponent<TodoStateRepository.State>(State()) { | ||
class State : BaseState() { | ||
var todoList: MutableList<String> by list() | ||
var doneList: MutableList<String> by list() | ||
} | ||
} | ||
|
||
override fun getAll(): List<String> { | ||
return todoList | ||
} | ||
|
||
override fun getState(): TodoStateRepository = this | ||
|
||
override fun loadState(state: TodoStateRepository) { | ||
XmlSerializerUtil.copyBean(state, this) | ||
} | ||
} |
8 changes: 0 additions & 8 deletions
8
src/main/kotlin/com/github/gon2gon2/mdtdd/services/TodoRepository.kt
This file was deleted.
Oops, something went wrong.
24 changes: 0 additions & 24 deletions
24
src/main/kotlin/com/github/gon2gon2/mdtdd/services/TodoService.kt
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
src/main/kotlin/com/github/gon2gon2/mdtdd/toolwindow/UnifiedToolWindow.kt
This file was deleted.
Oops, something went wrong.
28 changes: 28 additions & 0 deletions
28
src/main/kotlin/com/github/gon2gon2/mdtdd/view/UnifiedToolWindow.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.github.gon2gon2.mdtdd.view | ||
|
||
import com.github.gon2gon2.mdtdd.infra.TodoStateRepository | ||
import com.github.gon2gon2.mdtdd.view.timer.TimerPanel | ||
import com.github.gon2gon2.mdtdd.view.todo.TodoListPanel | ||
import com.intellij.openapi.components.service | ||
import com.intellij.openapi.project.Project | ||
import javax.swing.BoxLayout | ||
import javax.swing.JPanel | ||
|
||
class UnifiedToolWindow(project: Project) { | ||
private val mainPanel = JPanel() | ||
private val timerPanel = TimerPanel().panel | ||
|
||
private val todoListPanel = TodoListPanel( | ||
project.service<TodoStateRepository>().state.todoList, | ||
project.service<TodoStateRepository>().state.doneList, | ||
).panel | ||
|
||
init { | ||
mainPanel.layout = BoxLayout(mainPanel, BoxLayout.Y_AXIS) | ||
mainPanel.add(timerPanel) | ||
mainPanel.add(todoListPanel) | ||
} | ||
|
||
val content: JPanel | ||
get() = mainPanel | ||
} |
2 changes: 1 addition & 1 deletion
2
...gon2/mdtdd/toolwindow/panel/TimerPanel.kt → ...b/gon2gon2/mdtdd/view/timer/TimerPanel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/main/kotlin/com/github/gon2gon2/mdtdd/view/todo/CustomListModel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.github.gon2gon2.mdtdd.view.todo | ||
|
||
import javax.swing.AbstractListModel | ||
|
||
class CustomListModel(private val backingList: MutableList<String>) : AbstractListModel<String>() { | ||
override fun getSize(): Int = backingList.size | ||
|
||
override fun getElementAt(index: Int): String = backingList[index] | ||
|
||
fun addElement(element: String) { | ||
backingList.add(element) | ||
fireIntervalAdded(this, backingList.size - 1, backingList.size - 1) | ||
} | ||
|
||
fun removeElementAt(element: String) { | ||
val index = backingList.indexOf(element) | ||
if (index != -1) { | ||
backingList.removeAt(index) | ||
fireIntervalRemoved(this, index, index) | ||
} | ||
} | ||
|
||
fun removeElementAt(index: Int) { | ||
if (index != -1) { | ||
backingList.removeAt(index) | ||
fireIntervalRemoved(this, index, index) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters