Skip to content

Commit

Permalink
Implemented getClickConsumer() for opening plugin setting by tapping …
Browse files Browse the repository at this point in the history
…on widget
  • Loading branch information
HarshPanchal18 committed Sep 3, 2024
1 parent 61e1f21 commit 8a665d9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.harsh.jumpinglines.statusbar

import com.harsh.jumpinglines.settings.JumpingLinesSettings
import com.harsh.jumpinglines.utils.Const
import com.harsh.jumpinglines.utils.inHumanReadableForm
import com.harsh.jumpinglines.utils.jumpScore
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.options.ShowSettingsUtil
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
import com.intellij.openapi.wm.StatusBar
import com.intellij.openapi.wm.StatusBarWidget
Expand All @@ -11,7 +15,7 @@ import java.awt.Component
import java.awt.event.MouseEvent
import java.util.*

class JumpingLinesStatusBarWidget : StatusBarWidget,
class JumpingLinesStatusBarWidget(private val project: Project) : StatusBarWidget,
// IconLikeCustomStatusBarWidget
// StatusBarWidget.IconPresentation,
StatusBarWidget.TextPresentation {
Expand Down Expand Up @@ -45,8 +49,12 @@ class JumpingLinesStatusBarWidget : StatusBarWidget,
this.statusBar = statusBar
}

override fun getClickConsumer(): Consumer<MouseEvent>? {
return super.getClickConsumer()
override fun getClickConsumer(): Consumer<MouseEvent> {
return Consumer {
ApplicationManager.getApplication().invokeLater {
ShowSettingsUtil.getInstance().showSettingsDialog(project, JumpingLinesSettings::class.java)
}
}
}

// Method to refresh the widget
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ class JumpingLinesStatusBarWidgetFactory : StatusBarWidgetFactory {

override fun getId(): String = Const.PLUGIN_ID

override fun canBeEnabledOn(statusBar: StatusBar): Boolean {
return super.canBeEnabledOn(statusBar)
}
override fun canBeEnabledOn(statusBar: StatusBar): Boolean = true

override fun getDisplayName(): String = Const.JUMP_SCORE_TITLE

override fun isAvailable(project: Project) = true

override fun createWidget(project: Project): StatusBarWidget = JumpingLinesStatusBarWidget()
override fun createWidget(project: Project): StatusBarWidget = JumpingLinesStatusBarWidget(project)

override fun disposeWidget(widget: StatusBarWidget) {
widget.dispose()
Expand Down

0 comments on commit 8a665d9

Please sign in to comment.