44package software.aws.toolkits.jetbrains.core.explorer.devToolsTab.nodes.actions
55
66import com.intellij.icons.AllIcons
7- import com.intellij.openapi.actionSystem.ActionManager
8- import com.intellij.openapi.actionSystem.AnAction
97import com.intellij.openapi.actionSystem.AnActionEvent
108import com.intellij.openapi.actionSystem.CommonDataKeys
11- import com.intellij.openapi.actionSystem.ComputableActionGroup
9+ import com.intellij.openapi.actionSystem.DefaultActionGroup
1210import com.intellij.openapi.ide.CopyPasteManager
1311import com.intellij.openapi.progress.ProgressIndicator
1412import com.intellij.openapi.progress.Task
@@ -31,32 +29,34 @@ class CopyCawsRepositoryUrl : DumbAwareAction(AllIcons.Actions.Copy) {
3129 val project = e.getRequiredData(CommonDataKeys .PROJECT )
3230 val cawsConnectionSettings = CodeCatalystCredentialManager .getInstance(project).getConnectionSettings() ? : return
3331
34- JBPopupFactory .getInstance().createActionGroupPopup(
35- message(" caws.copy.url.select_repository" ),
36- object : ComputableActionGroup .Simple () {
37- override fun computeChildren (manager : ActionManager ): Array <AnAction > {
38- val cache = AwsResourceCache .getInstance()
39- return runBlocking {
40- val projects = cache.getResource(CawsResources .ALL_PROJECTS , cawsConnectionSettings).await()
32+ val cache = AwsResourceCache .getInstance()
33+ val actions = runBlocking {
34+ val projects = cache.getResource(CawsResources .ALL_PROJECTS , cawsConnectionSettings).await()
4135
42- projects.flatMap { cawsProject ->
43- cache.getResource(CawsResources .codeRepositories(cawsProject), cawsConnectionSettings).await()
44- }.map {
45- object : DumbAwareAction (it.presentableString) {
46- override fun actionPerformed (e : AnActionEvent ) {
47- copyUrl(project, cawsConnectionSettings, it)
48- }
49- }
50- }.toTypedArray()
36+ projects.flatMap { cawsProject ->
37+ cache.getResource(CawsResources .codeRepositories(cawsProject), cawsConnectionSettings).await()
38+ }.map {
39+ object : DumbAwareAction (it.presentableString) {
40+ override fun actionPerformed (e : AnActionEvent ) {
41+ copyUrl(project, cawsConnectionSettings, it)
5142 }
5243 }
53- },
44+ }.toList()
45+ }
46+
47+ val actionGroup = DefaultActionGroup ().apply {
48+ actions.forEach { add(it) }
49+ }
50+
51+ val popup = JBPopupFactory .getInstance().createActionGroupPopup(
52+ message(" caws.copy.url.select_repository" ),
53+ actionGroup,
5454 e.dataContext,
5555 false ,
5656 null ,
5757 5
5858 )
59- .showInBestPositionFor(e.dataContext )
59+ popup.showCenteredInCurrentWindow(project )
6060 }
6161
6262 private fun copyUrl (project : Project , cawsConnectionSettings : ClientConnectionSettings <* >, repository : CawsCodeRepository ) {
0 commit comments