generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from FindaDeveloper/dohun
Dohun
- Loading branch information
Showing
19 changed files
with
225 additions
and
45 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/kr/co/finda/androidtemplate/FindaProjectManagerListener.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,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<WaistUpService>() | ||
} | ||
} |
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
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
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
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
2 changes: 1 addition & 1 deletion
2
...e/feature/FindaTestTemplateContextType.kt → ...eTemplate/FindaTestTemplateContextType.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
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingComponent.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,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 | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/kotlin/kr/co/finda/androidtemplate/feature/setting/FindaSettingConfigurable.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,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" | ||
} | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/SetWaistUpStateAction.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,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()) | ||
} | ||
} |
63 changes: 63 additions & 0 deletions
63
src/main/kotlin/kr/co/finda/androidtemplate/feature/waistUp/WaistUpService.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,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<WaistUpState> { | ||
|
||
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) | ||
} | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/kotlin/kr/co/finda/androidtemplate/type/WaistUpState.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,7 @@ | ||
package kr.co.finda.androidtemplate.type | ||
|
||
data class WaistUpState( | ||
var isEnabled: Boolean = true, | ||
var hideDelay: Long = 2000, | ||
var waitDelay: Long = 2000 | ||
) |
2 changes: 1 addition & 1 deletion
2
...nda/androidtemplate/model/ActionRouter.kt → ...inda/androidtemplate/util/ActionRouter.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,4 +1,4 @@ | ||
package kr.co.finda.androidtemplate.model | ||
package kr.co.finda.androidtemplate.util | ||
|
||
interface ActionRouter { | ||
|
||
|
6 changes: 1 addition & 5 deletions
6
...finda/androidtemplate/model/FileHelper.kt → .../finda/androidtemplate/util/FileHelper.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
2 changes: 1 addition & 1 deletion
2
...o/finda/androidtemplate/model/Replacer.kt → ...co/finda/androidtemplate/util/Replacer.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
Oops, something went wrong.