Skip to content

Commit

Permalink
리팩토링
Browse files Browse the repository at this point in the history
  • Loading branch information
kimdohun0104 committed Feb 20, 2021
1 parent e18621e commit a28eddc
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -27,28 +28,20 @@ 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()
title = "Create Finda Template"
}

override fun createCenterPanel(): JComponent {
val panel = panel {
row("화면 이름:") {
nameTextField = textField({ "" }, {}).component
}

row("화면 종류:") {
comboBox(
screenTypeModel,
{ screenTypeModel.selectedItem },
{ screenTypeModel.setSelectedItem(it) }
)
}
}
panel.preferredFocusedComponent = nameTextField
return panel
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -21,20 +21,17 @@ 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()
title = "Create ViewModel Test Template"
}

override fun createCenterPanel(): JComponent {
val panel = panel {
row("ViewModel 이름:") {
nameTextField = textField({ "" }, {}).component
}
}
panel.preferredFocusedComponent = nameTextField
return panel
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kr.co.finda.androidtemplate.model
package kr.co.finda.androidtemplate.util

interface ActionRouter {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
package kr.co.finda.androidtemplate.model
package kr.co.finda.androidtemplate.util

import com.intellij.openapi.vfs.VfsUtil
import com.intellij.openapi.vfs.VirtualFile
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 {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package kr.co.finda.androidtemplate.model
package kr.co.finda.androidtemplate.util

import kr.co.finda.androidtemplate.ext.replaceAllIfNotNull

Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
icon="Icons.FindaLogo">
<add-to-group group-id="NewGroup" anchor="first"/>
</action>
<action id="kr.co.finda.androidtemplate.feature.waistUp.action.SetWaistUpStateAction"
class="kr.co.finda.androidtemplate.feature.waistUp.action.SetWaistUpStateAction"
<action id="kr.co.finda.androidtemplate.feature.waistUp.SetWaistUpStateAction"
class="kr.co.finda.androidtemplate.feature.waistUp.SetWaistUpStateAction"
text="Set Waist Up Timer"/>
</actions>

<extensions defaultExtensionNs="com.intellij">
<defaultLiveTemplates file="/liveTemplates/FindaTest.xml"/>
<liveTemplateContext implementation="kr.co.finda.androidtemplate.feature.FindaTestTemplateContextType"/>
<liveTemplateContext implementation="kr.co.finda.androidtemplate.feature.liveTemplate.FindaTestTemplateContextType"/>

<projectService serviceImplementation="kr.co.finda.androidtemplate.feature.waistUp.WaistUpService"/>

Expand Down

0 comments on commit a28eddc

Please sign in to comment.