From a63e9ecf856d1445d121c354164fc8a3c761924c Mon Sep 17 00:00:00 2001 From: Mykhailo Lytvyn Date: Thu, 13 Apr 2023 17:01:32 +0200 Subject: [PATCH] #331 | Added generate Diagram run line marker for Business Process and `items.xml` --- .../optional-diagram-dependencies.xml | 10 ++++- resources/META-INF/plugin-release-info.xml | 4 ++ .../plugin/hybris/common/HybrisConstants.kt | 3 +- .../ShowBusinessProcessDiagramAction.kt | 32 ++++++++++++++ .../ShowBPDiagramRunLineMarkerContributor.kt | 44 +++++++++++++++++++ .../ShowTSDiagramRunLineMarkerContributor.kt | 44 +++++++++++++++++++ ...HybrisSpringProcessReferenceContributor.kt | 2 +- .../businessProcess/BpDomFileDescription.kt | 3 +- .../system/type/file/TSDomFileDescription.kt | 2 +- 9 files changed, 138 insertions(+), 6 deletions(-) create mode 100644 src/com/intellij/idea/plugin/hybris/diagram/businessProcess/actions/ShowBusinessProcessDiagramAction.kt create mode 100644 src/com/intellij/idea/plugin/hybris/diagram/businessProcess/execution/lineMarker/ShowBPDiagramRunLineMarkerContributor.kt create mode 100644 src/com/intellij/idea/plugin/hybris/diagram/typeSystem/execution/lineMarker/ShowTSDiagramRunLineMarkerContributor.kt diff --git a/resources/META-INF/optional-diagram-dependencies.xml b/resources/META-INF/optional-diagram-dependencies.xml index 7a5c95389..f70588ed8 100644 --- a/resources/META-INF/optional-diagram-dependencies.xml +++ b/resources/META-INF/optional-diagram-dependencies.xml @@ -46,13 +46,21 @@ + + + + + + icon="com.intellij.idea.plugin.hybris.common.utils.HybrisIcons.TYPE_SYSTEM"> 2023.1.5 +
    +
  • Feature: Added generate Diagram run line marker for Business Process and items.xml (#327)
  • +

2023.1.4

  • Feature: Enabled Wizard-based Project Import from the Welcome Screen (#306)
  • diff --git a/src/com/intellij/idea/plugin/hybris/common/HybrisConstants.kt b/src/com/intellij/idea/plugin/hybris/common/HybrisConstants.kt index 4246181fa..f9a8d14d5 100644 --- a/src/com/intellij/idea/plugin/hybris/common/HybrisConstants.kt +++ b/src/com/intellij/idea/plugin/hybris/common/HybrisConstants.kt @@ -67,7 +67,8 @@ object HybrisConstants { const val FLEXIBLE_SEARCH_CONSOLE_TITLE = "[y] FS Console" const val SOLR_SEARCH_CONSOLE_TITLE = "[y] Solr search" - const val BUSINESS_PROCESS_ROOT_TAG = "process" + const val ROOT_TAG_BUSINESS_PROCESS_XML = "process" + const val ROOT_TAG_ITEMS_XML = "items" const val DOT_PROJECT = ".project" const val SETTINGS_GRADLE = "settings.gradle" diff --git a/src/com/intellij/idea/plugin/hybris/diagram/businessProcess/actions/ShowBusinessProcessDiagramAction.kt b/src/com/intellij/idea/plugin/hybris/diagram/businessProcess/actions/ShowBusinessProcessDiagramAction.kt new file mode 100644 index 000000000..54557768e --- /dev/null +++ b/src/com/intellij/idea/plugin/hybris/diagram/businessProcess/actions/ShowBusinessProcessDiagramAction.kt @@ -0,0 +1,32 @@ +/* + * This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA. + * Copyright (C) 2019 EPAM Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package com.intellij.idea.plugin.hybris.diagram.businessProcess.actions + +import com.intellij.idea.plugin.hybris.actions.ActionUtils +import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramProvider +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.uml.core.actions.ShowDiagram + +class ShowBusinessProcessDiagramAction : ShowDiagram() { + + override fun update(e: AnActionEvent) { + e.presentation.isEnabledAndVisible = ActionUtils.isHybrisContext(e) + } + + override fun getForcedProvider(e: AnActionEvent) = BpDiagramProvider() +} diff --git a/src/com/intellij/idea/plugin/hybris/diagram/businessProcess/execution/lineMarker/ShowBPDiagramRunLineMarkerContributor.kt b/src/com/intellij/idea/plugin/hybris/diagram/businessProcess/execution/lineMarker/ShowBPDiagramRunLineMarkerContributor.kt new file mode 100644 index 000000000..ee602c7b9 --- /dev/null +++ b/src/com/intellij/idea/plugin/hybris/diagram/businessProcess/execution/lineMarker/ShowBPDiagramRunLineMarkerContributor.kt @@ -0,0 +1,44 @@ +/* + * This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA. + * Copyright (C) 2019 EPAM Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package com.intellij.idea.plugin.hybris.diagram.businessProcess.execution.lineMarker + +import com.intellij.execution.lineMarker.RunLineMarkerContributor +import com.intellij.icons.AllIcons +import com.intellij.idea.plugin.hybris.common.HybrisConstants +import com.intellij.idea.plugin.hybris.system.businessProcess.model.Process +import com.intellij.openapi.actionSystem.ActionManager +import com.intellij.psi.PsiElement +import com.intellij.psi.xml.XmlFile +import com.intellij.psi.xml.XmlTag +import com.intellij.psi.xml.XmlToken +import com.intellij.util.xml.DomManager + +class ShowBPDiagramRunLineMarkerContributor : RunLineMarkerContributor() { + + override fun getInfo(element: PsiElement): Info? { + if (element !is XmlToken) return null + if (element.parent !is XmlTag) return null + val xmlFile = element.containingFile as? XmlFile ?: return null + + if (element.text != HybrisConstants.ROOT_TAG_BUSINESS_PROCESS_XML) return null + if (DomManager.getDomManager(xmlFile.project).getFileElement(xmlFile, Process::class.java) == null) return null + + val action = ActionManager.getInstance().getAction("ShowBusinessProcessDiagram") ?: return null + return Info(AllIcons.FileTypes.Diagram, arrayOf(action)) { action.templateText } + } +} diff --git a/src/com/intellij/idea/plugin/hybris/diagram/typeSystem/execution/lineMarker/ShowTSDiagramRunLineMarkerContributor.kt b/src/com/intellij/idea/plugin/hybris/diagram/typeSystem/execution/lineMarker/ShowTSDiagramRunLineMarkerContributor.kt new file mode 100644 index 000000000..df14c42e5 --- /dev/null +++ b/src/com/intellij/idea/plugin/hybris/diagram/typeSystem/execution/lineMarker/ShowTSDiagramRunLineMarkerContributor.kt @@ -0,0 +1,44 @@ +/* + * This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA. + * Copyright (C) 2019 EPAM Systems + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + */ +package com.intellij.idea.plugin.hybris.diagram.typeSystem.execution.lineMarker + +import com.intellij.execution.lineMarker.RunLineMarkerContributor +import com.intellij.icons.AllIcons +import com.intellij.idea.plugin.hybris.common.HybrisConstants +import com.intellij.idea.plugin.hybris.system.type.model.Items +import com.intellij.openapi.actionSystem.ActionManager +import com.intellij.psi.PsiElement +import com.intellij.psi.xml.XmlFile +import com.intellij.psi.xml.XmlTag +import com.intellij.psi.xml.XmlToken +import com.intellij.util.xml.DomManager + +class ShowTSDiagramRunLineMarkerContributor : RunLineMarkerContributor() { + + override fun getInfo(element: PsiElement): Info? { + if (element !is XmlToken) return null + if (element.parent !is XmlTag) return null + val xmlFile = element.containingFile as? XmlFile ?: return null + + if (element.text != HybrisConstants.ROOT_TAG_ITEMS_XML) return null + if (DomManager.getDomManager(xmlFile.project).getFileElement(xmlFile, Items::class.java) == null) return null + + val action = ActionManager.getInstance().getAction("ShowTypeSystemDiagram") ?: return null + return Info(AllIcons.FileTypes.Diagram, arrayOf(action)) { action.templateText } + } +} diff --git a/src/com/intellij/idea/plugin/hybris/psi/reference/contributor/HybrisSpringProcessReferenceContributor.kt b/src/com/intellij/idea/plugin/hybris/psi/reference/contributor/HybrisSpringProcessReferenceContributor.kt index 104fdfc1c..e1df9da7d 100644 --- a/src/com/intellij/idea/plugin/hybris/psi/reference/contributor/HybrisSpringProcessReferenceContributor.kt +++ b/src/com/intellij/idea/plugin/hybris/psi/reference/contributor/HybrisSpringProcessReferenceContributor.kt @@ -31,7 +31,7 @@ class HybrisSpringProcessReferenceContributor : PsiReferenceContributor() { override fun registerReferenceProviders(registrar: PsiReferenceRegistrar) { registrar.registerReferenceProvider( - tagAttributeValuePattern(HybrisConstants.BUSINESS_PROCESS_ROOT_TAG, "action", "bean"), + tagAttributeValuePattern(HybrisConstants.ROOT_TAG_BUSINESS_PROCESS_XML, "action", "bean"), HybrisSpringProcessReferenceProvider.instance ) diff --git a/src/com/intellij/idea/plugin/hybris/system/businessProcess/BpDomFileDescription.kt b/src/com/intellij/idea/plugin/hybris/system/businessProcess/BpDomFileDescription.kt index 29345d292..82e21f1c9 100644 --- a/src/com/intellij/idea/plugin/hybris/system/businessProcess/BpDomFileDescription.kt +++ b/src/com/intellij/idea/plugin/hybris/system/businessProcess/BpDomFileDescription.kt @@ -27,13 +27,12 @@ import com.intellij.psi.xml.XmlFile import com.intellij.util.xml.DomFileDescription import javax.swing.Icon -class BpDomFileDescription : DomFileDescription(Process::class.java, HybrisConstants.BUSINESS_PROCESS_ROOT_TAG) { +class BpDomFileDescription : DomFileDescription(Process::class.java, HybrisConstants.ROOT_TAG_BUSINESS_PROCESS_XML) { override fun getFileIcon(flags: Int): Icon = HybrisIcons.BUSINESS_PROCESS override fun isMyFile(file: XmlFile, module: Module?) = super.isMyFile(file, module) && (module != null || ModuleUtil.projectContainsFile(file.project, file.virtualFile, true)) - && super.isMyFile(file, module) && CommonIdeaService.getInstance().isHybrisProject(file.project) } \ No newline at end of file diff --git a/src/com/intellij/idea/plugin/hybris/system/type/file/TSDomFileDescription.kt b/src/com/intellij/idea/plugin/hybris/system/type/file/TSDomFileDescription.kt index bbef8f308..370f8815b 100644 --- a/src/com/intellij/idea/plugin/hybris/system/type/file/TSDomFileDescription.kt +++ b/src/com/intellij/idea/plugin/hybris/system/type/file/TSDomFileDescription.kt @@ -28,7 +28,7 @@ import com.intellij.psi.xml.XmlFile import com.intellij.util.xml.DomFileDescription import javax.swing.Icon -class TSDomFileDescription : DomFileDescription(Items::class.java, "items") { +class TSDomFileDescription : DomFileDescription(Items::class.java, HybrisConstants.ROOT_TAG_ITEMS_XML) { override fun isMyFile( file: XmlFile, module: Module?