Skip to content

Commit

Permalink
#331 | Added generate Diagram run line marker for Business Process an…
Browse files Browse the repository at this point in the history
…d `items.xml`
  • Loading branch information
mlytvyn authored Apr 13, 2023
1 parent 043e32d commit a63e9ec
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 6 deletions.
10 changes: 9 additions & 1 deletion resources/META-INF/optional-diagram-dependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,21 @@

<projectConfigurable id="hybris.project.diagram.ts.settings" parentId="hybris.project.settings" nonDefaultProject="true" dynamic="true"
provider="com.intellij.idea.plugin.hybris.settings.HybrisProjectDiagramTSSettingsConfigurableProvider"/>

<runLineMarkerContributor language="XML" implementationClass="com.intellij.idea.plugin.hybris.diagram.businessProcess.execution.lineMarker.ShowBPDiagramRunLineMarkerContributor"/>
<runLineMarkerContributor language="XML" implementationClass="com.intellij.idea.plugin.hybris.diagram.typeSystem.execution.lineMarker.ShowTSDiagramRunLineMarkerContributor"/>
</extensions>

<actions>
<action id="ShowBusinessProcessDiagram"
class="com.intellij.idea.plugin.hybris.diagram.businessProcess.actions.ShowBusinessProcessDiagramAction"
text="Show Business Process Diagram"
icon="com.intellij.idea.plugin.hybris.common.utils.HybrisIcons.BUSINESS_PROCESS">
</action>
<action id="ShowTypeSystemDiagram"
class="com.intellij.idea.plugin.hybris.diagram.typeSystem.actions.ShowTypeSystemDiagramAction"
text="Show Type System Diagram"
icon="AllIcons.FileTypes.Diagram">
icon="com.intellij.idea.plugin.hybris.common.utils.HybrisIcons.TYPE_SYSTEM">
<add-to-group group-id="HybrisToolsActions"/>
</action>
<action id="ShowModuleDependencyDiagram"
Expand Down
4 changes: 4 additions & 0 deletions resources/META-INF/plugin-release-info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,10 @@

<change-notes>
<![CDATA[
<h3>2023.1.5</h3>
<ul>
<li><i>Feature:</i> Added generate Diagram run line marker for Business Process and <code>items.xml</code> (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/327" target="_blank" rel="nofollow">#327</a>)</li>
</ul>
<h3>2023.1.4</h3>
<ul>
<li><i>Feature:</i> Enabled Wizard-based Project Import from the Welcome Screen (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/306" target="_blank" rel="nofollow">#306</a>)</li>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA.
* Copyright (C) 2019 EPAM Systems <[email protected]>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA.
* Copyright (C) 2019 EPAM Systems <[email protected]>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
* This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA.
* Copyright (C) 2019 EPAM Systems <[email protected]>
*
* 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 <http://www.gnu.org/licenses/>.
*/
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 }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,12 @@ import com.intellij.psi.xml.XmlFile
import com.intellij.util.xml.DomFileDescription
import javax.swing.Icon

class BpDomFileDescription : DomFileDescription<Process>(Process::class.java, HybrisConstants.BUSINESS_PROCESS_ROOT_TAG) {
class BpDomFileDescription : DomFileDescription<Process>(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)

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import com.intellij.psi.xml.XmlFile
import com.intellij.util.xml.DomFileDescription
import javax.swing.Icon

class TSDomFileDescription : DomFileDescription<Items>(Items::class.java, "items") {
class TSDomFileDescription : DomFileDescription<Items>(Items::class.java, HybrisConstants.ROOT_TAG_ITEMS_XML) {

override fun isMyFile(
file: XmlFile, module: Module?
Expand Down

0 comments on commit a63e9ec

Please sign in to comment.