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 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 0f3413e..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,7 @@ class CreateFindaTemplateDialog( } override fun createCenterPanel(): JComponent { - return panel { - - row("화면 이름:") { - nameTextField = textField({ "" }, {}).component - } - - row("화면 종류:") { - comboBox( - screenTypeModel, - { screenTypeModel.selectedItem }, - { screenTypeModel.setSelectedItem(it) } - ) - } - } + return panel } override fun doOKAction() { 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 7f57040..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,11 +32,7 @@ class CreateViewModelTestDialog( } override fun createCenterPanel(): JComponent { - return panel { - row("ViewModel 이름:") { - nameTextField = textField({ "" }, {}).component - } - } + return panel } override fun doOKAction() { 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/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..96b2f1a --- /dev/null +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingConfigurable.kt @@ -0,0 +1,46 @@ +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 component: FindaSettingComponent + + override fun createComponent(): JComponent { + component = FindaSettingComponent(WaistUpService.state) + return component.panel + } + + override fun isModified(): Boolean { + val state = WaistUpService.state + 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 = component.waistUpCheckBox.isSelected + state.hideDelay = component.hideDelayTextField.text.toLong() + state.waitDelay = component.waitDelayTextField.text.toLong() + + WaistUpService.setNotificationEnable(state.isEnabled) + } + + override fun getPreferredFocusedComponent(): JComponent { + return component.hideDelayTextField + } + + override fun reset() { + val state = WaistUpService.state + component.waistUpCheckBox.isSelected = state.isEnabled + component.hideDelayTextField.text = state.hideDelay.toString() + component.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/SetWaistUpStateAction.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/SetWaistUpStateAction.kt new file mode 100644 index 0000000..91690d0 --- /dev/null +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/SetWaistUpStateAction.kt @@ -0,0 +1,14 @@ +package kr.co.finda.androidtemplate.feature.waistUp + +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/feature/waistUp/WaistUpService.kt b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt new file mode 100644 index 0000000..fccdd64 --- /dev/null +++ b/src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.kt @@ -0,0 +1,63 @@ +package kr.co.finda.androidtemplate.feature.waistUp + +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.* +import kr.co.finda.androidtemplate.type.WaistUpState + +@State( + name = "WaistUp", + storages = [Storage("FindaPlugin.xml")] +) +object WaistUpService : PersistentStateComponent { + + private val balloonGroup = NotificationGroup( + "FindaTest", + NotificationDisplayType.BALLOON, + true + ) + + private var state = WaistUpState() + + var job: Job? = null + + init { + 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() { + job = GlobalScope.launch(Dispatchers.IO) { + while (true) { + val notification = balloonGroup.createNotification( + title = "허리펴!", + content = "Finda 플러그인은 당신의 건강을 책임집니다", + type = NotificationType.WARNING + ) + notification.addAction(SetWaistUpStateAction()) + notification.notify(null) + + delay(state.hideDelay) + notification.expire() + + delay(state.waitDelay) + } + } + } +} \ 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/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 51aacae..ea0758f 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 @@ -19,10 +19,26 @@ icon="Icons.FindaLogo"> + - + + + + + + + + +