Skip to content

Commit 6a30bd2

Browse files
authored
Provided displaying spaceName/projectName on statusBar of MDE (#3506)
* Provided displaying spaceName/projectName on statusBar of MDE * Addressed PR comments * Addressed PR comments * Feedback comments * Replaced with TextPresentation * PR comments * Addressed feedback comment
1 parent 38ee416 commit 6a30bd2

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

jetbrains-core/resources/META-INF/plugin.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ with what features/services are supported.
233233

234234
<statusBarWidgetFactory implementation="software.aws.toolkits.jetbrains.core.credentials.AwsSettingsPanelInstaller"/>
235235
<statusBarWidgetFactory implementation="software.aws.toolkits.jetbrains.services.codewhisperer.status.CodeWhispererStatusBarWidgetFactory"/>
236+
<statusBarWidgetFactory implementation="software.aws.toolkits.jetbrains.services.caws.CawsStatusBarInstaller"/>
236237

237238
<postStartupActivity implementation="software.aws.toolkits.jetbrains.core.AwsTelemetryPrompter"/>
238239
<postStartupActivity implementation="software.aws.toolkits.jetbrains.core.executables.ExecutableLoader"/>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
2+
// SPDX-License-Identifier: Apache-2.0
3+
package software.aws.toolkits.jetbrains.services.caws
4+
5+
import com.intellij.openapi.project.Project
6+
import com.intellij.openapi.util.Disposer
7+
import com.intellij.openapi.wm.StatusBar
8+
import com.intellij.openapi.wm.StatusBarWidget
9+
import com.intellij.openapi.wm.StatusBarWidgetFactory
10+
import com.intellij.util.Consumer
11+
import java.awt.Component
12+
import java.awt.event.MouseEvent
13+
14+
private const val WIDGET_ID = "CawsSpaceProjectInfo"
15+
16+
class CawsStatusBarInstaller : StatusBarWidgetFactory {
17+
private val spaceName: String? = System.getenv(CawsConstants.CAWS_ENV_ORG_NAME_VAR)
18+
private val projectName: String? = System.getenv(CawsConstants.CAWS_ENV_PROJECT_NAME_VAR)
19+
20+
override fun getId(): String = WIDGET_ID
21+
22+
override fun getDisplayName(): String = "$spaceName/$projectName"
23+
24+
override fun isAvailable(project: Project): Boolean = spaceName != null && projectName != null
25+
26+
override fun createWidget(project: Project): StatusBarWidget = CawsSpaceProjectInfo(spaceName, projectName)
27+
28+
override fun disposeWidget(widget: StatusBarWidget) {
29+
Disposer.dispose(widget)
30+
}
31+
32+
override fun canBeEnabledOn(statusBar: StatusBar): Boolean = true
33+
}
34+
35+
private class CawsSpaceProjectInfo(val spaceName: String?, val projectName: String?) :
36+
StatusBarWidget,
37+
StatusBarWidget.TextPresentation {
38+
39+
override fun ID(): String = WIDGET_ID
40+
41+
override fun getPresentation(): StatusBarWidget.WidgetPresentation = this
42+
43+
override fun getTooltipText(): String = "$spaceName/$projectName"
44+
override fun getClickConsumer(): Consumer<MouseEvent>? = null
45+
46+
override fun getText(): String = "$spaceName/$projectName"
47+
48+
override fun getAlignment(): Float = Component.CENTER_ALIGNMENT
49+
50+
override fun dispose() {}
51+
52+
override fun install(statusBar: StatusBar) {}
53+
}

0 commit comments

Comments
 (0)