Skip to content

Commit

Permalink
#287 | Added Context Parameters node for Business Process Diagram
Browse files Browse the repository at this point in the history
  • Loading branch information
mlytvyn authored Mar 17, 2023
1 parent 5517b43 commit fd18a54
Show file tree
Hide file tree
Showing 26 changed files with 293 additions and 96 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ intellij.update.since.until.build=true

intellij.plugin.name=SAP-Commerce-Developers-Toolset
intellij.plugin.version=2023.1.2
intellij.plugin.since.build=231.8109.2
intellij.plugin.since.build=231.8109.90
intellij.plugin.until.build=231.*

intellij.type=IU
Expand All @@ -27,7 +27,7 @@ intellij.download.sources=true
# https://github.com/JetBrains/gradle-intellij-plugin#plugin-verifier-dsl
# See https://jb.gg/intellij-platform-builds-list for available build versions
# EAP snapshots -> https://www.jetbrains.com/intellij-repository/snapshots
plugin.verifier.ide.versions=IU-231.8109.2
plugin.verifier.ide.versions=IU-231.8109.90

# Plugin Dependencies -> https://www.jetbrains.org/intellij/sdk/docs/basics/plugin_structure/plugin_dependencies.html
# Platform explorer (Plugin) -> https://plugins.jetbrains.com/intellij-platform-explorer/extensions
Expand Down
11 changes: 8 additions & 3 deletions resources/META-INF/plugin-release-info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,16 @@
<li><i>Feature:</i> Added Legend MD file (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/279" target="_blank" rel="nofollow">#279</a>)</li>
</ul>
</li>
<li>Business Process Diagrams Improvements
<ul>
<li><i>Feature:</i> Added node properties (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/267" target="_blank" rel="nofollow">#267</a>)</li>
<li><i>Feature:</i> Added edge coloring (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/265" target="_blank" rel="nofollow">#265</a>)</li>
<li><i>Feature:</i> Added cycle edges coloring (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/266" target="_blank" rel="nofollow">#266</a>)</li>
<li><i>Feature:</i> Added Context Parameters node (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/283" target="_blank" rel="nofollow">#283</a>)</li>
</ul>
</li>
<li><i>Feature:</i> Added navigation to generated Item and Enum classes from the <code>items.xml</code> (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/284" target="_blank" rel="nofollow">#284</a>)</li>
<li><i>Feature:</i> Added navigation to generated Enum Values fields from the <code>items.xml</code> (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/285" target="_blank" rel="nofollow">#285</a>)</li>
<li><i>Feature:</i> Added node properties for Business Process Diagrams (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/267" target="_blank" rel="nofollow">#267</a>)</li>
<li><i>Feature:</i> Added edges coloring for Business Process Diagrams (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/265" target="_blank" rel="nofollow">#265</a>)</li>
<li><i>Feature:</i> Added cycle edges coloring for Business Process Diagrams (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/266" target="_blank" rel="nofollow">#266</a>)</li>
<li><i>Feature:</i> Improved PSI cache usage (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/258" target="_blank" rel="nofollow">#258</a>)</li>
<li><i>Feature:</i> Improved performance of the Global Meta Model and TS LineMarker (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/257" target="_blank" rel="nofollow">#257</a>)</li>
<li><i>Feature:</i> IDEA modules by default will be stored in the <code>/.idea/idea-modules</code> (<a href="https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/259" target="_blank" rel="nofollow">#259</a>)</li>
Expand Down
1 change: 1 addition & 0 deletions resources/colorSchemes/HybrisDiagramDarcula.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<option name="BP_DIAGRAM_EDGE_CYCLE" value="9407ED"/>
<option name="BP_DIAGRAM_EDGE_CANCEL" value="F78058"/>
<option name="BP_DIAGRAM_EDGE_DEFAULT" value="9B9EA1"/>
<option name="BP_DIAGRAM_EDGE_PARAMETERS" value="88FFCC"/>

<!-- Module Dependencies Diagram -->
<!-- EDGES -->
Expand Down
1 change: 1 addition & 0 deletions resources/colorSchemes/HybrisDiagramDefault.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<option name="BP_DIAGRAM_EDGE_CYCLE" value="9407ED"/>
<option name="BP_DIAGRAM_EDGE_CANCEL" value="F78058"/>
<option name="BP_DIAGRAM_EDGE_DEFAULT" value="474747"/>
<option name="BP_DIAGRAM_EDGE_PARAMETERS" value="005765"/>

<!-- Module Dependencies Diagram -->
<!-- EDGES -->
Expand Down
28 changes: 15 additions & 13 deletions src/com/intellij/idea/plugin/hybris/common/utils/HybrisIcons.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,6 @@ private HybrisIcons() {
public static final Icon EXTENSION_EXT = getIcon("/icons/extension/ext.svg");
public static final Icon EXTENSION_OOTB = HYBRIS;

public static final Icon BP_DIAGRAM_WAIT = getIcon("/icons/businessProcess/diagram/wait.svg");
public static final Icon BP_DIAGRAM_END = getIcon("/icons/businessProcess/diagram/end.svg");
public static final Icon BP_DIAGRAM_NOTIFY = getIcon("/icons/businessProcess/diagram/notify.svg");
public static final Icon BP_DIAGRAM_ACTION = getIcon("/icons/businessProcess/diagram/action.svg");
public static final Icon BP_DIAGRAM_SPLIT = getIcon("/icons/businessProcess/diagram/split.svg");
public static final Icon BP_DIAGRAM_JOIN = getIcon("/icons/businessProcess/diagram/join.svg");
public static final Icon BP_DIAGRAM_SCRIPT = getIcon("/icons/businessProcess/diagram/script.svg");

public static final Icon TYPE_SYSTEM = getIcon("/icons/typeSystem.svg");
public static final Icon SPRING_BEAN = getIcon("icons/springBean.svg");
public static final Icon LOCALIZED = getIcon("/icons/localized.svg");
Expand Down Expand Up @@ -112,14 +104,24 @@ private HybrisIcons() {
public static final Icon BS_ENUM = getIcon("/icons/beanSystem/enum.svg");
public static final Icon BS_ENUM_VALUE = getIcon("/icons/beanSystem/enumValue.svg");

public static final Icon BS_DIAGRAM_PROPERTY = BS_PROPERTY;
public static final Icon BS_DIAGRAM_SPRING_BEAN = SPRING_BEAN;
public static final Icon BS_DIAGRAM_NODE = AllIcons.Nodes.FieldPK;
public static final Icon BS_DIAGRAM_FIELD = AllIcons.Nodes.Field;
public static final Icon BP_DIAGRAM_WAIT = getIcon("/icons/businessProcess/diagram/wait.svg");
public static final Icon BP_DIAGRAM_END = getIcon("/icons/businessProcess/diagram/end.svg");
public static final Icon BP_DIAGRAM_NOTIFY = getIcon("/icons/businessProcess/diagram/notify.svg");
public static final Icon BP_DIAGRAM_ACTION = getIcon("/icons/businessProcess/diagram/action.svg");
public static final Icon BP_DIAGRAM_SPLIT = getIcon("/icons/businessProcess/diagram/split.svg");
public static final Icon BP_DIAGRAM_JOIN = getIcon("/icons/businessProcess/diagram/join.svg");
public static final Icon BP_DIAGRAM_SCRIPT = getIcon("/icons/businessProcess/diagram/script.svg");
public static final Icon BP_DIAGRAM_PARAMETERS = AllIcons.Nodes.NewParameter;
public static final Icon BP_DIAGRAM_PROPERTY = BS_PROPERTY;
public static final Icon BP_DIAGRAM_SPRING_BEAN = SPRING_BEAN;
public static final Icon BP_DIAGRAM_NODE = AllIcons.Nodes.FieldPK;
public static final Icon BP_DIAGRAM_FIELD = AllIcons.Nodes.Field;
public static final Icon BP_DIAGRAM_CLASS = AllIcons.Nodes.Class;
public static final Icon BP_DIAGRAM_PARAMETER_REQUIRED = AllIcons.Nodes.Plugin;
public static final Icon BP_DIAGRAM_PARAMETER_OPTIONAL = AllIcons.Nodes.Pluginobsolete;

public static final Icon TS_DIAGRAM_PROPERTY = AllIcons.Nodes.Property;
public static final Icon TS_DIAGRAM_DEPLOYMENT = AllIcons.Debugger.Db_db_object;

public static final Icon TS_DIAGRAM_RESET_VIEW = getIcon("/icons/typeSystem/diagram/resetView.svg");
public static final Icon TS_DIAGRAM_SETTINGS = getIcon("/icons/typeSystem/diagram/settings.svg");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramColors.E
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramColors.EDGE_DEFAULT
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramColors.EDGE_NOK
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramColors.EDGE_OK
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramColors.EDGE_PARAMETERS
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramColors.EDGE_PARTIAL
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramColors.EDGE_START
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramColors.EDGE_TIMEOUT
Expand All @@ -45,6 +46,7 @@ class BpDiagramColorManager : DiagramColorManagerBase() {
BpDiagramEdgeType.PARTIAL -> EDGE_PARTIAL
BpDiagramEdgeType.CYCLE -> EDGE_CYCLE
BpDiagramEdgeType.TIMEOUT -> EDGE_TIMEOUT
BpDiagramEdgeType.PARAMETERS -> EDGE_PARAMETERS
else -> EDGE_DEFAULT
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ object BpDiagramColors {
val EDGE_CYCLE = createColorKeyWithFallback("BP_DIAGRAM_EDGE_CYCLE", DiagramColors.DEFAULT_EDGE)
val EDGE_CANCEL = createColorKeyWithFallback("BP_DIAGRAM_EDGE_CANCEL", DiagramColors.DEFAULT_EDGE)
val EDGE_DEFAULT = createColorKeyWithFallback("BP_DIAGRAM_EDGE_DEFAULT", DiagramColors.DEFAULT_EDGE)
val EDGE_PARAMETERS = createColorKeyWithFallback("BP_DIAGRAM_EDGE_PARAMETERS", DiagramColors.DEFAULT_EDGE)
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import com.intellij.diagram.AbstractDiagramElementManager
import com.intellij.diagram.DiagramBuilder
import com.intellij.idea.plugin.hybris.actions.ActionUtils
import com.intellij.idea.plugin.hybris.common.utils.HybrisIcons
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphFactory
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphFieldParameter
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNode
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.*
import com.intellij.idea.plugin.hybris.system.businessProcess.model.Action
import com.intellij.idea.plugin.hybris.system.businessProcess.model.ParameterUse
import com.intellij.idea.plugin.hybris.system.businessProcess.model.Process
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.ui.SimpleColoredText
Expand All @@ -43,26 +43,33 @@ class BpDiagramElementManager : AbstractDiagramElementManager<BpGraphNode>() {

override fun isAcceptableAsNode(o: Any?) = o is BpGraphNode
override fun getElementTitle(t: BpGraphNode) = t.name
override fun getNodeTooltip(t: BpGraphNode) = t.name
override fun getNodeTooltip(t: BpGraphNode) = null
override fun getNodeItems(parent: BpGraphNode?): Array<out Any> = parent?.properties ?: emptyArray()

override fun getItemName(nodeElement: BpGraphNode?, nodeItem: Any?, builder: DiagramBuilder) = when (nodeItem) {
is BpGraphFieldParameter -> SimpleColoredText(nodeItem.name, SimpleTextAttributes.REGULAR_ATTRIBUTES)
is BpGraphField -> SimpleColoredText(nodeItem.name, SimpleTextAttributes.REGULAR_ATTRIBUTES)
else -> null
}

override fun getItemType(element: Any?) = when (element) {
is BpGraphFieldContextParameter -> SimpleColoredText(element.type, SimpleTextAttributes.REGULAR_ATTRIBUTES)
is BpGraphFieldParameter -> SimpleColoredText(element.value, SimpleTextAttributes.REGULAR_ATTRIBUTES)
else -> null
}

override fun getItemIcon(nodeElement: BpGraphNode?, nodeItem: Any?, builder: DiagramBuilder?) = when (nodeItem) {
is BpGraphFieldParameter -> when (nodeItem.name) {
Action.BEAN -> HybrisIcons.BS_DIAGRAM_SPRING_BEAN
Action.NODE -> HybrisIcons.BS_DIAGRAM_NODE
Action.NODE_GROUP -> HybrisIcons.BS_DIAGRAM_NODE
Action.CAN_JOIN_PREVIOUS_NODE -> HybrisIcons.BS_DIAGRAM_FIELD
else -> HybrisIcons.BS_DIAGRAM_PROPERTY
is BpGraphFieldContextParameter -> when (nodeItem.use) {
ParameterUse.REQUIRED -> HybrisIcons.BP_DIAGRAM_PARAMETER_REQUIRED
else -> HybrisIcons.BP_DIAGRAM_PARAMETER_OPTIONAL
}
is BpGraphField -> when (nodeItem.name) {
Action.BEAN -> HybrisIcons.BP_DIAGRAM_SPRING_BEAN
Action.NODE -> HybrisIcons.BP_DIAGRAM_NODE
Action.NODE_GROUP -> HybrisIcons.BP_DIAGRAM_NODE
Action.CAN_JOIN_PREVIOUS_NODE -> HybrisIcons.BP_DIAGRAM_FIELD
Process.DEFAULT_NODE_GROUP -> HybrisIcons.BP_DIAGRAM_NODE
Process.PROCESS_CLASS -> HybrisIcons.BP_DIAGRAM_CLASS
else -> HybrisIcons.BP_DIAGRAM_PROPERTY
}

else -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,17 @@ import com.intellij.diagram.DiagramBuilder
import com.intellij.diagram.DiagramCategory
import com.intellij.icons.AllIcons
import com.intellij.idea.plugin.hybris.common.utils.HybrisI18NBundleUtils.message
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphFieldContextParameter
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphFieldParameter

class BpDiagramNodeContentManager : AbstractDiagramNodeContentManager() {

override fun getContentCategories() = CATEGORIES

override fun isInCategory(nodeElement: Any?, item: Any?, category: DiagramCategory, builder: DiagramBuilder?) = when (nodeElement) {
override fun isInCategory(nodeElement: Any?, item: Any?, category: DiagramCategory, builder: DiagramBuilder?) = when (item) {
is BpGraphFieldContextParameter -> category == PARAMETERS
is BpGraphFieldParameter -> category == PARAMETERS
else -> super.isInCategory(nodeElement, item, category, builder)
else -> false
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@ package com.intellij.idea.plugin.hybris.diagram.businessProcess.impl

import com.intellij.idea.plugin.hybris.common.utils.HybrisI18NBundleUtils.message
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpGraphService
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphFactory
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNode
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNodeRoot
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.*
import com.intellij.idea.plugin.hybris.system.businessProcess.model.*
import org.apache.commons.collections4.CollectionUtils

Expand Down Expand Up @@ -50,11 +48,25 @@ class BpGraphServiceImpl : BpGraphService {
?.let { nodesMap[it] }
?.let { rootGraphNode.transitions["On Error"] = it }

return nodesMap
val contextParametersNode = rootGraphNode.process.contextParameters
.filter { it.name.stringValue != null && it.type.stringValue != null }
.map {
BpGraphFieldContextParameter(it.name.stringValue!!, it.type.stringValue!!, it.use.value ?: ParameterUse.OPTIONAL)
}
.takeIf { it.isNotEmpty() }
?.let { BpGraphFactory.buildNode("Context Parameters", rootGraphNode, it.toTypedArray()) }

return if (contextParametersNode == null) nodesMap
else {
val mutableNodes: MutableMap<String, BpGraphNode> = nodesMap.toMutableMap()
mutableNodes["Context Parameters"] = contextParametersNode

mutableNodes
}
}

private fun populateNodesTransitions(
nodesMap: Map<String, BpGraphNode>,
nodesMap: Map<String, BpGraphNodeNavigable>,
nodes: List<NavigableElement>
) {
nodes.forEach {
Expand All @@ -75,15 +87,15 @@ class BpGraphServiceImpl : BpGraphService {

is Notify -> mapOf("" to navigableElement.then.stringValue)

is ScriptAction -> navigableElement.transitions
.associate { (it.name.stringValue ?: "") to it.to.stringValue }

is Action -> navigableElement.transitions
.associate { (it.name.stringValue ?: "") to it.to.stringValue }

is Split -> navigableElement.targetNodes
.associate { (it.name.stringValue ?: "") to it.name.stringValue }

is ScriptAction -> navigableElement.transitions
.associate { (it.name.stringValue ?: "") to it.to.stringValue }

is Wait -> {
val transitions = mutableMapOf(
"" to navigableElement.then.stringValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.intellij.diagram.DiagramProvider
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpGraphService
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphFactory
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNode
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNodeNavigable
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNodeRoot
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.ModificationTracker
Expand Down Expand Up @@ -61,11 +62,16 @@ class BpDiagramDataModel(

nodesMap[rootBpGraphNode.name] = BpDiagramNode(rootBpGraphNode, provider)

nodesMap["Context Parameters"]
?.let { BpGraphFactory.buildEdge("parameters", nodesMap[rootBpGraphNode.name]!!, it) }
?.let { edges.add(it) }

nodesMap.values
.filter { it.identifyingElement is BpGraphNodeNavigable }
.forEach { targetBpDiagramFileNode ->
val sourceBpGraphNode = targetBpDiagramFileNode.identifyingElement

sourceBpGraphNode.transitions
(sourceBpGraphNode as BpGraphNodeNavigable).transitions
.forEach { (transitionName, targetBpGraphNode) ->
nodesMap[targetBpGraphNode.name]
?.let { sourceBpDiagramFileNode -> BpGraphFactory.buildEdge(transitionName, sourceBpDiagramFileNode, targetBpDiagramFileNode) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ enum class BpDiagramEdgeType {
PARTIAL,
CYCLE,
TIMEOUT,
PARAMETERS,
DEFAULT
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ import com.intellij.diagram.DiagramNodeBase
import com.intellij.diagram.DiagramProvider
import com.intellij.idea.plugin.hybris.common.utils.HybrisIcons
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNode
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNodeContextParameters
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNodeNavigable
import com.intellij.idea.plugin.hybris.system.businessProcess.model.*
import java.io.Serial

Expand All @@ -29,15 +31,20 @@ class BpDiagramNode(val graphNode: BpGraphNode, provider: DiagramProvider<BpGrap
override fun getIdentifyingElement() = graphNode
override fun getTooltip() = graphNode.name

override fun getIcon() = when (graphNode.navigableElement) {
is Process -> HybrisIcons.BUSINESS_PROCESS
is ScriptAction -> HybrisIcons.BP_DIAGRAM_SCRIPT
is Action -> HybrisIcons.BP_DIAGRAM_ACTION
is Split -> HybrisIcons.BP_DIAGRAM_SPLIT
is Wait -> HybrisIcons.BP_DIAGRAM_WAIT
is Join -> HybrisIcons.BP_DIAGRAM_JOIN
is End -> HybrisIcons.BP_DIAGRAM_END
is Notify -> HybrisIcons.BP_DIAGRAM_NOTIFY
override fun getIcon() = when (graphNode) {
is BpGraphNodeContextParameters -> HybrisIcons.BP_DIAGRAM_PARAMETERS
is BpGraphNodeNavigable -> when (graphNode.navigableElement) {
is Process -> HybrisIcons.BUSINESS_PROCESS
is ScriptAction -> HybrisIcons.BP_DIAGRAM_SCRIPT
is Action -> HybrisIcons.BP_DIAGRAM_ACTION
is Split -> HybrisIcons.BP_DIAGRAM_SPLIT
is Wait -> HybrisIcons.BP_DIAGRAM_WAIT
is Join -> HybrisIcons.BP_DIAGRAM_JOIN
is End -> HybrisIcons.BP_DIAGRAM_END
is Notify -> HybrisIcons.BP_DIAGRAM_NOTIFY
else -> null
}

else -> null
}

Expand Down
Loading

0 comments on commit fd18a54

Please sign in to comment.