From 69846db1af16eaf19c752ec34c6b1d84d282651e Mon Sep 17 00:00:00 2001 From: Mykhailo Lytvyn Date: Sat, 23 Dec 2023 13:53:15 +0100 Subject: [PATCH] Added groups icons in the Structure view --- CHANGELOG.md | 3 ++ .../structureView/TSStructureTreeElement.kt | 29 +++++++------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fd191aa6..e2a49f201 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ - Add JDK Export Properties to JUnit Tests to run Integration Tests [#864](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/864) - Load Properties from Files and Environment [#864](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/864) +### `items.xml` enhancements +- Added groups icons in the Structure view [#865](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/865) + ## [2023.3.2] ### `Project Import` enhancements diff --git a/src/com/intellij/idea/plugin/hybris/system/type/structureView/TSStructureTreeElement.kt b/src/com/intellij/idea/plugin/hybris/system/type/structureView/TSStructureTreeElement.kt index ad961ba75..b4008e5fe 100644 --- a/src/com/intellij/idea/plugin/hybris/system/type/structureView/TSStructureTreeElement.kt +++ b/src/com/intellij/idea/plugin/hybris/system/type/structureView/TSStructureTreeElement.kt @@ -94,13 +94,10 @@ class TSStructureTreeElement( private fun resolveLocationString(dom: CollectionType) = dom.type.value.toString() + (dom.elementType.stringValue?.let { " of $it" } ?: "") - private fun resolveLocationString(dom: Description): String? { - val xmlElement = dom.xmlElement - if (xmlElement is XmlTag) { - return xmlElement.value.trimmedText - } - return null - } + private fun resolveLocationString(dom: Description) = dom.xmlElement + ?.let { it as? XmlTag } + ?.value + ?.trimmedText private fun resolveLocationString(dom: Deployment) = listOfNotNull( dom.table.stringValue, @@ -159,6 +156,13 @@ class TSStructureTreeElement( override fun getIcon(open: Boolean) = when (element) { is Description -> AllIcons.Windows.Help + is AtomicTypes -> HybrisIcons.TS_GROUP_ATOMIC + is CollectionTypes -> HybrisIcons.TS_GROUP_COLLECTION + is MapTypes -> HybrisIcons.TS_GROUP_MAP + is Relations -> HybrisIcons.TS_GROUP_RELATION + is ItemTypes -> HybrisIcons.TS_GROUP_ITEM + is TypeGroup -> HybrisIcons.TS_GROUP_ITEM + is EnumTypes -> HybrisIcons.TS_GROUP_ENUM is AtomicType -> HybrisIcons.TS_ATOMIC is EnumType -> HybrisIcons.TS_ENUM is EnumValue -> HybrisIcons.TS_ENUM_VALUE @@ -174,15 +178,4 @@ class TSStructureTreeElement( else -> null } -// : Icon? { -// val dom = element -// // TODO: add icons -// if (dom is Attribute) { -// val value = resolveValue(dom.type) -// if (StringUtils.startsWith(value, TS_ATTRIBUTE_LOCALIZED_PREFIX)) { -// return HybrisIcons.LOCALIZED -// } -// } -// return null -// } } \ No newline at end of file