generated from JetBrains/intellij-platform-plugin-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(statusbar): add AutoDev status bar widget factory
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
Showing
7 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
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
18 changes: 18 additions & 0 deletions
18
src/main/kotlin/cc/unitmesh/devti/actions/AutoDevOpenSettingsAction.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,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 | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
src/main/kotlin/cc/unitmesh/devti/statusbar/AutoDevStatusBarWidget.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,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 | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
src/main/kotlin/cc/unitmesh/devti/statusbar/AutoDevStatusBarWidgetFactory.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,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) | ||
} | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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