Skip to content

Commit

Permalink
Merge pull request #366 from valb3r/feature/FBP-73-IJ-Community-support
Browse files Browse the repository at this point in the history
Feature/fbp 73 ij community support
  • Loading branch information
valb3r committed Jul 22, 2023
2 parents 0172499 + f14e25b commit 6fbf7bc
Show file tree
Hide file tree
Showing 22 changed files with 393 additions and 275 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ Don't hesitate - ask or tell your opinion in gitter:
# Key features

1. BPMN process editing (BPMN modeler) - adding/removing elements, changing their properties, undo/redo, bulk drag-n-drop, bulk removal of elements
1. Code navigation - jump from `Delegate Expression` or `Class` property directly to bean/function/class in code
1. IntelliJ refactorings propagation to backing XML file of the process (i.e. rename bean)
1. Jump from an element to the underlying XML
1. BPMN process 'debugging' by allowing to see steps (and their order) done for latest process execution directly in plugin
1. Code navigation - jump from `Delegate Expression` **(IntelliJ Ultimate)** or `Class` **(IntelliJ Community)** property directly to bean/function/class in code
1. IntelliJ refactorings propagation to backing XML file of the process (i.e. rename bean) **(IntelliJ Ultimate)**
1. Jump from an element to the underlying XML **(IntelliJ Ultimate)**
1. BPMN process 'debugging' by allowing to see steps (and their order) done for latest process execution directly in plugin **(IntelliJ Ultimate)**


# Installation
Expand Down Expand Up @@ -117,7 +117,7 @@ If you want just to run the plugin in the `sandbox` you can execute
[![Work with plugin](https://img.youtube.com/vi/cyLbEeaMDvI/0.jpg)](https://youtu.be/cyLbEeaMDvI)


### BPMN-Java-XML 'gluing' usage
### BPMN-Java-XML 'gluing' usage (IntelliJ Ultimate, only classes for IntelliJ Community)

[![Work with plugin](https://img.youtube.com/vi/BQf0eglY2vo/0.jpg)](https://youtu.be/BQf0eglY2vo)

Expand Down
2 changes: 1 addition & 1 deletion activiti-intellij-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ intellij {
}

runPluginVerifier {
ideVersions = ["IU-2021.3"]
ideVersions = ["IU-2021.3", "IC-2021.3"]
}

verifyPlugin {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<idea-plugin>
<!-- Actions -->
<actions>
<group id="BpmnActivitiAttachToDataSource"
text="Attach To Schema"
description="Attach to database schema to investigate process"
icon="/icons/icon.png"
popup="false">
<!-- The <action> element defines an action to register.
- "id" (required) specifies an unique identifier for the action.
- "class" (required) specifies the full-qualified name of the class implementing the action.
- "text" (required) specifies the text (tooltip for toolbar button or text for menu item).
- "use-shortcut-of" (optional) specifies the ID of the action whose keyboard shortcut this action uses.
- "description" (optional) specifies the text displayed in the status bar when the action is focused.
- "icon" (optional) specifies the icon displayed on the toolbar button or next to the menu item. -->
<action id="BpmnDiagram.AttachActivitiToDataSource"
class="com.valb3r.bpmn.intellij.activiti.plugin.actions.AttachActivitiBpmnDebuggerToDbAction"
text="Attach To Schema (Activiti)"
description="Attach to database schema (Activiti) for BPMN process debugging"
icon="/icons/icon.png">
</action>
<!-- The <add-to-group> node specifies that the action should be added to an existing group.
An action can be added to several groups.
- "group-id" (required) specifies the ID of the group to which the action is added. The group must be
implemented by an instance of the DefaultActionGroup class.
- "anchor" (required) specifies the position of the action in the group relative to other actions.
It can have the values "first", "last", "before" and "after".
- "relative-to-action" (required if the anchor is set to "before" and "after") specifies the action
before or after which the current action is inserted. -->
<add-to-group group-id="DatabaseViewPopupMenu" anchor="last"/>
<!-- The <separator> element defines a separator between actions. -->
<!-- <separator/> -->
<!-- <group id="AnotherNestedGroup"/> -->
<!-- The <reference> element allows to add an existing action to the group.
- "ref" (required) specifies the ID of the action to add. -->
<!-- <reference ref="EditorCopy"/> -->
</group>
<group id="BpmnActivitiDetachFromDataSource"
text="Detach Debugger"
description="Detach BPMN debugger from DataSource"
icon="/icons/icon.png"
popup="false">
<!-- The <action> element defines an action to register.
- "id" (required) specifies an unique identifier for the action.
- "class" (required) specifies the full-qualified name of the class implementing the action.
- "text" (required) specifies the text (tooltip for toolbar button or text for menu item).
- "use-shortcut-of" (optional) specifies the ID of the action whose keyboard shortcut this action uses.
- "description" (optional) specifies the text displayed in the status bar when the action is focused.
- "icon" (optional) specifies the icon displayed on the toolbar button or next to the menu item. -->
<action id="BpmnDiagram.BpmnDetachActivitiFromDataSource"
class="com.valb3r.bpmn.intellij.activiti.plugin.actions.DetachActivitiBpmnDebuggerFromDbAction"
text="Detach Debugger"
description="Detach BPMN debugger from DataSource (Activiti)"
icon="/icons/icon.png">
</action>
<!-- The <add-to-group> node specifies that the action should be added to an existing group.
An action can be added to several groups.
- "group-id" (required) specifies the ID of the group to which the action is added. The group must be
implemented by an instance of the DefaultActionGroup class.
- "anchor" (required) specifies the position of the action in the group relative to other actions.
It can have the values "first", "last", "before" and "after".
- "relative-to-action" (required if the anchor is set to "before" and "after") specifies the action
before or after which the current action is inserted. -->
<add-to-group group-id="DatabaseViewPopupMenu" anchor="last"/>
<!-- The <separator> element defines a separator between actions. -->
<!-- <separator/> -->
<!-- <group id="AnotherNestedGroup"/> -->
<!-- The <reference> element allows to add an existing action to the group.
- "ref" (required) specifies the ID of the action to add. -->
<!-- <reference ref="EditorCopy"/> -->
</group>
</actions>
</idea-plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<idea-plugin>
<!-- Inject SpEL for highlighting -->
<extensions defaultExtensionNs="com.intellij">
<multiHostInjector implementation="com.valb3r.bpmn.intellij.activiti.plugin.langinjection.ActivitiDelegateExpressionUiInjector"/>
</extensions>
</idea-plugin>
97 changes: 14 additions & 83 deletions activiti-intellij-plugin/src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@
<name>Activiti BPMN visualizer</name>

<!-- Plugin version -->
<version>0.5.3.1</version>
<version>0.5.4</version>

<!-- Unique identifier of the plugin. Cannot be changed between the plugin versions.
If not specified, assumed to be equal to <name>. -->
<id>activiti-bpmn-visualizer</id>

<!-- Description of the plugin. -->
<description><![CDATA[
<p>The plugin to bring BPMN (Activiti) world closer to developer needs. It supports editing and visualizing Activiti 6.x and older
BPMN diagrams with navigation and process debugging support. Provides necessary glue to jump between code and BPMN diagram
<p>The plugin to bring BPMN (Activiti) world closer to developer needs. It supports editing and visualizing Activiti
BPMN diagrams with navigation and process debugging support. Provides necessary glue to jump between code and BPMN diagram
and bridges IntelliJ refactorings (changing bean names for example) to XML diagrams.</p>
<p><b>Please check <a href="https://github.com/valb3r/flowable-bpmn-intellij-plugin">plugin repository</a> for how-to videos</b> (yes it is correct URL)</p>
<p><strong>Key features</strong></p>
<ul>
<li>BPMN editing/viewing</li>
<li>Jumping from delegate expression or class directly to code</li>
<li>Language injections to underlying XML file, so that class usage and refactoring is available</li>
<li>BPMN process debugging</li>
<li>Jumping from delegate expression or class directly to code (IntelliJ Ultimate, only classes for IntelliJ Community)</li>
<li>Language injections to underlying XML file, so that class usage and refactoring is available (IntelliJ Ultimate, only classes for IntelliJ Community)</li>
<li>BPMN process debugging (IntelliJ Ultimate)</li>
</ul>
<br/>
<p><a href="https://github.com/valb3r/flowable-bpmn-intellij-plugin">Github</a> stars are welcome!</p>
Expand All @@ -39,6 +39,12 @@
<!-- Description of changes in the latest version of the plugin. Displayed in the "Plugins" settings dialog and
in the plugin repository Web interface. -->
<change-notes><![CDATA[
<p>0.5.4:</p>
<ul>
<li>
Initial support for IJ Community Edition and other JB IDEs (limited language injection support compared to IU)
</li>
</ul>
<p>0.5.3.1:</p>
<ul>
<li>
Expand Down Expand Up @@ -79,12 +85,6 @@
Stop using scheduled for removal IJ internal API
</li>
</ul>
<p>0.5.1:</p>
<ul>
<li>
Fix for changing settings in IntelliJ 2023.1+
</li>
</ul>
]]></change-notes>

<!-- The vendor of the plugin. The optional "url" attribute specifies the URL of the vendor homepage.
Expand All @@ -93,8 +93,8 @@

<!-- The unique identifiers of the plugins on which this plugin depends. -->
<depends>com.intellij.modules.lang</depends>
<depends>com.intellij.modules.java</depends>
<depends>com.intellij.database</depends>
<depends optional="true" config-file="activiti-bpmn-visualizer-with-java.xml">com.intellij.modules.java</depends>
<depends optional="true" config-file="activiti-bpmn-visualizer-with-db.xml">com.intellij.database</depends>

<!-- Optional dependency on another plugin. If the plugin with the "com.MySecondPlugin" ID is installed,
the contents of mysecondplugin.xml (the format of this file conforms to the format of plugin.xml)
Expand Down Expand Up @@ -202,74 +202,6 @@
- "ref" (required) specifies the ID of the action to add. -->
<!-- <reference ref="EditorCopy"/> -->
</group>
<group id="BpmnActivitiAttachToDataSource"
text="Attach To Schema"
description="Attach to database schema to investigate process"
icon="/icons/icon.png"
popup="false">
<!-- The <action> element defines an action to register.
- "id" (required) specifies an unique identifier for the action.
- "class" (required) specifies the full-qualified name of the class implementing the action.
- "text" (required) specifies the text (tooltip for toolbar button or text for menu item).
- "use-shortcut-of" (optional) specifies the ID of the action whose keyboard shortcut this action uses.
- "description" (optional) specifies the text displayed in the status bar when the action is focused.
- "icon" (optional) specifies the icon displayed on the toolbar button or next to the menu item. -->
<action id="BpmnDiagram.AttachActivitiToDataSource"
class="com.valb3r.bpmn.intellij.activiti.plugin.actions.AttachActivitiBpmnDebuggerToDbAction"
text="Attach To Schema (Activiti)"
description="Attach to database schema (Activiti) for BPMN process debugging"
icon="/icons/icon.png">
</action>
<!-- The <add-to-group> node specifies that the action should be added to an existing group.
An action can be added to several groups.
- "group-id" (required) specifies the ID of the group to which the action is added. The group must be
implemented by an instance of the DefaultActionGroup class.
- "anchor" (required) specifies the position of the action in the group relative to other actions.
It can have the values "first", "last", "before" and "after".
- "relative-to-action" (required if the anchor is set to "before" and "after") specifies the action
before or after which the current action is inserted. -->
<add-to-group group-id="DatabaseViewPopupMenu" anchor="last"/>
<!-- The <separator> element defines a separator between actions. -->
<!-- <separator/> -->
<!-- <group id="AnotherNestedGroup"/> -->
<!-- The <reference> element allows to add an existing action to the group.
- "ref" (required) specifies the ID of the action to add. -->
<!-- <reference ref="EditorCopy"/> -->
</group>
<group id="BpmnActivitiDetachFromDataSource"
text="Detach Debugger"
description="Detach BPMN debugger from DataSource"
icon="/icons/icon.png"
popup="false">
<!-- The <action> element defines an action to register.
- "id" (required) specifies an unique identifier for the action.
- "class" (required) specifies the full-qualified name of the class implementing the action.
- "text" (required) specifies the text (tooltip for toolbar button or text for menu item).
- "use-shortcut-of" (optional) specifies the ID of the action whose keyboard shortcut this action uses.
- "description" (optional) specifies the text displayed in the status bar when the action is focused.
- "icon" (optional) specifies the icon displayed on the toolbar button or next to the menu item. -->
<action id="BpmnDiagram.BpmnDetachActivitiFromDataSource"
class="com.valb3r.bpmn.intellij.activiti.plugin.actions.DetachActivitiBpmnDebuggerFromDbAction"
text="Detach Debugger"
description="Detach BPMN debugger from DataSource (Activiti)"
icon="/icons/icon.png">
</action>
<!-- The <add-to-group> node specifies that the action should be added to an existing group.
An action can be added to several groups.
- "group-id" (required) specifies the ID of the group to which the action is added. The group must be
implemented by an instance of the DefaultActionGroup class.
- "anchor" (required) specifies the position of the action in the group relative to other actions.
It can have the values "first", "last", "before" and "after".
- "relative-to-action" (required if the anchor is set to "before" and "after") specifies the action
before or after which the current action is inserted. -->
<add-to-group group-id="DatabaseViewPopupMenu" anchor="last"/>
<!-- The <separator> element defines a separator between actions. -->
<!-- <separator/> -->
<!-- <group id="AnotherNestedGroup"/> -->
<!-- The <reference> element allows to add an existing action to the group.
- "ref" (required) specifies the ID of the action to add. -->
<!-- <reference ref="EditorCopy"/> -->
</group>
</actions>

<!-- Extension points defined by the plugin. Extension points are registered by a plugin so that other plugins
Expand Down Expand Up @@ -298,7 +230,6 @@

<!-- Inject SpEL for highlighting -->
<extensions defaultExtensionNs="com.intellij">
<multiHostInjector implementation="com.valb3r.bpmn.intellij.activiti.plugin.langinjection.ActivitiDelegateExpressionUiInjector"/>
<multiHostInjector implementation="com.valb3r.bpmn.intellij.activiti.plugin.langinjection.xml.ActivitiXmlInjector"/>
</extensions>

Expand Down
1 change: 0 additions & 1 deletion bpmn-intellij-plugin-common-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ dependencies {

intellij {
version = intellijPlatform
plugins = intellijPlatformPlugins
}

patchPluginXml.enabled = false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiLanguageInjectionHost
import com.intellij.psi.PsiLiteralExpression
import org.jetbrains.uast.UastFacade.language
import java.util.*

private val currentFile = Collections.synchronizedMap(WeakHashMap<Project, PsiFile>())
Expand All @@ -27,6 +28,10 @@ abstract class DefaultDelegateExpressionUiInjector: MultiHostInjector {
return mutableListOf(PsiLiteralExpression::class.java)
}

private val spelStart = "^\"[$#]\\{".toRegex()

private val spelEnd = "}\""

override fun getLanguagesToInject(registrar: MultiHostRegistrar, context: PsiElement) {
if (context !is PsiLanguageInjectionHost) {
return
Expand All @@ -38,18 +43,20 @@ abstract class DefaultDelegateExpressionUiInjector: MultiHostInjector {
return
}

if (!context.text.contains("[$#]\\{".toRegex()) || !context.text.contains("}")) {
return
}

injectSpel(context, registrar)
}

private fun injectSpel(context: PsiLanguageInjectionHost, registrar: MultiHostRegistrar) {
val text = context.text
val beanName = Language.getRegisteredLanguages().first { it.id == "SpEL" }!!
registrar.startInjecting(beanName)
registrar.addPlace("", "", context, TextRange(3, text.length - 2))
val language = Language.getRegisteredLanguages().firstOrNull { it.id == "SpEL" } ?: return
registrar.startInjecting(language)
if (context.text.contains(spelStart)) {
registrar.addPlace("", "", context, TextRange(3, text.length - 1))
} else if (context.text.contains(spelStart) && context.text.endsWith(spelEnd)) {
registrar.addPlace("", "", context, TextRange(3, text.length - 2))
} else {
registrar.addPlace("", "", context, TextRange(1, text.length - 1))
}
registrar.doneInjecting()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.intellij.psi.xml.XmlAttribute
import com.intellij.psi.xml.XmlAttributeValue
import com.intellij.psi.xml.XmlTag
import com.intellij.psi.xml.XmlText
import com.valb3r.bpmn.intellij.plugin.core.settings.currentSettings

abstract class DefaultXmlInjector: MultiHostInjector {

Expand Down Expand Up @@ -37,7 +38,13 @@ abstract class DefaultXmlInjector: MultiHostInjector {
}

protected open fun invalidXmlFileExtension(context: PsiLanguageInjectionHost): Boolean {
return !context.containingFile.name.endsWith("bpmn20.xml") && context.containingFile?.context?.containingFile?.name?.endsWith("bpmn20.xml") != true
return isValidFileName(context.containingFile.name)
}

private fun isValidFileName(fileName: String?): Boolean {
val name = fileName ?: return false
val allowedExt = currentSettings().openExtensions
return allowedExt.any { name.endsWith(it) }
}

private fun tryToInjectSkipExpression(context: XmlAttributeValue, asHost: PsiLanguageInjectionHost, registrar: MultiHostRegistrar): Boolean {
Expand Down
Loading

0 comments on commit 6fbf7bc

Please sign in to comment.