Skip to content

Commit

Permalink
#265 | Added edges coloring for Business Process Diagrams
Browse files Browse the repository at this point in the history
  • Loading branch information
mlytvyn authored Mar 7, 2023
1 parent 09a3d20 commit 749929d
Show file tree
Hide file tree
Showing 11 changed files with 117 additions and 83 deletions.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ tasks {

runPluginVerifier {
ideVersions.addAll(pluginVerifierIdeVersions)
externalPrefixes.addAll("com.intellij.javaee", "com.intellij.spring", "com.intellij.diagram")
}

clean {
Expand Down
10 changes: 5 additions & 5 deletions buildSrc/src/main/kotlin/configuration.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ const val pluginVersion = "2023.1.2"
const val pluginSinceBuild = "231.7864.76"
const val pluginUntilBuild = "231.*"

const val platformType = "IU"
const val platformVersion = "LATEST-EAP-SNAPSHOT"
const val platformDownloadSources = true

// Plugin Verifier integration -> https://github.com/JetBrains/intellij-plugin-verifier
// 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
const val pluginVerifierIdeVersions = "231.7864.76"

const val platformType = "IU"
const val platformVersion = "LATEST-EAP-SNAPSHOT"
const val platformDownloadSources = true
const val pluginVerifierIdeVersions = "$platformType-231.7864.76"
// 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
// Example: platformPlugins = com.intellij.java, com.jetbrains.php:203.4449.22
Expand Down
2 changes: 2 additions & 0 deletions resources/META-INF/optional-diagram-dependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
<idea-plugin>

<extensions defaultExtensionNs="com.intellij">
<additionalTextAttributes scheme="Default" file="colorSchemes/BpDiagramDefault.xml"/>
<additionalTextAttributes scheme="Darcula" file="colorSchemes/BpDiagramDarcula.xml"/>

<diagram.Provider id="BusinessProcessDiagramProvider"
implementation="com.intellij.idea.plugin.hybris.diagram.businessProcess.impl.DefaultBpDiagramProvider"/>
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 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> 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
11 changes: 11 additions & 0 deletions resources/colorSchemes/BpDiagramDarcula.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<list>
<colors>
<!-- EDGES -->

<option name="BP_DIAGRAM_OK_EDGE" value="098000"/>
<option name="BP_DIAGRAM_NOK_EDGE" value="A1312A"/>
<option name="BP_DIAGRAM_TIMEOUT_EDGE" value="A1312A"/>
<option name="BP_DIAGRAM_DEFAULT_EDGE" value="9B9EA1"/>
</colors>
</list>
12 changes: 12 additions & 0 deletions resources/colorSchemes/BpDiagramDefault.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<list>
<colors>
<!-- EDGES -->

<option name="BP_DIAGRAM_OK_EDGE" value="098000"/>
<option name="BP_DIAGRAM_NOK_EDGE" value="A1312A"/>
<option name="BP_DIAGRAM_TIMEOUT_EDGE" value="A1312A"/>
<option name="BP_DIAGRAM_DEFAULT_EDGE" value="474747"/>

</colors>
</list>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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.openapi.editor.colors.ColorKey
import com.intellij.openapi.editor.colors.ColorKey.createColorKeyWithFallback
import com.intellij.openapi.editor.colors.ColorKey.find

object BpColors {

val OK: ColorKey = createColorKeyWithFallback("BP_DIAGRAM_OK_EDGE", find("DIAGRAM_DEFAULT_EDGE"))
val NOK: ColorKey = createColorKeyWithFallback("BP_DIAGRAM_NOK_EDGE", find("DIAGRAM_DEFAULT_EDGE"))
val TIMEOUT: ColorKey = createColorKeyWithFallback("BP_DIAGRAM_TIMEOUT_EDGE", find("DIAGRAM_DEFAULT_EDGE"))
val DEFAULT: ColorKey = createColorKeyWithFallback("BP_DIAGRAM_DEFAULT_EDGE", find("DIAGRAM_DEFAULT_EDGE"))
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* This file is part of "hybris integration" plugin for Intellij IDEA.
* Copyright (C) 2014-2016 Alexander Bartash <[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.DiagramBuilder
import com.intellij.diagram.DiagramEdge
import com.intellij.idea.plugin.hybris.common.utils.HybrisI18NBundleUtils.message
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpColors.DEFAULT
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpColors.NOK
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpColors.OK
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpColors.TIMEOUT
import com.intellij.idea.plugin.hybris.diagram.businessProcess.BpDiagramColorManager
import com.intellij.openapi.editor.colors.ColorKey
import org.apache.commons.lang3.StringUtils

class BpDiagramColorManagerIml : BpDiagramColorManager() {

private val badEdges = arrayOf("NOK", "ERROR", "FAIL")

override fun getEdgeColorKey(builder: DiagramBuilder, edge: DiagramEdge<*>): ColorKey {
val edgeType = edge.relationship.toString()

return when {
isOK(edgeType) -> OK
isNOK(edgeType) -> NOK
isTIMEOUT(edgeType) -> TIMEOUT
else -> DEFAULT
}
}

private fun isOK(edgeType: String) = StringUtils.isBlank(edgeType) || "OK".equals(edgeType, ignoreCase = true)
private fun isNOK(edgeType: String) = badEdges.contains(edgeType.uppercase())
private fun isTIMEOUT(edgeType: String) = StringUtils.startsWith(edgeType, message("hybris.business.process.timeout"))
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,32 @@

import com.intellij.diagram.AbstractUmlVisibilityManager;
import com.intellij.diagram.VisibilityLevel;
import com.intellij.openapi.util.Comparing;
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.Comparator;

/**
* @author Eugene.Kudelevsky
*/
public class ModuleDepDiagramVisibilityManager extends AbstractUmlVisibilityManager {
public final class ModuleDepDiagramVisibilityManager extends AbstractUmlVisibilityManager {

public static final VisibilityLevel SMALL = new VisibilityLevel("Small");
public static final VisibilityLevel MEDIUM = new VisibilityLevel("Medium");
public static final VisibilityLevel LARGE = new VisibilityLevel("Large");

private static final VisibilityLevel[] LEVELS = {SMALL, MEDIUM, LARGE};

private final Comparator<VisibilityLevel> COMPARATOR = (level1, level2) ->
Comparing.compare(ArrayUtil.indexOf(LEVELS, level1), ArrayUtil.indexOf(LEVELS, level2));
private final Comparator<VisibilityLevel> COMPARATOR = Comparator.comparingInt(level -> ArrayUtil.indexOf(LEVELS, level));

public ModuleDepDiagramVisibilityManager() {
setCurrentVisibilityLevel(SMALL);
}

@Override
public VisibilityLevel[] getVisibilityLevels() {
return LEVELS;
public VisibilityLevel @NotNull [] getVisibilityLevels() {
return LEVELS.clone();
}

@Nullable
Expand All @@ -56,7 +55,7 @@ public VisibilityLevel getVisibilityLevel(final Object o) {
}

@Override
public Comparator<VisibilityLevel> getComparator() {
public @NotNull Comparator<VisibilityLevel> getComparator() {
return COMPARATOR;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@

package com.intellij.idea.plugin.hybris.system.cockpitng.util.xml

import com.intellij.idea.plugin.hybris.system.cockpitng.meta.CngMetaModelAccess
import com.intellij.idea.plugin.hybris.system.cockpitng.model.config.Context
import com.intellij.idea.plugin.hybris.system.cockpitng.util.CngUtils
import com.intellij.util.xml.ConvertContext
import com.intellij.util.xml.ResolvingConverter
Expand Down

0 comments on commit 749929d

Please sign in to comment.