-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
38ee416
commit 6a30bd2
Showing
2 changed files
with
54 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
53 changes: 53 additions & 0 deletions
53
jetbrains-core/src/software/aws/toolkits/jetbrains/services/caws/CawsSpaceProjectInfo.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,53 @@ | ||
// Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package software.aws.toolkits.jetbrains.services.caws | ||
|
||
import com.intellij.openapi.project.Project | ||
import com.intellij.openapi.util.Disposer | ||
import com.intellij.openapi.wm.StatusBar | ||
import com.intellij.openapi.wm.StatusBarWidget | ||
import com.intellij.openapi.wm.StatusBarWidgetFactory | ||
import com.intellij.util.Consumer | ||
import java.awt.Component | ||
import java.awt.event.MouseEvent | ||
|
||
private const val WIDGET_ID = "CawsSpaceProjectInfo" | ||
|
||
class CawsStatusBarInstaller : StatusBarWidgetFactory { | ||
private val spaceName: String? = System.getenv(CawsConstants.CAWS_ENV_ORG_NAME_VAR) | ||
private val projectName: String? = System.getenv(CawsConstants.CAWS_ENV_PROJECT_NAME_VAR) | ||
|
||
override fun getId(): String = WIDGET_ID | ||
|
||
override fun getDisplayName(): String = "$spaceName/$projectName" | ||
|
||
override fun isAvailable(project: Project): Boolean = spaceName != null && projectName != null | ||
|
||
override fun createWidget(project: Project): StatusBarWidget = CawsSpaceProjectInfo(spaceName, projectName) | ||
|
||
override fun disposeWidget(widget: StatusBarWidget) { | ||
Disposer.dispose(widget) | ||
} | ||
|
||
override fun canBeEnabledOn(statusBar: StatusBar): Boolean = true | ||
} | ||
|
||
private class CawsSpaceProjectInfo(val spaceName: String?, val projectName: String?) : | ||
StatusBarWidget, | ||
StatusBarWidget.TextPresentation { | ||
|
||
override fun ID(): String = WIDGET_ID | ||
|
||
override fun getPresentation(): StatusBarWidget.WidgetPresentation = this | ||
|
||
override fun getTooltipText(): String = "$spaceName/$projectName" | ||
override fun getClickConsumer(): Consumer<MouseEvent>? = null | ||
|
||
override fun getText(): String = "$spaceName/$projectName" | ||
|
||
override fun getAlignment(): Float = Component.CENTER_ALIGNMENT | ||
|
||
override fun dispose() {} | ||
|
||
override fun install(statusBar: StatusBar) {} | ||
} |