From f5628719676cfd074f4f67eff6593db8b1d6c1c5 Mon Sep 17 00:00:00 2001 From: kimdohun Date: Tue, 16 Feb 2021 11:22:55 +0900 Subject: [PATCH 1/6] =?UTF-8?q?=EA=B0=84=EB=8B=A8=ED=95=9C=20=ED=97=88?= =?UTF-8?q?=EB=A6=AC=ED=8E=B4=20=EA=B5=AC=ED=98=84=20=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../FindaProjectManagerListener.kt | 13 ++++++++++ .../action/CreateFindaTemplateAction.kt | 6 +++++ .../feature/waistUp/WaistUpNotification.kt | 14 +++++++++++ .../feature/waistUp/WaistUpService.kt | 25 +++++++++++++++++++ src/main/resources/META-INF/plugin.xml | 10 ++++++++ 5 files changed, 68 insertions(+) create mode 100644 src/main/kotlin/kr/co/finda/androidtemplate/FindaProjectManagerListener.kt create mode 100644 src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpNotification.kt create mode 100644 src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/FindaProjectManagerListener.kt b/src/main/kotlin/kr/co/finda/androidtemplate/FindaProjectManagerListener.kt new file mode 100644 index 0000000..eaf71cb --- /dev/null +++ b/src/main/kotlin/kr/co/finda/androidtemplate/FindaProjectManagerListener.kt @@ -0,0 +1,13 @@ +package kr.co.finda.androidtemplate + +import com.intellij.openapi.components.service +import com.intellij.openapi.project.Project +import com.intellij.openapi.project.ProjectManagerListener +import kr.co.finda.androidtemplate.feature.waistUp.WaistUpService + +class FindaProjectManagerListener : ProjectManagerListener { + + override fun projectOpened(project: Project) { + project.service() + } +} \ No newline at end of file diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/action/CreateFindaTemplateAction.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/action/CreateFindaTemplateAction.kt index 11ffcf2..b4104d5 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/action/CreateFindaTemplateAction.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/action/CreateFindaTemplateAction.kt @@ -1,14 +1,20 @@ package kr.co.finda.androidtemplate.feature.createFindaTemplate.action +import com.intellij.find.impl.livePreview.ReplacementView +import com.intellij.ide.IdeTooltipManager import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.actionSystem.CommonDataKeys import com.intellij.openapi.project.Project import com.intellij.openapi.ui.Messages +import com.intellij.openapi.ui.popup.BalloonBuilder +import com.intellij.openapi.ui.popup.JBPopupFactory import com.intellij.openapi.vfs.VirtualFile +import com.intellij.util.ui.PositionTracker import icons.Icons import kr.co.finda.androidtemplate.model.PluginError import kr.co.finda.androidtemplate.feature.createFindaTemplate.dialog.CreateFindaTemplateDialog +import kr.co.finda.androidtemplate.feature.waistUp.WaistUpNotification class CreateFindaTemplateAction : AnAction(), CreateFindaTemplateActionContract.View { diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpNotification.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpNotification.kt new file mode 100644 index 0000000..9a24d6c --- /dev/null +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpNotification.kt @@ -0,0 +1,14 @@ +package kr.co.finda.androidtemplate.feature.waistUp + +import com.intellij.notification.Notification +import com.intellij.notification.NotificationType +import icons.Icons + +class WaistUpNotification : Notification( + "FINDA", + "허리펴!", + "Finda 플러그인은 당신의 건강을 책임집니다", + NotificationType.INFORMATION +) { + +} \ No newline at end of file diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt new file mode 100644 index 0000000..67486bc --- /dev/null +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt @@ -0,0 +1,25 @@ +package kr.co.finda.androidtemplate.feature.waistUp + +import com.intellij.openapi.project.Project +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.delay +import kotlinx.coroutines.launch + +class WaistUpService( + private val project: Project +) { + + init { + startNotification() + } + + private fun startNotification() { + GlobalScope.launch(Dispatchers.IO) { + while (true) { + WaistUpNotification().notify(project) + delay(10000) + } + } + } +} \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 5cc042f..349cf7c 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -14,4 +14,14 @@ + + + + + + + + From bee9a8e1d1ba17fd27e8dbfb27efabc7917ab952 Mon Sep 17 00:00:00 2001 From: kimdohun Date: Fri, 19 Feb 2021 22:28:56 +0900 Subject: [PATCH 2/6] Notification with group --- .../feature/waistUp/WaistUpNotification.kt | 14 ------------- .../feature/waistUp/WaistUpService.kt | 20 +++++++++++++++++-- 2 files changed, 18 insertions(+), 16 deletions(-) delete mode 100644 src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpNotification.kt diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpNotification.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpNotification.kt deleted file mode 100644 index 9a24d6c..0000000 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpNotification.kt +++ /dev/null @@ -1,14 +0,0 @@ -package kr.co.finda.androidtemplate.feature.waistUp - -import com.intellij.notification.Notification -import com.intellij.notification.NotificationType -import icons.Icons - -class WaistUpNotification : Notification( - "FINDA", - "허리펴!", - "Finda 플러그인은 당신의 건강을 책임집니다", - NotificationType.INFORMATION -) { - -} \ No newline at end of file diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt index 67486bc..12cd7a7 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt @@ -1,5 +1,6 @@ package kr.co.finda.androidtemplate.feature.waistUp +import com.intellij.notification.* import com.intellij.openapi.project.Project import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.GlobalScope @@ -10,6 +11,12 @@ class WaistUpService( private val project: Project ) { + private val balloonGroup = NotificationGroup( + "FindaTest", + NotificationDisplayType.BALLOON, + true + ) + init { startNotification() } @@ -17,8 +24,17 @@ class WaistUpService( private fun startNotification() { GlobalScope.launch(Dispatchers.IO) { while (true) { - WaistUpNotification().notify(project) - delay(10000) + val notification = balloonGroup.createNotification( + title = "허리펴!", + content = "Finda 플러그인은 당신의 건강을 책임집니다", + type = NotificationType.WARNING + ) + notification.notify(project) + + delay(3000) + notification.expire() + + delay(8000) } } } From d97c4972d56d5723e66e33493dc17d25e1f4d59b Mon Sep 17 00:00:00 2001 From: kimdohun Date: Sat, 20 Feb 2021 16:22:57 +0900 Subject: [PATCH 3/6] =?UTF-8?q?=ED=83=80=EC=9D=B4=EB=A8=B8=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dialog/CreateFindaTemplateDialog.kt | 5 ++- .../dialog/CreateViewModelTestDialog.kt | 4 +- .../feature/setting/FindaSettingComponent.kt | 32 +++++++++++++ .../setting/FindaSettingConfigurable.kt | 45 +++++++++++++++++++ .../feature/waistUp/WaistUpService.kt | 42 ++++++++++++----- .../waistUp/action/SetWaistUpStateAction.kt | 14 ++++++ .../androidtemplate/type/WaistUpState.kt | 7 +++ src/main/resources/META-INF/plugin.xml | 13 +++++- 8 files changed, 147 insertions(+), 15 deletions(-) create mode 100644 src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingComponent.kt create mode 100644 src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingConfigurable.kt create mode 100644 src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/action/SetWaistUpStateAction.kt create mode 100644 src/main/kotlin/kr/co/finda/androidtemplate/type/WaistUpState.kt diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/dialog/CreateFindaTemplateDialog.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/dialog/CreateFindaTemplateDialog.kt index 0f3413e..46137b1 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/dialog/CreateFindaTemplateDialog.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/dialog/CreateFindaTemplateDialog.kt @@ -35,8 +35,7 @@ class CreateFindaTemplateDialog( } override fun createCenterPanel(): JComponent { - return panel { - + val panel = panel { row("화면 이름:") { nameTextField = textField({ "" }, {}).component } @@ -49,6 +48,8 @@ class CreateFindaTemplateDialog( ) } } + panel.preferredFocusedComponent = nameTextField + return panel } override fun doOKAction() { diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/dialog/CreateViewModelTestDialog.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/dialog/CreateViewModelTestDialog.kt index 7f57040..bd32514 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/dialog/CreateViewModelTestDialog.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/dialog/CreateViewModelTestDialog.kt @@ -29,11 +29,13 @@ class CreateViewModelTestDialog( } override fun createCenterPanel(): JComponent { - return panel { + val panel = panel { row("ViewModel 이름:") { nameTextField = textField({ "" }, {}).component } } + panel.preferredFocusedComponent = nameTextField + return panel } override fun doOKAction() { diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingComponent.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingComponent.kt new file mode 100644 index 0000000..430bcd7 --- /dev/null +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingComponent.kt @@ -0,0 +1,32 @@ +package kr.co.finda.androidtemplate.feature.setting + +import com.intellij.ui.components.CheckBox +import com.intellij.ui.components.JBCheckBox +import com.intellij.ui.components.JBLabel +import com.intellij.ui.components.JBTextField +import com.intellij.ui.layout.panel +import com.intellij.util.ui.FormBuilder +import kr.co.finda.androidtemplate.type.WaistUpState +import javax.swing.JPanel + +class FindaSettingComponent( + state: WaistUpState +) { + + val hideDelayTextField: JBTextField = JBTextField() + val waitDelayTextField: JBTextField = JBTextField() + val waistUpCheckBox: JBCheckBox = JBCheckBox("허리펴! 알림 활성화") + + val panel: JPanel = FormBuilder.createFormBuilder() + .addComponent(JBLabel("허리펴! 설정")) + .addLabeledComponent("숨김 시간", hideDelayTextField) + .addLabeledComponent("다음 허리펴! 까지 시간", waitDelayTextField) + .addComponent(waistUpCheckBox) + .panel + + init { + hideDelayTextField.text = state.hideDelay.toString() + waitDelayTextField.text = state.waitDelay.toString() + waistUpCheckBox.isSelected = state.isEnabled + } +} \ No newline at end of file diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingConfigurable.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingConfigurable.kt new file mode 100644 index 0000000..3f5ca18 --- /dev/null +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingConfigurable.kt @@ -0,0 +1,45 @@ +package kr.co.finda.androidtemplate.feature.setting + +import com.intellij.openapi.options.Configurable +import kr.co.finda.androidtemplate.feature.waistUp.WaistUpService +import javax.swing.JComponent + +class FindaSettingConfigurable : Configurable { + + private lateinit var findaSettingComponent: FindaSettingComponent + + override fun createComponent(): JComponent { + findaSettingComponent = FindaSettingComponent(WaistUpService.state) + return findaSettingComponent.panel + } + + override fun isModified(): Boolean { + println("isModified") + val state = WaistUpService.state + return state.isEnabled != findaSettingComponent.waistUpCheckBox.isSelected + || state.hideDelay != findaSettingComponent.hideDelayTextField.text.toLong() + || state.waitDelay != findaSettingComponent.waitDelayTextField.text.toLong() + } + + override fun apply() { + val state = WaistUpService.state + state.isEnabled = findaSettingComponent.waistUpCheckBox.isSelected + state.hideDelay = findaSettingComponent.hideDelayTextField.text.toLong() + state.waitDelay = findaSettingComponent.waitDelayTextField.text.toLong() + } + + override fun getPreferredFocusedComponent(): JComponent { + return findaSettingComponent.hideDelayTextField + } + + override fun reset() { + val state = WaistUpService.state + findaSettingComponent.waistUpCheckBox.isSelected = state.isEnabled + findaSettingComponent.hideDelayTextField.text = state.hideDelay.toString() + findaSettingComponent.waitDelayTextField.text = state.waitDelay.toString() + } + + override fun getDisplayName(): String { + return "Finda Settings" + } +} \ No newline at end of file diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt index 12cd7a7..bd8fc95 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt @@ -1,15 +1,22 @@ package kr.co.finda.androidtemplate.feature.waistUp -import com.intellij.notification.* -import com.intellij.openapi.project.Project -import kotlinx.coroutines.Dispatchers +import com.intellij.notification.NotificationDisplayType +import com.intellij.notification.NotificationGroup +import com.intellij.notification.NotificationType +import com.intellij.openapi.components.PersistentStateComponent +import com.intellij.openapi.components.State +import com.intellij.openapi.components.Storage import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.delay import kotlinx.coroutines.launch +import kr.co.finda.androidtemplate.feature.waistUp.action.SetWaistUpStateAction +import kr.co.finda.androidtemplate.type.WaistUpState -class WaistUpService( - private val project: Project -) { +@State( + name = "WaistUp", + storages = [Storage("FindaPlugin.xml")] +) +object WaistUpService : PersistentStateComponent { private val balloonGroup = NotificationGroup( "FindaTest", @@ -17,25 +24,40 @@ class WaistUpService( true ) + private var state = WaistUpState() + init { startNotification() } private fun startNotification() { - GlobalScope.launch(Dispatchers.IO) { + GlobalScope.launch { while (true) { + if (!state.isEnabled) { + break + } + val notification = balloonGroup.createNotification( title = "허리펴!", content = "Finda 플러그인은 당신의 건강을 책임집니다", type = NotificationType.WARNING ) - notification.notify(project) + notification.addAction(SetWaistUpStateAction()) + notification.notify(null) - delay(3000) + delay(state.hideDelay) notification.expire() - delay(8000) + delay(state.waitDelay) } } } + + override fun getState(): WaistUpState { + return state + } + + override fun loadState(state: WaistUpState) { + this.state = state + } } \ No newline at end of file diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/action/SetWaistUpStateAction.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/action/SetWaistUpStateAction.kt new file mode 100644 index 0000000..dddafc4 --- /dev/null +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/action/SetWaistUpStateAction.kt @@ -0,0 +1,14 @@ +package kr.co.finda.androidtemplate.feature.waistUp.action + +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.options.ShowSettingsUtil +import com.intellij.openapi.options.newEditor.SettingsDialog +import kr.co.finda.androidtemplate.feature.setting.FindaSettingConfigurable + +class SetWaistUpStateAction : AnAction("타이머 설정") { + + override fun actionPerformed(e: AnActionEvent) { + ShowSettingsUtil.getInstance().editConfigurable(e.project, FindaSettingConfigurable()) + } +} \ No newline at end of file diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/type/WaistUpState.kt b/src/main/kotlin/kr/co/finda/androidtemplate/type/WaistUpState.kt new file mode 100644 index 0000000..c337ec4 --- /dev/null +++ b/src/main/kotlin/kr/co/finda/androidtemplate/type/WaistUpState.kt @@ -0,0 +1,7 @@ +package kr.co.finda.androidtemplate.type + +data class WaistUpState( + var isEnabled: Boolean = true, + var hideDelay: Long = 2000, + var waitDelay: Long = 2000 +) \ No newline at end of file diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index cbc10ce..0f96ddc 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -19,17 +19,26 @@ icon="Icons.FindaLogo"> + - + + + + + topic="com.intellij.openapi.project.ProjectManagerListener"/> From e85c5b09fbf9f911bcabccc09c98d65a70551d3c Mon Sep 17 00:00:00 2001 From: kimdohun Date: Sat, 20 Feb 2021 17:02:14 +0900 Subject: [PATCH 4/6] =?UTF-8?q?=ED=97=88=EB=A6=AC=ED=8E=B4=20=EB=B9=84?= =?UTF-8?q?=ED=99=9C=EC=84=B1=ED=99=94=20=EB=B2=84=EA=B7=B8=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../setting/FindaSettingConfigurable.kt | 3 +- .../feature/waistUp/WaistUpService.kt | 35 ++++++++++--------- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingConfigurable.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingConfigurable.kt index 3f5ca18..0bb58ae 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingConfigurable.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingConfigurable.kt @@ -14,7 +14,6 @@ class FindaSettingConfigurable : Configurable { } override fun isModified(): Boolean { - println("isModified") val state = WaistUpService.state return state.isEnabled != findaSettingComponent.waistUpCheckBox.isSelected || state.hideDelay != findaSettingComponent.hideDelayTextField.text.toLong() @@ -26,6 +25,8 @@ class FindaSettingConfigurable : Configurable { state.isEnabled = findaSettingComponent.waistUpCheckBox.isSelected state.hideDelay = findaSettingComponent.hideDelayTextField.text.toLong() state.waitDelay = findaSettingComponent.waitDelayTextField.text.toLong() + + WaistUpService.setNotificationEnable(state.isEnabled) } override fun getPreferredFocusedComponent(): JComponent { diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt index bd8fc95..3ae43b9 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt @@ -6,9 +6,7 @@ import com.intellij.notification.NotificationType import com.intellij.openapi.components.PersistentStateComponent import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.delay -import kotlinx.coroutines.launch +import kotlinx.coroutines.* import kr.co.finda.androidtemplate.feature.waistUp.action.SetWaistUpStateAction import kr.co.finda.androidtemplate.type.WaistUpState @@ -26,17 +24,28 @@ object WaistUpService : PersistentStateComponent { private var state = WaistUpState() + var job: Job? = null + init { - startNotification() + setNotificationEnable(state.isEnabled) + } + + override fun getState(): WaistUpState { + return state + } + + override fun loadState(state: WaistUpState) { + this.state = state + } + + fun setNotificationEnable(isEnable: Boolean) { + job?.cancel() + if (isEnable) startNotification() } private fun startNotification() { - GlobalScope.launch { + job = GlobalScope.launch(Dispatchers.IO) { while (true) { - if (!state.isEnabled) { - break - } - val notification = balloonGroup.createNotification( title = "허리펴!", content = "Finda 플러그인은 당신의 건강을 책임집니다", @@ -52,12 +61,4 @@ object WaistUpService : PersistentStateComponent { } } } - - override fun getState(): WaistUpState { - return state - } - - override fun loadState(state: WaistUpState) { - this.state = state - } } \ No newline at end of file From e18621ed22f8cf52794c42148cf6fe11145f2e36 Mon Sep 17 00:00:00 2001 From: kimdohun Date: Sat, 20 Feb 2021 17:49:55 +0900 Subject: [PATCH 5/6] require restart --- src/main/resources/META-INF/plugin.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 0f96ddc..fa2c86e 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,4 +1,4 @@ - + kr.co.finda.androidtemplate FindaTemplate Dohun Kim From a28eddc413097d80e39b17132c39570a56dbb951 Mon Sep 17 00:00:00 2001 From: kimdohun Date: Sat, 20 Feb 2021 18:32:55 +0900 Subject: [PATCH 6/6] =?UTF-8?q?=EB=A6=AC=ED=8C=A9=ED=86=A0=EB=A7=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/CreateFindaTemplateAction.kt | 2 +- .../CreateFindaTemplateActionPresenter.kt | 2 +- .../dialog/CreateFindaTemplateDialog.kt | 29 +++++++------------ .../CreateFindaTemplateDialogPresenter.kt | 4 +-- .../action/CreateViewModelTestAction.kt | 2 +- .../CreateViewModelTestActionPresenter.kt | 2 +- .../dialog/CreateViewModelTestDialog.kt | 17 +++++------ .../CreateViewModelTestDialogPresenter.kt | 4 +-- .../FindaTestTemplateContextType.kt | 2 +- .../setting/FindaSettingConfigurable.kt | 26 ++++++++--------- .../{action => }/SetWaistUpStateAction.kt | 2 +- .../feature/waistUp/WaistUpService.kt | 1 - .../{model => util}/ActionRouter.kt | 2 +- .../{model => util}/FileHelper.kt | 6 +--- .../{model => util}/Replacer.kt | 2 +- src/main/resources/META-INF/plugin.xml | 6 ++-- 16 files changed, 47 insertions(+), 62 deletions(-) rename src/main/kotlin/kr/co/finda/androidtemplate/feature/{ => liveTemplate}/FindaTestTemplateContextType.kt (84%) rename src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/{action => }/SetWaistUpStateAction.kt (89%) rename src/main/kotlin/kr/co/finda/androidtemplate/{model => util}/ActionRouter.kt (92%) rename src/main/kotlin/kr/co/finda/androidtemplate/{model => util}/FileHelper.kt (94%) rename src/main/kotlin/kr/co/finda/androidtemplate/{model => util}/Replacer.kt (94%) diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/action/CreateFindaTemplateAction.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/action/CreateFindaTemplateAction.kt index 7f1125d..730db97 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/action/CreateFindaTemplateAction.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/action/CreateFindaTemplateAction.kt @@ -9,7 +9,7 @@ import com.intellij.openapi.vfs.VirtualFile import icons.Icons import kr.co.finda.androidtemplate.type.PluginError import kr.co.finda.androidtemplate.feature.createFindaTemplate.dialog.CreateFindaTemplateDialog -import kr.co.finda.androidtemplate.model.ActionRouterImpl +import kr.co.finda.androidtemplate.util.ActionRouterImpl class CreateFindaTemplateAction : AnAction(), CreateFindaTemplateActionContract.View { diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/action/CreateFindaTemplateActionPresenter.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/action/CreateFindaTemplateActionPresenter.kt index a73df57..3bf9a75 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/action/CreateFindaTemplateActionPresenter.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/action/CreateFindaTemplateActionPresenter.kt @@ -3,7 +3,7 @@ package kr.co.finda.androidtemplate.feature.createFindaTemplate.action import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile -import kr.co.finda.androidtemplate.model.ActionRouter +import kr.co.finda.androidtemplate.util.ActionRouter import kr.co.finda.androidtemplate.type.PluginError class CreateFindaTemplateActionPresenter( diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/dialog/CreateFindaTemplateDialog.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/dialog/CreateFindaTemplateDialog.kt index 46137b1..85d1b50 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/dialog/CreateFindaTemplateDialog.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/dialog/CreateFindaTemplateDialog.kt @@ -1,16 +1,17 @@ package kr.co.finda.androidtemplate.feature.createFindaTemplate.dialog import com.intellij.openapi.project.Project +import com.intellij.openapi.ui.ComboBox import com.intellij.openapi.ui.DialogWrapper import com.intellij.openapi.ui.Messages import com.intellij.openapi.vfs.VirtualFile import com.intellij.ui.EnumComboBoxModel import com.intellij.ui.components.JBTextField -import com.intellij.ui.layout.panel +import com.intellij.util.ui.FormBuilder import icons.Icons import kr.co.finda.androidtemplate.type.PluginError -import kr.co.finda.androidtemplate.model.FileHelperImpl -import kr.co.finda.androidtemplate.model.ReplacerImpl +import kr.co.finda.androidtemplate.util.FileHelperImpl +import kr.co.finda.androidtemplate.util.ReplacerImpl import kr.co.finda.androidtemplate.type.ScreenType import javax.swing.JComponent @@ -27,7 +28,13 @@ class CreateFindaTemplateDialog( } private val screenTypeModel = EnumComboBoxModel(ScreenType::class.java) - private lateinit var nameTextField: JBTextField + + private val nameTextField = JBTextField() + private val screenTypeComboBox = ComboBox(screenTypeModel) + private val panel = FormBuilder.createFormBuilder() + .addLabeledComponent("화면 이름:", nameTextField) + .addLabeledComponent("화면 종류:", screenTypeComboBox) + .panel init { init() @@ -35,20 +42,6 @@ class CreateFindaTemplateDialog( } override fun createCenterPanel(): JComponent { - val panel = panel { - row("화면 이름:") { - nameTextField = textField({ "" }, {}).component - } - - row("화면 종류:") { - comboBox( - screenTypeModel, - { screenTypeModel.selectedItem }, - { screenTypeModel.setSelectedItem(it) } - ) - } - } - panel.preferredFocusedComponent = nameTextField return panel } diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/dialog/CreateFindaTemplateDialogPresenter.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/dialog/CreateFindaTemplateDialogPresenter.kt index 46c5f34..066143c 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/dialog/CreateFindaTemplateDialogPresenter.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createFindaTemplate/dialog/CreateFindaTemplateDialogPresenter.kt @@ -3,8 +3,8 @@ package kr.co.finda.androidtemplate.feature.createFindaTemplate.dialog import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile import kr.co.finda.androidtemplate.type.PluginError -import kr.co.finda.androidtemplate.model.FileHelper -import kr.co.finda.androidtemplate.model.Replacements +import kr.co.finda.androidtemplate.util.FileHelper +import kr.co.finda.androidtemplate.util.Replacements import kr.co.finda.androidtemplate.ext.decapitalizeWithUnderBar import kr.co.finda.androidtemplate.type.FileExtension import kr.co.finda.androidtemplate.type.ScreenType diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/action/CreateViewModelTestAction.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/action/CreateViewModelTestAction.kt index 9b69472..87c7151 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/action/CreateViewModelTestAction.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/action/CreateViewModelTestAction.kt @@ -8,7 +8,7 @@ import com.intellij.openapi.ui.Messages import com.intellij.openapi.vfs.VirtualFile import icons.Icons import kr.co.finda.androidtemplate.feature.createViewModelTest.dialog.CreateViewModelTestDialog -import kr.co.finda.androidtemplate.model.ActionRouterImpl +import kr.co.finda.androidtemplate.util.ActionRouterImpl import kr.co.finda.androidtemplate.type.PluginError class CreateViewModelTestAction : diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/action/CreateViewModelTestActionPresenter.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/action/CreateViewModelTestActionPresenter.kt index 80aa537..72990de 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/action/CreateViewModelTestActionPresenter.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/action/CreateViewModelTestActionPresenter.kt @@ -3,7 +3,7 @@ package kr.co.finda.androidtemplate.feature.createViewModelTest.action import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile -import kr.co.finda.androidtemplate.model.ActionRouter +import kr.co.finda.androidtemplate.util.ActionRouter import kr.co.finda.androidtemplate.type.PluginError class CreateViewModelTestActionPresenter( diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/dialog/CreateViewModelTestDialog.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/dialog/CreateViewModelTestDialog.kt index bd32514..e03f4d5 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/dialog/CreateViewModelTestDialog.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/dialog/CreateViewModelTestDialog.kt @@ -5,10 +5,10 @@ import com.intellij.openapi.ui.DialogWrapper import com.intellij.openapi.ui.Messages import com.intellij.openapi.vfs.VirtualFile import com.intellij.ui.components.JBTextField -import com.intellij.ui.layout.panel +import com.intellij.util.ui.FormBuilder import icons.Icons -import kr.co.finda.androidtemplate.model.FileHelperImpl -import kr.co.finda.androidtemplate.model.ReplacerImpl +import kr.co.finda.androidtemplate.util.FileHelperImpl +import kr.co.finda.androidtemplate.util.ReplacerImpl import kr.co.finda.androidtemplate.type.PluginError import javax.swing.JComponent @@ -21,7 +21,10 @@ class CreateViewModelTestDialog( CreateViewModelTestDialogPresenter(this, FileHelperImpl(ReplacerImpl())) } - private lateinit var nameTextField: JBTextField + private val nameTextField = JBTextField() + private val panel = FormBuilder.createFormBuilder() + .addLabeledComponent("ViewModel 이름:", nameTextField) + .panel init { init() @@ -29,12 +32,6 @@ class CreateViewModelTestDialog( } override fun createCenterPanel(): JComponent { - val panel = panel { - row("ViewModel 이름:") { - nameTextField = textField({ "" }, {}).component - } - } - panel.preferredFocusedComponent = nameTextField return panel } diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/dialog/CreateViewModelTestDialogPresenter.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/dialog/CreateViewModelTestDialogPresenter.kt index 571b546..5891c63 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/dialog/CreateViewModelTestDialogPresenter.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/createViewModelTest/dialog/CreateViewModelTestDialogPresenter.kt @@ -2,8 +2,8 @@ package kr.co.finda.androidtemplate.feature.createViewModelTest.dialog import com.intellij.openapi.project.Project import com.intellij.openapi.vfs.VirtualFile -import kr.co.finda.androidtemplate.model.FileHelper -import kr.co.finda.androidtemplate.model.Replacements +import kr.co.finda.androidtemplate.util.FileHelper +import kr.co.finda.androidtemplate.util.Replacements import kr.co.finda.androidtemplate.type.FileExtension import kr.co.finda.androidtemplate.type.PluginError diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/FindaTestTemplateContextType.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/liveTemplate/FindaTestTemplateContextType.kt similarity index 84% rename from src/main/kotlin/kr/co/finda/androidtemplate/feature/FindaTestTemplateContextType.kt rename to src/main/kotlin/kr/co/finda/androidtemplate/feature/liveTemplate/FindaTestTemplateContextType.kt index e1bee6b..de16f3d 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/FindaTestTemplateContextType.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/liveTemplate/FindaTestTemplateContextType.kt @@ -1,4 +1,4 @@ -package kr.co.finda.androidtemplate.feature +package kr.co.finda.androidtemplate.feature.liveTemplate import com.intellij.codeInsight.template.TemplateContextType import com.intellij.psi.PsiFile diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingConfigurable.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingConfigurable.kt index 0bb58ae..96b2f1a 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingConfigurable.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingConfigurable.kt @@ -6,38 +6,38 @@ import javax.swing.JComponent class FindaSettingConfigurable : Configurable { - private lateinit var findaSettingComponent: FindaSettingComponent + private lateinit var component: FindaSettingComponent override fun createComponent(): JComponent { - findaSettingComponent = FindaSettingComponent(WaistUpService.state) - return findaSettingComponent.panel + component = FindaSettingComponent(WaistUpService.state) + return component.panel } override fun isModified(): Boolean { val state = WaistUpService.state - return state.isEnabled != findaSettingComponent.waistUpCheckBox.isSelected - || state.hideDelay != findaSettingComponent.hideDelayTextField.text.toLong() - || state.waitDelay != findaSettingComponent.waitDelayTextField.text.toLong() + return state.isEnabled != component.waistUpCheckBox.isSelected + || state.hideDelay != component.hideDelayTextField.text.toLong() + || state.waitDelay != component.waitDelayTextField.text.toLong() } override fun apply() { val state = WaistUpService.state - state.isEnabled = findaSettingComponent.waistUpCheckBox.isSelected - state.hideDelay = findaSettingComponent.hideDelayTextField.text.toLong() - state.waitDelay = findaSettingComponent.waitDelayTextField.text.toLong() + state.isEnabled = component.waistUpCheckBox.isSelected + state.hideDelay = component.hideDelayTextField.text.toLong() + state.waitDelay = component.waitDelayTextField.text.toLong() WaistUpService.setNotificationEnable(state.isEnabled) } override fun getPreferredFocusedComponent(): JComponent { - return findaSettingComponent.hideDelayTextField + return component.hideDelayTextField } override fun reset() { val state = WaistUpService.state - findaSettingComponent.waistUpCheckBox.isSelected = state.isEnabled - findaSettingComponent.hideDelayTextField.text = state.hideDelay.toString() - findaSettingComponent.waitDelayTextField.text = state.waitDelay.toString() + component.waistUpCheckBox.isSelected = state.isEnabled + component.hideDelayTextField.text = state.hideDelay.toString() + component.waitDelayTextField.text = state.waitDelay.toString() } override fun getDisplayName(): String { diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/action/SetWaistUpStateAction.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/SetWaistUpStateAction.kt similarity index 89% rename from src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/action/SetWaistUpStateAction.kt rename to src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/SetWaistUpStateAction.kt index dddafc4..91690d0 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/action/SetWaistUpStateAction.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/SetWaistUpStateAction.kt @@ -1,4 +1,4 @@ -package kr.co.finda.androidtemplate.feature.waistUp.action +package kr.co.finda.androidtemplate.feature.waistUp import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt index 3ae43b9..fccdd64 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt @@ -7,7 +7,6 @@ import com.intellij.openapi.components.PersistentStateComponent import com.intellij.openapi.components.State import com.intellij.openapi.components.Storage import kotlinx.coroutines.* -import kr.co.finda.androidtemplate.feature.waistUp.action.SetWaistUpStateAction import kr.co.finda.androidtemplate.type.WaistUpState @State( diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/model/ActionRouter.kt b/src/main/kotlin/kr/co/finda/androidtemplate/util/ActionRouter.kt similarity index 92% rename from src/main/kotlin/kr/co/finda/androidtemplate/model/ActionRouter.kt rename to src/main/kotlin/kr/co/finda/androidtemplate/util/ActionRouter.kt index 03320e0..c0a5bd4 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/model/ActionRouter.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/util/ActionRouter.kt @@ -1,4 +1,4 @@ -package kr.co.finda.androidtemplate.model +package kr.co.finda.androidtemplate.util interface ActionRouter { diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/model/FileHelper.kt b/src/main/kotlin/kr/co/finda/androidtemplate/util/FileHelper.kt similarity index 94% rename from src/main/kotlin/kr/co/finda/androidtemplate/model/FileHelper.kt rename to src/main/kotlin/kr/co/finda/androidtemplate/util/FileHelper.kt index 4d8ab4d..97e2b21 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/model/FileHelper.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/util/FileHelper.kt @@ -1,4 +1,4 @@ -package kr.co.finda.androidtemplate.model +package kr.co.finda.androidtemplate.util import com.intellij.openapi.vfs.VfsUtil import com.intellij.openapi.vfs.VirtualFile @@ -6,10 +6,6 @@ import com.intellij.openapi.vfs.VirtualFileManager import com.intellij.util.ResourceUtil import kr.co.finda.androidtemplate.ext.replaceAll import kr.co.finda.androidtemplate.type.FileExtension -import java.io.File -import java.net.URI -import java.nio.file.Files -import java.nio.file.Paths interface FileHelper { diff --git a/src/main/kotlin/kr/co/finda/androidtemplate/model/Replacer.kt b/src/main/kotlin/kr/co/finda/androidtemplate/util/Replacer.kt similarity index 94% rename from src/main/kotlin/kr/co/finda/androidtemplate/model/Replacer.kt rename to src/main/kotlin/kr/co/finda/androidtemplate/util/Replacer.kt index b8f79fd..064f34c 100644 --- a/src/main/kotlin/kr/co/finda/androidtemplate/model/Replacer.kt +++ b/src/main/kotlin/kr/co/finda/androidtemplate/util/Replacer.kt @@ -1,4 +1,4 @@ -package kr.co.finda.androidtemplate.model +package kr.co.finda.androidtemplate.util import kr.co.finda.androidtemplate.ext.replaceAllIfNotNull diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index fa2c86e..ea0758f 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -19,14 +19,14 @@ icon="Icons.FindaLogo"> - - +