Skip to content

Commit

Permalink
feat(statusbar): add AutoDev status bar widget factory
Browse files Browse the repository at this point in the history
This commit adds a new file `AutoDevStatusBarWidgetFactory.kt` in the `cc.unitmesh.devti.statusbar` package. The file contains the implementation of the `AutoDevStatusBarWidgetFactory` class, which is responsible for creating the AutoDev status bar widget. The widget displays the AutoDev icon and has a tooltip with the text "AutoDev". The factory also provides an ID and a display name for the widget.
  • Loading branch information
phodal committed Jan 12, 2024
1 parent 19ac488 commit 38b37f6
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/233/main/resources/META-INF/autodev-core.xml
Expand Up @@ -33,6 +33,8 @@

<applicationService serviceImplementation="cc.unitmesh.devti.settings.AutoDevSettingsState"/>

<statusBarWidgetFactory id="AIAssistant" implementation="cc.unitmesh.devti.statusbar.AutoDevStatusBarWidgetFactory"/>

<runConfigurationProducer
implementation="cc.unitmesh.devti.runconfig.command.AutoDevFeatureConfigurationProducer"/>
<runConfigurationProducer
Expand Down
3 changes: 3 additions & 0 deletions src/main/kotlin/cc/unitmesh/devti/AutoDevIcons.kt
Expand Up @@ -10,6 +10,9 @@ object AutoDevIcons {
@JvmField
val AI_COPILOT: Icon = IconLoader.getIcon("/icons/ai-copilot.svg", AutoDevIcons::class.java)

@JvmField
val DARK: Icon = IconLoader.getIcon("/icons/autodev-dark.svg", AutoDevIcons::class.java)

@JvmField
val Send: Icon = IconLoader.getIcon("/icons/send.svg", AutoDevIcons::class.java)

Expand Down
@@ -0,0 +1,18 @@
package cc.unitmesh.devti.actions

import cc.unitmesh.devti.settings.AutoDevSettingsConfigurable
import com.intellij.openapi.actionSystem.ActionUpdateThread
import com.intellij.openapi.actionSystem.AnAction
import com.intellij.openapi.actionSystem.AnActionEvent
import com.intellij.openapi.options.ShowSettingsUtil

class AutoDevOpenSettingsAction : AnAction() {
override fun actionPerformed(event: AnActionEvent) {
val project = event.project ?: return
ShowSettingsUtil.getInstance().showSettingsDialog(project, AutoDevSettingsConfigurable::class.java)
}

override fun getActionUpdateThread(): ActionUpdateThread {
return ActionUpdateThread.BGT
}
}
@@ -0,0 +1,33 @@
package cc.unitmesh.devti.statusbar

import cc.unitmesh.devti.AutoDevBundle
import cc.unitmesh.devti.AutoDevIcons
import com.intellij.openapi.project.Project
import com.intellij.openapi.wm.CustomStatusBarWidget
import com.intellij.ui.ClickListener
import java.awt.event.MouseEvent
import javax.swing.JComponent
import javax.swing.JLabel
import javax.swing.SwingUtilities

class AutoDevStatusBarWidget(val project: Project) : CustomStatusBarWidget {
override fun ID(): String = "AutoDev"

override fun getComponent(): JComponent {
val jLabel = JLabel()
jLabel.icon = AutoDevIcons.DARK
jLabel.toolTipText = AutoDevBundle.message("autodev.statusbar.toolTipText")

object : ClickListener() {
override fun onClick(event: MouseEvent, clickCount: Int): Boolean {
if (SwingUtilities.isLeftMouseButton(event)) {
// todo: show popup
return true
}
return true
}
}.installOn(jLabel)

return jLabel
}
}
@@ -0,0 +1,20 @@
package cc.unitmesh.devti.statusbar

import cc.unitmesh.devti.AutoDevBundle
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.NlsContexts
import com.intellij.openapi.wm.StatusBarWidget
import com.intellij.openapi.wm.StatusBarWidgetFactory
import org.jetbrains.annotations.NonNls

class AutoDevStatusBarWidgetFactory : StatusBarWidgetFactory {
override fun getId(): @NonNls String = "AutoDev"

override fun getDisplayName(): @NlsContexts.ConfigurableName String {
return AutoDevBundle.message("autodev.statusbar.name")
}

override fun createWidget(project: Project): StatusBarWidget {
return AutoDevStatusBarWidget(project)
}
}
14 changes: 14 additions & 0 deletions src/main/resources/icons/autodev-dark.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions src/main/resources/messages/AutoDevBundle.properties
Expand Up @@ -96,4 +96,6 @@ settings.autodev.coder.explainCode=Explain code
settings.autodev.coder.refactorCode=Refactor code
settings.autodev.coder.fixIssueCode=Fix issue
settings.autodev.coder.generateTest=Generate test
autodev.statusbar.name=AutoDev Status Bar
autodev.statusbar.toolTipText=AutoDev

0 comments on commit 38b37f6

Please sign in to comment.