diff --git a/plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties b/plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties index f7ab0a1ef79..dfedb8023e4 100644 --- a/plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties +++ b/plugins/core/resources/resources/software/aws/toolkits/resources/MessagesBundle.properties @@ -573,6 +573,8 @@ cloudformation.explorer.stacks.load_more_stacks=Load More Stacks cloudformation.explorer.stacks.node_name=Stacks cloudformation.explorer.stacks.refresh=Refresh Stacks cloudformation.explorer.tab.title=CloudFormation +cloudformation.explorer.try_new_panel=Try the new CloudFormation panel +cloudformation.explorer.try_new_panel.tooltip=Double-click to open the CloudFormation panel cloudformation.invalid_property=Property {0} has invalid value {1} cloudformation.key_not_found={0} not found on resource {1} cloudformation.lsp.action.configure_node=Configure Node.js diff --git a/plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/explorer/DefaultAwsExplorerTreeStructureProvider.kt b/plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/explorer/DefaultAwsExplorerTreeStructureProvider.kt index e88334b7be4..c2244ee825f 100644 --- a/plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/explorer/DefaultAwsExplorerTreeStructureProvider.kt +++ b/plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/core/explorer/DefaultAwsExplorerTreeStructureProvider.kt @@ -6,7 +6,14 @@ package software.aws.toolkits.jetbrains.core.explorer import com.intellij.ide.util.treeView.AbstractTreeNode class DefaultAwsExplorerTreeStructureProvider : AwsExplorerTreeStructureProvider() { - // By default sort the children in alphabetical order override fun modify(parent: AbstractTreeNode<*>, children: MutableCollection>): MutableCollection> = - children.sortedWith(compareBy(String.CASE_INSENSITIVE_ORDER) { it.toString() }).toMutableList() + children.sortedWith( + compareBy> { it !is PinnedFirstNode } + .thenComparing(compareBy(String.CASE_INSENSITIVE_ORDER) { it.toString() }) + ).toMutableList() } + +/** + * Marker interface for nodes that should always appear first in alphabetically sorted lists. + */ +interface PinnedFirstNode diff --git a/plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/cloudformation/CloudFormationExplorerNodes.kt b/plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/cloudformation/CloudFormationExplorerNodes.kt index d082139f548..b6be703c303 100644 --- a/plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/cloudformation/CloudFormationExplorerNodes.kt +++ b/plugins/toolkit/jetbrains-core/src/software/aws/toolkits/jetbrains/services/cloudformation/CloudFormationExplorerNodes.kt @@ -3,19 +3,29 @@ package software.aws.toolkits.jetbrains.services.cloudformation +import com.intellij.icons.AllIcons +import com.intellij.ide.projectView.PresentationData import com.intellij.openapi.project.Project +import com.intellij.ui.SimpleTextAttributes +import com.intellij.ui.treeStructure.Tree +import com.intellij.util.ui.UIUtil +import com.intellij.util.ui.tree.TreeUtil import icons.AwsIcons import software.amazon.awssdk.services.cloudformation.CloudFormationClient import software.amazon.awssdk.services.cloudformation.model.StackStatus import software.amazon.awssdk.services.cloudformation.model.StackSummary import software.aws.toolkit.jetbrains.utils.toHumanReadable +import software.aws.toolkits.jetbrains.core.explorer.AwsToolkitExplorerToolWindow +import software.aws.toolkits.jetbrains.core.explorer.PinnedFirstNode +import software.aws.toolkits.jetbrains.core.explorer.ToolkitToolWindowTab import software.aws.toolkits.jetbrains.core.explorer.nodes.AwsExplorerNode import software.aws.toolkits.jetbrains.core.explorer.nodes.AwsExplorerResourceNode import software.aws.toolkits.jetbrains.core.explorer.nodes.AwsExplorerServiceNode import software.aws.toolkits.jetbrains.core.explorer.nodes.CacheBackedAwsExplorerServiceRootNode import software.aws.toolkits.jetbrains.services.cloudformation.resources.CloudFormationResources import software.aws.toolkits.jetbrains.services.cloudformation.stack.StackWindowManager -import software.aws.toolkits.resources.message +import software.aws.toolkits.resources.AwsToolkitBundle.message +import javax.swing.JComponent class CloudFormationServiceNode(project: Project, service: AwsExplorerServiceNode) : CacheBackedAwsExplorerServiceRootNode( project, @@ -24,6 +34,17 @@ class CloudFormationServiceNode(project: Project, service: AwsExplorerServiceNod ) { override fun displayName(): String = message("explorer.node.cloudformation") override fun toNode(child: StackSummary): AwsExplorerNode<*> = CloudFormationStackNode(nodeProject, child.stackName(), child.stackStatus(), child.stackId()) + + override fun getChildren(): List> { + val hasCfnPanel = ToolkitToolWindowTab.EP_NAME.extensionList.any { + it.tabId == message("cloudformation.explorer.tab.title") && it.enabled() + } + return if (hasCfnPanel) { + listOf(TryCloudFormationPanelNode(nodeProject)) + super.getChildren() + } else { + super.getChildren() + } + } } class CloudFormationStackNode( @@ -49,3 +70,32 @@ class CloudFormationStackNode( StackWindowManager.getInstance(nodeProject).openStack(stackName, stackId) } } + +class TryCloudFormationPanelNode(project: Project) : + AwsExplorerNode(project, "try-cfn-panel", AllIcons.Nodes.Favorite), PinnedFirstNode { + + override fun getChildren(): List> = emptyList() + + override fun isAlwaysLeaf(): Boolean = true + + override fun displayName(): String = message("cloudformation.explorer.try_new_panel") + + override fun update(presentation: PresentationData) { + presentation.setIcon(AllIcons.Nodes.Favorite) + presentation.addText(displayName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES) + presentation.tooltip = message("cloudformation.explorer.try_new_panel.tooltip") + } + + override fun onDoubleClick() { + val toolWindow = AwsToolkitExplorerToolWindow.toolWindow(nodeProject) + toolWindow.activate { + val explorerWindow = AwsToolkitExplorerToolWindow.getInstance(nodeProject) + val tabComponent = explorerWindow.selectTab(message("cloudformation.explorer.tab.title")) + (tabComponent as? JComponent)?.let { component -> + UIUtil.findComponentOfType(component, Tree::class.java)?.let { tree -> + TreeUtil.expand(tree, 1) + } + } + } + } +}