Skip to content

Commit

Permalink
#267 | Added node properties for Business Process Diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
mlytvyn authored Mar 8, 2023
1 parent 6db7c21 commit 9c7daaa
Show file tree
Hide file tree
Showing 28 changed files with 360 additions and 151 deletions.
14 changes: 6 additions & 8 deletions resources/META-INF/optional-diagram-dependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<additionalTextAttributes scheme="Darcula" file="colorSchemes/BpDiagramDarcula.xml"/>

<diagram.Provider id="HybrisBusinessProcessDiagramProvider"
implementation="com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.DefaultBpDiagramProvider"/>
implementation="com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.BpDiagramProviderImpl"/>

<diagram.Provider id="HybrisModuleDependencies"
implementation="com.intellij.idea.plugin.hybris.diagram.module.ModuleDepDiagramProvider"/>
Expand All @@ -32,19 +32,17 @@
<!-- implementation="com.intellij.idea.plugin.hybris.diagram.typeSystem.TSDiagramProvider"/>-->

<applicationService serviceInterface="com.intellij.idea.plugin.hybris.diagram.businessProcess.BpGraphService"
serviceImplementation="com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.DefaultBpGraphService"/>

serviceImplementation="com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.BpGraphServiceImpl"/>
<applicationService serviceInterface="com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramProvider"
serviceImplementation="com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.DefaultBpDiagramProvider"/>

serviceImplementation="com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.BpDiagramProviderImpl"/>
<applicationService serviceInterface="com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramElementManager"
serviceImplementation="com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.BpDiagramElementManagerIml"/>

<applicationService serviceInterface="com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramVfsResolver"
serviceImplementation="com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.DefaultBpDiagramVfsResolver"/>

serviceImplementation="com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.BpDiagramVfsResolverImpl"/>
<applicationService serviceInterface="com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramColorManager"
serviceImplementation="com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.BpDiagramColorManagerIml"/>
<applicationService serviceInterface="com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramNodeContentManager"
serviceImplementation="com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.BpDiagramNodeContentManagerImpl"/>

<applicationService serviceInterface="com.intellij.idea.plugin.hybris.diagram.typeSystem.TSDiagramVisibilityManager"
serviceImplementation="com.intellij.idea.plugin.hybris.diagram.typeSystem.impl.TSDiagramVisibilityManagerImpl"/>
Expand Down
1 change: 1 addition & 0 deletions resources/META-INF/plugin-release-info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
<![CDATA[
<h3>2023.1.2</h3>
<ul>
<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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ 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 GUTTER_POPULATOR = getIcon("/icons/gutter/populator.svg");

public static final Icon CONSOLE_SOLR = getIcon("/icons/console/solr.svg");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@
package com.intellij.idea.plugin.hybris.diagram.businessProcess

import com.intellij.diagram.DiagramColorManagerBase
import com.intellij.openapi.application.ApplicationManager

abstract class BpDiagramColorManager : DiagramColorManagerBase()
abstract class BpDiagramColorManager : DiagramColorManagerBase() {

companion object {
val instance: BpDiagramColorManager = ApplicationManager.getApplication().getService(BpDiagramColorManager::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@
package com.intellij.idea.plugin.hybris.diagram.businessProcess

import com.intellij.diagram.DiagramElementManager
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNode
import com.intellij.openapi.application.ApplicationManager

interface BpDiagramElementManager : DiagramElementManager<BpGraphNode>
interface BpDiagramElementManager : DiagramElementManager<BpGraphNode> {

companion object {
val instance: BpDiagramElementManager = ApplicationManager.getApplication().getService(BpDiagramElementManager::class.java)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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

import com.intellij.diagram.DiagramNodeContentManager
import com.intellij.openapi.application.ApplicationManager

interface BpDiagramNodeContentManager : DiagramNodeContentManager {

companion object {
val instance: BpDiagramNodeContentManager = ApplicationManager.getApplication().getService(BpDiagramNodeContentManager::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@
package com.intellij.idea.plugin.hybris.diagram.businessProcess

import com.intellij.diagram.BaseDiagramProvider
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNode
import com.intellij.openapi.application.ApplicationManager

abstract class BpDiagramProvider : BaseDiagramProvider<BpGraphNode>()
abstract class BpDiagramProvider : BaseDiagramProvider<BpGraphNode>() {

companion object {
val instance: BpDiagramProvider = ApplicationManager.getApplication().getService(BpDiagramProvider::class.java)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,12 @@
package com.intellij.idea.plugin.hybris.diagram.businessProcess

import com.intellij.diagram.DiagramVfsResolver
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNode
import com.intellij.openapi.application.ApplicationManager

interface BpDiagramVfsResolver : DiagramVfsResolver<BpGraphNode?>
interface BpDiagramVfsResolver : DiagramVfsResolver<BpGraphNode?> {

companion object {
val instance: BpDiagramVfsResolver = ApplicationManager.getApplication().getService(BpDiagramVfsResolver::class.java)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* 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

import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphDefaultNode
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNode
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphParameterNodeField
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphRootNode
import com.intellij.idea.plugin.hybris.system.businessProcess.model.*
import com.intellij.util.xml.DomElement

object BpGraphFactory {

fun buildNode(nodeName: String, element: Action, rootGraphNode: BpGraphRootNode): BpGraphNode {
val properties = mutableListOf(
BpGraphParameterNodeField(Action.CAN_JOIN_PREVIOUS_NODE, (element.canJoinPreviousNode.stringValue
?: "false"))
)
element.node.stringValue
?.let { properties.add(BpGraphParameterNodeField(Action.NODE, it)) }
element.nodeGroup.stringValue
?.let { properties.add(BpGraphParameterNodeField(Action.NODE_GROUP, it)) }
element.bean.stringValue
?.let { properties.add(BpGraphParameterNodeField(Action.BEAN, it)) }
element.parameters
.forEach {
properties.add(BpGraphParameterNodeField(it.name.stringValue ?: "", it.value.stringValue ?: ""))
}

return BpGraphDefaultNode(nodeName, element, rootGraphNode.virtualFile, rootGraphNode.process, properties.toTypedArray())
}

fun buildNode(nodeName: String, element: End, rootGraphNode: BpGraphRootNode): BpGraphNode {
val properties = (element.state.stringValue
?.let { arrayOf(BpGraphParameterNodeField(End.STATE, it)) }
?: emptyArray())
return BpGraphDefaultNode(nodeName, element, rootGraphNode.virtualFile, rootGraphNode.process, properties)
}

fun buildNode(nodeName: String, element: Wait, rootGraphNode: BpGraphRootNode): BpGraphNode {
val properties = mutableListOf(
BpGraphParameterNodeField(Wait.PREPEND_PROCESS_CODE, (element.prependProcessCode.stringValue
?: "true"))
)
return BpGraphDefaultNode(nodeName, element, rootGraphNode.virtualFile, rootGraphNode.process, properties.toTypedArray())
}

fun buildNode(nodeName: String, element: Notify, rootGraphNode: BpGraphRootNode): BpGraphNode {
val properties = element.userGroups
.filter { it.name.stringValue?.isNotEmpty() ?: false }
.map { BpGraphParameterNodeField(it.name.stringValue!!, "") }
.toTypedArray()
return BpGraphDefaultNode(nodeName, element, rootGraphNode.virtualFile, rootGraphNode.process, properties)
}

fun buildNode(nodeName: String, element: ScriptAction, rootGraphNode: BpGraphRootNode): BpGraphNode {
val properties = element.script.type.stringValue
?.let { arrayOf(BpGraphParameterNodeField(ScriptAction.SCRIPT, it)) }
?: emptyArray()
return BpGraphDefaultNode(nodeName, element, rootGraphNode.virtualFile, rootGraphNode.process, properties)
}

fun buildNode(nodeName: String, element: DomElement, rootGraphNode: BpGraphRootNode) = BpGraphDefaultNode(nodeName, element, rootGraphNode.virtualFile, rootGraphNode.process)


}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,18 @@
*/
package com.intellij.idea.plugin.hybris.diagram.businessProcess

import com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.BpDiagramFileEdge
import com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.BpDiagramFileNode
import com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.BpRootGraphNode
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.BpDiagramFileEdge
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.BpDiagramFileNode
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNode
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphRootNode
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.vfs.VirtualFile

interface BpGraphService {
fun buildRootNode(project: Project?, virtualFile: VirtualFile?): BpGraphNode?

fun buildNodes(rootGraphNode: BpRootGraphNode): Map<String, BpGraphNode>
fun buildNodes(rootGraphNode: BpGraphRootNode): Map<String, BpGraphNode>

fun buildEdge(name: String, source: BpDiagramFileNode, target: BpDiagramFileNode): BpDiagramFileEdge

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpColors.PARTIAL
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpColors.START
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpColors.TIMEOUT
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramColorManager
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.*

/**
* TODO: Add user-defined project-based mapping for custom transition names
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,18 @@
package com.intellij.idea.plugin.hybris.diagram.businessProcess.impl

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.BpDiagramElementManager
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpGraphNode
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpGraphService
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphNode
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphParameterNodeField
import com.intellij.idea.plugin.hybris.system.businessProcess.model.Action
import com.intellij.openapi.actionSystem.CommonDataKeys
import com.intellij.openapi.actionSystem.DataContext
import com.intellij.ui.SimpleColoredText
import com.intellij.ui.SimpleTextAttributes

class BpDiagramElementManagerIml : AbstractDiagramElementManager<BpGraphNode>(), BpDiagramElementManager {

Expand All @@ -37,11 +43,32 @@ class BpDiagramElementManagerIml : AbstractDiagramElementManager<BpGraphNode>(),
}

override fun isAcceptableAsNode(o: Any?) = o is BpGraphNode
override fun getElementTitle(t: BpGraphNode) = t.nodeName
override fun getNodeTooltip(t: BpGraphNode) = t.nodeName
override fun getElementTitle(t: BpGraphNode) = t.name
override fun getNodeTooltip(t: BpGraphNode) = t.name

override fun getNodeItems(parent: BpGraphNode?): Array<Any> {
// TODO: add properties for each node here
return emptyArray()
override fun getNodeItems(parent: BpGraphNode?): Array<out Any> = parent?.properties ?: emptyArray()

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

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

override fun getItemIcon(nodeElement: BpGraphNode?, nodeItem: Any?, builder: DiagramBuilder?) = when (nodeItem) {
is BpGraphParameterNodeField -> 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
}

else -> null
}

override fun getElementTitle(element: BpGraphNode?, builder: DiagramBuilder) = element?.name
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* 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.impl

import com.intellij.diagram.AbstractDiagramNodeContentManager
import com.intellij.diagram.DiagramBuilder
import com.intellij.diagram.DiagramCategory
import com.intellij.icons.AllIcons
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramNodeContentManager
import com.intellij.idea.plugin.hybris.diagram.businessProcess.node.graph.BpGraphParameterNodeField

class BpDiagramNodeContentManagerImpl : AbstractDiagramNodeContentManager(), BpDiagramNodeContentManager {

override fun getContentCategories() = CATEGORIES

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

companion object {
private val PARAMETERS = DiagramCategory({ "Parameters" }, AllIcons.Nodes.Property, true, false)
private val CATEGORIES = arrayOf(PARAMETERS)
}

}
Loading

0 comments on commit 9c7daaa

Please sign in to comment.