From 116f0db166d8473a99631cdce1ab3bce779ee86f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Fri, 14 Apr 2023 23:13:16 +0200 Subject: [PATCH 01/66] Add ability to create empty composite block --- .../adapters/fbnetwork/FBNetworkEditors.kt | 91 ++++++++++++++++--- 1 file changed, 76 insertions(+), 15 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt index f9915f4cf..ada6c75a5 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt @@ -18,7 +18,6 @@ import org.fbme.lib.common.Declaration import org.fbme.lib.common.StringIdentifier import org.fbme.lib.iec61499.DeclarationsScope import org.fbme.lib.iec61499.IEC61499Factory -import org.fbme.lib.iec61499.declarations.FBTypeDeclaration import org.fbme.lib.iec61499.declarations.ParameterAssignment import org.fbme.lib.iec61499.fbnetwork.FBNetwork import org.fbme.lib.iec61499.instances.Instance @@ -281,25 +280,87 @@ object FBNetworkEditors { fbNetwork: FBNetwork, scale: Float ): List { - return scope.findAllFBTypeDeclarations().map { type: FBTypeDeclaration -> - object : PositionalCompletionItem { - override fun getMatchingText(pattern: String?): String { - return type.name - } + val completionList = mutableListOf(); - override val descriptionText: String - get() { - return "create function block" + scope.findAllFBTypeDeclarations().forEach { type -> + completionList.add( + createPositionalCompletionItem(type.name, "Create function block") { _: String?, x: Int, y: Int -> + val declaration = factory.createFunctionBlockDeclaration(StringIdentifier(type.name)) + declaration.x = (x / scale).toInt() + declaration.y = (y / scale).toInt() + declaration.typeReference.setTarget(type) + fbNetwork.functionBlocks.add(declaration) } + ) + } + + completionList.add(createPositionalCompletionItem( + "New functional block", + "Empty block for creating definition") { _: String?, x: Int, y: Int -> + val identifier = createNewCompositeBlock(scope, fbNetwork, factory) + val declaration = factory.createFunctionBlockDeclaration(identifier) + declaration.x = (x / scale).toInt() + declaration.y = (y / scale).toInt() + val type = scope.findAllFBTypeDeclarations().find { + it.name == identifier.value + } ?: error("Can't create empty block") + declaration.typeReference.setTarget(type) + fbNetwork.functionBlocks.add(declaration) + }) + + return completionList + } + + private fun createPositionalCompletionItem( + name: String, + description: String, + invokeFun: (pattern: String?, x: Int, y: Int) -> Unit + ): PositionalCompletionItem { + return object : PositionalCompletionItem { + override fun getMatchingText(pattern: String?): String { + return name + } - override fun invoke(pattern: String?, x: Int, y: Int) { - val declaration = factory.createFunctionBlockDeclaration(StringIdentifier(type.name)) - declaration.x = (x / scale).toInt() - declaration.y = (y / scale).toInt() - declaration.typeReference.setTarget(type) - fbNetwork.functionBlocks.add(declaration) + override val descriptionText: String + get() { + return description } + + override fun invoke(pattern: String?, x: Int, y: Int) { + invokeFun(pattern, x, y) + } + } + } + + private fun createNewCompositeBlock( + scope: DeclarationsScope, + fbNetwork: FBNetwork, + factory: IEC61499Factory + ): StringIdentifier { + val getName: (Int?) -> String = { ind -> + val baseName = "Empty block" + if (ind == null) { + baseName + } else { + "$baseName $ind" } } + + var prefix: Int? = null + val names = scope.findAllFBTypeDeclarations().map { it.name }.toSet() + + while (names.contains(getName(prefix))) { + prefix = (prefix ?: 0) + 1 + } + + val identifier = StringIdentifier(getName(prefix)) + + val networkNode = (fbNetwork as PlatformElement).node + val networkModel = networkNode.model + val newFbType = factory.createCompositeFBTypeDeclaration(identifier) + val fbTypeNode = (newFbType as PlatformElement).node + networkModel!!.addRootNode(fbTypeNode) + + return identifier } } From bd62c4c9513a11d748600d79aefd5ba458bebb31 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 17 Apr 2023 19:31:53 +0200 Subject: [PATCH 02/66] Add maket button for edit --- .idea/.name | 1 - .idea/codeStyles/codeStyleConfig.xml | 5 - .idea/compiler.xml | 31 ---- .idea/dictionaries/IEC_61499_Terms.xml | 7 - .idea/dictionaries/default.xml | 7 - .idea/dictionaries/project_dictionary.xml | 7 - .idea/encodings.xml | 4 - .idea/inspectionProfiles/Project_Default.xml | 6 - .idea/inspectionProfiles/Project_check.xml | 13 -- .idea/jarRepositories.xml | 70 --------- .idea/kotlinScripting.xml | 6 - .idea/kotlinc.xml | 6 - .idea/misc.xml | 17 --- .idea/modules/fbme.iml | 8 -- .idea/runConfigurations/Remote_debug_MPS.xml | 15 -- ...Test_Teamcity_configuration_generation.xml | 27 ---- .idea/scopes/Checked_source_files.xml | 3 - .idea/uiDesigner.xml | 124 ---------------- .idea/vcs.xml | 11 -- .../org.fbme.ide.integration.fordiac.mps | 6 +- .../events/ARTimeOut.adp | 43 ++---- .../iec61499.4diac.stdlib/events/ATimeOut.adp | 43 ++---- .../iec61499.4diac.stdlib/events/E_CTD.fbt | 61 ++++---- .../iec61499.4diac.stdlib/events/E_CTU.fbt | 60 ++++---- .../iec61499.4diac.stdlib/events/E_CTUD.fbt | 117 ++++++++------- .../iec61499.4diac.stdlib/events/E_CYCLE.fbt | 33 +++-- .../iec61499.4diac.stdlib/events/E_DELAY.fbt | 22 ++- .../iec61499.4diac.stdlib/events/E_DEMUX.fbt | 65 +++++---- .../iec61499.4diac.stdlib/events/E_D_FF.fbt | 42 +++--- .../iec61499.4diac.stdlib/events/E_F_TRIG.fbt | 33 +++-- .../iec61499.4diac.stdlib/events/E_MERGE.fbt | 30 ++-- .../iec61499.4diac.stdlib/events/E_PERMIT.fbt | 29 ++-- .../iec61499.4diac.stdlib/events/E_RDELAY.fbt | 48 ++----- .../iec61499.4diac.stdlib/events/E_REND.fbt | 44 +++--- .../iec61499.4diac.stdlib/events/E_RS.fbt | 45 +++--- .../iec61499.4diac.stdlib/events/E_R_TRIG.fbt | 33 +++-- .../iec61499.4diac.stdlib/events/E_SELECT.fbt | 35 +++-- .../iec61499.4diac.stdlib/events/E_SPLIT.fbt | 30 ++-- .../iec61499.4diac.stdlib/events/E_SR.fbt | 45 +++--- .../iec61499.4diac.stdlib/events/E_SWITCH.fbt | 39 +++-- .../iec61499.4diac.stdlib/events/E_TABLE.fbt | 50 +++---- .../iec61499.4diac.stdlib/events/E_TRAIN.fbt | 54 +++---- .../iec61499.4diac.stdlib/events/E_T_FF.fbt | 33 +++-- .../models/iec61499.4diac.stdlib/io/ID.fbt | 44 +++--- .../models/iec61499.4diac.stdlib/io/IW.fbt | 45 +++--- .../models/iec61499.4diac.stdlib/io/IX.fbt | 54 ++++--- .../models/iec61499.4diac.stdlib/io/QD.fbt | 109 +++----------- .../models/iec61499.4diac.stdlib/io/QW.fbt | 110 +++----------- .../models/iec61499.4diac.stdlib/io/QX.fbt | 111 +++------------ .../iec61499.4diac.stdlib/math/FB_RANDOM.fbt | 53 ++++--- .../iec61499.4diac.stdlib/net/CLIENT_1.fbt | 48 +++---- .../iec61499.4diac.stdlib/net/CLIENT_2_1.fbt | 52 +++---- .../iec61499.4diac.stdlib/net/PUBLISH_0.fbt | 40 +++--- .../iec61499.4diac.stdlib/net/PUBLISH_1.fbt | 44 +++--- .../iec61499.4diac.stdlib/net/PUBLISH_10.fbt | 76 +++++----- .../iec61499.4diac.stdlib/net/PUBLISH_2.fbt | 48 +++---- .../iec61499.4diac.stdlib/net/PUBLISH_3.fbt | 52 +++---- .../iec61499.4diac.stdlib/net/PUBLISH_4.fbt | 56 ++++---- .../iec61499.4diac.stdlib/net/PUBLISH_5.fbt | 60 ++++---- .../iec61499.4diac.stdlib/net/PUBLISH_6.fbt | 64 ++++----- .../iec61499.4diac.stdlib/net/PUBLISH_7.fbt | 68 ++++----- .../iec61499.4diac.stdlib/net/PUBLISH_8.fbt | 72 +++++----- .../iec61499.4diac.stdlib/net/PUBLISH_9.fbt | 80 +++++------ .../iec61499.4diac.stdlib/net/SERVER_1.fbt | 48 +++---- .../iec61499.4diac.stdlib/net/SERVER_1_2.fbt | 52 +++---- .../iec61499.4diac.stdlib/net/SUBSCRIBE_0.fbt | 40 +++--- .../iec61499.4diac.stdlib/net/SUBSCRIBE_1.fbt | 44 +++--- .../net/SUBSCRIBE_10.fbt | 81 ++++++----- .../iec61499.4diac.stdlib/net/SUBSCRIBE_2.fbt | 48 +++---- .../iec61499.4diac.stdlib/net/SUBSCRIBE_3.fbt | 52 +++---- .../iec61499.4diac.stdlib/net/SUBSCRIBE_4.fbt | 56 ++++---- .../iec61499.4diac.stdlib/net/SUBSCRIBE_5.fbt | 60 ++++---- .../iec61499.4diac.stdlib/net/SUBSCRIBE_6.fbt | 64 ++++----- .../iec61499.4diac.stdlib/net/SUBSCRIBE_7.fbt | 68 ++++----- .../iec61499.4diac.stdlib/net/SUBSCRIBE_8.fbt | 72 +++++----- .../iec61499.4diac.stdlib/net/SUBSCRIBE_9.fbt | 76 +++++----- .../utils/APPEND_STRING_2.fbt | 26 ++-- .../utils/APPEND_STRING_3.fbt | 30 ++-- .../utils/ARRAY2ARRAY_2_LREAL.fbt | 23 ++- .../utils/ARRAY2VALUES_2_LREAL.fbt | 26 ++-- .../utils/CSV_WRITER_1.fbt | 44 +++--- .../utils/CSV_WRITER_10.fbt | 118 ++++++--------- .../utils/CSV_WRITER_2.fbt | 48 +++---- .../utils/CSV_WRITER_3.fbt | 52 +++---- .../utils/CSV_WRITER_4.fbt | 56 ++++---- .../utils/CSV_WRITER_5.fbt | 60 ++++---- .../utils/CSV_WRITER_6.fbt | 64 ++++----- .../utils/CSV_WRITER_7.fbt | 68 ++++----- .../utils/CSV_WRITER_8.fbt | 72 +++++----- .../utils/CSV_WRITER_9.fbt | 114 +++++---------- .../iec61499.4diac.stdlib/utils/F_MUX_2_1.fbt | 37 +++-- .../iec61499.4diac.stdlib/utils/F_MUX_2_2.fbt | 48 +++---- .../utils/GET_AT_INDEX.fbt | 30 ++-- .../utils/OUT_ANY_CONSOLE.fbt | 33 ++--- .../utils/SET_AT_INDEX.fbt | 34 ++--- .../iec61499.4diac.stdlib/utils/STEST_END.fbt | 18 +-- .../utils/VALUES2ARRAY_2_LREAL.fbt | 26 ++-- .../models/org.fbme.debugger.build.mps | 2 +- .../models/org.fbme.debugger.plugin.mps | 134 +++++++++--------- .../org.fbme.ide.iec61499.lang.mpl | 1 + .../fbnetwork/FunctionBlockController.kt | 1 + .../adapters/fbnetwork/fb/AbstractFBCell.kt | 4 + .../adapters/fbnetwork/fb/FBCell.kt | 1 + .../fbnetwork/fb/FBTypeCellComponent.kt | 15 ++ .../components/ComponentsFacility.kt | 15 ++ ....fbme.ide.iec61499.lang.sandbox.blinky.mps | 40 +++--- .../DeliveryServices.app | 64 ++++----- ...e.iec61499.lang.sandbox.mpsPersistence.mps | 130 ++++++++++++++--- 108 files changed, 2137 insertions(+), 2752 deletions(-) delete mode 100644 .idea/.name delete mode 100644 .idea/codeStyles/codeStyleConfig.xml delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/dictionaries/IEC_61499_Terms.xml delete mode 100644 .idea/dictionaries/default.xml delete mode 100644 .idea/dictionaries/project_dictionary.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/Project_check.xml delete mode 100644 .idea/jarRepositories.xml delete mode 100644 .idea/kotlinScripting.xml delete mode 100644 .idea/kotlinc.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules/fbme.iml delete mode 100644 .idea/runConfigurations/Remote_debug_MPS.xml delete mode 100644 .idea/runConfigurations/Test_Teamcity_configuration_generation.xml delete mode 100644 .idea/scopes/Checked_source_files.xml delete mode 100644 .idea/uiDesigner.xml delete mode 100644 .idea/vcs.xml diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index dae8a134b..000000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -FBME \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index a55e7a179..000000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 58d13c02c..000000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/dictionaries/IEC_61499_Terms.xml b/.idea/dictionaries/IEC_61499_Terms.xml deleted file mode 100644 index 97a1283bd..000000000 --- a/.idea/dictionaries/IEC_61499_Terms.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - subapplication - - - \ No newline at end of file diff --git a/.idea/dictionaries/default.xml b/.idea/dictionaries/default.xml deleted file mode 100644 index 459e72842..000000000 --- a/.idea/dictionaries/default.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - mbeddr - - - \ No newline at end of file diff --git a/.idea/dictionaries/project_dictionary.xml b/.idea/dictionaries/project_dictionary.xml deleted file mode 100644 index 8ad2401b9..000000000 --- a/.idea/dictionaries/project_dictionary.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - fbme - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 15a15b218..000000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 81a16643f..000000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_check.xml b/.idea/inspectionProfiles/Project_check.xml deleted file mode 100644 index 36e04539b..000000000 --- a/.idea/inspectionProfiles/Project_check.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml deleted file mode 100644 index dc08c64af..000000000 --- a/.idea/jarRepositories.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/kotlinScripting.xml b/.idea/kotlinScripting.xml deleted file mode 100644 index a6fe551d0..000000000 --- a/.idea/kotlinScripting.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml deleted file mode 100644 index 7e340a776..000000000 --- a/.idea/kotlinc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 4981e477a..000000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules/fbme.iml b/.idea/modules/fbme.iml deleted file mode 100644 index f49154055..000000000 --- a/.idea/modules/fbme.iml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/Remote_debug_MPS.xml b/.idea/runConfigurations/Remote_debug_MPS.xml deleted file mode 100644 index 20f273054..000000000 --- a/.idea/runConfigurations/Remote_debug_MPS.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/Test_Teamcity_configuration_generation.xml b/.idea/runConfigurations/Test_Teamcity_configuration_generation.xml deleted file mode 100644 index a92656d88..000000000 --- a/.idea/runConfigurations/Test_Teamcity_configuration_generation.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/scopes/Checked_source_files.xml b/.idea/scopes/Checked_source_files.xml deleted file mode 100644 index f07539016..000000000 --- a/.idea/scopes/Checked_source_files.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml deleted file mode 100644 index e96534fb2..000000000 --- a/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 5fc092178..000000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/code/4diac-integration/solutions/org.fbme.ide.integration.fordiac/models/org.fbme.ide.integration.fordiac.mps b/code/4diac-integration/solutions/org.fbme.ide.integration.fordiac/models/org.fbme.ide.integration.fordiac.mps index d79377fa0..7e0a22dda 100644 --- a/code/4diac-integration/solutions/org.fbme.ide.integration.fordiac/models/org.fbme.ide.integration.fordiac.mps +++ b/code/4diac-integration/solutions/org.fbme.ide.integration.fordiac/models/org.fbme.ide.integration.fordiac.mps @@ -2409,7 +2409,7 @@ - + @@ -3452,7 +3452,7 @@ - + @@ -3515,7 +3515,7 @@ - + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ARTimeOut.adp b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ARTimeOut.adp index a1db20d5e..241e4efd0 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ARTimeOut.adp +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ARTimeOut.adp @@ -1,43 +1,20 @@ - - - - - + + + + - + - - + + - + - - + - - - - - - - - - - - - - - - - - - - - - - + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ATimeOut.adp b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ATimeOut.adp index 3f1e31e83..98cedb509 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ATimeOut.adp +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ATimeOut.adp @@ -1,43 +1,20 @@ - - - - - + + + + - + - - + + - + - - + - - - - - - - - - - - - - - - - - - - - - - + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTD.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTD.fbt index 4009ff2af..befb80a3c 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTD.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTD.fbt @@ -1,53 +1,52 @@ - - - - - - + + + + - - - + + + - - - + + + - - - + + + - + - - + + - - - + + + - - + + - - - - + + + + - - + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTU.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTU.fbt index b25d18607..d589e50e1 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTU.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTU.fbt @@ -1,52 +1,52 @@ - - - - - + + + + - - + + - + - - - + + + - - - + + + - + - - + + - - - + + + - - + + - - - - + + + + - - + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTUD.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTUD.fbt index 4d25a82e0..b8e951a30 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTUD.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTUD.fbt @@ -1,88 +1,87 @@ - - - - - - + + + + - - + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - - - - - - + + + + + + + + - - + + - - + + - - + + - - + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CYCLE.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CYCLE.fbt index d9cf7d0c5..fb489a591 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CYCLE.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CYCLE.fbt @@ -1,33 +1,32 @@ - - - - - + + + + - - + + - + - + - + - - + - + - - - - + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DELAY.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DELAY.fbt index 1c946292f..4ff104963 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DELAY.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DELAY.fbt @@ -1,22 +1,20 @@ - - - - - + + + + - - + + - + - + - + - - + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DEMUX.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DEMUX.fbt index 37b71de45..7eb1d6054 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DEMUX.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DEMUX.fbt @@ -1,51 +1,50 @@ - - - - - + + + + - - + + - - - - + + + + - + - - - - - + + + + - - + + - - + + - - + + - - - - - - - - - - + + + + + + + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_D_FF.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_D_FF.fbt index 17088f6e5..f7de52036 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_D_FF.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_D_FF.fbt @@ -1,41 +1,41 @@ - - - - - + + + + - - + + - - + + - + - + - - - + + + - - + + - - - + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_F_TRIG.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_F_TRIG.fbt index ddb8d1385..14fe1a40c 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_F_TRIG.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_F_TRIG.fbt @@ -1,33 +1,32 @@ - - - - - + + + + - - + + - + - + - - - + + - - + + - - - + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_MERGE.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_MERGE.fbt index 38d301c6d..0b1daf198 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_MERGE.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_MERGE.fbt @@ -1,28 +1,26 @@ - - - - - + + + + - - + + - + - - - - - + + + - - - + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_PERMIT.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_PERMIT.fbt index e25cf44ae..12ef92e95 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_PERMIT.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_PERMIT.fbt @@ -1,30 +1,29 @@ - - - - - + + + + - - + + - + - + - - - - + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RDELAY.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RDELAY.fbt index 8a9a6e731..fdf4785b5 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RDELAY.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RDELAY.fbt @@ -1,48 +1,20 @@ - - - - - + + + + - - + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_REND.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_REND.fbt index ee243fe7e..1e3d8064f 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_REND.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_REND.fbt @@ -1,35 +1,33 @@ - - - - - + + + + - - - + + + - + - - - - - - + + + + - - - - - - - - + + + + + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RS.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RS.fbt index 93e7f0729..84b71ed8d 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RS.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RS.fbt @@ -1,41 +1,40 @@ - - - - - + + + + - - + + - - + + - - + - - - + + + - - + + - - - + + + - - + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_R_TRIG.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_R_TRIG.fbt index ef5bf7f0a..a869162db 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_R_TRIG.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_R_TRIG.fbt @@ -1,33 +1,32 @@ - - - - - + + + + - - + + - + - + - - - + + - - + + - - - + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SELECT.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SELECT.fbt index 952f0a944..26f8e3b80 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SELECT.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SELECT.fbt @@ -1,34 +1,33 @@ - - - - - + + + + - - + + - - + + - + - + - - - - + + + - - - + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SPLIT.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SPLIT.fbt index fe05f3082..00c703b82 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SPLIT.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SPLIT.fbt @@ -1,28 +1,26 @@ - - - - - + + + + - + - - + + - - - - - - + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SR.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SR.fbt index 7abea8e07..7dc6604a7 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SR.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SR.fbt @@ -1,41 +1,40 @@ - - - - - + + + + - - + + - - + + - - + - - - + + + - - + + - - - + + + - - + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SWITCH.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SWITCH.fbt index 0baa676f4..5021cc9ac 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SWITCH.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SWITCH.fbt @@ -1,36 +1,35 @@ - - - - - + + + + - - + + - - + + - + - - - - + + + - - + + - - - - + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TABLE.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TABLE.fbt index 71165d7a3..f4fab690b 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TABLE.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TABLE.fbt @@ -1,44 +1,44 @@ - - - - - + + + + - - - + + + - + - - + + - - + + - + - - + + - - - - + + + + - - - - - + + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TRAIN.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TRAIN.fbt index b3275bf54..cf6c563bf 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TRAIN.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TRAIN.fbt @@ -1,47 +1,47 @@ - - - - - + + + + - - + + - - + + - - + + - - + + - + - - - + + + - - - - + + + + - - - - - - + + + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_T_FF.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_T_FF.fbt index a707553f1..f14cbb562 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_T_FF.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_T_FF.fbt @@ -1,33 +1,32 @@ - - - - - + + + + - + - - + + - - + - - - + + + - - + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/ID.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/ID.fbt index a9e323a10..dfb168333 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/ID.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/ID.fbt @@ -1,37 +1,37 @@ - - - - - + + + + - - - + + + - - + + - - - + + + - - - - + + + + - - + + - - - + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IW.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IW.fbt index 7a814ffd7..2e6876b7e 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IW.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IW.fbt @@ -1,38 +1,37 @@ - - - - - - + + + + - - - + + + - - + + - - - + + + - - - - + + + + - - + + - - - + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IX.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IX.fbt index 5e18120a4..3976f99d0 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IX.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IX.fbt @@ -1,44 +1,42 @@ - - - - - - - + + + + - - - + + + - - + + - - - + + + - - - - + + + + - - - - + + + + - - + + - - - + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QD.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QD.fbt index 81ae3f259..79e123d4d 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QD.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QD.fbt @@ -1,102 +1,37 @@ - - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QW.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QW.fbt index daaa10218..6b02e35d9 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QW.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QW.fbt @@ -1,103 +1,37 @@ - - - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QX.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QX.fbt index e74bbfc75..591f6c75a 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QX.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QX.fbt @@ -1,104 +1,37 @@ - - - - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/math/FB_RANDOM.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/math/FB_RANDOM.fbt index 001488292..f809fa6cd 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/math/FB_RANDOM.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/math/FB_RANDOM.fbt @@ -1,48 +1,47 @@ - - - - - + + + + - - + + - + - - - + + + - + - + - - - + + + - - + + - - - - + + + + - - + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_1.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_1.fbt index 2d8ffdd75..f0e7fb376 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_1.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_1.fbt @@ -1,39 +1,39 @@ - - - - - + + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - + + + - - - + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_2_1.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_2_1.fbt index babd5aac3..92c3e8b21 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_2_1.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_2_1.fbt @@ -1,41 +1,41 @@ - - - - - + + + + - - - + + + - - - - + + + + - - - + + + - - - - + + + + - - - - + + + + - - - + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_0.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_0.fbt index d0d4bfeb6..2e1be9cc8 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_0.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_0.fbt @@ -1,35 +1,35 @@ - - - - - + + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_1.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_1.fbt index 278a67253..eb2a06134 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_1.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_1.fbt @@ -1,37 +1,37 @@ - - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_10.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_10.fbt index 536beceb4..cc7b8884c 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_10.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_10.fbt @@ -1,53 +1,53 @@ - - - - - + + + + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_2.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_2.fbt index a842da09d..5c10b2aba 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_2.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_2.fbt @@ -1,39 +1,39 @@ - - - - - + + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - - + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_3.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_3.fbt index 6fbcb5d90..a2e341c8a 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_3.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_3.fbt @@ -1,41 +1,41 @@ - - - - - + + + + - - - + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_4.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_4.fbt index 609b7a2ff..69937a261 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_4.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_4.fbt @@ -1,43 +1,43 @@ - - - - - + + + + - - - + + + - - - - - - + + + + + + - - - + + + - - - + + + - - - - - - + + + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_5.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_5.fbt index 5ee1bddbf..6cc72c38b 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_5.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_5.fbt @@ -1,45 +1,45 @@ - - - - - + + + + - - - + + + - - - - - - - + + + + + + + - - - + + + - - - + + + - - - - - - - + + + + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_6.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_6.fbt index a70260c4c..d9a70abfb 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_6.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_6.fbt @@ -1,47 +1,47 @@ - - - - - + + + + - - - + + + - - - - - - - - + + + + + + + + - - - + + + - - - + + + - - - - - - - - + + + + + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_7.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_7.fbt index 13478dcf1..9209dc124 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_7.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_7.fbt @@ -1,49 +1,49 @@ - - - - - + + + + - - - + + + - - - - - - - - - + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - + + + + + + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_8.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_8.fbt index 64e1d477b..e3690b4ba 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_8.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_8.fbt @@ -1,51 +1,51 @@ - - - - - + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - + + + + + + + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_9.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_9.fbt index 1a96b6856..770e7cdc8 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_9.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_9.fbt @@ -1,55 +1,55 @@ - - - - - + + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1.fbt index f14ea0be0..2d2634649 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1.fbt @@ -1,39 +1,39 @@ - - - - - + + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - + + + - - - + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1_2.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1_2.fbt index f8dd0fbd9..072ae81e0 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1_2.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1_2.fbt @@ -1,41 +1,41 @@ - - - - - + + + + - - - + + + - - - + + + - - - + + + - - - - - + + + + + - - - + + + - - - - + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_0.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_0.fbt index ebe1f459e..fab48d14c 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_0.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_0.fbt @@ -1,35 +1,35 @@ - - - - - + + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_1.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_1.fbt index 6788a4a3c..7e65c31dd 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_1.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_1.fbt @@ -1,37 +1,37 @@ - - - - - + + + + - - - + + + - - + + - - - + + + - - - - + + + + - - + + - - - + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_10.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_10.fbt index bfebc7d4d..1ada8f98d 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_10.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_10.fbt @@ -1,56 +1,55 @@ - - - - - + + + + - - - + + + - - + + - - - + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - + + - - - - - - - - - - - - + + + + + + + + + + + + - + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_2.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_2.fbt index 9ea1363c0..fe543fbae 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_2.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_2.fbt @@ -1,39 +1,39 @@ - - - - - + + + + - - - + + + - - + + - - - + + + - - - - - + + + + + - - + + - - - - + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_3.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_3.fbt index 8450323a2..64fe75189 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_3.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_3.fbt @@ -1,41 +1,41 @@ - - - - - + + + + - - - + + + - - + + - - - + + + - - - - - - + + + + + + - - + + - - - - - + + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_4.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_4.fbt index 8919d0cd2..ed1d06d7c 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_4.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_4.fbt @@ -1,43 +1,43 @@ - - - - - + + + + - - - + + + - - + + - - - + + + - - - - - - - + + + + + + + - - + + - - - - - - + + + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_5.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_5.fbt index 748c51066..fb0c0dead 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_5.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_5.fbt @@ -1,45 +1,45 @@ - - - - - + + + + - - - + + + - - + + - - - + + + - - - - - - - - + + + + + + + + - - + + - - - - - - - + + + + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_6.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_6.fbt index 30ca78bc1..b2be6dffa 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_6.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_6.fbt @@ -1,47 +1,47 @@ - - - - - + + + + - - - + + + - - + + - - - + + + - - - - - - - - - + + + + + + + + + - - + + - - - - - - - - + + + + + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_7.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_7.fbt index 0ff26cb89..4be21224c 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_7.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_7.fbt @@ -1,49 +1,49 @@ - - - - - + + + + - - - + + + - - + + - - - + + + - - - - - - - - - - + + + + + + + + + + - - + + - - - - - - - - - + + + + + + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_8.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_8.fbt index d2702e30b..afef3cbe3 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_8.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_8.fbt @@ -1,51 +1,51 @@ - - - - - + + + + - - - + + + - - + + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - + + - - - - - - - - - - + + + + + + + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_9.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_9.fbt index 6cfc72066..7977ceaf6 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_9.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_9.fbt @@ -1,53 +1,53 @@ - - - - - + + + + - - - + + + - - + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + - - + + - - - - - - - - - - - + + + + + + + + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_2.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_2.fbt index 90391f9f6..e528d31ca 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_2.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_2.fbt @@ -1,26 +1,26 @@ - - - - - + + + + - - - + + + - - + + - - + + - + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_3.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_3.fbt index 8ae5f2f18..021b97a9e 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_3.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_3.fbt @@ -1,28 +1,28 @@ - - - - - + + + + - - - - + + + + - - + + - - - + + + - + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2ARRAY_2_LREAL.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2ARRAY_2_LREAL.fbt index c00f7079e..d8d3ef970 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2ARRAY_2_LREAL.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2ARRAY_2_LREAL.fbt @@ -1,25 +1,24 @@ - - - - - + + + + - - + + - - + + - + - + - + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2VALUES_2_LREAL.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2VALUES_2_LREAL.fbt index 4aa17fa66..798a8b190 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2VALUES_2_LREAL.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2VALUES_2_LREAL.fbt @@ -1,26 +1,26 @@ - - - - - + + + + - - + + - - - + + + - + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_1.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_1.fbt index 974084c1b..d64599310 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_1.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_1.fbt @@ -1,37 +1,37 @@ - - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_10.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_10.fbt index 78056b948..ae4b3a822 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_10.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_10.fbt @@ -1,93 +1,55 @@ - - - - - + + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_2.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_2.fbt index d30d4eec3..76fff65a6 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_2.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_2.fbt @@ -1,39 +1,39 @@ - - - - - + + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - - + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_3.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_3.fbt index efd08dc20..b488f514b 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_3.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_3.fbt @@ -1,41 +1,41 @@ - - - - - + + + + - - - + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_4.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_4.fbt index 6bd3fe9d4..3dfcbeffd 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_4.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_4.fbt @@ -1,43 +1,43 @@ - - - - - + + + + - - - + + + - - - - - - + + + + + + - - - + + + - - - + + + - - - - - - + + + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_5.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_5.fbt index 218ff749d..3fa5a89fa 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_5.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_5.fbt @@ -1,45 +1,45 @@ - - - - - + + + + - - - + + + - - - - - - - + + + + + + + - - - + + + - - - + + + - - - - - - - + + + + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_6.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_6.fbt index 06ecf77ce..662f4fb00 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_6.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_6.fbt @@ -1,47 +1,47 @@ - - - - - + + + + - - - + + + - - - - - - - - + + + + + + + + - - - + + + - - - + + + - - - - - - - - + + + + + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_7.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_7.fbt index 942a5b8c7..7efd7f001 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_7.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_7.fbt @@ -1,49 +1,49 @@ - - - - - + + + + - - - + + + - - - - - - - - - + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - + + + + + + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_8.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_8.fbt index 155c99ed8..6a3f249e5 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_8.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_8.fbt @@ -1,51 +1,51 @@ - - - - - + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - + + + + + + + + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_9.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_9.fbt index 9f788046c..3ceec55a3 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_9.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_9.fbt @@ -1,91 +1,53 @@ - - - - - + + + + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_1.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_1.fbt index 7e43b4a51..1ed6dab6b 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_1.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_1.fbt @@ -1,33 +1,32 @@ - - - - - + + + + - - + + - - + + - - - - + + + + - - + + - - - + + + - + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_2.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_2.fbt index 726bb7549..41046a868 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_2.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_2.fbt @@ -1,38 +1,38 @@ - - - - - + + + + - - - + + + - - - + + + - - - - - + + + + + - - - - + + + + - - - - + + + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/GET_AT_INDEX.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/GET_AT_INDEX.fbt index e447d1b13..63509b753 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/GET_AT_INDEX.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/GET_AT_INDEX.fbt @@ -1,28 +1,28 @@ - - - - - + + + + - - - + + + - - - + + + - - + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/OUT_ANY_CONSOLE.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/OUT_ANY_CONSOLE.fbt index 8dba4bd27..6e60e3fc2 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/OUT_ANY_CONSOLE.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/OUT_ANY_CONSOLE.fbt @@ -1,31 +1,28 @@ - - - - - - - - + + + + - - - - + + + + - - + + - - - + + + - + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/SET_AT_INDEX.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/SET_AT_INDEX.fbt index b53a8cbaa..fade1a828 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/SET_AT_INDEX.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/SET_AT_INDEX.fbt @@ -1,30 +1,30 @@ - - - - - + + + + - - - - + + + + - - - + + + - - - + + + - - + + + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/STEST_END.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/STEST_END.fbt index 7cd2785e1..c1d5417d9 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/STEST_END.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/STEST_END.fbt @@ -1,17 +1,11 @@ - - - - - - - + + + + - + - - - - + diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/VALUES2ARRAY_2_LREAL.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/VALUES2ARRAY_2_LREAL.fbt index 078afd773..b692b9541 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/VALUES2ARRAY_2_LREAL.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/VALUES2ARRAY_2_LREAL.fbt @@ -1,26 +1,26 @@ - - - - - + + + + - - - + + + - - + + - - + + - + + diff --git a/code/debugger/buildsolution/models/org.fbme.debugger.build.mps b/code/debugger/buildsolution/models/org.fbme.debugger.build.mps index e62b1e639..7699996d1 100644 --- a/code/debugger/buildsolution/models/org.fbme.debugger.build.mps +++ b/code/debugger/buildsolution/models/org.fbme.debugger.build.mps @@ -138,7 +138,7 @@ - + diff --git a/code/debugger/solutions/org.fbme.debugger/models/org.fbme.debugger.plugin.mps b/code/debugger/solutions/org.fbme.debugger/models/org.fbme.debugger.plugin.mps index f61dac21e..409594761 100644 --- a/code/debugger/solutions/org.fbme.debugger/models/org.fbme.debugger.plugin.mps +++ b/code/debugger/solutions/org.fbme.debugger/models/org.fbme.debugger.plugin.mps @@ -458,7 +458,7 @@ - + @@ -497,7 +497,7 @@ - + @@ -552,8 +552,8 @@ - - + + @@ -970,7 +970,7 @@ - + @@ -997,7 +997,7 @@ - + @@ -1032,11 +1032,11 @@ - + - + @@ -1075,7 +1075,7 @@ - + @@ -1126,7 +1126,7 @@ - + @@ -1140,7 +1140,7 @@ - + @@ -1180,11 +1180,11 @@ - + - + @@ -1221,7 +1221,7 @@ - + @@ -1232,7 +1232,7 @@ - + @@ -1293,7 +1293,7 @@ - + @@ -1315,7 +1315,7 @@ - + @@ -1348,7 +1348,7 @@ - + @@ -1367,7 +1367,7 @@ - + @@ -1385,7 +1385,7 @@ - + @@ -1407,7 +1407,7 @@ - + @@ -1469,11 +1469,11 @@ - + - + @@ -1502,7 +1502,7 @@ - + @@ -1526,7 +1526,7 @@ - + @@ -1610,7 +1610,7 @@ - + @@ -1632,7 +1632,7 @@ - + @@ -1694,11 +1694,11 @@ - + - + @@ -1727,7 +1727,7 @@ - + @@ -1750,7 +1750,7 @@ - + @@ -1830,7 +1830,7 @@ - + @@ -1852,7 +1852,7 @@ - + @@ -1933,11 +1933,11 @@ - + - + @@ -1963,7 +1963,7 @@ - + @@ -2022,7 +2022,7 @@ - + @@ -2044,7 +2044,7 @@ - + @@ -2077,7 +2077,7 @@ - + @@ -2096,7 +2096,7 @@ - + @@ -2114,7 +2114,7 @@ - + @@ -2136,7 +2136,7 @@ - + @@ -2198,11 +2198,11 @@ - + - + @@ -2231,7 +2231,7 @@ - + @@ -2255,7 +2255,7 @@ - + @@ -2339,7 +2339,7 @@ - + @@ -2361,7 +2361,7 @@ - + @@ -2423,11 +2423,11 @@ - + - + @@ -2456,7 +2456,7 @@ - + @@ -2479,7 +2479,7 @@ - + @@ -2559,7 +2559,7 @@ - + @@ -2581,7 +2581,7 @@ - + @@ -2662,11 +2662,11 @@ - + - + @@ -2692,7 +2692,7 @@ - + @@ -2811,8 +2811,8 @@ - - + + @@ -7608,7 +7608,7 @@ - + @@ -7774,8 +7774,8 @@ - - + + @@ -8194,8 +8194,8 @@ - - + + @@ -8298,7 +8298,7 @@ - + @@ -8997,8 +8997,8 @@ - - + + diff --git a/code/language/languages/org.fbme.ide.iec61499.lang/org.fbme.ide.iec61499.lang.mpl b/code/language/languages/org.fbme.ide.iec61499.lang/org.fbme.ide.iec61499.lang.mpl index 9304586c9..7352eddd1 100644 --- a/code/language/languages/org.fbme.ide.iec61499.lang/org.fbme.ide.iec61499.lang.mpl +++ b/code/language/languages/org.fbme.ide.iec61499.lang/org.fbme.ide.iec61499.lang.mpl @@ -52,6 +52,7 @@ + diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt index 73cdbaac1..8a23bdb32 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt @@ -177,6 +177,7 @@ class FunctionBlockController( override fun updateCellSelection(selected: Boolean) { myNameProperty.style.set(StyleAttributes.FONT_STYLE, if (selected) Font.BOLD else Font.PLAIN) + fbCell.isSelected = selected } override fun paintTrace(g: Graphics?, form: Point) { diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt index 2fd9a137f..e8ce8d108 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt @@ -71,6 +71,10 @@ abstract class AbstractFBCell protected constructor( override val bounds: Rectangle get() = Rectangle(rootCell.x, rootCell.y, width, height) + override var isSelected: Boolean + get() = false + set(value) {} + override fun relayout() { relayoutChildren() } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBCell.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBCell.kt index 55ebb4e0c..dffb33e2f 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBCell.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBCell.kt @@ -20,6 +20,7 @@ interface FBCell { val eventPortsCount: Int val inputEventPortsCount: Int val outputEventPortsCount: Int + var isSelected: Boolean fun getInputEventPortPosition(eventNumber: Int): Point fun getOutputEventPortPosition(eventNumber: Int): Point fun getInputDataPortPosition(dataNumber: Int): Point diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt index 03ac0ad2a..16a8d645b 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt @@ -23,6 +23,8 @@ import org.fbme.scenes.cells.EditorCell_SceneLabel import org.jetbrains.mps.openapi.model.SNode import java.awt.* import java.awt.geom.AffineTransform +import java.awt.geom.Ellipse2D +import java.awt.geom.GeneralPath import java.util.* import kotlin.math.max @@ -41,6 +43,8 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node private val foregroundColor: Color get() = rootCell.style.get(StyleAttributes.TEXT_COLOR) + override var isSelected: Boolean = false + init { rootCell = createRootCell() rootCell.style.set(RichEditorStyleAttributes.TYPE, fbType) @@ -194,6 +198,16 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node drawAllPortIcons(graphics, foreground) } + fun drawEditIcon(graphics: Graphics2D, mainComponent: GeneralPath) { + if (isSelected) { + val x = mainComponent.bounds2D.maxX + 10 + val y = mainComponent.bounds2D.minY - 20 + val shape: Shape = Ellipse2D.Double(x, y, 15.0, 15.0) + graphics.paint = Color(0x737373) + graphics.fill(shape) + } + } + private fun drawComponentShape(graphics: Graphics2D, background: Color, foreground: Color) { val x = rootCell.x val y = rootCell.y @@ -213,6 +227,7 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node graphics.stroke = BasicStroke(scale(1).toFloat()) graphics.color = foreground graphics.draw(shape) + drawEditIcon(graphics, shape) } private fun calculateHeight(): Int { diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt index 36e002663..ae1a515ed 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt @@ -151,6 +151,10 @@ class ComponentsFacility( private inner class MyClickEventListener : ClickEventListener { override fun onMouseClicked(event: ClickEvent) { val component = layout.findAt(event.awt.x, event.awt.y) + ?: layout.findAt(event.awt.x - 35, event.awt.y - 25) + ?: layout.findAt(event.awt.x - 35, event.awt.y + 25) + ?: layout.findAt(event.awt.x + 35, event.awt.y - 25) + ?: layout.findAt(event.awt.x + 35, event.awt.y + 35) if (component != null) { setSelection(component, clickShouldSelect) components[component]!!.relayout() @@ -219,6 +223,16 @@ class ComponentsFacility( } } + private inner class MyCursorListener() : CursorListener { + override fun onCursorMoved(event: CursorEvent) { + val component = layout.findAt(event.awt.x, event.awt.y) + + if (component != null) { + + } + } + } + companion object { private val SELECTION_KEY = SceneStateKey?>("comp-selection") } @@ -234,6 +248,7 @@ class ComponentsFacility( editor.addCellProvider(componentsLayer, MyCellProvider()) editor.addClickListener(componentsLayer, MyClickEventListener()) editor.addDragListener(componentsLayer, MyDragEventListener()) + editor.addCursorListener(MyCursorListener()) editor.addPainter(tracesLayer, MyPainter()) editor.addInitializer(MySelectionInitializer()) } diff --git a/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.blinky.mps b/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.blinky.mps index 77ad4dbfb..b3940b5a3 100644 --- a/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.blinky.mps +++ b/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.blinky.mps @@ -299,10 +299,10 @@ - - - - + + + + @@ -314,10 +314,10 @@ - - - - + + + + @@ -329,7 +329,9 @@ - + + + @@ -340,30 +342,32 @@ - + + + - - + + - - + + - - + + @@ -375,8 +379,8 @@ - - + + diff --git a/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.enas/DeliveryServices.app b/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.enas/DeliveryServices.app index f46fb79bb..482d196f9 100644 --- a/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.enas/DeliveryServices.app +++ b/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.enas/DeliveryServices.app @@ -55,49 +55,49 @@ - + - + - + - + - + - - - - - - + + + + + + - + - + - - - - - + + + + + @@ -107,9 +107,9 @@ - + - + @@ -119,28 +119,28 @@ - + - - + + - - + + - - - - + + + + - - - + + + diff --git a/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.mpsPersistence.mps b/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.mpsPersistence.mps index 67b9e3804..8c7a122d6 100644 --- a/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.mpsPersistence.mps +++ b/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.mpsPersistence.mps @@ -24,6 +24,7 @@ + @@ -53,6 +54,7 @@ + @@ -956,8 +958,8 @@ - - + + @@ -976,8 +978,8 @@ - - + + @@ -989,8 +991,8 @@ - - + + @@ -1027,7 +1029,7 @@ - + @@ -1053,8 +1055,8 @@ - - + + @@ -1117,7 +1119,9 @@ - + + + @@ -1128,14 +1132,18 @@ - + + + + + - - + + @@ -1236,16 +1244,16 @@ - - + + - - + + @@ -1532,5 +1540,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 4da7caaf5dc16704a1acf00b786ca55b56948ef7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Tue, 18 Apr 2023 16:49:24 +0200 Subject: [PATCH 03/66] Refactor methods --- .../fbnetwork/fb/FBTypeCellComponent.kt | 181 ++++++++---------- 1 file changed, 77 insertions(+), 104 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt index 16a8d645b..6f50c555c 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt @@ -29,7 +29,7 @@ import java.util.* import kotlin.math.max class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node: SNode, isEditable: Boolean) : - AbstractFBCell(context, fbType, node, isEditable) { + AbstractFBCell(context, fbType, node, isEditable) { private val typeNameLabel: EditorCell_SceneLabel override val rootCell: EditorCell_Collection @@ -77,53 +77,41 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node relayoutLabel(lineSize) } - override fun getInputEventPortBounds(eventNumber: Int): Rectangle { + private fun getPortBounds( + position: Int, + ports: List, + isOutput: Boolean = false, + verticalOffset: Int = 0): Rectangle { val lineSize = lineSize - val port = inputEventPorts[eventNumber] - val width = (port as PortWithLabel).label.width + scale(INNER_BORDER_PADDING) - val y = eventNumber * lineSize - return Rectangle(0, y, width, lineSize) - } + val port = ports[position] - override fun getOutputEventPortBounds(eventNumber: Int): Rectangle { - val lineSize = lineSize - val port = outputEventPorts[eventNumber] val width = (port as PortWithLabel).label.width + scale(INNER_BORDER_PADDING) - val y = eventNumber * lineSize - return Rectangle(rootCell.width - width, y, width, lineSize) - } - override fun getInputDataPortBounds(dataNumber: Int): Rectangle { - val lineSize = lineSize - val port = inputDataPorts[dataNumber] - val width = (port as PortWithLabel).label.width + scale(INNER_BORDER_PADDING) - val y = (eventPortsCount + 2 + dataNumber) * lineSize - return Rectangle(0, y, width, lineSize) - } + val y = (verticalOffset + position) * lineSize + val x = if (isOutput) rootCell.width - width else 0 - override fun getOutputDataPortBounds(dataNumber: Int): Rectangle { - val lineSize = lineSize - val port = outputDataPorts[dataNumber] - val width = (port as PortWithLabel).label.width + scale(INNER_BORDER_PADDING) - val y = (eventPortsCount + 2 + dataNumber) * lineSize - return Rectangle(rootCell.width - width, y, width, lineSize) + return Rectangle(x, y, width, lineSize) } - override fun getSocketPortBounds(socketNumber: Int): Rectangle { - val lineSize = lineSize - val port = socketPorts[socketNumber] - val width = (port as PortWithLabel).label.width + scale(INNER_BORDER_PADDING) - val y = (eventPortsCount + inputDataPortsCount + 2 + socketNumber) * lineSize - return Rectangle(0, y, width, lineSize) - } + override fun getInputEventPortBounds(eventNumber: Int): Rectangle = + getPortBounds(eventNumber, inputEventPorts) + + override fun getOutputEventPortBounds(eventNumber: Int): Rectangle = + getPortBounds(eventNumber, outputEventPorts, isOutput = true) + + override fun getInputDataPortBounds(dataNumber: Int): Rectangle = + getPortBounds(dataNumber, inputDataPorts, verticalOffset = 2 + eventPortsCount) + + override fun getOutputDataPortBounds(dataNumber: Int): Rectangle = + getPortBounds(dataNumber, outputDataPorts, isOutput = true, verticalOffset = 2 + eventPortsCount) - override fun getPlugPortBounds(plugNumber: Int): Rectangle { - val lineSize = lineSize - val port = plugPorts[plugNumber] - val width = (port as PortWithLabel).label.width + scale(INNER_BORDER_PADDING) - val y = (eventPortsCount + 2 + outputDataPortsCount + plugNumber) * lineSize - return Rectangle(rootCell.width - width, y, width, lineSize) - } + + override fun getSocketPortBounds(socketNumber: Int): Rectangle = + getPortBounds(socketNumber, socketPorts, verticalOffset = 2 + eventPortsCount + inputDataPortsCount) + + override fun getPlugPortBounds(plugNumber: Int): Rectangle = + getPortBounds(plugNumber, plugPorts, isOutput = true, + verticalOffset = 2 + eventPortsCount + outputDataPortsCount) private fun relayoutPortLabels(lineSize: Int) { val leftX = rootCell.x + scale(INNER_BORDER_PADDING) @@ -138,51 +126,36 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node relayoutPlugPortLabels(rightX, dataY + lineSize * outputDataPorts.size, lineSize) } - private fun relayoutDataOutputPortLabels(x: Int, y: Int, lineSize: Int) { - relayoutOutputPortLabels(x, y, lineSize, outputDataPorts) - } + private fun relayoutDataOutputPortLabels(x: Int, y: Int, lineSize: Int) = + relayoutPortLabels(x, y, lineSize, outputDataPorts, isOutput = true) - private fun relayoutEventOutputPortLabels(x: Int, y: Int, lineSize: Int) { - relayoutOutputPortLabels(x, y, lineSize, outputEventPorts) - } + private fun relayoutEventOutputPortLabels(x: Int, y: Int, lineSize: Int) = + relayoutPortLabels(x, y, lineSize, outputEventPorts, isOutput = true) - private fun relayoutPlugPortLabels(x: Int, y: Int, lineSize: Int) { - relayoutOutputPortLabels(x, y, lineSize, plugPorts) - } + private fun relayoutPlugPortLabels(x: Int, y: Int, lineSize: Int) = + relayoutPortLabels(x, y, lineSize, plugPorts, isOutput = true) - private fun relayoutOutputPortLabels(x: Int, y: Int, lineSize: Int, outputPorts: List) { - var curY = y - for (port in outputPorts) { - val label = (port as PortWithLabel).label - label.moveTo(x - label.width, curY) - curY += lineSize - } - } + private fun relayoutDataInputPortLabels(x: Int, y: Int, lineSize: Int) = + relayoutPortLabels(x, y, lineSize, inputDataPorts) - private fun relayoutDataInputPortLabels(x: Int, y: Int, lineSize: Int) { - relayoutInputPortLabels(x, y, lineSize, inputDataPorts) - } + private fun relayoutEventInputPortLabels(x: Int, y: Int, lineSize: Int) = + relayoutPortLabels(x, y, lineSize, inputEventPorts) - private fun relayoutEventInputPortLabels(x: Int, y: Int, lineSize: Int) { - relayoutInputPortLabels(x, y, lineSize, inputEventPorts) - } - - private fun relayoutSocketPortLabels(x: Int, y: Int, lineSize: Int) { - relayoutInputPortLabels(x, y, lineSize, socketPorts) - } + private fun relayoutSocketPortLabels(x: Int, y: Int, lineSize: Int) = + relayoutPortLabels(x, y, lineSize, socketPorts) + private fun relayoutPortLabels(x: Int, y: Int, lineSize: Int, ports: List, isOutput: Boolean = false) = + ports.forEachIndexed { index, port -> + val label = (port as PortWithLabel).label + val curY = y + index * lineSize + val curX = x - if (isOutput) label.width else 0 + label.moveTo(curX, curY) + } - private fun relayoutInputPortLabels(x: Int, y: Int, lineSize: Int, inputPorts: List) { - var curY = y - for (port in inputPorts) { - (port as PortWithLabel).label.moveTo(x, curY) - curY += lineSize - } - } private fun relayoutLabel(lineSize: Int) { typeNameLabel.moveTo( - rootCell.x + rootCell.width / 2 - typeNameLabel.width / 2, - rootCell.y + (eventPortsCount + 1) * lineSize - lineSize / 4 + rootCell.x + rootCell.width / 2 - typeNameLabel.width / 2, + rootCell.y + (eventPortsCount + 1) * lineSize - lineSize / 4 ) } @@ -198,10 +171,10 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node drawAllPortIcons(graphics, foreground) } - fun drawEditIcon(graphics: Graphics2D, mainComponent: GeneralPath) { + fun drawEditIcon(graphics: Graphics2D, shape: GeneralPath) { if (isSelected) { - val x = mainComponent.bounds2D.maxX + 10 - val y = mainComponent.bounds2D.minY - 20 + val x = shape.bounds2D.maxX + 10 + val y = shape.bounds2D.minY - 20 val shape: Shape = Ellipse2D.Double(x, y, 15.0, 15.0) graphics.paint = Color(0x737373) graphics.fill(shape) @@ -220,8 +193,8 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node graphics.paint = DiagramColors.createGradientPaint(background, Rectangle(x, y, rootCell.width, rootCell.height)) graphics.fill(shape) graphics.paint = DiagramColors.createGradientPaint( - typeBackgroundColor, - Rectangle(x, y, rootCell.width, rootCell.height) + typeBackgroundColor, + Rectangle(x, y, rootCell.width, rootCell.height) ) graphics.fill(Rectangle(x, typeNameY, rootCell.width, lineSize)) graphics.stroke = BasicStroke(scale(1).toFloat()) @@ -239,12 +212,12 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node private fun calculateWidth(): Int { val typeNameRowWidth = typeNameLabel.width val inputsWidth = max( - portsColumnWidth(inputEventPorts), - max(portsColumnWidth(inputDataPorts), portsColumnWidth(socketPorts)) + portsColumnWidth(inputEventPorts), + max(portsColumnWidth(inputDataPorts), portsColumnWidth(socketPorts)) ) val outputsWidth = max( - portsColumnWidth(outputEventPorts), - max(portsColumnWidth(outputDataPorts), portsColumnWidth(plugPorts)) + portsColumnWidth(outputEventPorts), + max(portsColumnWidth(outputDataPorts), portsColumnWidth(plugPorts)) ) val regularRowsWidth = inputsWidth + outputsWidth + scale(CENTER_PADDING + 2 * INNER_BORDER_PADDING) return max(regularRowsWidth, typeNameRowWidth) + scale(2 * INNER_BORDER_PADDING) @@ -252,18 +225,18 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node private fun createRootCell(): EditorCell_Collection { return object : EditorCell_Collection( - context, - node, - object : AbstractCellLayout() { - override fun doLayout(collection: jetbrains.mps.openapi.editor.cells.EditorCell_Collection) { - assert(collection === rootCell) - relayout() - } - - override fun doLayoutText(iterable: Iterable): TextBuilder { - return TextBuilderImpl() + context, + node, + object : AbstractCellLayout() { + override fun doLayout(collection: jetbrains.mps.openapi.editor.cells.EditorCell_Collection) { + assert(collection === rootCell) + relayout() + } + + override fun doLayoutText(iterable: Iterable): TextBuilder { + return TextBuilderImpl() + } } - } ) { override fun paintContent(g: Graphics, parentSettings: ParentSettings) { this@FBTypeCellComponent.paint(g.create() as Graphics2D) @@ -301,8 +274,8 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node val childNetworkInstance = child.containedNetwork if (childNetworkInstance is NetworkInstance) { val navigationStub = NetworkInstanceNavigationSupport.getNavigationStub( - rootCell.context.operationContext.project, - childNetworkInstance + rootCell.context.operationContext.project, + childNetworkInstance ) style.set(StyleAttributes.NAVIGATABLE_NODE, navigationStub) return @@ -319,17 +292,17 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node private const val CENTER_PADDING = 20 private const val INNER_BORDER_PADDING = 2 private val PORT_LABEL_WIDTH_COMPARATOR = - Comparator.comparing { port: Port -> (port as PortWithLabel).label.width } + Comparator.comparing { port: Port -> (port as PortWithLabel).label.width } private fun portsColumnWidth(ports: List): Int { return if (ports.isEmpty()) { 0 } else ( - Collections.max( - ports, - PORT_LABEL_WIDTH_COMPARATOR - ) as PortWithLabel - ).label.width + Collections.max( + ports, + PORT_LABEL_WIDTH_COMPARATOR + ) as PortWithLabel + ).label.width } } } From d8f4ff872d74566cbc3ea472a7fc67992baeaf8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Tue, 18 Apr 2023 18:33:40 +0200 Subject: [PATCH 04/66] refactor abstractfbcell --- .../adapters/fbnetwork/fb/AbstractFBCell.kt | 54 ++++++------------- 1 file changed, 16 insertions(+), 38 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt index e8ce8d108..5e69d128d 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt @@ -12,6 +12,8 @@ import org.fbme.scenes.controllers.LayoutUtil.getLineSize import org.jetbrains.mps.openapi.model.SNode import java.awt.* import java.awt.geom.GeneralPath +import java.util.function.Function +import java.util.function.Supplier import kotlin.math.max abstract class AbstractFBCell protected constructor( @@ -79,53 +81,29 @@ abstract class AbstractFBCell protected constructor( relayoutChildren() } - override fun getInputEventPortPosition(eventNumber: Int): Point { + private fun getPortPosition(bounds: Rectangle, isOutput: Boolean = false): Point { val lineSize = lineSize - val bounds = getInputEventPortBounds(eventNumber) - val x = bounds.x - scale(PORT_SIZE) / 2 + val xOffset = if (isOutput) bounds.width + scale(PORT_SIZE) / 2 else - scale(PORT_SIZE) / 2 + val x = bounds.x + xOffset val y = bounds.y + lineSize / 2 return Point(x, y) } - override fun getOutputEventPortPosition(eventNumber: Int): Point { - val lineSize = lineSize - val bounds = getOutputEventPortBounds(eventNumber) - val x = bounds.x + bounds.width + scale(PORT_SIZE) / 2 - val y = bounds.y + lineSize / 2 - return Point(x, y) - } + override fun getInputEventPortPosition(eventNumber: Int): Point = + getPortPosition(getInputEventPortBounds(eventNumber)) - override fun getInputDataPortPosition(dataNumber: Int): Point { - val lineSize = lineSize - val bounds = getInputDataPortBounds(dataNumber) - val x = bounds.x - scale(PORT_SIZE) / 2 - val y = bounds.y + lineSize / 2 - return Point(x, y) - } + override fun getOutputEventPortPosition(eventNumber: Int): Point = + getPortPosition(getOutputEventPortBounds(eventNumber), isOutput = true) - override fun getOutputDataPortPosition(dataNumber: Int): Point { - val lineSize = lineSize - val bounds = getOutputDataPortBounds(dataNumber) - val x = bounds.x + bounds.width + scale(PORT_SIZE) / 2 - val y = bounds.y + lineSize / 2 - return Point(x, y) - } + override fun getInputDataPortPosition(dataNumber: Int): Point = getPortPosition(getInputDataPortBounds(dataNumber)) - override fun getSocketPortPosition(dataNumber: Int): Point { - val lineSize = lineSize - val bounds = getSocketPortBounds(dataNumber) - val x = bounds.x - scale(PORT_SIZE) / 2 - val y = bounds.y + lineSize / 2 - return Point(x, y) - } + override fun getOutputDataPortPosition(dataNumber: Int): Point = + getPortPosition(getOutputDataPortBounds(dataNumber), isOutput = true) - override fun getPlugPortPosition(dataNumber: Int): Point { - val lineSize = lineSize - val bounds = getPlugPortBounds(dataNumber) - val x = bounds.x + bounds.width + scale(PORT_SIZE) / 2 - val y = bounds.y + lineSize / 2 - return Point(x, y) - } + override fun getSocketPortPosition(dataNumber: Int): Point = getPortPosition(getSocketPortBounds(dataNumber)) + + override fun getPlugPortPosition(dataNumber: Int): Point = + getPortPosition(getPlugPortBounds(dataNumber), isOutput = true) protected fun initPorts() { initPorts(inputEventPorts, fbType.eventInputPorts) From 2cc3484c9d9fc46e497e1c3699d0fbd089d972d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Thu, 20 Apr 2023 18:16:48 +0200 Subject: [PATCH 05/66] Add button to fbCells --- .../fbnetwork/FunctionBlockController.kt | 66 +++++++-- .../adapters/fbnetwork/fb/AbstractFBCell.kt | 4 - .../adapters/fbnetwork/fb/FBCell.kt | 1 - .../fbnetwork/fb/FBTypeCellComponent.kt | 16 --- .../fbnetwork/fb/FBTypeEditCellComponent.kt | 130 ++++++++++++++++++ .../fbme/scenes/cells/EditorCell_Button.kt | 31 +++++ .../components/ComponentsFacility.kt | 4 +- 7 files changed, 216 insertions(+), 36 deletions(-) create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt index 8a23bdb32..248b6abe1 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt @@ -1,14 +1,20 @@ package org.fbme.ide.richediting.adapters.fbnetwork +import jetbrains.mps.editor.runtime.style.CellAlign +import jetbrains.mps.editor.runtime.style.Measure +import jetbrains.mps.editor.runtime.style.Padding import jetbrains.mps.editor.runtime.style.StyleAttributes import jetbrains.mps.nodeEditor.MPSColors import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Vertical import jetbrains.mps.nodeEditor.cells.* import jetbrains.mps.openapi.editor.EditorContext +import jetbrains.mps.openapi.editor.cells.CellAction +import jetbrains.mps.openapi.editor.cells.CellActionType import jetbrains.mps.openapi.editor.cells.EditorCell_Collection import org.fbme.ide.richediting.adapters.fbnetwork.fb.FBCell import org.fbme.ide.richediting.adapters.fbnetwork.fb.FBSceneCell import org.fbme.ide.richediting.adapters.fbnetwork.fb.FBTypeCellComponent +import org.fbme.ide.richediting.adapters.fbnetwork.fb.FBTypeEditCellComponent import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.ide.richediting.viewmodel.FunctionBlockPortView import org.fbme.ide.richediting.viewmodel.FunctionBlockView @@ -16,6 +22,7 @@ import org.fbme.ide.richediting.viewmodel.NetworkPortView import org.fbme.lib.iec61499.fbnetwork.EntryKind import org.fbme.lib.iec61499.instances.FunctionBlockInstance import org.fbme.lib.iec61499.instances.NetworkInstance +import org.fbme.scenes.cells.EditorCell_Button import org.fbme.scenes.controllers.LayoutUtil.getLineSize import org.fbme.scenes.controllers.components.ComponentController import org.jetbrains.mps.openapi.model.SNode @@ -29,6 +36,7 @@ class FunctionBlockController( val expandedComponentsController: ExpandedComponentsController ) : ComponentController, FBNetworkComponentController { private val myNameProperty: EditorCell_Property + private val editButton: EditorCell_Button private val cellCollection: jetbrains.mps.nodeEditor.cells.EditorCell_Collection private val isEditable: Boolean = view.isEditable private val fbCell: FBCell @@ -59,21 +67,13 @@ class FunctionBlockController( ) } - private fun createRootCell( - context: EditorContext, - node: SNode - ): jetbrains.mps.nodeEditor.cells.EditorCell_Collection { + private fun createRootCell(context: EditorContext, node: SNode): jetbrains.mps.nodeEditor.cells.EditorCell_Collection { return EditorCell_Collection( context, node, object : CellLayout_Vertical() { override fun doLayout(editorCells: EditorCell_Collection) { super.doLayout(editorCells) - fbCell.rootCell.moveTo(cellCollection.x, cellCollection.y + lineSize) - myNameProperty.moveTo( - cellCollection.x + fbCell.width / 2 - myNameProperty.width / 2, - cellCollection.y - lineSize / 4 - ) } } ) @@ -94,6 +94,14 @@ class FunctionBlockController( return FBTypeCellComponent(cellCollection.context, view.type, view.associatedNode, isEditable) } + private fun initializeFBEditCell(): FBCell { + return FBTypeEditCellComponent(cellCollection.context, view.type, view.associatedNode, isEditable) + } + + private fun getEditButton(context: EditorContext, node: SNode): EditorCell_Button { + return EditorCell_Button(context, node) + } + val fbInstance: FunctionBlockInstance? get() = networkInstance.getChild(view.component) @@ -125,7 +133,7 @@ class FunctionBlockController( EntryKind.ADAPTER -> if (isSource) fbCell.getPlugPortPosition(index) else fbCell.getSocketPortPosition(index) else -> error("") } - coordinates.translate(position.x, position.y + lineSize) + coordinates.translate(position.x, position.y + getVerticalOffset()) return coordinates } @@ -146,7 +154,7 @@ class FunctionBlockController( EntryKind.ADAPTER -> if (isSource) fbCell.getPlugPortBounds(index) else fbCell.getSocketPortBounds(index) else -> error("Unknown port kind") } - bounds.translate(position.x, position.y + lineSize) + bounds.translate(position.x, position.y + getVerticalOffset()) return bounds } @@ -177,14 +185,14 @@ class FunctionBlockController( override fun updateCellSelection(selected: Boolean) { myNameProperty.style.set(StyleAttributes.FONT_STYLE, if (selected) Font.BOLD else Font.PLAIN) - fbCell.isSelected = selected + editButton.style.set(StyleAttributes.TRANSPARENT, selected) } override fun paintTrace(g: Graphics?, form: Point) { fbCell.paintTrace( g!!.create() as Graphics2D, form.x, - form.y + if (fbCell is FBTypeCellComponent) lineSize else 0 + form.y + if (fbCell is FBTypeCellComponent) getVerticalOffset() else 0 ) } @@ -197,13 +205,45 @@ class FunctionBlockController( cellCollection.style.set(RichEditorStyleAttributes.FB, view.component) cellCollection.isBig = true this.networkInstance = networkInstance + //edit button + editButton = getEditButton(context, node) + editButton.style.set(StyleAttributes.HORIZONTAL_ALIGN, CellAlign.RIGHT) + editButton.setAction(CellActionType.CLICK, toEditModeAction()) + editButton.style.set( + StyleAttributes.PADDING_BOTTOM, + Padding(EditorCell_Button.OY_OFFSET.toDouble(), Measure.PIXELS) + ) + editButton.style.set(StyleAttributes.TRANSPARENT, true) + cellCollection.addEditorCell(editButton) + //name property myNameProperty = getNameProperty(context, view, node) myNameProperty.style.set(StyleAttributes.TEXT_COLOR, if (isEditable) MPSColors.BLACK else MPSColors.DARK_GRAY) + myNameProperty.style.set(StyleAttributes.HORIZONTAL_ALIGN, CellAlign.CENTER) cellCollection.addEditorCell(myNameProperty) + val isExpanded = expandedComponentsController.isExpanded(view) val editorShift = expandedComponentsController.getEditorShift(view) + fbCell = if (isExpanded) initializeFBSceneCell(editorShift) else initializeFBCell() cellCollection.addEditorCell(fbCell.rootCell) fbCell.relayout() } + + private fun getVerticalOffset(): Int { + return fbCell.rootCell.y - cellCollection.y + } + private fun toEditModeAction(): CellAction { + return object : CellAction { + override fun getDescriptionText(): String = "on click" + + override fun executeInCommand(): Boolean = true + + override fun canExecute(context: EditorContext): Boolean = true + + override fun execute(context: EditorContext) = + context.repository.modelAccess.executeCommandInEDT { + view.type.declaration?.name = "new name on click" + } + } + } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt index 5e69d128d..c0ba6bef1 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt @@ -73,10 +73,6 @@ abstract class AbstractFBCell protected constructor( override val bounds: Rectangle get() = Rectangle(rootCell.x, rootCell.y, width, height) - override var isSelected: Boolean - get() = false - set(value) {} - override fun relayout() { relayoutChildren() } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBCell.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBCell.kt index dffb33e2f..55ebb4e0c 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBCell.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBCell.kt @@ -20,7 +20,6 @@ interface FBCell { val eventPortsCount: Int val inputEventPortsCount: Int val outputEventPortsCount: Int - var isSelected: Boolean fun getInputEventPortPosition(eventNumber: Int): Point fun getOutputEventPortPosition(eventNumber: Int): Point fun getInputDataPortPosition(dataNumber: Int): Point diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt index 6f50c555c..51bc8c946 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt @@ -23,14 +23,11 @@ import org.fbme.scenes.cells.EditorCell_SceneLabel import org.jetbrains.mps.openapi.model.SNode import java.awt.* import java.awt.geom.AffineTransform -import java.awt.geom.Ellipse2D -import java.awt.geom.GeneralPath import java.util.* import kotlin.math.max class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node: SNode, isEditable: Boolean) : AbstractFBCell(context, fbType, node, isEditable) { - private val typeNameLabel: EditorCell_SceneLabel override val rootCell: EditorCell_Collection private val backgroundColor: Color @@ -43,8 +40,6 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node private val foregroundColor: Color get() = rootCell.style.get(StyleAttributes.TEXT_COLOR) - override var isSelected: Boolean = false - init { rootCell = createRootCell() rootCell.style.set(RichEditorStyleAttributes.TYPE, fbType) @@ -171,16 +166,6 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node drawAllPortIcons(graphics, foreground) } - fun drawEditIcon(graphics: Graphics2D, shape: GeneralPath) { - if (isSelected) { - val x = shape.bounds2D.maxX + 10 - val y = shape.bounds2D.minY - 20 - val shape: Shape = Ellipse2D.Double(x, y, 15.0, 15.0) - graphics.paint = Color(0x737373) - graphics.fill(shape) - } - } - private fun drawComponentShape(graphics: Graphics2D, background: Color, foreground: Color) { val x = rootCell.x val y = rootCell.y @@ -200,7 +185,6 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node graphics.stroke = BasicStroke(scale(1).toFloat()) graphics.color = foreground graphics.draw(shape) - drawEditIcon(graphics, shape) } private fun calculateHeight(): Int { diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt new file mode 100644 index 000000000..6b6ebdf98 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt @@ -0,0 +1,130 @@ +package org.fbme.ide.richediting.adapters.fbnetwork.fb + +import jetbrains.mps.editor.runtime.TextBuilderImpl +import jetbrains.mps.editor.runtime.style.StyleAttributes +import jetbrains.mps.nodeEditor.MPSColors +import jetbrains.mps.nodeEditor.cellLayout.AbstractCellLayout +import jetbrains.mps.nodeEditor.cells.EditorCell_Collection +import jetbrains.mps.nodeEditor.cells.ParentSettings +import jetbrains.mps.openapi.editor.EditorContext +import jetbrains.mps.openapi.editor.TextBuilder +import jetbrains.mps.openapi.editor.cells.CellActionType +import jetbrains.mps.openapi.editor.cells.EditorCell +import org.fbme.ide.richediting.adapters.fbnetwork.FBConnectionPathPainter +import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.lib.iec61499.descriptors.FBTypeDescriptor +import org.fbme.scenes.cells.EditorCell_SceneLabel +import org.jetbrains.mps.openapi.model.SNode +import java.awt.Color +import java.awt.Graphics +import java.awt.Graphics2D +import java.awt.Rectangle + +class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node: SNode, isEditable: Boolean) + : AbstractFBCell(context, fbType, node, isEditable) { + + private val typeNameLabel: EditorCell_SceneLabel + + override val rootCell: EditorCell_Collection + private val backgroundColor: Color + get() { + val background = rootCell.style.get(StyleAttributes.BACKGROUND_COLOR) + return background ?: MPSColors.LIGHT_GRAY + } + private val typeBackgroundColor: Color + get() = MPSColors.LIGHT_BLUE + private val foregroundColor: Color + get() = rootCell.style.get(StyleAttributes.TEXT_COLOR) + init { + rootCell = createRootCell() + rootCell.style.set(RichEditorStyleAttributes.TYPE, fbType) + typeNameLabel = createTypeNameLabel() + rootCell.addEditorCell(typeNameLabel) + rootCell.style.set(StyleAttributes.TEXT_COLOR, if (isEditable) MPSColors.BLACK else MPSColors.DARK_GRAY) + initPorts() + } + + private fun createRootCell(): EditorCell_Collection { + return object : EditorCell_Collection( + context, + node, + object : AbstractCellLayout() { + override fun doLayout(collection: jetbrains.mps.openapi.editor.cells.EditorCell_Collection) { + assert(collection === rootCell) + relayout() + } + + override fun doLayoutText(iterable: Iterable): TextBuilder { + return TextBuilderImpl() + } + } + ) { + override fun paintContent(g: Graphics, parentSettings: ParentSettings) { + this@FBTypeEditCellComponent.paint(g.create() as Graphics2D) + } + + override fun paintSelection(g: Graphics, c: Color, drawBorder: Boolean, parentSettings: ParentSettings) { + // do noting + } + + override fun findLeaf(x: Int, y: Int): EditorCell? { + val leaf = super.findLeaf(x, y) + if (leaf != null) { + return leaf + } + return if (Rectangle(myX, myY, myWidth, myHeight).contains(x, y)) { + this + } else null + } + + override fun onAdd() { + super.onAdd() + installNavigatable() + setAction(CellActionType.BACKSPACE, parent.parent.getAction(CellActionType.BACKSPACE)) + } + } + } + + private fun paint(graphics2D: Graphics2D) { + TODO("Not yet implemented") + } + + private fun installNavigatable() { + TODO("Not yet implemented") + } + + override fun paintTrace(g: Graphics2D, x: Int, y: Int) { + val shape = getComponentShape(x, y) + g.paint = MPSColors.GRAY + FBConnectionPathPainter.setupShadowPathPaint(g, scale(1).toFloat()) + g.draw(shape) + } + + override val eventPortsCount: Int + get() = super.eventPortsCount + 3 + + override fun getInputEventPortBounds(eventNumber: Int): Rectangle { + TODO("Not yet implemented") + } + + override fun getOutputEventPortBounds(eventNumber: Int): Rectangle { + TODO("Not yet implemented") + } + + override fun getInputDataPortBounds(dataNumber: Int): Rectangle { + TODO("Not yet implemented") + } + + override fun getOutputDataPortBounds(dataNumber: Int): Rectangle { + TODO("Not yet implemented") + } + + override fun getSocketPortBounds(socketNumber: Int): Rectangle { + TODO("Not yet implemented") + } + + override fun getPlugPortBounds(plugNumber: Int): Rectangle { + TODO("Not yet implemented") + } + +} diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt new file mode 100644 index 000000000..5e5aa0867 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt @@ -0,0 +1,31 @@ +package org.fbme.scenes.cells + +import jetbrains.mps.nodeEditor.MPSColors +import jetbrains.mps.nodeEditor.cells.* +import jetbrains.mps.openapi.editor.EditorContext +import org.jetbrains.mps.openapi.model.SNode +import java.awt.Graphics +import java.awt.Graphics2D +import java.awt.geom.Ellipse2D + +class EditorCell_Button( + context: EditorContext, + node: SNode?, +): EditorCell_Basic(context, node) { + override fun paintContent(g: Graphics, p1: ParentSettings) { + val graphics = g.create() as Graphics2D + graphics.paint = MPSColors.white + graphics.fill(Ellipse2D.Double(myX.toDouble(), myY.toDouble(), DIAMETER, DIAMETER)) + } + + init { + myWidth = DIAMETER.toInt() + myHeight = DIAMETER.toInt() + } + + companion object { + const val OX_OFFSET = 5 + const val OY_OFFSET = -5 + const val DIAMETER = 15.0 + } +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt index ae1a515ed..98f938d50 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt @@ -151,10 +151,10 @@ class ComponentsFacility( private inner class MyClickEventListener : ClickEventListener { override fun onMouseClicked(event: ClickEvent) { val component = layout.findAt(event.awt.x, event.awt.y) - ?: layout.findAt(event.awt.x - 35, event.awt.y - 25) + /*?: layout.findAt(event.awt.x - 35, event.awt.y - 25) ?: layout.findAt(event.awt.x - 35, event.awt.y + 25) ?: layout.findAt(event.awt.x + 35, event.awt.y - 25) - ?: layout.findAt(event.awt.x + 35, event.awt.y + 35) + ?: layout.findAt(event.awt.x + 35, event.awt.y + 35)*/ if (component != null) { setSelection(component, clickShouldSelect) components[component]!!.relayout() From 70c65a6b658212bede4c3fdac1c14d0db199b145 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 23 Apr 2023 18:49:49 +0200 Subject: [PATCH 06/66] Add first version of edit component state --- .../fbnetwork/EditedComponentsController.kt | 32 ++ .../adapters/fbnetwork/EndpointPortCell.kt | 1 + .../adapters/fbnetwork/FBNetworkEditors.kt | 8 +- .../fbnetwork/FunctionBlockController.kt | 116 ++++---- .../adapters/fbnetwork/fb/AbstractFBCell.kt | 8 +- .../fbnetwork/fb/FBTypeCellComponent.kt | 5 +- .../fbnetwork/fb/FBTypeEditCellComponent.kt | 278 +++++++++++++++--- .../adapters/fbnetwork/{ => port}/Port.kt | 2 +- .../adapters/fbnetwork/{ => port}/PortBase.kt | 2 +- .../adapters/fbnetwork/{ => port}/PortCell.kt | 2 +- .../fbnetwork/port/PortWithEditableLabel.kt | 30 ++ .../fbnetwork/{ => port}/PortWithLabel.kt | 2 +- .../components/ComponentsFacility.kt | 4 - 13 files changed, 389 insertions(+), 101 deletions(-) create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/EditedComponentsController.kt rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/{ => port}/Port.kt (64%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/{ => port}/PortBase.kt (80%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/{ => port}/PortCell.kt (88%) create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/{ => port}/PortWithLabel.kt (90%) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/EditedComponentsController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/EditedComponentsController.kt new file mode 100644 index 000000000..f2ce2e6a3 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/EditedComponentsController.kt @@ -0,0 +1,32 @@ +package org.fbme.ide.richediting.adapters.fbnetwork + +import org.fbme.ide.richediting.viewmodel.FunctionBlockView +import org.fbme.scenes.cells.EditorCell_Scene +import org.fbme.scenes.controllers.scene.SceneStateKey + +class EditedComponentsController(val scene: EditorCell_Scene) { + private val inEditFBs: MutableList + + init { + inEditFBs = scene.loadState(EDITED_FBS_KEY) ?: mutableListOf() + scene.storeState(EDITED_FBS_KEY, inEditFBs) + } + + fun addFB( + functionBlock: FunctionBlockView, + ) { + inEditFBs.add(functionBlock) + } + + fun removeFB(functionBlock: FunctionBlockView) { + inEditFBs.remove(functionBlock) + } + + fun isEdited(functionBlock: FunctionBlockView): Boolean { + return inEditFBs.contains(functionBlock) + } + + companion object { + private val EDITED_FBS_KEY = SceneStateKey>("edited-fbs") + } +} \ No newline at end of file diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/EndpointPortCell.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/EndpointPortCell.kt index 7404d0272..5dffde6cf 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/EndpointPortCell.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/EndpointPortCell.kt @@ -9,6 +9,7 @@ import jetbrains.mps.nodeEditor.cells.ParentSettings import jetbrains.mps.openapi.editor.EditorContext import org.fbme.ide.richediting.adapters.fbnetwork.fb.AbstractFBCell import org.fbme.ide.richediting.adapters.fbnetwork.fb.DiagramColors +import org.fbme.ide.richediting.adapters.fbnetwork.port.PortCell import org.fbme.ide.richediting.viewmodel.InterfaceEndpointView import org.fbme.lib.iec61499.fbnetwork.EntryKind import org.fbme.scenes.cells.EditorCell_SceneLabel diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt index ada6c75a5..fdf5dfe04 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt @@ -160,10 +160,11 @@ object FBNetworkEditors { style.set(RichEditorStyleAttributes.SELECTED_FBS, componentsSelection) val componentsLayout = DefaultLayoutModel(context.repository) val expandedComponentsController = ExpandedComponentsController(scene, context) + val editedComponentsController = EditedComponentsController(scene) val componentsFacility = ComponentsFacility( scene, networkView.componentsView, - getComponentControllerFactory(networkInstance, expandedComponentsController), + getComponentControllerFactory(networkInstance, expandedComponentsController, editedComponentsController), FBNetworkComponentSynchronizer(viewpoint, scale, expandedComponentsController), componentsLayout, componentsSelection, @@ -259,12 +260,13 @@ object FBNetworkEditors { @JvmStatic fun getComponentControllerFactory( instance: NetworkInstance, - expandedComponentsController: ExpandedComponentsController + expandedComponentsController: ExpandedComponentsController, + editedComponentsController: EditedComponentsController ): ComponentControllerFactory { return object : ComponentControllerFactory { override fun create(context: EditorContext, view: NetworkComponentView): ComponentController? { if (view is FunctionBlockView) { - return FunctionBlockController(context, view, instance, expandedComponentsController) + return FunctionBlockController(context, view, instance, expandedComponentsController, editedComponentsController) } if (view is InterfaceEndpointView) { return EndpointPortController(context, view) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt index 248b6abe1..1243511c0 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt @@ -6,11 +6,13 @@ import jetbrains.mps.editor.runtime.style.Padding import jetbrains.mps.editor.runtime.style.StyleAttributes import jetbrains.mps.nodeEditor.MPSColors import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Vertical -import jetbrains.mps.nodeEditor.cells.* +import jetbrains.mps.nodeEditor.cells.EditorCell +import jetbrains.mps.nodeEditor.cells.EditorCell_Collection +import jetbrains.mps.nodeEditor.cells.EditorCell_Property +import jetbrains.mps.nodeEditor.cells.ModelAccessor import jetbrains.mps.openapi.editor.EditorContext import jetbrains.mps.openapi.editor.cells.CellAction import jetbrains.mps.openapi.editor.cells.CellActionType -import jetbrains.mps.openapi.editor.cells.EditorCell_Collection import org.fbme.ide.richediting.adapters.fbnetwork.fb.FBCell import org.fbme.ide.richediting.adapters.fbnetwork.fb.FBSceneCell import org.fbme.ide.richediting.adapters.fbnetwork.fb.FBTypeCellComponent @@ -30,16 +32,17 @@ import java.awt.* import java.util.function.Function class FunctionBlockController( - context: EditorContext, - private val view: FunctionBlockView, - networkInstance: NetworkInstance, - val expandedComponentsController: ExpandedComponentsController + context: EditorContext, + private val view: FunctionBlockView, + networkInstance: NetworkInstance, + val expandedComponentsController: ExpandedComponentsController, + val editedController: EditedComponentsController ) : ComponentController, FBNetworkComponentController { private val myNameProperty: EditorCell_Property private val editButton: EditorCell_Button - private val cellCollection: jetbrains.mps.nodeEditor.cells.EditorCell_Collection + private val cellCollection: EditorCell_Collection private val isEditable: Boolean = view.isEditable - private val fbCell: FBCell + private var fbCell: FBCell private val networkInstance: NetworkInstance override fun getFBCellBounds(position: Point): Rectangle { @@ -48,45 +51,41 @@ class FunctionBlockController( private fun getNameProperty(context: EditorContext, view: FunctionBlockView, node: SNode): EditorCell_Property { return EditorCell_Property( - context, - object : ModelAccessor { - override fun getText(): String? { - val name = view.component.name - return if (name == "") null else name - } - - override fun setText(text: String) { - view.component.name = text - } - - override fun isValidText(text: String): Boolean { - return true - } - }, - node + context, + object : ModelAccessor { + override fun getText(): String? { + val name = view.component.name + return if (name == "") null else name + } + + override fun setText(text: String) { + view.component.name = text + } + + override fun isValidText(text: String): Boolean { + return true + } + }, + node ) } - private fun createRootCell(context: EditorContext, node: SNode): jetbrains.mps.nodeEditor.cells.EditorCell_Collection { + private fun createRootCell(context: EditorContext, node: SNode): EditorCell_Collection { return EditorCell_Collection( - context, - node, - object : CellLayout_Vertical() { - override fun doLayout(editorCells: EditorCell_Collection) { - super.doLayout(editorCells) - } - } + context, + node, + CellLayout_Vertical() ) } private fun initializeFBSceneCell(editorShift: Point = Point()): FBCell { return FBSceneCell( - cellCollection.context, - view.type, - view.associatedNode, - false, - networkInstance.getChild(view.component)!!, - editorShift + cellCollection.context, + view.type, + view.associatedNode, + false, + networkInstance.getChild(view.component)!!, + editorShift ) } @@ -123,11 +122,11 @@ class FunctionBlockController( val isSource = functionBlockPort.isSource val coordinates: Point = when (kind) { EntryKind.EVENT -> if (isSource) fbCell.getOutputEventPortPosition(index) else fbCell.getInputEventPortPosition( - index + index ) EntryKind.DATA -> if (isSource) fbCell.getOutputDataPortPosition(index) else fbCell.getInputDataPortPosition( - index + index ) EntryKind.ADAPTER -> if (isSource) fbCell.getPlugPortPosition(index) else fbCell.getSocketPortPosition(index) @@ -144,11 +143,11 @@ class FunctionBlockController( val isSource = functionBlockPort.isSource val bounds: Rectangle = when (kind) { EntryKind.EVENT -> if (isSource) fbCell.getOutputEventPortBounds(index) else fbCell.getInputEventPortBounds( - index + index ) EntryKind.DATA -> if (isSource) fbCell.getOutputDataPortBounds(index) else fbCell.getInputDataPortBounds( - index + index ) EntryKind.ADAPTER -> if (isSource) fbCell.getPlugPortBounds(index) else fbCell.getSocketPortBounds(index) @@ -190,9 +189,9 @@ class FunctionBlockController( override fun paintTrace(g: Graphics?, form: Point) { fbCell.paintTrace( - g!!.create() as Graphics2D, - form.x, - form.y + if (fbCell is FBTypeCellComponent) getVerticalOffset() else 0 + g!!.create() as Graphics2D, + form.x, + form.y + if (fbCell is FBTypeCellComponent) getVerticalOffset() else 0 ) } @@ -224,14 +223,32 @@ class FunctionBlockController( val isExpanded = expandedComponentsController.isExpanded(view) val editorShift = expandedComponentsController.getEditorShift(view) - fbCell = if (isExpanded) initializeFBSceneCell(editorShift) else initializeFBCell() + + fbCell = if (isExpanded) initializeFBSceneCell(editorShift) else if (editedController.isEdited(view)) initializeFBEditCell() else initializeFBCell() + cellCollection.addEditorCell(fbCell.rootCell) + fbCell.relayout() + } + + private fun turnToEdit() { + val oldCell = fbCell + cellCollection.removeCell(oldCell.rootCell) + fbCell = if (oldCell is FBTypeCellComponent) { + val isExpanded = expandedComponentsController.isExpanded(view) + val editorShift = expandedComponentsController.getEditorShift(view) + if (isExpanded) initializeFBSceneCell(editorShift) else initializeFBEditCell() + } else { + initializeFBCell() + } cellCollection.addEditorCell(fbCell.rootCell) + fbCell.rootCell.moveTo(cellCollection.x, myNameProperty.y + myNameProperty.height) fbCell.relayout() + cellCollection.relayout() } private fun getVerticalOffset(): Int { return fbCell.rootCell.y - cellCollection.y } + private fun toEditModeAction(): CellAction { return object : CellAction { override fun getDescriptionText(): String = "on click" @@ -240,10 +257,9 @@ class FunctionBlockController( override fun canExecute(context: EditorContext): Boolean = true - override fun execute(context: EditorContext) = - context.repository.modelAccess.executeCommandInEDT { - view.type.declaration?.name = "new name on click" - } + override fun execute(context: EditorContext) { + if (editedController.isEdited(view)) editedController.removeFB(view) else editedController.addFB(view) + } } } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt index c0ba6bef1..8d2253fc1 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt @@ -2,8 +2,8 @@ package org.fbme.ide.richediting.adapters.fbnetwork.fb import jetbrains.mps.nodeEditor.EditorSettings import jetbrains.mps.openapi.editor.EditorContext -import org.fbme.ide.richediting.adapters.fbnetwork.Port -import org.fbme.ide.richediting.adapters.fbnetwork.PortBase +import org.fbme.ide.richediting.adapters.fbnetwork.port.Port +import org.fbme.ide.richediting.adapters.fbnetwork.port.PortBase import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.descriptors.FBTypeDescriptor import org.fbme.scenes.cells.EditorCell_SceneLabel @@ -12,8 +12,6 @@ import org.fbme.scenes.controllers.LayoutUtil.getLineSize import org.jetbrains.mps.openapi.model.SNode import java.awt.* import java.awt.geom.GeneralPath -import java.util.function.Function -import java.util.function.Supplier import kotlin.math.max abstract class AbstractFBCell protected constructor( @@ -159,7 +157,7 @@ abstract class AbstractFBCell protected constructor( return EditorCell_SceneLabel(context, node, fbType.typeName, typeDeclaration == null) } - protected fun getComponentShape(x: Int, y: Int): GeneralPath { + protected open fun getComponentShape(x: Int, y: Int): GeneralPath { val shape = GeneralPath() val eventPortsCount = eventPortsCount val lineSize = lineSize diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt index 51bc8c946..1f6f29958 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt @@ -12,8 +12,8 @@ import jetbrains.mps.openapi.editor.cells.CellActionType import jetbrains.mps.openapi.editor.cells.EditorCell import org.fbme.ide.iec61499.repository.PlatformElement import org.fbme.ide.richediting.adapters.fbnetwork.FBConnectionPathPainter -import org.fbme.ide.richediting.adapters.fbnetwork.Port -import org.fbme.ide.richediting.adapters.fbnetwork.PortWithLabel +import org.fbme.ide.richediting.adapters.fbnetwork.port.Port +import org.fbme.ide.richediting.adapters.fbnetwork.port.PortWithLabel import org.fbme.ide.richediting.editor.NetworkInstanceNavigationSupport import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.lib.iec61499.descriptors.FBPortDescriptor @@ -47,6 +47,7 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node rootCell.addEditorCell(typeNameLabel) rootCell.style.set(StyleAttributes.TEXT_COLOR, if (isEditable) MPSColors.BLACK else MPSColors.DARK_GRAY) initPorts() + relayout() } override fun initPorts(ports: MutableList, portDescriptors: List) { diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt index 6b6ebdf98..746bbb405 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt @@ -1,31 +1,52 @@ package org.fbme.ide.richediting.adapters.fbnetwork.fb -import jetbrains.mps.editor.runtime.TextBuilderImpl +import jetbrains.mps.editor.runtime.style.CellAlign +import jetbrains.mps.editor.runtime.style.Measure +import jetbrains.mps.editor.runtime.style.Padding import jetbrains.mps.editor.runtime.style.StyleAttributes import jetbrains.mps.nodeEditor.MPSColors -import jetbrains.mps.nodeEditor.cellLayout.AbstractCellLayout +import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Horizontal +import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Vertical import jetbrains.mps.nodeEditor.cells.EditorCell_Collection +import jetbrains.mps.nodeEditor.cells.EditorCell_Property +import jetbrains.mps.nodeEditor.cells.ModelAccessor import jetbrains.mps.nodeEditor.cells.ParentSettings import jetbrains.mps.openapi.editor.EditorContext -import jetbrains.mps.openapi.editor.TextBuilder import jetbrains.mps.openapi.editor.cells.CellActionType import jetbrains.mps.openapi.editor.cells.EditorCell +import jetbrains.mps.openapi.editor.style.StyleAttribute +import org.fbme.ide.iec61499.repository.PlatformElement import org.fbme.ide.richediting.adapters.fbnetwork.FBConnectionPathPainter +import org.fbme.ide.richediting.adapters.fbnetwork.port.Port +import org.fbme.ide.richediting.adapters.fbnetwork.port.PortWithEditableLabel +import org.fbme.ide.richediting.adapters.fbnetwork.port.PortWithLabel +import org.fbme.ide.richediting.editor.NetworkInstanceNavigationSupport import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.descriptors.FBTypeDescriptor -import org.fbme.scenes.cells.EditorCell_SceneLabel +import org.fbme.lib.iec61499.instances.NetworkInstance import org.jetbrains.mps.openapi.model.SNode -import java.awt.Color -import java.awt.Graphics -import java.awt.Graphics2D -import java.awt.Rectangle +import java.awt.* +import java.awt.geom.AffineTransform +import java.awt.geom.GeneralPath +import kotlin.math.max class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node: SNode, isEditable: Boolean) : AbstractFBCell(context, fbType, node, isEditable) { - private val typeNameLabel: EditorCell_SceneLabel + private val typeNameLabel: EditorCell_Property override val rootCell: EditorCell_Collection + private val eventPortsContainer: EditorCell_Collection + private val dataPortsContainer: EditorCell_Collection + private val otherPortsContainer: EditorCell_Collection + + private val inputPorts: Set + get() = inputEventPorts.union(inputDataPorts).union(socketPorts) + + private val outputPorts: Set + get() = outputEventPorts.union(outputDataPorts).union(plugPorts) + private val backgroundColor: Color get() { val background = rootCell.style.get(StyleAttributes.BACKGROUND_COLOR) @@ -35,30 +56,74 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, get() = MPSColors.LIGHT_BLUE private val foregroundColor: Color get() = rootCell.style.get(StyleAttributes.TEXT_COLOR) + init { rootCell = createRootCell() rootCell.style.set(RichEditorStyleAttributes.TYPE, fbType) - typeNameLabel = createTypeNameLabel() + + eventPortsContainer = createPortContainer(fbType.eventInputPorts, fbType.eventOutputPorts, inputEventPorts, outputEventPorts) + typeNameLabel = createNameLabel() + dataPortsContainer = createPortContainer(fbType.dataInputPorts, fbType.dataOutputPorts, inputDataPorts, outputDataPorts) + otherPortsContainer = createPortContainer(fbType.socketPorts, fbType.plugPorts, socketPorts, plugPorts) + + rootCell.addEditorCell(eventPortsContainer) rootCell.addEditorCell(typeNameLabel) + rootCell.addEditorCell(dataPortsContainer) + rootCell.addEditorCell(otherPortsContainer) + rootCell.style.set(StyleAttributes.TEXT_COLOR, if (isEditable) MPSColors.BLACK else MPSColors.DARK_GRAY) - initPorts() + } + + private fun createPortContainer( + input: List, + output: List, + inputList: MutableList, + outputList: MutableList): EditorCell_Collection { + val container = object : EditorCell_Collection(context, node, CellLayout_Horizontal()) {} + + val inputContainer = createPortBlock(input, inputList, CellAlign.LEFT, StyleAttributes.PADDING_LEFT) + val outputContainer = createPortBlock(output, outputList, CellAlign.RIGHT, StyleAttributes.PADDING_RIGHT) + + container.addEditorCell(inputContainer) + container.addEditorCell(outputContainer) + + container.style.set(StyleAttributes.HORIZONTAL_ALIGN, CellAlign.CENTER) + + return container + } + + private fun createPortBlock( + portsDescriptors: List, + ports: MutableList, + horizontalAlign: CellAlign, + padding: StyleAttribute + ) : EditorCell_Collection { + val block = object : EditorCell_Collection(context, node, CellLayout_Vertical()) {} + + for (port in portsDescriptors) { + val portWithLabel = PortWithEditableLabel(context, node, port) + portWithLabel.label.style.set(StyleAttributes.HORIZONTAL_ALIGN, horizontalAlign) + portWithLabel.label.style.set(padding, Padding(INNER_BORDER_PADDING.toDouble(), Measure.PIXELS)) + ports.add(portWithLabel) + block.addEditorCell(portWithLabel.label) + } + + return block } private fun createRootCell(): EditorCell_Collection { return object : EditorCell_Collection( context, node, - object : AbstractCellLayout() { - override fun doLayout(collection: jetbrains.mps.openapi.editor.cells.EditorCell_Collection) { - assert(collection === rootCell) + object : CellLayout_Vertical() { + override fun doLayout(editorCells: jetbrains.mps.openapi.editor.cells.EditorCell_Collection?) { + super.doLayout(editorCells) relayout() } - - override fun doLayoutText(iterable: Iterable): TextBuilder { - return TextBuilderImpl() - } } ) { + + override fun paintContent(g: Graphics, parentSettings: ParentSettings) { this@FBTypeEditCellComponent.paint(g.create() as Graphics2D) } @@ -85,12 +150,96 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, } } - private fun paint(graphics2D: Graphics2D) { - TODO("Not yet implemented") + private fun paint(graphics: Graphics2D) { + val background = backgroundColor + val foreground = foregroundColor + drawComponentShape(graphics, background, foreground) + drawPortIcons(graphics, foreground) + } + + private fun drawPortIcons(graphics: Graphics2D, color: Color?) { + drawPortIcons(graphics, rootCell.x - scale(PORT_SIZE), inputPorts, color) + drawPortIcons(graphics, rootCell.x + rootCell.width + scale(PORT_SIZE), outputPorts, color) + } + + private fun drawPortIcons(graphics: Graphics2D, x: Int, ports: Set, color: Color?) { + for (port in ports) { + val portWithLabel = port as PortWithEditableLabel + val y = portWithLabel.label.y + portWithLabel.label.height / 2 - scale(PORT_SIZE) / 2 + val form = Rectangle(x, y, scale(PORT_SIZE), scale(PORT_SIZE)) + + graphics.color = DiagramColors.getColorFor(port.connectionKind, isEditable) + graphics.fill(form) + graphics.color = color + graphics.draw(form) + } + } + + private fun drawComponentShape(graphics: Graphics2D, background: Color, foreground: Color) { + val x = rootCell.x + val y = rootCell.y + val shape = getComponentShape(x, y) + val shadowShape = shape.createTransformedShape(AffineTransform.getTranslateInstance(2.0, 2.0)) + graphics.paint = Color(0xEEEEEE) + graphics.fill(shadowShape) + graphics.paint = DiagramColors.createGradientPaint(background, Rectangle(x, y, rootCell.width, rootCell.height)) + graphics.fill(shape) + graphics.paint = DiagramColors.createGradientPaint(typeBackgroundColor, Rectangle(x, y, rootCell.width, rootCell.height)) + graphics.fill(Rectangle(x, typeNameLabel.y + lineSize / 2, rootCell.width, typeNameLabel.height - lineSize)) + graphics.stroke = BasicStroke(scale(1).toFloat()) + graphics.color = foreground + graphics.draw(shape) + } + + override fun getComponentShape(x: Int, y: Int): GeneralPath { + val shape = GeneralPath() + val lineSize = lineSize.toDouble() + val width = rootCell.width.toDouble() + val height = rootCell.height.toDouble() + val xRight = x + width + val yTop = y + height + val yCenterB = typeNameLabel.y - lineSize / 2 + val yCenterT = typeNameLabel.y.toDouble() + lineSize / 2 + val xLeftS = x + lineSize + val xRightS = xRight - lineSize + shape.moveTo(x.toDouble(), y.toDouble()) + shape.lineTo(x.toDouble(), yCenterB) + shape.lineTo(xLeftS, yCenterB) + shape.lineTo(xLeftS, yCenterT) + shape.lineTo(x.toDouble(), yCenterT) + shape.lineTo(x.toDouble(), yTop) + shape.lineTo(xRight, yTop) + shape.lineTo(xRight, yCenterT) + shape.lineTo(xRightS, yCenterT) + shape.lineTo(xRightS, yCenterB) + shape.lineTo(xRight, yCenterB) + shape.lineTo(xRight, y.toDouble()) + shape.closePath() + return shape } private fun installNavigatable() { - TODO("Not yet implemented") + val style = typeNameLabel.style + val instance = style.get(RichEditorStyleAttributes.NETWORK_INSTANCE) + if (instance != null) { + val functionBlock = style.get(RichEditorStyleAttributes.FB) + val child = instance.getChild(functionBlock!!) + if (child != null) { + val childNetworkInstance = child.containedNetwork + if (childNetworkInstance is NetworkInstance) { + val navigationStub = NetworkInstanceNavigationSupport.getNavigationStub( + rootCell.context.operationContext.project, + childNetworkInstance + ) + style.set(StyleAttributes.NAVIGATABLE_NODE, navigationStub) + return + } + } + } + val typeDeclaration = style.get(RichEditorStyleAttributes.TYPE).declaration + if (typeDeclaration is PlatformElement) { + style.set(StyleAttributes.NAVIGATABLE_NODE, (typeDeclaration as PlatformElement).node) + } } override fun paintTrace(g: Graphics2D, x: Int, y: Int) { @@ -103,28 +252,91 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, override val eventPortsCount: Int get() = super.eventPortsCount + 3 - override fun getInputEventPortBounds(eventNumber: Int): Rectangle { - TODO("Not yet implemented") + private fun getPortBounds(port: Port, isOutput: Boolean = false): Rectangle { + val editablePort = port as PortWithEditableLabel + + val width = editablePort.label.width + scale(INNER_BORDER_PADDING) + val y = editablePort.label.y - rootCell.y + + val x = if (isOutput) rootCell.width - width else 0 + + return Rectangle(x, y, width, editablePort.label.height) } - override fun getOutputEventPortBounds(eventNumber: Int): Rectangle { - TODO("Not yet implemented") + override fun getInputEventPortBounds(eventNumber: Int): Rectangle = getPortBounds(inputEventPorts[eventNumber]) + + override fun getOutputEventPortBounds(eventNumber: Int): Rectangle = getPortBounds(outputEventPorts[eventNumber], true) + + override fun getInputDataPortBounds(dataNumber: Int): Rectangle = getPortBounds(inputDataPorts[dataNumber]) + + override fun getOutputDataPortBounds(dataNumber: Int): Rectangle = getPortBounds(outputDataPorts[dataNumber], true) + + override fun getSocketPortBounds(socketNumber: Int): Rectangle = getPortBounds(socketPorts[socketNumber]) + + override fun getPlugPortBounds(plugNumber: Int): Rectangle = getPortBounds(plugPorts[plugNumber], true) + + private fun calculateWidth(): Int { + val typeNameRowWidth = typeNameLabel.width + val inputsWidth = portsColumnWidth(inputPorts) + val outputsWidth = portsColumnWidth(outputPorts) + + val regularRowsWidth = inputsWidth + outputsWidth + scale(CENTER_PADDING + 2 * INNER_BORDER_PADDING) + return max(regularRowsWidth, typeNameRowWidth) + scale(2 * INNER_BORDER_PADDING) } - override fun getInputDataPortBounds(dataNumber: Int): Rectangle { - TODO("Not yet implemented") + private fun createNameLabel(): EditorCell_Property { + val typeDeclaration = fbType.declaration + + val result = EditorCell_Property( + context, + object : ModelAccessor { + override fun getText(): String? = typeDeclaration?.name + + override fun setText(text: String) { + typeDeclaration?.name = text + } + + override fun isValidText(text: String): Boolean { + return true + } + }, + node + ) + + result.style.set(StyleAttributes.HORIZONTAL_ALIGN, CellAlign.CENTER) + result.style.set(StyleAttributes.FONT_SIZE, fontSize) + result.style.set(StyleAttributes.PADDING_TOP, Padding((lineSize).toDouble() / 2, Measure.PIXELS)) + result.style.set(StyleAttributes.PADDING_BOTTOM, Padding((lineSize).toDouble() / 2, Measure.PIXELS)) + return result } - override fun getOutputDataPortBounds(dataNumber: Int): Rectangle { - TODO("Not yet implemented") + override fun relayout() { + super.relayout() + val width = calculateWidth() + rootCell.width = width + eventPortsContainer.width = width + dataPortsContainer.width = width + otherPortsContainer.width = width + addCentralGap(width) } - override fun getSocketPortBounds(socketNumber: Int): Rectangle { - TODO("Not yet implemented") + private fun addCentralGap(width: Int) { + addCentralGap(width, outputEventPorts, eventPortsContainer) + addCentralGap(width, outputDataPorts, dataPortsContainer) + addCentralGap(width, plugPorts, otherPortsContainer) } - override fun getPlugPortBounds(plugNumber: Int): Rectangle { - TODO("Not yet implemented") + private fun addCentralGap(width: Int, ports: List, container: EditorCell_Collection) { + val gap = (width - portsColumnWidth(ports) - INNER_BORDER_PADDING) + container.cells[1].moveTo(gap, container.cells[1].y) } + companion object { + private const val CENTER_PADDING = 20 + private const val INNER_BORDER_PADDING = 2 + + private fun portsColumnWidth(ports: Collection): Int { + return ports.maxOfOrNull { (it as PortWithEditableLabel).label.width } ?: 0 + } + } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/Port.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/Port.kt similarity index 64% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/Port.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/Port.kt index d791a3a10..4b3cf54ae 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/Port.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/Port.kt @@ -1,4 +1,4 @@ -package org.fbme.ide.richediting.adapters.fbnetwork +package org.fbme.ide.richediting.adapters.fbnetwork.port import org.fbme.lib.iec61499.fbnetwork.EntryKind diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/PortBase.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortBase.kt similarity index 80% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/PortBase.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortBase.kt index 3c89edcb0..7529a5ae9 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/PortBase.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortBase.kt @@ -1,4 +1,4 @@ -package org.fbme.ide.richediting.adapters.fbnetwork +package org.fbme.ide.richediting.adapters.fbnetwork.port import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.fbnetwork.EntryKind diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/PortCell.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortCell.kt similarity index 88% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/PortCell.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortCell.kt index 8d63c7ff9..28d1fe1e0 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/PortCell.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortCell.kt @@ -1,4 +1,4 @@ -package org.fbme.ide.richediting.adapters.fbnetwork +package org.fbme.ide.richediting.adapters.fbnetwork.port import jetbrains.mps.nodeEditor.cells.EditorCell_Collection import java.awt.Graphics2D diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt new file mode 100644 index 000000000..fefda8324 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt @@ -0,0 +1,30 @@ +package org.fbme.ide.richediting.adapters.fbnetwork.port + +import jetbrains.mps.nodeEditor.cells.EditorCell_Property +import jetbrains.mps.nodeEditor.cells.ModelAccessor +import jetbrains.mps.openapi.editor.EditorContext +import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.lib.iec61499.descriptors.FBPortDescriptor +import org.jetbrains.mps.openapi.model.SNode + +class PortWithEditableLabel(context: EditorContext, node: SNode, port: FBPortDescriptor) : PortBase(port) { + val label: EditorCell_Property + + init { + label = EditorCell_Property(context, + object : ModelAccessor { + override fun getText(): String { + return port.declaration?.name ?: "" + } + + override fun setText(text: String) { + port.declaration?.name = text + } + + override fun isValidText(text: String): Boolean { + return true + } + }, node) + label.style.set(RichEditorStyleAttributes.PORT, port) + } +} \ No newline at end of file diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/PortWithLabel.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithLabel.kt similarity index 90% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/PortWithLabel.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithLabel.kt index 3266cc452..39ddc6448 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/PortWithLabel.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithLabel.kt @@ -1,4 +1,4 @@ -package org.fbme.ide.richediting.adapters.fbnetwork +package org.fbme.ide.richediting.adapters.fbnetwork.port import jetbrains.mps.openapi.editor.EditorContext import org.fbme.ide.richediting.editor.RichEditorStyleAttributes diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt index 98f938d50..66ed633ea 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt @@ -151,10 +151,6 @@ class ComponentsFacility( private inner class MyClickEventListener : ClickEventListener { override fun onMouseClicked(event: ClickEvent) { val component = layout.findAt(event.awt.x, event.awt.y) - /*?: layout.findAt(event.awt.x - 35, event.awt.y - 25) - ?: layout.findAt(event.awt.x - 35, event.awt.y + 25) - ?: layout.findAt(event.awt.x + 35, event.awt.y - 25) - ?: layout.findAt(event.awt.x + 35, event.awt.y + 35)*/ if (component != null) { setSelection(component, clickShouldSelect) components[component]!!.relayout() From c4192fa248be7a1f253979346bda621d32b02d22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Tue, 25 Apr 2023 18:36:39 +0200 Subject: [PATCH 07/66] Add ability to add ports --- .../adapters/fbnetwork/FBNetworkEditors.kt | 11 +-- .../fbnetwork/FunctionBlockController.kt | 32 +++---- .../fbnetwork/fb/FBTypeEditCellComponent.kt | 86 +++++++++++++++++-- .../adapters/fbnetwork/port/PortButton.kt | 10 +++ .../fbnetwork/port/PortWithEditableLabel.kt | 44 +++++++++- .../fbme/scenes/cells/EditorCell_Button.kt | 21 ++--- .../org/fbme/scenes/cells/button/Button.kt | 9 ++ .../fbme/scenes/cells/button/CrossButton.kt | 25 ++++++ .../fbme/scenes/cells/button/EditButton.kt | 29 +++++++ .../fbme/scenes/cells/button/MinusButton.kt | 11 +++ .../fbme/scenes/cells/button/PlusButton.kt | 12 +++ .../fbme/scenes/cells/button/SquareButton.kt | 25 ++++++ 12 files changed, 271 insertions(+), 44 deletions(-) create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortButton.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/Button.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/CrossButton.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/EditButton.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MinusButton.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/PlusButton.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/SquareButton.kt diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt index fdf5dfe04..88e7426b8 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt @@ -164,7 +164,7 @@ object FBNetworkEditors { val componentsFacility = ComponentsFacility( scene, networkView.componentsView, - getComponentControllerFactory(networkInstance, expandedComponentsController, editedComponentsController), + getComponentControllerFactory(networkInstance, expandedComponentsController, editedComponentsController, repository.iec61499Factory), FBNetworkComponentSynchronizer(viewpoint, scale, expandedComponentsController), componentsLayout, componentsSelection, @@ -259,14 +259,15 @@ object FBNetworkEditors { @JvmStatic fun getComponentControllerFactory( - instance: NetworkInstance, - expandedComponentsController: ExpandedComponentsController, - editedComponentsController: EditedComponentsController + instance: NetworkInstance, + expandedComponentsController: ExpandedComponentsController, + editedComponentsController: EditedComponentsController, + iec61499Factory: IEC61499Factory ): ComponentControllerFactory { return object : ComponentControllerFactory { override fun create(context: EditorContext, view: NetworkComponentView): ComponentController? { if (view is FunctionBlockView) { - return FunctionBlockController(context, view, instance, expandedComponentsController, editedComponentsController) + return FunctionBlockController(context, view, instance, expandedComponentsController, editedComponentsController, iec61499Factory) } if (view is InterfaceEndpointView) { return EndpointPortController(context, view) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt index 1243511c0..c918114f6 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt @@ -21,10 +21,13 @@ import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.ide.richediting.viewmodel.FunctionBlockPortView import org.fbme.ide.richediting.viewmodel.FunctionBlockView import org.fbme.ide.richediting.viewmodel.NetworkPortView +import org.fbme.lib.iec61499.IEC61499Factory import org.fbme.lib.iec61499.fbnetwork.EntryKind import org.fbme.lib.iec61499.instances.FunctionBlockInstance import org.fbme.lib.iec61499.instances.NetworkInstance import org.fbme.scenes.cells.EditorCell_Button +import org.fbme.scenes.cells.button.CrossButton +import org.fbme.scenes.cells.button.EditButton import org.fbme.scenes.controllers.LayoutUtil.getLineSize import org.fbme.scenes.controllers.components.ComponentController import org.jetbrains.mps.openapi.model.SNode @@ -36,7 +39,8 @@ class FunctionBlockController( private val view: FunctionBlockView, networkInstance: NetworkInstance, val expandedComponentsController: ExpandedComponentsController, - val editedController: EditedComponentsController + val editedController: EditedComponentsController, + iec61499Factory: IEC61499Factory ) : ComponentController, FBNetworkComponentController { private val myNameProperty: EditorCell_Property private val editButton: EditorCell_Button @@ -93,12 +97,13 @@ class FunctionBlockController( return FBTypeCellComponent(cellCollection.context, view.type, view.associatedNode, isEditable) } - private fun initializeFBEditCell(): FBCell { - return FBTypeEditCellComponent(cellCollection.context, view.type, view.associatedNode, isEditable) + private fun initializeFBEditCell(iec61499Factory: IEC61499Factory): FBCell { + return FBTypeEditCellComponent(cellCollection.context, view.type, view.associatedNode, iec61499Factory, isEditable) } private fun getEditButton(context: EditorContext, node: SNode): EditorCell_Button { - return EditorCell_Button(context, node) + + return EditorCell_Button(context, node, if (!editedController.isEdited(view)) EditButton(18) else CrossButton(18)) } val fbInstance: FunctionBlockInstance? @@ -224,27 +229,11 @@ class FunctionBlockController( val editorShift = expandedComponentsController.getEditorShift(view) - fbCell = if (isExpanded) initializeFBSceneCell(editorShift) else if (editedController.isEdited(view)) initializeFBEditCell() else initializeFBCell() + fbCell = if (isExpanded) initializeFBSceneCell(editorShift) else if (editedController.isEdited(view)) initializeFBEditCell(iec61499Factory) else initializeFBCell() cellCollection.addEditorCell(fbCell.rootCell) fbCell.relayout() } - private fun turnToEdit() { - val oldCell = fbCell - cellCollection.removeCell(oldCell.rootCell) - fbCell = if (oldCell is FBTypeCellComponent) { - val isExpanded = expandedComponentsController.isExpanded(view) - val editorShift = expandedComponentsController.getEditorShift(view) - if (isExpanded) initializeFBSceneCell(editorShift) else initializeFBEditCell() - } else { - initializeFBCell() - } - cellCollection.addEditorCell(fbCell.rootCell) - fbCell.rootCell.moveTo(cellCollection.x, myNameProperty.y + myNameProperty.height) - fbCell.relayout() - cellCollection.relayout() - } - private fun getVerticalOffset(): Int { return fbCell.rootCell.y - cellCollection.y } @@ -259,6 +248,7 @@ class FunctionBlockController( override fun execute(context: EditorContext) { if (editedController.isEdited(view)) editedController.removeFB(view) else editedController.addFB(view) + context.editorComponent.updater.update() } } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt index 746bbb405..db2e2ec2a 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt @@ -12,6 +12,7 @@ import jetbrains.mps.nodeEditor.cells.EditorCell_Property import jetbrains.mps.nodeEditor.cells.ModelAccessor import jetbrains.mps.nodeEditor.cells.ParentSettings import jetbrains.mps.openapi.editor.EditorContext +import jetbrains.mps.openapi.editor.cells.CellAction import jetbrains.mps.openapi.editor.cells.CellActionType import jetbrains.mps.openapi.editor.cells.EditorCell import jetbrains.mps.openapi.editor.style.StyleAttribute @@ -19,25 +20,30 @@ import org.fbme.ide.iec61499.repository.PlatformElement import org.fbme.ide.richediting.adapters.fbnetwork.FBConnectionPathPainter import org.fbme.ide.richediting.adapters.fbnetwork.port.Port import org.fbme.ide.richediting.adapters.fbnetwork.port.PortWithEditableLabel -import org.fbme.ide.richediting.adapters.fbnetwork.port.PortWithLabel import org.fbme.ide.richediting.editor.NetworkInstanceNavigationSupport import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.lib.common.* +import org.fbme.lib.iec61499.IEC61499Factory +import org.fbme.lib.iec61499.declarations.FBInterfaceDeclaration import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.descriptors.FBTypeDescriptor import org.fbme.lib.iec61499.instances.NetworkInstance +import org.fbme.scenes.cells.EditorCell_Button +import org.fbme.scenes.cells.button.PlusButton import org.jetbrains.mps.openapi.model.SNode import java.awt.* import java.awt.geom.AffineTransform import java.awt.geom.GeneralPath import kotlin.math.max -class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node: SNode, isEditable: Boolean) +class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node: SNode, val iec61499Factory: IEC61499Factory, isEditable: Boolean) : AbstractFBCell(context, fbType, node, isEditable) { private val typeNameLabel: EditorCell_Property override val rootCell: EditorCell_Collection private val eventPortsContainer: EditorCell_Collection + private val eventButtonContiner: EditorCell_Collection private val dataPortsContainer: EditorCell_Collection private val otherPortsContainer: EditorCell_Collection @@ -62,11 +68,46 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, rootCell.style.set(RichEditorStyleAttributes.TYPE, fbType) eventPortsContainer = createPortContainer(fbType.eventInputPorts, fbType.eventOutputPorts, inputEventPorts, outputEventPorts) + eventButtonContiner = createButtonContainer( + object : CellAction { + override fun getDescriptionText(): String = "Add input event port" + + override fun executeInCommand(): Boolean = true + + override fun canExecute(p0: EditorContext?): Boolean = true + + override fun execute(context: EditorContext) { + context.repository.modelAccess.runWriteInEDT { + val declaration = fbType.declaration + if (declaration is FBInterfaceDeclaration) { + declaration.inputEvents.add(iec61499Factory.createEventDeclaration(StringIdentifier("Iinput"))) + } + context.editorComponent.updater.update() + } + } + }, object : CellAction { + override fun getDescriptionText(): String = "Add output event port" + + override fun executeInCommand(): Boolean = true + + override fun canExecute(p0: EditorContext?): Boolean = true + + override fun execute(context: EditorContext) { + context.repository.modelAccess.runWriteAction { + val declaration = fbType.declaration + if (declaration is FBInterfaceDeclaration) { + declaration.outputEvents.add(iec61499Factory.createEventDeclaration(StringIdentifier("Ioutput"))) + } + context.editorComponent.updater.update() + } + } + }) typeNameLabel = createNameLabel() dataPortsContainer = createPortContainer(fbType.dataInputPorts, fbType.dataOutputPorts, inputDataPorts, outputDataPorts) otherPortsContainer = createPortContainer(fbType.socketPorts, fbType.plugPorts, socketPorts, plugPorts) rootCell.addEditorCell(eventPortsContainer) + rootCell.addEditorCell(eventButtonContiner) rootCell.addEditorCell(typeNameLabel) rootCell.addEditorCell(dataPortsContainer) rootCell.addEditorCell(otherPortsContainer) @@ -74,6 +115,28 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, rootCell.style.set(StyleAttributes.TEXT_COLOR, if (isEditable) MPSColors.BLACK else MPSColors.DARK_GRAY) } + private fun createButtonContainer(inputAction: CellAction, outputAction: CellAction): EditorCell_Collection { + val container = object : EditorCell_Collection(context, node, CellLayout_Horizontal()) {} + + val leftButton = createButton(inputAction) + val rightButton = createButton(outputAction) + + container.style.set(StyleAttributes.HORIZONTAL_ALIGN, CellAlign.CENTER) + + container.addEditorCell(leftButton) + container.addEditorCell(rightButton) + + return container + } + + private fun createButton(cellAction: CellAction): EditorCell { + val button = EditorCell_Button(context, node, PlusButton(15)) + + button.setAction(CellActionType.CLICK, cellAction) + + return button + } + private fun createPortContainer( input: List, output: List, @@ -101,7 +164,7 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, val block = object : EditorCell_Collection(context, node, CellLayout_Vertical()) {} for (port in portsDescriptors) { - val portWithLabel = PortWithEditableLabel(context, node, port) + val portWithLabel = PortWithEditableLabel(context, node, port, fbType.declaration) portWithLabel.label.style.set(StyleAttributes.HORIZONTAL_ALIGN, horizontalAlign) portWithLabel.label.style.set(padding, Padding(INNER_BORDER_PADDING.toDouble(), Measure.PIXELS)) ports.add(portWithLabel) @@ -198,8 +261,8 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, val height = rootCell.height.toDouble() val xRight = x + width val yTop = y + height - val yCenterB = typeNameLabel.y - lineSize / 2 - val yCenterT = typeNameLabel.y.toDouble() + lineSize / 2 + val yCenterB = typeNameLabel.y - lineSize / 2 + val yCenterT = typeNameLabel.y + lineSize / 2 val xLeftS = x + lineSize val xRightS = xRight - lineSize shape.moveTo(x.toDouble(), y.toDouble()) @@ -277,11 +340,12 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, private fun calculateWidth(): Int { val typeNameRowWidth = typeNameLabel.width + val buttonWidth = eventButtonContiner.width val inputsWidth = portsColumnWidth(inputPorts) val outputsWidth = portsColumnWidth(outputPorts) - val regularRowsWidth = inputsWidth + outputsWidth + scale(CENTER_PADDING + 2 * INNER_BORDER_PADDING) - return max(regularRowsWidth, typeNameRowWidth) + scale(2 * INNER_BORDER_PADDING) + val regularRowsWidth = max(inputsWidth, outputsWidth) * 2 + scale(CENTER_PADDING + 2 * INNER_BORDER_PADDING) + return (listOf(regularRowsWidth, typeNameRowWidth).maxOrNull() ?: 0) + scale(2 * INNER_BORDER_PADDING) } private fun createNameLabel(): EditorCell_Property { @@ -318,12 +382,15 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, dataPortsContainer.width = width otherPortsContainer.width = width addCentralGap(width) + eventButtonContiner.height = eventButtonContiner.cells[0].height + lineSize / 2 + eventButtonContiner.width = width } private fun addCentralGap(width: Int) { addCentralGap(width, outputEventPorts, eventPortsContainer) addCentralGap(width, outputDataPorts, dataPortsContainer) addCentralGap(width, plugPorts, otherPortsContainer) + addGapForButtons(width) } private fun addCentralGap(width: Int, ports: List, container: EditorCell_Collection) { @@ -331,6 +398,11 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, container.cells[1].moveTo(gap, container.cells[1].y) } + private fun addGapForButtons(width: Int) { + eventButtonContiner.cells[1].moveTo(width - 15, eventButtonContiner.cells[1].y + eventButtonContiner.height - eventButtonContiner.cells[1].height) + eventButtonContiner.cells[0].moveTo(0, eventButtonContiner.cells[0].y + eventButtonContiner.height - eventButtonContiner.cells[0].height) + } + companion object { private const val CENTER_PADDING = 20 private const val INNER_BORDER_PADDING = 2 diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortButton.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortButton.kt new file mode 100644 index 000000000..e53cd1b3b --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortButton.kt @@ -0,0 +1,10 @@ +package org.fbme.ide.richediting.adapters.fbnetwork.port + +/* +import jetbrains.mps.openapi.editor.EditorContext +import org.fbme.scenes.cells.EditorCell_SceneLabel +import org.jetbrains.mps.openapi.model.SNode + +class PortButton(context: EditorContext, node: SNode) : EditorCell_SceneLabel(context, node) { + +}*/ diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt index fefda8324..319b77a84 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt @@ -3,17 +3,25 @@ package org.fbme.ide.richediting.adapters.fbnetwork.port import jetbrains.mps.nodeEditor.cells.EditorCell_Property import jetbrains.mps.nodeEditor.cells.ModelAccessor import jetbrains.mps.openapi.editor.EditorContext +import jetbrains.mps.openapi.editor.cells.CellAction +import jetbrains.mps.openapi.editor.cells.CellActionType import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.lib.common.Declaration +import org.fbme.lib.common.StringIdentifier +import org.fbme.lib.iec61499.declarations.FBInterfaceDeclaration +import org.fbme.lib.iec61499.declarations.FBInterfaceDeclarationWithAdapters import org.fbme.lib.iec61499.descriptors.FBPortDescriptor +import org.fbme.lib.iec61499.fbnetwork.EntryKind import org.jetbrains.mps.openapi.model.SNode -class PortWithEditableLabel(context: EditorContext, node: SNode, port: FBPortDescriptor) : PortBase(port) { +class PortWithEditableLabel(context: EditorContext, node: SNode, port: FBPortDescriptor, declaration: Declaration?) : PortBase(port) { val label: EditorCell_Property init { label = EditorCell_Property(context, object : ModelAccessor { override fun getText(): String { + port.declaration return port.declaration?.name ?: "" } @@ -25,6 +33,40 @@ class PortWithEditableLabel(context: EditorContext, node: SNode, port: FBPortDes return true } }, node) + + label.setAction(CellActionType.BACKSPACE, object : CellAction { + override fun getDescriptionText(): String { + return "Delete port" + } + + override fun executeInCommand(): Boolean { + return true + } + + override fun canExecute(context: EditorContext): Boolean { + return port.declaration?.name?.isEmpty() ?: true + } + + override fun execute(p0: EditorContext?) { + if (declaration is FBInterfaceDeclaration) { + val ports = if (port.isInput) { + when (port.connectionKind) { + EntryKind.EVENT -> declaration.inputEvents + EntryKind.DATA -> declaration.inputParameters + else -> if (declaration is FBInterfaceDeclarationWithAdapters) declaration.sockets else mutableListOf() + } + } else { + when (port.connectionKind) { + EntryKind.EVENT -> declaration.outputEvents + EntryKind.DATA -> declaration.outputParameters + else -> if (declaration is FBInterfaceDeclarationWithAdapters) declaration.plugs else mutableListOf() + } + } + + ports.remove(port.declaration) + } + } + }) label.style.set(RichEditorStyleAttributes.PORT, port) } } \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt index 5e5aa0867..3c6674bf1 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt @@ -1,31 +1,32 @@ package org.fbme.scenes.cells -import jetbrains.mps.nodeEditor.MPSColors import jetbrains.mps.nodeEditor.cells.* import jetbrains.mps.openapi.editor.EditorContext +import org.fbme.scenes.cells.button.Button import org.jetbrains.mps.openapi.model.SNode +import java.awt.Color import java.awt.Graphics import java.awt.Graphics2D -import java.awt.geom.Ellipse2D class EditorCell_Button( context: EditorContext, node: SNode?, + private val button: Button ): EditorCell_Basic(context, node) { override fun paintContent(g: Graphics, p1: ParentSettings) { - val graphics = g.create() as Graphics2D - graphics.paint = MPSColors.white - graphics.fill(Ellipse2D.Double(myX.toDouble(), myY.toDouble(), DIAMETER, DIAMETER)) + button.paint(g.create() as Graphics2D, myX, myY) + } + + override fun paintSelection(g: Graphics?, c: Color?, drawBorder: Boolean, parentSettings: ParentSettings?) { + //do nothing } init { - myWidth = DIAMETER.toInt() - myHeight = DIAMETER.toInt() + myWidth = button.width + myHeight = button.height } companion object { - const val OX_OFFSET = 5 const val OY_OFFSET = -5 - const val DIAMETER = 15.0 } -} \ No newline at end of file +} diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/Button.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/Button.kt new file mode 100644 index 000000000..67d5dbb74 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/Button.kt @@ -0,0 +1,9 @@ +package org.fbme.scenes.cells.button + +import java.awt.Graphics2D + +interface Button { + val height: Int + val width: Int + fun paint(g: Graphics2D, x: Int, y: Int) +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/CrossButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/CrossButton.kt new file mode 100644 index 000000000..bba7acafd --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/CrossButton.kt @@ -0,0 +1,25 @@ +package org.fbme.scenes.cells.button + +import com.intellij.ui.JBColor +import java.awt.Color +import java.awt.Graphics2D +import java.awt.geom.RoundRectangle2D + +class CrossButton(private val size: Int): Button { + override val height: Int + get() = size + override val width: Int + get() = size + + override fun paint(g: Graphics2D, x: Int, y: Int) { + g.color = JBColor.WHITE + g.fill(RoundRectangle2D.Double(x.toDouble(), y.toDouble(), size.toDouble(), size.toDouble(), (size / 4).toDouble(), (size / 4).toDouble())) + drawCross(g, x + 3, y + 3, size - 6) + } + + private fun drawCross(g: Graphics2D, x: Int, y: Int, size: Int) { + g.color = Color.WHITE + g.drawLine(x, y, x + size, y + size) + g.drawLine(x, y + size, x + size, y) + } +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/EditButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/EditButton.kt new file mode 100644 index 000000000..287c21034 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/EditButton.kt @@ -0,0 +1,29 @@ +package org.fbme.scenes.cells.button + +import com.intellij.ui.JBColor +import java.awt.Color +import java.awt.Graphics2D +import java.awt.geom.RoundRectangle2D + +class EditButton(private val size: Int): Button { + override val height: Int + get() = size + override val width: Int + get() = size + + override fun paint(g: Graphics2D, x: Int, y: Int) { + g.color = JBColor.WHITE + g.fill(RoundRectangle2D.Double(x.toDouble(), y.toDouble(), size.toDouble(), size.toDouble(), (size / 4).toDouble(), (size / 4).toDouble())) + paintPen(g, x + 3, y + 3, size - 6) + } + + private fun paintPen(g: Graphics2D, x: Int, y: Int, size: Int) { + g.color = Color.WHITE + g.drawLine(x, y + size, x + 2 * size / 5, y + size) //- + g.drawLine(x, y + size, x, y + 3 * size / 5) // | + g.drawLine(x, y + 3 * size / 5, x + 2 * size / 5, y + size)// |_\ + g.drawLine(x + 2 * size / 5, y + size, x + size, y + size / 5) // / + g.drawLine(x, y + 3 * size / 5, x + 4 * size / 5, y) // // + g.drawLine(x + size, y + size / 5, x + 4 * size / 5, y) + } +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MinusButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MinusButton.kt new file mode 100644 index 000000000..a808d1545 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MinusButton.kt @@ -0,0 +1,11 @@ +package org.fbme.scenes.cells.button + +import com.intellij.ui.JBColor +import java.awt.Graphics2D + +class MinusButton(size: Int): SquareButton(size) { + override fun paintInside(g: Graphics2D, x: Int, y: Int) { + g.color = JBColor.BLACK + g.drawLine(x + INNER_PADDING, y + height / 2, x + width - INNER_PADDING, y + height / 2) + } +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/PlusButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/PlusButton.kt new file mode 100644 index 000000000..25693aa32 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/PlusButton.kt @@ -0,0 +1,12 @@ +package org.fbme.scenes.cells.button + +import java.awt.Color +import java.awt.Graphics2D + +class PlusButton(size: Int): SquareButton(size) { + override fun paintInside(g: Graphics2D, x: Int, y: Int) { + g.color = Color.BLACK + g.drawLine(x + width / 2, y + INNER_PADDING, x + width / 2, y + height - INNER_PADDING) + g.drawLine(x + INNER_PADDING, y + height / 2, x + width - INNER_PADDING, y + height / 2) + } +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/SquareButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/SquareButton.kt new file mode 100644 index 000000000..4a425b9b4 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/SquareButton.kt @@ -0,0 +1,25 @@ +package org.fbme.scenes.cells.button + +import com.intellij.openapi.rd.fill2DRect +import com.intellij.ui.JBColor +import java.awt.Color +import java.awt.Graphics2D +import java.awt.Rectangle + +abstract class SquareButton(private val size: Int) : Button { + override val height: Int + get() = size + override val width: Int + get() = size + + override fun paint(g: Graphics2D, x: Int, y: Int) { + g.fill2DRect(Rectangle(x, y, size, size), Color.WHITE) + paintInside(g, x, y) + } + + protected abstract fun paintInside(g: Graphics2D, x: Int, y: Int) + + companion object { + const val INNER_PADDING: Int = 2 + } +} \ No newline at end of file From e7666a7978dd1118632d93e8c62906ee6466cd78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Fri, 28 Apr 2023 14:41:59 +0200 Subject: [PATCH 08/66] Add ability to add parameters and socket with plugins --- .../repository/PlatformDeclarationsScope.kt | 12 + .../fbme/lib/iec61499/DeclarationsScope.kt | 1 + .../adapters/fbnetwork/FBNetworkEditors.kt | 7 +- .../fbnetwork/FunctionBlockController.kt | 11 +- .../adapters/fbnetwork/fb/AbstractFBCell.kt | 2 +- .../fbnetwork/fb/FBTypeEditCellComponent.kt | 250 ++++++++++++------ .../fbnetwork/port/PortActionFactory.kt | 98 +++++++ .../fbnetwork/port/PortWithEditableLabel.kt | 4 +- .../fbnetwork/port/PortWithLabelAndType.kt | 70 +++++ .../suggestion/CustomSubstituteInfo.kt | 27 ++ .../scenes/cells/EditorCell_SceneLabel.kt | 2 +- .../fbme/scenes/cells/action/DefaultAction.kt | 10 + .../action/ShowSubstituteChooserAction.kt | 18 ++ .../scenes/cells/action/port/AddPortAction.kt | 24 ++ .../fbme/scenes/viewmodel/CompletionItem.kt | 10 + 15 files changed, 456 insertions(+), 90 deletions(-) create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithLabelAndType.kt create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/suggestion/CustomSubstituteInfo.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/DefaultAction.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/ShowSubstituteChooserAction.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/port/AddPortAction.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/viewmodel/CompletionItem.kt diff --git a/code/language/src/main/kotlin/org/fbme/ide/iec61499/repository/PlatformDeclarationsScope.kt b/code/language/src/main/kotlin/org/fbme/ide/iec61499/repository/PlatformDeclarationsScope.kt index eca6aeb1d..167bb3470 100644 --- a/code/language/src/main/kotlin/org/fbme/ide/iec61499/repository/PlatformDeclarationsScope.kt +++ b/code/language/src/main/kotlin/org/fbme/ide/iec61499/repository/PlatformDeclarationsScope.kt @@ -61,6 +61,18 @@ internal class PlatformDeclarationsScope( .mapNotNull { myRepository.getAdapter(it, FBTypeDeclaration::class.java) } } + override fun findAllAdapterTypeDeclarations(): List { + return myRepository.mpsRepository.modules + .flatMap { it.models } + .filter { + myModel == null || + myModel.reference == it.reference || + ModelImports(myModel).importedModels.contains(it.reference) + } + .flatMap { it.rootNodes } + .mapNotNull { myRepository.getAdapter(it, AdapterTypeDeclaration::class.java) } + } + private fun findNode(identifier: Identifier): SNode? { val node = getNodeReference(identifier).resolve(myRepository.mpsRepository) ?: return null if (myModel == null) { diff --git a/code/library/src/main/kotlin/org/fbme/lib/iec61499/DeclarationsScope.kt b/code/library/src/main/kotlin/org/fbme/lib/iec61499/DeclarationsScope.kt index 3e35d940a..6103e9d54 100644 --- a/code/library/src/main/kotlin/org/fbme/lib/iec61499/DeclarationsScope.kt +++ b/code/library/src/main/kotlin/org/fbme/lib/iec61499/DeclarationsScope.kt @@ -15,4 +15,5 @@ interface DeclarationsScope { fun findResourceDeclaration(identifier: Identifier): ResourceDeclaration? fun findFunctionBlockDeclaration(identifier: Identifier): FunctionBlockDeclaration? fun findAllFBTypeDeclarations(): List + fun findAllAdapterTypeDeclarations(): List } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt index 88e7426b8..6aef79483 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt @@ -164,7 +164,7 @@ object FBNetworkEditors { val componentsFacility = ComponentsFacility( scene, networkView.componentsView, - getComponentControllerFactory(networkInstance, expandedComponentsController, editedComponentsController, repository.iec61499Factory), + getComponentControllerFactory(networkInstance, expandedComponentsController, editedComponentsController, repository.iec61499Factory, repository.getDeclarationScopeFor(model)), FBNetworkComponentSynchronizer(viewpoint, scale, expandedComponentsController), componentsLayout, componentsSelection, @@ -262,12 +262,13 @@ object FBNetworkEditors { instance: NetworkInstance, expandedComponentsController: ExpandedComponentsController, editedComponentsController: EditedComponentsController, - iec61499Factory: IEC61499Factory + iec61499Factory: IEC61499Factory, + scope: DeclarationsScope ): ComponentControllerFactory { return object : ComponentControllerFactory { override fun create(context: EditorContext, view: NetworkComponentView): ComponentController? { if (view is FunctionBlockView) { - return FunctionBlockController(context, view, instance, expandedComponentsController, editedComponentsController, iec61499Factory) + return FunctionBlockController(context, view, instance, expandedComponentsController, editedComponentsController, iec61499Factory, scope) } if (view is InterfaceEndpointView) { return EndpointPortController(context, view) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt index c918114f6..2f2047783 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt @@ -21,11 +21,13 @@ import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.ide.richediting.viewmodel.FunctionBlockPortView import org.fbme.ide.richediting.viewmodel.FunctionBlockView import org.fbme.ide.richediting.viewmodel.NetworkPortView +import org.fbme.lib.iec61499.DeclarationsScope import org.fbme.lib.iec61499.IEC61499Factory import org.fbme.lib.iec61499.fbnetwork.EntryKind import org.fbme.lib.iec61499.instances.FunctionBlockInstance import org.fbme.lib.iec61499.instances.NetworkInstance import org.fbme.scenes.cells.EditorCell_Button +import org.fbme.scenes.cells.EditorCell_Scene import org.fbme.scenes.cells.button.CrossButton import org.fbme.scenes.cells.button.EditButton import org.fbme.scenes.controllers.LayoutUtil.getLineSize @@ -40,7 +42,8 @@ class FunctionBlockController( networkInstance: NetworkInstance, val expandedComponentsController: ExpandedComponentsController, val editedController: EditedComponentsController, - iec61499Factory: IEC61499Factory + iec61499Factory: IEC61499Factory, + scope: DeclarationsScope ) : ComponentController, FBNetworkComponentController { private val myNameProperty: EditorCell_Property private val editButton: EditorCell_Button @@ -97,8 +100,8 @@ class FunctionBlockController( return FBTypeCellComponent(cellCollection.context, view.type, view.associatedNode, isEditable) } - private fun initializeFBEditCell(iec61499Factory: IEC61499Factory): FBCell { - return FBTypeEditCellComponent(cellCollection.context, view.type, view.associatedNode, iec61499Factory, isEditable) + private fun initializeFBEditCell(iec61499Factory: IEC61499Factory, scope: DeclarationsScope,): FBCell { + return FBTypeEditCellComponent(cellCollection.context, view.type, view.associatedNode, iec61499Factory, scope, isEditable) } private fun getEditButton(context: EditorContext, node: SNode): EditorCell_Button { @@ -229,7 +232,7 @@ class FunctionBlockController( val editorShift = expandedComponentsController.getEditorShift(view) - fbCell = if (isExpanded) initializeFBSceneCell(editorShift) else if (editedController.isEdited(view)) initializeFBEditCell(iec61499Factory) else initializeFBCell() + fbCell = if (isExpanded) initializeFBSceneCell(editorShift) else if (editedController.isEdited(view)) initializeFBEditCell(iec61499Factory, scope) else initializeFBCell() cellCollection.addEditorCell(fbCell.rootCell) fbCell.relayout() } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt index 8d2253fc1..0060813d2 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/AbstractFBCell.kt @@ -75,7 +75,7 @@ abstract class AbstractFBCell protected constructor( relayoutChildren() } - private fun getPortPosition(bounds: Rectangle, isOutput: Boolean = false): Point { + protected open fun getPortPosition(bounds: Rectangle, isOutput: Boolean = false): Point { val lineSize = lineSize val xOffset = if (isOutput) bounds.width + scale(PORT_SIZE) / 2 else - scale(PORT_SIZE) / 2 val x = bounds.x + xOffset diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt index db2e2ec2a..af3185f23 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt @@ -19,25 +19,38 @@ import jetbrains.mps.openapi.editor.style.StyleAttribute import org.fbme.ide.iec61499.repository.PlatformElement import org.fbme.ide.richediting.adapters.fbnetwork.FBConnectionPathPainter import org.fbme.ide.richediting.adapters.fbnetwork.port.Port +import org.fbme.ide.richediting.adapters.fbnetwork.port.PortActionFactory import org.fbme.ide.richediting.adapters.fbnetwork.port.PortWithEditableLabel +import org.fbme.ide.richediting.adapters.fbnetwork.port.PortWithLabelAndType import org.fbme.ide.richediting.editor.NetworkInstanceNavigationSupport import org.fbme.ide.richediting.editor.RichEditorStyleAttributes -import org.fbme.lib.common.* +import org.fbme.lib.common.StringIdentifier +import org.fbme.lib.iec61499.DeclarationsScope import org.fbme.lib.iec61499.IEC61499Factory -import org.fbme.lib.iec61499.declarations.FBInterfaceDeclaration +import org.fbme.lib.iec61499.declarations.* import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.descriptors.FBTypeDescriptor import org.fbme.lib.iec61499.instances.NetworkInstance +import org.fbme.lib.st.types.DataType +import org.fbme.lib.st.types.ElementaryType +import org.fbme.lib.st.types.GenericType import org.fbme.scenes.cells.EditorCell_Button import org.fbme.scenes.cells.button.PlusButton +import org.fbme.scenes.viewmodel.CompletionItem import org.jetbrains.mps.openapi.model.SNode import java.awt.* import java.awt.geom.AffineTransform import java.awt.geom.GeneralPath import kotlin.math.max -class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node: SNode, val iec61499Factory: IEC61499Factory, isEditable: Boolean) - : AbstractFBCell(context, fbType, node, isEditable) { +class FBTypeEditCellComponent( + context: EditorContext, + fbType: FBTypeDescriptor, + node: SNode, + val iec61499Factory: IEC61499Factory, + val scope: DeclarationsScope, + isEditable: Boolean, +) : AbstractFBCell(context, fbType, node, isEditable) { private val typeNameLabel: EditorCell_Property @@ -45,7 +58,9 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, private val eventPortsContainer: EditorCell_Collection private val eventButtonContiner: EditorCell_Collection private val dataPortsContainer: EditorCell_Collection + private val dataButtonContiner: EditorCell_Collection private val otherPortsContainer: EditorCell_Collection + private val otherButtonContainer: EditorCell_Collection private val inputPorts: Set get() = inputEventPorts.union(inputDataPorts).union(socketPorts) @@ -64,53 +79,39 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, get() = rootCell.style.get(StyleAttributes.TEXT_COLOR) init { + val declaration = fbType.declaration as FBInterfaceDeclaration + rootCell = createRootCell() rootCell.style.set(RichEditorStyleAttributes.TYPE, fbType) - eventPortsContainer = createPortContainer(fbType.eventInputPorts, fbType.eventOutputPorts, inputEventPorts, outputEventPorts) - eventButtonContiner = createButtonContainer( - object : CellAction { - override fun getDescriptionText(): String = "Add input event port" - - override fun executeInCommand(): Boolean = true + eventPortsContainer = createPortContainer(fbType.eventInputPorts, fbType.eventOutputPorts, inputEventPorts, outputEventPorts, ::createPortBlock) - override fun canExecute(p0: EditorContext?): Boolean = true + eventButtonContiner = createButtonContainer( + PortActionFactory.getInputEventAction(declaration, iec61499Factory), + PortActionFactory.getOutputEventAction(declaration, iec61499Factory) + ) - override fun execute(context: EditorContext) { - context.repository.modelAccess.runWriteInEDT { - val declaration = fbType.declaration - if (declaration is FBInterfaceDeclaration) { - declaration.inputEvents.add(iec61499Factory.createEventDeclaration(StringIdentifier("Iinput"))) - } - context.editorComponent.updater.update() - } - } - }, object : CellAction { - override fun getDescriptionText(): String = "Add output event port" + typeNameLabel = createNameLabel() - override fun executeInCommand(): Boolean = true + dataPortsContainer = createPortContainer(fbType.dataInputPorts, fbType.dataOutputPorts, inputDataPorts, outputDataPorts, ::createDataPortBlock) - override fun canExecute(p0: EditorContext?): Boolean = true + dataButtonContiner = createButtonContainer( + PortActionFactory.getInputParameterAction(declaration, iec61499Factory), + PortActionFactory.getOutputParameterAction(declaration, iec61499Factory)) - override fun execute(context: EditorContext) { - context.repository.modelAccess.runWriteAction { - val declaration = fbType.declaration - if (declaration is FBInterfaceDeclaration) { - declaration.outputEvents.add(iec61499Factory.createEventDeclaration(StringIdentifier("Ioutput"))) - } - context.editorComponent.updater.update() - } - } - }) - typeNameLabel = createNameLabel() - dataPortsContainer = createPortContainer(fbType.dataInputPorts, fbType.dataOutputPorts, inputDataPorts, outputDataPorts) - otherPortsContainer = createPortContainer(fbType.socketPorts, fbType.plugPorts, socketPorts, plugPorts) + otherPortsContainer = createPortContainer(fbType.socketPorts, fbType.plugPorts, socketPorts, plugPorts, ::createPlugSocketPortBlock) + otherButtonContainer = createButtonContainer( + PortActionFactory.getSocketAction(declaration as FBInterfaceDeclarationWithAdapters, iec61499Factory), + PortActionFactory.getPluginAction(declaration, iec61499Factory) + ) rootCell.addEditorCell(eventPortsContainer) rootCell.addEditorCell(eventButtonContiner) rootCell.addEditorCell(typeNameLabel) rootCell.addEditorCell(dataPortsContainer) + rootCell.addEditorCell(dataButtonContiner) rootCell.addEditorCell(otherPortsContainer) + rootCell.addEditorCell(otherButtonContainer) rootCell.style.set(StyleAttributes.TEXT_COLOR, if (isEditable) MPSColors.BLACK else MPSColors.DARK_GRAY) } @@ -141,11 +142,18 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, input: List, output: List, inputList: MutableList, - outputList: MutableList): EditorCell_Collection { + outputList: MutableList, + creator: ( + portsDescriptors: List, + ports: MutableList, + horizontalAlign: CellAlign, + padding: StyleAttribute, + ) -> EditorCell_Collection, + ): EditorCell_Collection { val container = object : EditorCell_Collection(context, node, CellLayout_Horizontal()) {} - val inputContainer = createPortBlock(input, inputList, CellAlign.LEFT, StyleAttributes.PADDING_LEFT) - val outputContainer = createPortBlock(output, outputList, CellAlign.RIGHT, StyleAttributes.PADDING_RIGHT) + val inputContainer = creator(input, inputList, CellAlign.LEFT, StyleAttributes.PADDING_LEFT) + val outputContainer = creator(output, outputList, CellAlign.RIGHT, StyleAttributes.PADDING_RIGHT) container.addEditorCell(inputContainer) container.addEditorCell(outputContainer) @@ -159,8 +167,8 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, portsDescriptors: List, ports: MutableList, horizontalAlign: CellAlign, - padding: StyleAttribute - ) : EditorCell_Collection { + padding: StyleAttribute, + ): EditorCell_Collection { val block = object : EditorCell_Collection(context, node, CellLayout_Vertical()) {} for (port in portsDescriptors) { @@ -174,25 +182,109 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, return block } - private fun createRootCell(): EditorCell_Collection { - return object : EditorCell_Collection( - context, - node, - object : CellLayout_Vertical() { - override fun doLayout(editorCells: jetbrains.mps.openapi.editor.cells.EditorCell_Collection?) { - super.doLayout(editorCells) - relayout() + private fun createDataPortBlock( + portsDescriptors: List, + ports: MutableList, + horizontalAlign: CellAlign, + padding: StyleAttribute, + ): EditorCell_Collection { + val block = object : EditorCell_Collection(context, node, CellLayout_Vertical()) {} + val types = mutableListOf() + types.addAll(ElementaryType.values()) + types.addAll(GenericType.values()) + + for (port in portsDescriptors) { + val typeDeclaration = port.declaration as ParameterDeclaration + val items = types.map { + object : CompletionItem { + override fun getMatchingText(pattern: String?): String? = it.stringify() + + override val descriptionText: String = "" + + override fun doSubstitute(editorContext: EditorContext?, pattern: String?): SNode? { + typeDeclaration.type = it + return null } } - ) { + } + val portWithLabel = PortWithLabelAndType(context, node, port, fbType.declaration, typeDeclaration.type?.stringify(), items) + portWithLabel.label.style.set(StyleAttributes.HORIZONTAL_ALIGN, horizontalAlign) + portWithLabel.label.style.set(padding, Padding(INNER_BORDER_PADDING.toDouble(), Measure.PIXELS)) + ports.add(portWithLabel) + block.addEditorCell(portWithLabel.cell) + } + + return block + } + + private fun createPlugSocketPortBlock( + portsDescriptors: List, + ports: MutableList, + horizontalAlign: CellAlign, + padding: StyleAttribute, + ): EditorCell_Collection { + val block = object : EditorCell_Collection(context, node, CellLayout_Vertical()) {} + val types = scope.findAllAdapterTypeDeclarations() + + for (port in portsDescriptors) { + if (port.isInput) { + val typeDeclaration = port.declaration as SocketDeclaration + val items = types.map { + object : CompletionItem { + override fun getMatchingText(pattern: String?): String = it.name + + override val descriptionText: String = "" + + override fun doSubstitute(editorContext: EditorContext?, pattern: String?): SNode? { + typeDeclaration.typeReference.setTarget(it) + return null + } + } + } + val portWithLabel = PortWithLabelAndType(context, node, port, fbType.declaration, typeDeclaration.typeReference.presentation, items) + portWithLabel.label.style.set(StyleAttributes.HORIZONTAL_ALIGN, horizontalAlign) + portWithLabel.label.style.set(padding, Padding(INNER_BORDER_PADDING.toDouble(), Measure.PIXELS)) + ports.add(portWithLabel) + block.addEditorCell(portWithLabel.cell) + } else { + val typeDeclaration = port.declaration as PlugDeclaration + val items = types.map { + object : CompletionItem { + override fun getMatchingText(pattern: String?): String = it.name + + override val descriptionText: String = "" + + override fun doSubstitute(editorContext: EditorContext?, pattern: String?): SNode? { + typeDeclaration.typeReference.setTarget(it) + return null + } + } + } + val portWithLabel = PortWithLabelAndType(context, node, port, fbType.declaration, typeDeclaration.typeReference.presentation, items) + portWithLabel.label.style.set(StyleAttributes.HORIZONTAL_ALIGN, horizontalAlign) + portWithLabel.label.style.set(padding, Padding(INNER_BORDER_PADDING.toDouble(), Measure.PIXELS)) + ports.add(portWithLabel) + block.addEditorCell(portWithLabel.cell) + } + } + + return block + } + + private fun createRootCell(): EditorCell_Collection { + return object : EditorCell_Collection(context, node, object : CellLayout_Vertical() { + override fun doLayout(editorCells: jetbrains.mps.openapi.editor.cells.EditorCell_Collection?) { + super.doLayout(editorCells) + relayout() + } + }) { override fun paintContent(g: Graphics, parentSettings: ParentSettings) { this@FBTypeEditCellComponent.paint(g.create() as Graphics2D) } - override fun paintSelection(g: Graphics, c: Color, drawBorder: Boolean, parentSettings: ParentSettings) { - // do noting + override fun paintSelection(g: Graphics, c: Color, drawBorder: Boolean, parentSettings: ParentSettings) { // do noting } override fun findLeaf(x: Int, y: Int): EditorCell? { @@ -222,14 +314,14 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, private fun drawPortIcons(graphics: Graphics2D, color: Color?) { drawPortIcons(graphics, rootCell.x - scale(PORT_SIZE), inputPorts, color) - drawPortIcons(graphics, rootCell.x + rootCell.width + scale(PORT_SIZE), outputPorts, color) + drawPortIcons(graphics, rootCell.x + rootCell.width, outputPorts, color) } private fun drawPortIcons(graphics: Graphics2D, x: Int, ports: Set, color: Color?) { for (port in ports) { - val portWithLabel = port as PortWithEditableLabel + val portWithLabel = port as PortWithEditableLabel val y = portWithLabel.label.y + portWithLabel.label.height / 2 - scale(PORT_SIZE) / 2 - val form = Rectangle(x, y, scale(PORT_SIZE), scale(PORT_SIZE)) + val form = Rectangle(x, y, scale(PORT_SIZE), scale(PORT_SIZE)) graphics.color = DiagramColors.getColorFor(port.connectionKind, isEditable) graphics.fill(form) @@ -261,7 +353,7 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, val height = rootCell.height.toDouble() val xRight = x + width val yTop = y + height - val yCenterB = typeNameLabel.y - lineSize / 2 + val yCenterB = typeNameLabel.y - lineSize / 2 val yCenterT = typeNameLabel.y + lineSize / 2 val xLeftS = x + lineSize val xRightS = xRight - lineSize @@ -290,10 +382,7 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, if (child != null) { val childNetworkInstance = child.containedNetwork if (childNetworkInstance is NetworkInstance) { - val navigationStub = NetworkInstanceNavigationSupport.getNavigationStub( - rootCell.context.operationContext.project, - childNetworkInstance - ) + val navigationStub = NetworkInstanceNavigationSupport.getNavigationStub(rootCell.context.operationContext.project, childNetworkInstance) style.set(StyleAttributes.NAVIGATABLE_NODE, navigationStub) return } @@ -351,21 +440,17 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, private fun createNameLabel(): EditorCell_Property { val typeDeclaration = fbType.declaration - val result = EditorCell_Property( - context, - object : ModelAccessor { - override fun getText(): String? = typeDeclaration?.name + val result = EditorCell_Property(context, object : ModelAccessor { + override fun getText(): String? = typeDeclaration?.name - override fun setText(text: String) { - typeDeclaration?.name = text - } + override fun setText(text: String) { + typeDeclaration?.name = text + } - override fun isValidText(text: String): Boolean { - return true - } - }, - node - ) + override fun isValidText(text: String): Boolean { + return true + } + }, node) result.style.set(StyleAttributes.HORIZONTAL_ALIGN, CellAlign.CENTER) result.style.set(StyleAttributes.FONT_SIZE, fontSize) @@ -383,14 +468,20 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, otherPortsContainer.width = width addCentralGap(width) eventButtonContiner.height = eventButtonContiner.cells[0].height + lineSize / 2 + dataButtonContiner.height = dataButtonContiner.cells[0].height + lineSize / 2 + otherButtonContainer.height = otherButtonContainer.cells[0].height + lineSize / 2 eventButtonContiner.width = width + dataButtonContiner.width = width + otherButtonContainer.width = width } private fun addCentralGap(width: Int) { addCentralGap(width, outputEventPorts, eventPortsContainer) addCentralGap(width, outputDataPorts, dataPortsContainer) addCentralGap(width, plugPorts, otherPortsContainer) - addGapForButtons(width) + addGapForButtons(width, eventButtonContiner) + addGapForButtons(width, dataButtonContiner) + addGapForButtons(width, otherButtonContainer) } private fun addCentralGap(width: Int, ports: List, container: EditorCell_Collection) { @@ -398,9 +489,9 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, container.cells[1].moveTo(gap, container.cells[1].y) } - private fun addGapForButtons(width: Int) { - eventButtonContiner.cells[1].moveTo(width - 15, eventButtonContiner.cells[1].y + eventButtonContiner.height - eventButtonContiner.cells[1].height) - eventButtonContiner.cells[0].moveTo(0, eventButtonContiner.cells[0].y + eventButtonContiner.height - eventButtonContiner.cells[0].height) + private fun addGapForButtons(width: Int, cell: EditorCell_Collection) { + cell.cells[1].moveTo(width - 15, cell.cells[1].y + cell.height - cell.cells[1].height) + cell.cells[0].moveTo(0, cell.cells[0].y + cell.height - cell.cells[0].height) } companion object { @@ -408,7 +499,8 @@ class FBTypeEditCellComponent(context: EditorContext, fbType: FBTypeDescriptor, private const val INNER_BORDER_PADDING = 2 private fun portsColumnWidth(ports: Collection): Int { - return ports.maxOfOrNull { (it as PortWithEditableLabel).label.width } ?: 0 + return ports.maxOfOrNull { if (it is PortWithLabelAndType) it.cell.width else (it as PortWithEditableLabel).label.width } + ?: 0 } } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt new file mode 100644 index 000000000..198af04d0 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt @@ -0,0 +1,98 @@ +package org.fbme.ide.richediting.adapters.fbnetwork.port + +import org.fbme.lib.common.Identifier +import org.fbme.lib.common.StringIdentifier +import org.fbme.lib.iec61499.IEC61499Factory +import org.fbme.lib.iec61499.declarations.* +import org.fbme.scenes.cells.action.port.AddPortAction +import java.util.function.Supplier + +object PortActionFactory { + fun getInputEventAction( + declaration: FBInterfaceDeclaration, + iec61499Factory: IEC61499Factory, + identifierFactory: Supplier = IDENTIFIER_FACTORY("Ievent", declaration.inputEvents.map { it.name }), + ): AddPortAction { + return AddPortAction( + "Add input event port", + declaration.inputEvents, + { iec61499Factory.createEventDeclaration(identifierFactory.get()) } + ) + } + + fun getOutputEventAction( + declaration: FBInterfaceDeclaration, + iec61499Factory: IEC61499Factory, + identifierFactory: Supplier = IDENTIFIER_FACTORY("Oevent", declaration.outputEvents.map { it.name }), + ): AddPortAction { + return AddPortAction( + "Add output event port", + declaration.outputEvents, + { iec61499Factory.createEventDeclaration(identifierFactory.get()) } + ) + } + + fun getInputParameterAction( + declaration: FBInterfaceDeclaration, + iec61499Factory: IEC61499Factory, + identifierFactory: Supplier = IDENTIFIER_FACTORY("Idata", declaration.inputParameters.map { it.name }), + ) : AddPortAction { + return AddPortAction( + "Add input data port", + declaration.inputParameters, + { iec61499Factory.createParameterDeclaration(identifierFactory.get()) } + ) + } + + fun getOutputParameterAction( + declaration: FBInterfaceDeclaration, + iec61499Factory: IEC61499Factory, + identifierFactory: Supplier = IDENTIFIER_FACTORY("Odata", declaration.outputParameters.map { it.name }), + ) : AddPortAction { + return AddPortAction( + "Add output data port", + declaration.outputParameters, + { iec61499Factory.createParameterDeclaration(identifierFactory.get()) } + ) + } + + fun getSocketAction( + declaration: FBInterfaceDeclarationWithAdapters, + iec61499Factory: IEC61499Factory, + identifierFactory: Supplier = IDENTIFIER_FACTORY("Socket", declaration.sockets.map { it.name }), + ) : AddPortAction { + return AddPortAction( + "Add socket port", + declaration.sockets, + { iec61499Factory.createSocketDeclaration(identifierFactory.get()) } + ) + } + + fun getPluginAction( + declaration: FBInterfaceDeclarationWithAdapters, + iec61499Factory: IEC61499Factory, + identifierFactory: Supplier = IDENTIFIER_FACTORY("Plugin", declaration.plugs.map { it.name }), + ) : AddPortAction { + return AddPortAction( + "Add plugin port", + declaration.plugs, + { iec61499Factory.createPlugDeclaration(identifierFactory.get()) } + ) + } + + val IDENTIFIER_FACTORY: (prefix: String, values: List) -> Supplier = { prefix, names -> + var index: Int? = null + + val getName: () -> String = { + "${prefix}${index ?: ""}" + } + + Supplier { + while (names.contains(getName())) { + index = (index ?: 0) + 1 + } + + StringIdentifier(getName()) + } + } +} \ No newline at end of file diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt index 319b77a84..2e4d1f1e0 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt @@ -14,7 +14,7 @@ import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.fbnetwork.EntryKind import org.jetbrains.mps.openapi.model.SNode -class PortWithEditableLabel(context: EditorContext, node: SNode, port: FBPortDescriptor, declaration: Declaration?) : PortBase(port) { +open class PortWithEditableLabel(context: EditorContext, node: SNode, val port: FBPortDescriptor, declaration: Declaration?) : PortBase(port) { val label: EditorCell_Property init { @@ -36,7 +36,7 @@ class PortWithEditableLabel(context: EditorContext, node: SNode, port: FBPortDes label.setAction(CellActionType.BACKSPACE, object : CellAction { override fun getDescriptionText(): String { - return "Delete port" + return "Delete port" } override fun executeInCommand(): Boolean { diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithLabelAndType.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithLabelAndType.kt new file mode 100644 index 000000000..8458305b6 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithLabelAndType.kt @@ -0,0 +1,70 @@ +package org.fbme.ide.richediting.adapters.fbnetwork.port + +import com.intellij.ui.JBColor +import jetbrains.mps.editor.runtime.style.Measure +import jetbrains.mps.editor.runtime.style.Padding +import jetbrains.mps.editor.runtime.style.StyleAttributes +import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Vertical +import jetbrains.mps.nodeEditor.cells.EditorCell_Collection +import jetbrains.mps.openapi.editor.EditorContext +import jetbrains.mps.openapi.editor.cells.CellActionType +import org.fbme.ide.richediting.adapters.fbnetwork.suggestion.CustomSubstituteInfo +import org.fbme.lib.common.Declaration +import org.fbme.lib.iec61499.descriptors.FBPortDescriptor +import org.fbme.scenes.cells.EditorCell_SceneLabel +import org.fbme.scenes.cells.action.ShowSubstituteChooserAction +import org.fbme.scenes.viewmodel.CompletionItem +import org.jetbrains.mps.openapi.model.SNode + +class PortWithLabelAndType( + context: EditorContext, + node: SNode, + port: FBPortDescriptor, + declaration: Declaration?, + typeName: String?, + items: List, +) : PortWithEditableLabel(context, node, port, declaration) { + val cell: EditorCell_Collection + val typeLabel: EditorCell_SceneLabel + + private fun createTypeLabel( + context: EditorContext, + node: SNode, + typeName: String?, + items: List, + ): EditorCell_SceneLabel { + val typeLabel = object : EditorCell_SceneLabel(context, node, typeName + ?: TYPE_DEFAULT_NAME, typeName.isNullOrEmpty()) { + override fun setSelected(selected: Boolean) { //do nothing + } + } + + //set style + typeLabel.style.set(StyleAttributes.PADDING_LEFT, Padding(HORIZONTAL_PADDING, Measure.PIXELS)) + typeLabel.style.set(StyleAttributes.PADDING_RIGHT, Padding(HORIZONTAL_PADDING, Measure.PIXELS)) + typeLabel.style.set(StyleAttributes.UNDERLINED, true) + typeLabel.style.set(StyleAttributes.FONT_SIZE, TYPE_FONT_SIZE) //TODO: add color with error + typeLabel.style.set(StyleAttributes.TEXT_COLOR, TYPE_ERROR_COLOR) + + //Add showing suggestion + typeLabel.setAction(CellActionType.CLICK, ShowSubstituteChooserAction(typeLabel)) + typeLabel.substituteInfo = CustomSubstituteInfo(context, typeLabel, items) + + return typeLabel + } + + init { + cell = EditorCell_Collection(context, node, CellLayout_Vertical()) + typeLabel = createTypeLabel(context, node, typeName, items) + + cell.addEditorCell(label) + cell.addEditorCell(typeLabel) + } + + companion object { + const val HORIZONTAL_PADDING = 10.0 + const val TYPE_FONT_SIZE = 10 + val TYPE_ERROR_COLOR = JBColor.RED!! + const val TYPE_DEFAULT_NAME = "none" + } +} \ No newline at end of file diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/suggestion/CustomSubstituteInfo.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/suggestion/CustomSubstituteInfo.kt new file mode 100644 index 000000000..09e1698b0 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/suggestion/CustomSubstituteInfo.kt @@ -0,0 +1,27 @@ +package org.fbme.ide.richediting.adapters.fbnetwork.suggestion + +import jetbrains.mps.nodeEditor.cellMenu.AbstractNodeSubstituteInfo +import jetbrains.mps.openapi.editor.EditorContext +import jetbrains.mps.openapi.editor.cells.EditorCell +import jetbrains.mps.openapi.editor.cells.SubstituteAction +import jetbrains.mps.smodel.action.AbstractSubstituteAction +import org.fbme.scenes.viewmodel.CompletionItem +import org.jetbrains.mps.openapi.model.SNode + +class CustomSubstituteInfo( + context: EditorContext, + val cell: EditorCell, + val items: List, +) : AbstractNodeSubstituteInfo(context) { + override fun createActions(): MutableList = items.map { + object : AbstractSubstituteAction(cell.sNode) { + override fun getMatchingText(pattern: String?): String = it.getMatchingText(pattern) ?: "" + + override fun getDescriptionText(description: String?): String = it.descriptionText ?: "" + + override fun doSubstitute(editorContext: EditorContext?, pattern: String?): SNode? { + return it.doSubstitute(editorContext, pattern) + } + } + }.toMutableList() +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_SceneLabel.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_SceneLabel.kt index ef6a59e96..b8d1e9be8 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_SceneLabel.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_SceneLabel.kt @@ -9,7 +9,7 @@ import org.jetbrains.mps.openapi.model.SNode import java.awt.Color import java.awt.Graphics -class EditorCell_SceneLabel( +open class EditorCell_SceneLabel( context: EditorContext, node: SNode?, text: String?, diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/DefaultAction.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/DefaultAction.kt new file mode 100644 index 000000000..6fcfe573e --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/DefaultAction.kt @@ -0,0 +1,10 @@ +package org.fbme.scenes.cells.action + +import jetbrains.mps.openapi.editor.EditorContext +import jetbrains.mps.openapi.editor.cells.CellAction + +abstract class DefaultAction(val executeInCommand: Boolean, var canExecute: Boolean) : CellAction { + override fun executeInCommand(): Boolean = executeInCommand + + override fun canExecute(context: EditorContext?): Boolean = canExecute +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/ShowSubstituteChooserAction.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/ShowSubstituteChooserAction.kt new file mode 100644 index 000000000..e5a4c86ba --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/ShowSubstituteChooserAction.kt @@ -0,0 +1,18 @@ +package org.fbme.scenes.cells.action + +import jetbrains.mps.nodeEditor.EditorComponent +import jetbrains.mps.openapi.editor.EditorContext +import jetbrains.mps.openapi.editor.cells.EditorCell + +open class ShowSubstituteChooserAction( + val cell: EditorCell, + canExecute: Boolean = true, + executeInCommand: Boolean = true, +) : DefaultAction(executeInCommand = executeInCommand, canExecute = canExecute) { + override fun getDescriptionText(): String = "Show suggestion tab" + + override fun execute(context: EditorContext?) { + val ec = context?.editorComponent as? EditorComponent + ec?.activateNodeSubstituteChooser(cell, true) + } +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/port/AddPortAction.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/port/AddPortAction.kt new file mode 100644 index 000000000..2c58694a3 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/port/AddPortAction.kt @@ -0,0 +1,24 @@ +package org.fbme.scenes.cells.action.port + +import jetbrains.mps.openapi.editor.EditorContext +import org.fbme.scenes.cells.action.DefaultAction +import java.util.function.Supplier + +open class AddPortAction( + private val descriptionText: String, + private val portsDescription: MutableList, + private val portFactory: Supplier, + canExecute: Boolean = true, + executeInCommand: Boolean = true, +) : DefaultAction(canExecute = canExecute, executeInCommand = executeInCommand) { + override fun getDescriptionText(): String = descriptionText + + override fun execute(context: EditorContext?) { + context ?: return + + context.repository.modelAccess.runWriteInEDT { + portsDescription.add(portFactory.get()) + context.editorComponent.updater.update() + } + } +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/viewmodel/CompletionItem.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/viewmodel/CompletionItem.kt new file mode 100644 index 000000000..d541507d8 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/viewmodel/CompletionItem.kt @@ -0,0 +1,10 @@ +package org.fbme.scenes.viewmodel + +import jetbrains.mps.openapi.editor.EditorContext +import org.jetbrains.mps.openapi.model.SNode + +interface CompletionItem { + fun getMatchingText(pattern: String?): String? + val descriptionText: String? + fun doSubstitute(editorContext: EditorContext?, pattern: String?): SNode? +} \ No newline at end of file From 66f812294db88edae2b7e3ed08e25e71a2adfe85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 30 Apr 2023 13:27:54 +0200 Subject: [PATCH 09/66] Some fixes --- .../iec61499/declarations/PlugDeclaration.kt | 8 +- .../declarations/SocketDeclaration.kt | 8 +- .../declarations/SocketPluginDeclaration.kt | 9 + .../org/fbme/lib/st/types/DataTypeUtil.kt | 7 + .../actions/cell/DeclarationNameAccessor.kt | 18 ++ .../fbnetwork/actions/cell}/DefaultAction.kt | 2 +- .../cell}/ShowSubstituteChooserAction.kt | 4 +- .../actions/cell}/port/AddPortAction.kt | 4 +- .../actions/cell/port/DeletePortAction.kt | 26 +++ .../fbnetwork/fb/FBTypeEditCellComponent.kt | 160 +++++++----------- .../fbnetwork/port/PortActionFactory.kt | 45 ++++- .../adapters/fbnetwork/port/PortBase.kt | 5 +- .../fbnetwork/port/PortWithEditableLabel.kt | 65 +------ .../fbnetwork/port/PortWithLabelAndType.kt | 6 +- .../components/ComponentsFacility.kt | 11 -- 15 files changed, 179 insertions(+), 199 deletions(-) create mode 100644 code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketPluginDeclaration.kt create mode 100644 code/library/src/main/kotlin/org/fbme/lib/st/types/DataTypeUtil.kt create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/DeclarationNameAccessor.kt rename code/{scenes/src/main/kotlin/org/fbme/scenes/cells/action => richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell}/DefaultAction.kt (84%) rename code/{scenes/src/main/kotlin/org/fbme/scenes/cells/action => richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell}/ShowSubstituteChooserAction.kt (82%) rename code/{scenes/src/main/kotlin/org/fbme/scenes/cells/action => richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell}/port/AddPortAction.kt (83%) create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/port/DeletePortAction.kt diff --git a/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/PlugDeclaration.kt b/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/PlugDeclaration.kt index 9d7f8ee96..22f910ebc 100644 --- a/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/PlugDeclaration.kt +++ b/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/PlugDeclaration.kt @@ -1,9 +1,3 @@ package org.fbme.lib.iec61499.declarations -import org.fbme.lib.common.Reference -import org.fbme.lib.iec61499.fbnetwork.FunctionBlockDeclarationBase - -interface PlugDeclaration : FunctionBlockDeclarationBase { - override val container: FBInterfaceDeclarationWithAdapters? - val typeReference: Reference -} +interface PlugDeclaration : SocketPluginDeclaration diff --git a/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketDeclaration.kt b/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketDeclaration.kt index 0887a1eb8..16205f1a3 100644 --- a/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketDeclaration.kt +++ b/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketDeclaration.kt @@ -1,9 +1,3 @@ package org.fbme.lib.iec61499.declarations -import org.fbme.lib.common.Reference -import org.fbme.lib.iec61499.fbnetwork.FunctionBlockDeclarationBase - -interface SocketDeclaration : FunctionBlockDeclarationBase { - override val container: FBInterfaceDeclarationWithAdapters? - val typeReference: Reference -} +interface SocketDeclaration : SocketPluginDeclaration diff --git a/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketPluginDeclaration.kt b/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketPluginDeclaration.kt new file mode 100644 index 000000000..d20bf7d10 --- /dev/null +++ b/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketPluginDeclaration.kt @@ -0,0 +1,9 @@ +package org.fbme.lib.iec61499.declarations + +import org.fbme.lib.common.Reference +import org.fbme.lib.iec61499.fbnetwork.FunctionBlockDeclarationBase + +interface SocketPluginDeclaration : FunctionBlockDeclarationBase { + override val container: FBInterfaceDeclarationWithAdapters? + val typeReference: Reference +} \ No newline at end of file diff --git a/code/library/src/main/kotlin/org/fbme/lib/st/types/DataTypeUtil.kt b/code/library/src/main/kotlin/org/fbme/lib/st/types/DataTypeUtil.kt new file mode 100644 index 000000000..9eedb1c97 --- /dev/null +++ b/code/library/src/main/kotlin/org/fbme/lib/st/types/DataTypeUtil.kt @@ -0,0 +1,7 @@ +package org.fbme.lib.st.types + +object DataTypeUtil { + fun getBasicTypes(): List { + return listOf(*GenericType.values(), *ElementaryType.values()) + } +} \ No newline at end of file diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/DeclarationNameAccessor.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/DeclarationNameAccessor.kt new file mode 100644 index 000000000..3f8b76d2d --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/DeclarationNameAccessor.kt @@ -0,0 +1,18 @@ +package org.fbme.ide.richediting.adapters.fbnetwork.actions.cell + +import jetbrains.mps.nodeEditor.cells.ModelAccessor +import org.fbme.lib.common.Declaration +import java.util.function.Predicate + +class DeclarationNameAccessor( + val declaration: Declaration?, + private val validator: Predicate = Predicate { true } +) : ModelAccessor { + override fun getText(): String = declaration?.name ?: "" + + override fun setText(text: String?) { + declaration?.name = text ?: "" + } + + override fun isValidText(text: String?): Boolean = validator.test(text) +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/DefaultAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/DefaultAction.kt similarity index 84% rename from code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/DefaultAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/DefaultAction.kt index 6fcfe573e..a959f6a6e 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/DefaultAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/DefaultAction.kt @@ -1,4 +1,4 @@ -package org.fbme.scenes.cells.action +package org.fbme.ide.richediting.adapters.fbnetwork.actions.cell import jetbrains.mps.openapi.editor.EditorContext import jetbrains.mps.openapi.editor.cells.CellAction diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/ShowSubstituteChooserAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/ShowSubstituteChooserAction.kt similarity index 82% rename from code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/ShowSubstituteChooserAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/ShowSubstituteChooserAction.kt index e5a4c86ba..7b0ab6675 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/ShowSubstituteChooserAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/ShowSubstituteChooserAction.kt @@ -1,4 +1,4 @@ -package org.fbme.scenes.cells.action +package org.fbme.ide.richediting.adapters.fbnetwork.actions.cell import jetbrains.mps.nodeEditor.EditorComponent import jetbrains.mps.openapi.editor.EditorContext @@ -13,6 +13,6 @@ open class ShowSubstituteChooserAction( override fun execute(context: EditorContext?) { val ec = context?.editorComponent as? EditorComponent - ec?.activateNodeSubstituteChooser(cell, true) + ec?.activateNodeSubstituteChooser(cell, true, true) } } \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/port/AddPortAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/port/AddPortAction.kt similarity index 83% rename from code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/port/AddPortAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/port/AddPortAction.kt index 2c58694a3..510b9b16e 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/action/port/AddPortAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/port/AddPortAction.kt @@ -1,7 +1,7 @@ -package org.fbme.scenes.cells.action.port +package org.fbme.ide.richediting.adapters.fbnetwork.actions.cell.port import jetbrains.mps.openapi.editor.EditorContext -import org.fbme.scenes.cells.action.DefaultAction +import org.fbme.ide.richediting.adapters.fbnetwork.actions.cell.DefaultAction import java.util.function.Supplier open class AddPortAction( diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/port/DeletePortAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/port/DeletePortAction.kt new file mode 100644 index 000000000..d04c23dcd --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/port/DeletePortAction.kt @@ -0,0 +1,26 @@ +package org.fbme.ide.richediting.adapters.fbnetwork.actions.cell.port + +import jetbrains.mps.openapi.editor.EditorContext +import org.fbme.ide.richediting.adapters.fbnetwork.actions.cell.DefaultAction +import org.fbme.lib.common.Declaration +import org.fbme.lib.iec61499.descriptors.FBPortDescriptor + +class DeletePortAction( + private val port: FBPortDescriptor, + private val ports: MutableList +): DefaultAction(canExecute = false, executeInCommand = true) { + override fun getDescriptionText(): String = "Delete port" + + override fun canExecute(context: EditorContext?): Boolean { + return port.declaration?.name.isNullOrEmpty() + } + + override fun execute(context: EditorContext?) { + context ?: return + + context.repository.modelAccess.runWriteInEDT { + ports.remove(port.declaration) + context.editorComponent.updater.update() + } + } +} \ No newline at end of file diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt index af3185f23..525a8672a 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt @@ -9,7 +9,6 @@ import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Horizontal import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Vertical import jetbrains.mps.nodeEditor.cells.EditorCell_Collection import jetbrains.mps.nodeEditor.cells.EditorCell_Property -import jetbrains.mps.nodeEditor.cells.ModelAccessor import jetbrains.mps.nodeEditor.cells.ParentSettings import jetbrains.mps.openapi.editor.EditorContext import jetbrains.mps.openapi.editor.cells.CellAction @@ -18,22 +17,24 @@ import jetbrains.mps.openapi.editor.cells.EditorCell import jetbrains.mps.openapi.editor.style.StyleAttribute import org.fbme.ide.iec61499.repository.PlatformElement import org.fbme.ide.richediting.adapters.fbnetwork.FBConnectionPathPainter +import org.fbme.ide.richediting.adapters.fbnetwork.actions.cell.DeclarationNameAccessor import org.fbme.ide.richediting.adapters.fbnetwork.port.Port import org.fbme.ide.richediting.adapters.fbnetwork.port.PortActionFactory import org.fbme.ide.richediting.adapters.fbnetwork.port.PortWithEditableLabel import org.fbme.ide.richediting.adapters.fbnetwork.port.PortWithLabelAndType import org.fbme.ide.richediting.editor.NetworkInstanceNavigationSupport import org.fbme.ide.richediting.editor.RichEditorStyleAttributes -import org.fbme.lib.common.StringIdentifier import org.fbme.lib.iec61499.DeclarationsScope import org.fbme.lib.iec61499.IEC61499Factory -import org.fbme.lib.iec61499.declarations.* +import org.fbme.lib.iec61499.declarations.FBInterfaceDeclaration +import org.fbme.lib.iec61499.declarations.FBInterfaceDeclarationWithAdapters +import org.fbme.lib.iec61499.declarations.ParameterDeclaration +import org.fbme.lib.iec61499.declarations.SocketPluginDeclaration import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.descriptors.FBTypeDescriptor +import org.fbme.lib.iec61499.fbnetwork.EntryKind import org.fbme.lib.iec61499.instances.NetworkInstance -import org.fbme.lib.st.types.DataType -import org.fbme.lib.st.types.ElementaryType -import org.fbme.lib.st.types.GenericType +import org.fbme.lib.st.types.DataTypeUtil import org.fbme.scenes.cells.EditorCell_Button import org.fbme.scenes.cells.button.PlusButton import org.fbme.scenes.viewmodel.CompletionItem @@ -41,6 +42,7 @@ import org.jetbrains.mps.openapi.model.SNode import java.awt.* import java.awt.geom.AffineTransform import java.awt.geom.GeneralPath +import java.util.* import kotlin.math.max class FBTypeEditCellComponent( @@ -55,19 +57,15 @@ class FBTypeEditCellComponent( private val typeNameLabel: EditorCell_Property override val rootCell: EditorCell_Collection + private val buttons: EnumMap private val eventPortsContainer: EditorCell_Collection - private val eventButtonContiner: EditorCell_Collection private val dataPortsContainer: EditorCell_Collection - private val dataButtonContiner: EditorCell_Collection private val otherPortsContainer: EditorCell_Collection - private val otherButtonContainer: EditorCell_Collection private val inputPorts: Set get() = inputEventPorts.union(inputDataPorts).union(socketPorts) - private val outputPorts: Set get() = outputEventPorts.union(outputDataPorts).union(plugPorts) - private val backgroundColor: Color get() { val background = rootCell.style.get(StyleAttributes.BACKGROUND_COLOR) @@ -79,40 +77,37 @@ class FBTypeEditCellComponent( get() = rootCell.style.get(StyleAttributes.TEXT_COLOR) init { - val declaration = fbType.declaration as FBInterfaceDeclaration + val declaration = fbType.declaration rootCell = createRootCell() rootCell.style.set(RichEditorStyleAttributes.TYPE, fbType) - eventPortsContainer = createPortContainer(fbType.eventInputPorts, fbType.eventOutputPorts, inputEventPorts, outputEventPorts, ::createPortBlock) - - eventButtonContiner = createButtonContainer( - PortActionFactory.getInputEventAction(declaration, iec61499Factory), - PortActionFactory.getOutputEventAction(declaration, iec61499Factory) - ) + buttons = EnumMap(EntryKind::class.java) + eventPortsContainer = createPortContainer(fbType.eventInputPorts, fbType.eventOutputPorts, inputEventPorts, outputEventPorts, ::createPortBlock) typeNameLabel = createNameLabel() - dataPortsContainer = createPortContainer(fbType.dataInputPorts, fbType.dataOutputPorts, inputDataPorts, outputDataPorts, ::createDataPortBlock) - - dataButtonContiner = createButtonContainer( - PortActionFactory.getInputParameterAction(declaration, iec61499Factory), - PortActionFactory.getOutputParameterAction(declaration, iec61499Factory)) - otherPortsContainer = createPortContainer(fbType.socketPorts, fbType.plugPorts, socketPorts, plugPorts, ::createPlugSocketPortBlock) - otherButtonContainer = createButtonContainer( - PortActionFactory.getSocketAction(declaration as FBInterfaceDeclarationWithAdapters, iec61499Factory), - PortActionFactory.getPluginAction(declaration, iec61499Factory) - ) rootCell.addEditorCell(eventPortsContainer) - rootCell.addEditorCell(eventButtonContiner) + if (declaration is FBInterfaceDeclaration) { + buttons[EntryKind.EVENT] = createButtonContainer(PortActionFactory.createInputEventAction(declaration, iec61499Factory), PortActionFactory.createOutputEventAction(declaration, iec61499Factory)) + + rootCell.addEditorCell(buttons[EntryKind.EVENT]) + } rootCell.addEditorCell(typeNameLabel) rootCell.addEditorCell(dataPortsContainer) - rootCell.addEditorCell(dataButtonContiner) + if (declaration is FBInterfaceDeclaration) { + buttons[EntryKind.DATA] = createButtonContainer(PortActionFactory.createInputParameterAction(declaration, iec61499Factory), PortActionFactory.createOutputParameterAction(declaration, iec61499Factory)) + + rootCell.addEditorCell(buttons[EntryKind.DATA]) + } rootCell.addEditorCell(otherPortsContainer) - rootCell.addEditorCell(otherButtonContainer) + if (declaration is FBInterfaceDeclarationWithAdapters) { + buttons[EntryKind.ADAPTER] = createButtonContainer(PortActionFactory.createSocketAction(declaration, iec61499Factory), PortActionFactory.createPluginAction(declaration, iec61499Factory)) + rootCell.addEditorCell(buttons[EntryKind.ADAPTER]) + } rootCell.style.set(StyleAttributes.TEXT_COLOR, if (isEditable) MPSColors.BLACK else MPSColors.DARK_GRAY) } @@ -131,7 +126,7 @@ class FBTypeEditCellComponent( } private fun createButton(cellAction: CellAction): EditorCell { - val button = EditorCell_Button(context, node, PlusButton(15)) + val button = EditorCell_Button(context, node, PlusButton(PLUS_BUTTON_SIZE)) button.setAction(CellActionType.CLICK, cellAction) @@ -189,15 +184,12 @@ class FBTypeEditCellComponent( padding: StyleAttribute, ): EditorCell_Collection { val block = object : EditorCell_Collection(context, node, CellLayout_Vertical()) {} - val types = mutableListOf() - types.addAll(ElementaryType.values()) - types.addAll(GenericType.values()) for (port in portsDescriptors) { val typeDeclaration = port.declaration as ParameterDeclaration - val items = types.map { + val items = DataTypeUtil.getBasicTypes().map { object : CompletionItem { - override fun getMatchingText(pattern: String?): String? = it.stringify() + override fun getMatchingText(pattern: String?): String = it.stringify() override val descriptionText: String = "" @@ -227,45 +219,24 @@ class FBTypeEditCellComponent( val types = scope.findAllAdapterTypeDeclarations() for (port in portsDescriptors) { - if (port.isInput) { - val typeDeclaration = port.declaration as SocketDeclaration - val items = types.map { - object : CompletionItem { - override fun getMatchingText(pattern: String?): String = it.name - - override val descriptionText: String = "" - - override fun doSubstitute(editorContext: EditorContext?, pattern: String?): SNode? { - typeDeclaration.typeReference.setTarget(it) - return null - } - } - } - val portWithLabel = PortWithLabelAndType(context, node, port, fbType.declaration, typeDeclaration.typeReference.presentation, items) - portWithLabel.label.style.set(StyleAttributes.HORIZONTAL_ALIGN, horizontalAlign) - portWithLabel.label.style.set(padding, Padding(INNER_BORDER_PADDING.toDouble(), Measure.PIXELS)) - ports.add(portWithLabel) - block.addEditorCell(portWithLabel.cell) - } else { - val typeDeclaration = port.declaration as PlugDeclaration - val items = types.map { - object : CompletionItem { - override fun getMatchingText(pattern: String?): String = it.name - - override val descriptionText: String = "" - - override fun doSubstitute(editorContext: EditorContext?, pattern: String?): SNode? { - typeDeclaration.typeReference.setTarget(it) - return null - } + val typeDeclaration = port.declaration as SocketPluginDeclaration + val items = types.map { + object : CompletionItem { + override fun getMatchingText(pattern: String?): String = it.name + + override val descriptionText: String = "" + + override fun doSubstitute(editorContext: EditorContext?, pattern: String?): SNode? { + typeDeclaration.typeReference.setTarget(it) + return null } } - val portWithLabel = PortWithLabelAndType(context, node, port, fbType.declaration, typeDeclaration.typeReference.presentation, items) - portWithLabel.label.style.set(StyleAttributes.HORIZONTAL_ALIGN, horizontalAlign) - portWithLabel.label.style.set(padding, Padding(INNER_BORDER_PADDING.toDouble(), Measure.PIXELS)) - ports.add(portWithLabel) - block.addEditorCell(portWithLabel.cell) } + val portWithLabel = PortWithLabelAndType(context, node, port, fbType.declaration, typeDeclaration.typeReference.presentation, items) + portWithLabel.label.style.set(StyleAttributes.HORIZONTAL_ALIGN, horizontalAlign) + portWithLabel.label.style.set(padding, Padding(INNER_BORDER_PADDING.toDouble(), Measure.PIXELS)) + ports.add(portWithLabel) + block.addEditorCell(portWithLabel.cell) } return block @@ -401,9 +372,6 @@ class FBTypeEditCellComponent( g.draw(shape) } - override val eventPortsCount: Int - get() = super.eventPortsCount + 3 - private fun getPortBounds(port: Port, isOutput: Boolean = false): Rectangle { val editablePort = port as PortWithEditableLabel @@ -429,7 +397,6 @@ class FBTypeEditCellComponent( private fun calculateWidth(): Int { val typeNameRowWidth = typeNameLabel.width - val buttonWidth = eventButtonContiner.width val inputsWidth = portsColumnWidth(inputPorts) val outputsWidth = portsColumnWidth(outputPorts) @@ -438,19 +405,7 @@ class FBTypeEditCellComponent( } private fun createNameLabel(): EditorCell_Property { - val typeDeclaration = fbType.declaration - - val result = EditorCell_Property(context, object : ModelAccessor { - override fun getText(): String? = typeDeclaration?.name - - override fun setText(text: String) { - typeDeclaration?.name = text - } - - override fun isValidText(text: String): Boolean { - return true - } - }, node) + val result = EditorCell_Property(context, DeclarationNameAccessor(fbType.declaration) { !it.isNullOrEmpty() }, node) result.style.set(StyleAttributes.HORIZONTAL_ALIGN, CellAlign.CENTER) result.style.set(StyleAttributes.FONT_SIZE, fontSize) @@ -467,36 +422,37 @@ class FBTypeEditCellComponent( dataPortsContainer.width = width otherPortsContainer.width = width addCentralGap(width) - eventButtonContiner.height = eventButtonContiner.cells[0].height + lineSize / 2 - dataButtonContiner.height = dataButtonContiner.cells[0].height + lineSize / 2 - otherButtonContainer.height = otherButtonContainer.cells[0].height + lineSize / 2 - eventButtonContiner.width = width - dataButtonContiner.width = width - otherButtonContainer.width = width + + buttons.values.forEach { + addGapForButtons(width, it) + it.height = it.cells.first().height + lineSize / 2 + it.width = width + } } private fun addCentralGap(width: Int) { addCentralGap(width, outputEventPorts, eventPortsContainer) addCentralGap(width, outputDataPorts, dataPortsContainer) addCentralGap(width, plugPorts, otherPortsContainer) - addGapForButtons(width, eventButtonContiner) - addGapForButtons(width, dataButtonContiner) - addGapForButtons(width, otherButtonContainer) } private fun addCentralGap(width: Int, ports: List, container: EditorCell_Collection) { + val right = container.cells.last() val gap = (width - portsColumnWidth(ports) - INNER_BORDER_PADDING) - container.cells[1].moveTo(gap, container.cells[1].y) + right.moveTo(gap, right.y) } private fun addGapForButtons(width: Int, cell: EditorCell_Collection) { - cell.cells[1].moveTo(width - 15, cell.cells[1].y + cell.height - cell.cells[1].height) - cell.cells[0].moveTo(0, cell.cells[0].y + cell.height - cell.cells[0].height) + val left = cell.cells.first() + val right = cell.cells.last() + right.moveTo(width - 15, right.y + cell.height - right.height) + left.moveTo(0, left.y + cell.height - left.height) } companion object { private const val CENTER_PADDING = 20 private const val INNER_BORDER_PADDING = 2 + private const val PLUS_BUTTON_SIZE = 15 private fun portsColumnWidth(ports: Collection): Int { return ports.maxOfOrNull { if (it is PortWithLabelAndType) it.cell.width else (it as PortWithEditableLabel).label.width } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt index 198af04d0..47ebeaf8e 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt @@ -1,14 +1,19 @@ package org.fbme.ide.richediting.adapters.fbnetwork.port +import jetbrains.mps.openapi.editor.cells.CellAction import org.fbme.lib.common.Identifier import org.fbme.lib.common.StringIdentifier import org.fbme.lib.iec61499.IEC61499Factory import org.fbme.lib.iec61499.declarations.* -import org.fbme.scenes.cells.action.port.AddPortAction +import org.fbme.ide.richediting.adapters.fbnetwork.actions.cell.port.AddPortAction +import org.fbme.ide.richediting.adapters.fbnetwork.actions.cell.port.DeletePortAction +import org.fbme.lib.common.Declaration +import org.fbme.lib.iec61499.descriptors.FBPortDescriptor +import org.fbme.lib.iec61499.fbnetwork.EntryKind import java.util.function.Supplier object PortActionFactory { - fun getInputEventAction( + fun createInputEventAction( declaration: FBInterfaceDeclaration, iec61499Factory: IEC61499Factory, identifierFactory: Supplier = IDENTIFIER_FACTORY("Ievent", declaration.inputEvents.map { it.name }), @@ -20,7 +25,7 @@ object PortActionFactory { ) } - fun getOutputEventAction( + fun createOutputEventAction( declaration: FBInterfaceDeclaration, iec61499Factory: IEC61499Factory, identifierFactory: Supplier = IDENTIFIER_FACTORY("Oevent", declaration.outputEvents.map { it.name }), @@ -32,7 +37,7 @@ object PortActionFactory { ) } - fun getInputParameterAction( + fun createInputParameterAction( declaration: FBInterfaceDeclaration, iec61499Factory: IEC61499Factory, identifierFactory: Supplier = IDENTIFIER_FACTORY("Idata", declaration.inputParameters.map { it.name }), @@ -44,7 +49,7 @@ object PortActionFactory { ) } - fun getOutputParameterAction( + fun createOutputParameterAction( declaration: FBInterfaceDeclaration, iec61499Factory: IEC61499Factory, identifierFactory: Supplier = IDENTIFIER_FACTORY("Odata", declaration.outputParameters.map { it.name }), @@ -56,7 +61,7 @@ object PortActionFactory { ) } - fun getSocketAction( + fun createSocketAction( declaration: FBInterfaceDeclarationWithAdapters, iec61499Factory: IEC61499Factory, identifierFactory: Supplier = IDENTIFIER_FACTORY("Socket", declaration.sockets.map { it.name }), @@ -68,7 +73,7 @@ object PortActionFactory { ) } - fun getPluginAction( + fun createPluginAction( declaration: FBInterfaceDeclarationWithAdapters, iec61499Factory: IEC61499Factory, identifierFactory: Supplier = IDENTIFIER_FACTORY("Plugin", declaration.plugs.map { it.name }), @@ -80,6 +85,32 @@ object PortActionFactory { ) } + fun deletePortAction(port: FBPortDescriptor, fbTypeDeclaration: Declaration?) : CellAction? { + fbTypeDeclaration ?: return null + + if (fbTypeDeclaration !is FBInterfaceDeclaration) { + return null + } + + val ports: MutableList = when (port.connectionKind) { + EntryKind.EVENT -> if (port.isInput) fbTypeDeclaration.inputEvents else fbTypeDeclaration.outputEvents + EntryKind.DATA -> if (port.isInput) fbTypeDeclaration.inputParameters else fbTypeDeclaration.outputParameters + EntryKind.ADAPTER -> { + if (fbTypeDeclaration !is FBInterfaceDeclarationWithAdapters) { + return null + } + + if (port.isInput) { + fbTypeDeclaration.sockets + } else { + fbTypeDeclaration.plugs + } + } + } + + return DeletePortAction(port, ports) + } + val IDENTIFIER_FACTORY: (prefix: String, values: List) -> Supplier = { prefix, names -> var index: Int? = null diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortBase.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortBase.kt index 7529a5ae9..bf74b601f 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortBase.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortBase.kt @@ -3,6 +3,7 @@ package org.fbme.ide.richediting.adapters.fbnetwork.port import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.fbnetwork.EntryKind -open class PortBase(port: FBPortDescriptor) : Port { - override val connectionKind: EntryKind = port.connectionKind +open class PortBase(val port: FBPortDescriptor) : Port { + override val connectionKind: EntryKind + get() = port.connectionKind } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt index 2e4d1f1e0..769de6097 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt @@ -1,72 +1,25 @@ package org.fbme.ide.richediting.adapters.fbnetwork.port import jetbrains.mps.nodeEditor.cells.EditorCell_Property -import jetbrains.mps.nodeEditor.cells.ModelAccessor import jetbrains.mps.openapi.editor.EditorContext -import jetbrains.mps.openapi.editor.cells.CellAction import jetbrains.mps.openapi.editor.cells.CellActionType +import org.fbme.ide.richediting.adapters.fbnetwork.actions.cell.DeclarationNameAccessor import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.lib.common.Declaration -import org.fbme.lib.common.StringIdentifier -import org.fbme.lib.iec61499.declarations.FBInterfaceDeclaration -import org.fbme.lib.iec61499.declarations.FBInterfaceDeclarationWithAdapters import org.fbme.lib.iec61499.descriptors.FBPortDescriptor -import org.fbme.lib.iec61499.fbnetwork.EntryKind import org.jetbrains.mps.openapi.model.SNode -open class PortWithEditableLabel(context: EditorContext, node: SNode, val port: FBPortDescriptor, declaration: Declaration?) : PortBase(port) { +open class PortWithEditableLabel( + context: EditorContext, + node: SNode, + port: FBPortDescriptor, + declaration: Declaration?, +) : PortBase(port) { val label: EditorCell_Property init { - label = EditorCell_Property(context, - object : ModelAccessor { - override fun getText(): String { - port.declaration - return port.declaration?.name ?: "" - } - - override fun setText(text: String) { - port.declaration?.name = text - } - - override fun isValidText(text: String): Boolean { - return true - } - }, node) - - label.setAction(CellActionType.BACKSPACE, object : CellAction { - override fun getDescriptionText(): String { - return "Delete port" - } - - override fun executeInCommand(): Boolean { - return true - } - - override fun canExecute(context: EditorContext): Boolean { - return port.declaration?.name?.isEmpty() ?: true - } - - override fun execute(p0: EditorContext?) { - if (declaration is FBInterfaceDeclaration) { - val ports = if (port.isInput) { - when (port.connectionKind) { - EntryKind.EVENT -> declaration.inputEvents - EntryKind.DATA -> declaration.inputParameters - else -> if (declaration is FBInterfaceDeclarationWithAdapters) declaration.sockets else mutableListOf() - } - } else { - when (port.connectionKind) { - EntryKind.EVENT -> declaration.outputEvents - EntryKind.DATA -> declaration.outputParameters - else -> if (declaration is FBInterfaceDeclarationWithAdapters) declaration.plugs else mutableListOf() - } - } - - ports.remove(port.declaration) - } - } - }) + label = EditorCell_Property(context, DeclarationNameAccessor(port.declaration) { true }, node) + label.setAction(CellActionType.BACKSPACE, PortActionFactory.deletePortAction(port, declaration)) label.style.set(RichEditorStyleAttributes.PORT, port) } } \ No newline at end of file diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithLabelAndType.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithLabelAndType.kt index 8458305b6..d203559d1 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithLabelAndType.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithLabelAndType.kt @@ -12,7 +12,8 @@ import org.fbme.ide.richediting.adapters.fbnetwork.suggestion.CustomSubstituteIn import org.fbme.lib.common.Declaration import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.scenes.cells.EditorCell_SceneLabel -import org.fbme.scenes.cells.action.ShowSubstituteChooserAction +import org.fbme.ide.richediting.adapters.fbnetwork.actions.cell.ShowSubstituteChooserAction +import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.scenes.viewmodel.CompletionItem import org.jetbrains.mps.openapi.model.SNode @@ -20,7 +21,7 @@ class PortWithLabelAndType( context: EditorContext, node: SNode, port: FBPortDescriptor, - declaration: Declaration?, + val declaration: Declaration?, typeName: String?, items: List, ) : PortWithEditableLabel(context, node, port, declaration) { @@ -49,6 +50,7 @@ class PortWithLabelAndType( //Add showing suggestion typeLabel.setAction(CellActionType.CLICK, ShowSubstituteChooserAction(typeLabel)) typeLabel.substituteInfo = CustomSubstituteInfo(context, typeLabel, items) + typeLabel.style.set(RichEditorStyleAttributes.PORT, port) return typeLabel } diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt index 66ed633ea..36e002663 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt @@ -219,16 +219,6 @@ class ComponentsFacility( } } - private inner class MyCursorListener() : CursorListener { - override fun onCursorMoved(event: CursorEvent) { - val component = layout.findAt(event.awt.x, event.awt.y) - - if (component != null) { - - } - } - } - companion object { private val SELECTION_KEY = SceneStateKey?>("comp-selection") } @@ -244,7 +234,6 @@ class ComponentsFacility( editor.addCellProvider(componentsLayer, MyCellProvider()) editor.addClickListener(componentsLayer, MyClickEventListener()) editor.addDragListener(componentsLayer, MyDragEventListener()) - editor.addCursorListener(MyCursorListener()) editor.addPainter(tracesLayer, MyPainter()) editor.addInitializer(MySelectionInitializer()) } From a13f1ac0d285cae740ac2f1749698b3d3a3ee735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Tue, 2 May 2023 20:09:37 +0200 Subject: [PATCH 10/66] Fix button styles in different colors --- .../fbnetwork/FunctionBlockController.kt | 90 ++++++------------- .../fbme/scenes/cells/EditorCell_Button.kt | 5 +- .../org/fbme/scenes/cells/button/Button.kt | 2 +- .../fbme/scenes/cells/button/CrossButton.kt | 25 ------ .../fbme/scenes/cells/button/EditButton.kt | 19 ++-- .../fbme/scenes/cells/button/MinusButton.kt | 6 +- .../fbme/scenes/cells/button/PlusButton.kt | 4 +- .../fbme/scenes/cells/button/SquareButton.kt | 12 +-- .../fbme/scenes/cells/button/TickButton.kt | 30 +++++++ 9 files changed, 87 insertions(+), 106 deletions(-) delete mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/CrossButton.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/TickButton.kt diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt index 2f2047783..4805b96a5 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt @@ -27,8 +27,7 @@ import org.fbme.lib.iec61499.fbnetwork.EntryKind import org.fbme.lib.iec61499.instances.FunctionBlockInstance import org.fbme.lib.iec61499.instances.NetworkInstance import org.fbme.scenes.cells.EditorCell_Button -import org.fbme.scenes.cells.EditorCell_Scene -import org.fbme.scenes.cells.button.CrossButton +import org.fbme.scenes.cells.button.TickButton import org.fbme.scenes.cells.button.EditButton import org.fbme.scenes.controllers.LayoutUtil.getLineSize import org.fbme.scenes.controllers.components.ComponentController @@ -43,7 +42,7 @@ class FunctionBlockController( val expandedComponentsController: ExpandedComponentsController, val editedController: EditedComponentsController, iec61499Factory: IEC61499Factory, - scope: DeclarationsScope + scope: DeclarationsScope, ) : ComponentController, FBNetworkComponentController { private val myNameProperty: EditorCell_Property private val editButton: EditorCell_Button @@ -57,56 +56,40 @@ class FunctionBlockController( } private fun getNameProperty(context: EditorContext, view: FunctionBlockView, node: SNode): EditorCell_Property { - return EditorCell_Property( - context, - object : ModelAccessor { - override fun getText(): String? { - val name = view.component.name - return if (name == "") null else name - } - - override fun setText(text: String) { - view.component.name = text - } - - override fun isValidText(text: String): Boolean { - return true - } - }, - node - ) + return EditorCell_Property(context, object : ModelAccessor { + override fun getText(): String? { + val name = view.component.name + return if (name == "") null else name + } + + override fun setText(text: String) { + view.component.name = text + } + + override fun isValidText(text: String): Boolean { + return true + } + }, node) } private fun createRootCell(context: EditorContext, node: SNode): EditorCell_Collection { - return EditorCell_Collection( - context, - node, - CellLayout_Vertical() - ) + return EditorCell_Collection(context, node, CellLayout_Vertical()) } private fun initializeFBSceneCell(editorShift: Point = Point()): FBCell { - return FBSceneCell( - cellCollection.context, - view.type, - view.associatedNode, - false, - networkInstance.getChild(view.component)!!, - editorShift - ) + return FBSceneCell(cellCollection.context, view.type, view.associatedNode, false, networkInstance.getChild(view.component)!!, editorShift) } private fun initializeFBCell(): FBCell { return FBTypeCellComponent(cellCollection.context, view.type, view.associatedNode, isEditable) } - private fun initializeFBEditCell(iec61499Factory: IEC61499Factory, scope: DeclarationsScope,): FBCell { + private fun initializeFBEditCell(iec61499Factory: IEC61499Factory, scope: DeclarationsScope): FBCell { return FBTypeEditCellComponent(cellCollection.context, view.type, view.associatedNode, iec61499Factory, scope, isEditable) } private fun getEditButton(context: EditorContext, node: SNode): EditorCell_Button { - - return EditorCell_Button(context, node, if (!editedController.isEdited(view)) EditButton(18) else CrossButton(18)) + return EditorCell_Button(context, node, if (!editedController.isEdited(view)) EditButton(18) else TickButton(18)) } val fbInstance: FunctionBlockInstance? @@ -129,13 +112,9 @@ class FunctionBlockController( val kind = functionBlockPort.kind val isSource = functionBlockPort.isSource val coordinates: Point = when (kind) { - EntryKind.EVENT -> if (isSource) fbCell.getOutputEventPortPosition(index) else fbCell.getInputEventPortPosition( - index - ) + EntryKind.EVENT -> if (isSource) fbCell.getOutputEventPortPosition(index) else fbCell.getInputEventPortPosition(index) - EntryKind.DATA -> if (isSource) fbCell.getOutputDataPortPosition(index) else fbCell.getInputDataPortPosition( - index - ) + EntryKind.DATA -> if (isSource) fbCell.getOutputDataPortPosition(index) else fbCell.getInputDataPortPosition(index) EntryKind.ADAPTER -> if (isSource) fbCell.getPlugPortPosition(index) else fbCell.getSocketPortPosition(index) else -> error("") @@ -150,13 +129,9 @@ class FunctionBlockController( val kind = functionBlockPort.kind val isSource = functionBlockPort.isSource val bounds: Rectangle = when (kind) { - EntryKind.EVENT -> if (isSource) fbCell.getOutputEventPortBounds(index) else fbCell.getInputEventPortBounds( - index - ) + EntryKind.EVENT -> if (isSource) fbCell.getOutputEventPortBounds(index) else fbCell.getInputEventPortBounds(index) - EntryKind.DATA -> if (isSource) fbCell.getOutputDataPortBounds(index) else fbCell.getInputDataPortBounds( - index - ) + EntryKind.DATA -> if (isSource) fbCell.getOutputDataPortBounds(index) else fbCell.getInputDataPortBounds(index) EntryKind.ADAPTER -> if (isSource) fbCell.getPlugPortBounds(index) else fbCell.getSocketPortBounds(index) else -> error("Unknown port kind") @@ -196,11 +171,7 @@ class FunctionBlockController( } override fun paintTrace(g: Graphics?, form: Point) { - fbCell.paintTrace( - g!!.create() as Graphics2D, - form.x, - form.y + if (fbCell is FBTypeCellComponent) getVerticalOffset() else 0 - ) + fbCell.paintTrace(g!!.create() as Graphics2D, form.x, form.y + if (fbCell is FBTypeCellComponent) getVerticalOffset() else 0) } private val lineSize: Int @@ -211,18 +182,13 @@ class FunctionBlockController( cellCollection = createRootCell(context, node) cellCollection.style.set(RichEditorStyleAttributes.FB, view.component) cellCollection.isBig = true - this.networkInstance = networkInstance - //edit button + this.networkInstance = networkInstance //edit button editButton = getEditButton(context, node) editButton.style.set(StyleAttributes.HORIZONTAL_ALIGN, CellAlign.RIGHT) editButton.setAction(CellActionType.CLICK, toEditModeAction()) - editButton.style.set( - StyleAttributes.PADDING_BOTTOM, - Padding(EditorCell_Button.OY_OFFSET.toDouble(), Measure.PIXELS) - ) + editButton.style.set(StyleAttributes.PADDING_BOTTOM, Padding(EditorCell_Button.OY_OFFSET.toDouble(), Measure.PIXELS)) editButton.style.set(StyleAttributes.TRANSPARENT, true) - cellCollection.addEditorCell(editButton) - //name property + cellCollection.addEditorCell(editButton) //name property myNameProperty = getNameProperty(context, view, node) myNameProperty.style.set(StyleAttributes.TEXT_COLOR, if (isEditable) MPSColors.BLACK else MPSColors.DARK_GRAY) myNameProperty.style.set(StyleAttributes.HORIZONTAL_ALIGN, CellAlign.CENTER) diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt index 3c6674bf1..1f4a3ad17 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt @@ -1,5 +1,6 @@ package org.fbme.scenes.cells +import com.intellij.util.ui.StartupUiUtil import jetbrains.mps.nodeEditor.cells.* import jetbrains.mps.openapi.editor.EditorContext import org.fbme.scenes.cells.button.Button @@ -13,8 +14,10 @@ class EditorCell_Button( node: SNode?, private val button: Button ): EditorCell_Basic(context, node) { + val isDark = StartupUiUtil.isUnderDarcula() + override fun paintContent(g: Graphics, p1: ParentSettings) { - button.paint(g.create() as Graphics2D, myX, myY) + button.paint(g.create() as Graphics2D, myX, myY, isDark) } override fun paintSelection(g: Graphics?, c: Color?, drawBorder: Boolean, parentSettings: ParentSettings?) { diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/Button.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/Button.kt index 67d5dbb74..45504f3cb 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/Button.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/Button.kt @@ -5,5 +5,5 @@ import java.awt.Graphics2D interface Button { val height: Int val width: Int - fun paint(g: Graphics2D, x: Int, y: Int) + fun paint(g: Graphics2D, x: Int, y: Int, isDark: Boolean) } \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/CrossButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/CrossButton.kt deleted file mode 100644 index bba7acafd..000000000 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/CrossButton.kt +++ /dev/null @@ -1,25 +0,0 @@ -package org.fbme.scenes.cells.button - -import com.intellij.ui.JBColor -import java.awt.Color -import java.awt.Graphics2D -import java.awt.geom.RoundRectangle2D - -class CrossButton(private val size: Int): Button { - override val height: Int - get() = size - override val width: Int - get() = size - - override fun paint(g: Graphics2D, x: Int, y: Int) { - g.color = JBColor.WHITE - g.fill(RoundRectangle2D.Double(x.toDouble(), y.toDouble(), size.toDouble(), size.toDouble(), (size / 4).toDouble(), (size / 4).toDouble())) - drawCross(g, x + 3, y + 3, size - 6) - } - - private fun drawCross(g: Graphics2D, x: Int, y: Int, size: Int) { - g.color = Color.WHITE - g.drawLine(x, y, x + size, y + size) - g.drawLine(x, y + size, x + size, y) - } -} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/EditButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/EditButton.kt index 287c21034..5ebb0b689 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/EditButton.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/EditButton.kt @@ -1,6 +1,5 @@ package org.fbme.scenes.cells.button -import com.intellij.ui.JBColor import java.awt.Color import java.awt.Graphics2D import java.awt.geom.RoundRectangle2D @@ -11,14 +10,15 @@ class EditButton(private val size: Int): Button { override val width: Int get() = size - override fun paint(g: Graphics2D, x: Int, y: Int) { - g.color = JBColor.WHITE - g.fill(RoundRectangle2D.Double(x.toDouble(), y.toDouble(), size.toDouble(), size.toDouble(), (size / 4).toDouble(), (size / 4).toDouble())) - paintPen(g, x + 3, y + 3, size - 6) + override fun paint(g: Graphics2D, x: Int, y: Int, isDark: Boolean) { + val color = if (isDark) ON_DARK_COLOR else ON_LIGHT_COLOR + g.color = color + g.draw(RoundRectangle2D.Double(x.toDouble(), y.toDouble(), size.toDouble(), size.toDouble(), (size / 4).toDouble(), (size / 4).toDouble())) + paintPen(g, x + 3, y + 3, size - 6, color) } - private fun paintPen(g: Graphics2D, x: Int, y: Int, size: Int) { - g.color = Color.WHITE + private fun paintPen(g: Graphics2D, x: Int, y: Int, size: Int, color: Color) { + g.color = color g.drawLine(x, y + size, x + 2 * size / 5, y + size) //- g.drawLine(x, y + size, x, y + 3 * size / 5) // | g.drawLine(x, y + 3 * size / 5, x + 2 * size / 5, y + size)// |_\ @@ -26,4 +26,9 @@ class EditButton(private val size: Int): Button { g.drawLine(x, y + 3 * size / 5, x + 4 * size / 5, y) // // g.drawLine(x + size, y + size / 5, x + 4 * size / 5, y) } + + companion object { + val ON_DARK_COLOR = Color.WHITE + val ON_LIGHT_COLOR = Color.BLACK + } } \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MinusButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MinusButton.kt index a808d1545..5454e5ea8 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MinusButton.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MinusButton.kt @@ -1,11 +1,11 @@ package org.fbme.scenes.cells.button -import com.intellij.ui.JBColor +import java.awt.Color import java.awt.Graphics2D class MinusButton(size: Int): SquareButton(size) { - override fun paintInside(g: Graphics2D, x: Int, y: Int) { - g.color = JBColor.BLACK + override fun paintInside(g: Graphics2D, x: Int, y: Int, color: Color) { + g.color = color g.drawLine(x + INNER_PADDING, y + height / 2, x + width - INNER_PADDING, y + height / 2) } } \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/PlusButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/PlusButton.kt index 25693aa32..958fa80d5 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/PlusButton.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/PlusButton.kt @@ -4,8 +4,8 @@ import java.awt.Color import java.awt.Graphics2D class PlusButton(size: Int): SquareButton(size) { - override fun paintInside(g: Graphics2D, x: Int, y: Int) { - g.color = Color.BLACK + override fun paintInside(g: Graphics2D, x: Int, y: Int, color: Color) { + g.color = color g.drawLine(x + width / 2, y + INNER_PADDING, x + width / 2, y + height - INNER_PADDING) g.drawLine(x + INNER_PADDING, y + height / 2, x + width - INNER_PADDING, y + height / 2) } diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/SquareButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/SquareButton.kt index 4a425b9b4..5b542e1e8 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/SquareButton.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/SquareButton.kt @@ -1,7 +1,7 @@ package org.fbme.scenes.cells.button import com.intellij.openapi.rd.fill2DRect -import com.intellij.ui.JBColor +import jetbrains.mps.nodeEditor.MPSColors import java.awt.Color import java.awt.Graphics2D import java.awt.Rectangle @@ -12,14 +12,16 @@ abstract class SquareButton(private val size: Int) : Button { override val width: Int get() = size - override fun paint(g: Graphics2D, x: Int, y: Int) { - g.fill2DRect(Rectangle(x, y, size, size), Color.WHITE) - paintInside(g, x, y) + override fun paint(g: Graphics2D, x: Int, y: Int, isDark: Boolean) { + g.fill2DRect(Rectangle(x, y, size, size), if (isDark) ON_DARK_COLOR else ON_LIGHT_COLOR) + paintInside(g, x, y, if (!isDark) ON_DARK_COLOR else ON_LIGHT_COLOR) } - protected abstract fun paintInside(g: Graphics2D, x: Int, y: Int) + protected abstract fun paintInside(g: Graphics2D, x: Int, y: Int, color: Color) companion object { const val INNER_PADDING: Int = 2 + val ON_DARK_COLOR = Color.WHITE + val ON_LIGHT_COLOR = Color.BLACK } } \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/TickButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/TickButton.kt new file mode 100644 index 000000000..ec64fc5c8 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/TickButton.kt @@ -0,0 +1,30 @@ +package org.fbme.scenes.cells.button + +import java.awt.Color +import java.awt.Graphics2D +import java.awt.geom.RoundRectangle2D + +class TickButton(private val size: Int): Button { + override val height: Int + get() = size + override val width: Int + get() = size + + override fun paint(g: Graphics2D, x: Int, y: Int, isDark: Boolean) { + val color = if (isDark) ON_DARK_COLOR else ON_LIGHT_COLOR + g.color = color + g.draw(RoundRectangle2D.Double(x.toDouble(), y.toDouble(), size.toDouble(), size.toDouble(), (size / 4).toDouble(), (size / 4).toDouble())) + drawCross(g, x + 3, y + 3, size - 6, color) + } + + private fun drawCross(g: Graphics2D, x: Int, y: Int, size: Int, color: Color) { + g.color = color + g.drawLine(x, y + 2 * size / 3, x + size / 3, y + size) + g.drawLine(x + size / 3, y + size, x + size, y) + } + + companion object { + val ON_DARK_COLOR = Color.WHITE + val ON_LIGHT_COLOR = Color.BLACK + } +} \ No newline at end of file From 6f56bf2d1df884b849933e827ba755c98db76770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Tue, 2 May 2023 21:19:07 +0200 Subject: [PATCH 11/66] Fix dragging problem --- .../scenes/controllers/components/ComponentsFacility.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt index 36e002663..759ce6546 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt @@ -202,6 +202,8 @@ class ComponentsFacility( override fun dragTo(x: Int, y: Int) { val dx = x - myOrigin.x val dy = y - myOrigin.y + + if (!(dx * dx > 25 || dy * dy > 25)) return myHandle.moveTo(dx, dy) editor.fireRelayout() for (component in myMovedComponents) { @@ -210,6 +212,11 @@ class ComponentsFacility( } override fun completeAt(x: Int, y: Int) { + val dx = x - myOrigin.x + val dy = y - myOrigin.y + + if (!(dx * dx > 25 || dy * dy > 25)) return + myHandle.moveTo(x - myOrigin.x, y - myOrigin.y) myHandle.complete() editor.fireRelayout() From f990193983cd9bf957aa82025fb829640a37334c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Fri, 5 May 2023 09:38:39 +0200 Subject: [PATCH 12/66] Add creating new port on connection --- .../adapters/ecc/ECCViewAdapter.kt | 4 + .../adapters/ecc/ECPortSettingProvider.kt | 2 +- .../fbnetwork/FBNetworkComponentController.kt | 16 +++ .../fbnetwork/FBPortSettingProvider.kt | 29 +++- .../fbnetwork/FunctionBlockController.kt | 94 +++++++++++- .../fbnetwork/fb/FBTypeEditCellComponent.kt | 134 +++++++++++++----- .../FunctionBlockPortTemplateView.kt | 12 ++ .../ide/richediting/viewmodel/NetworkView.kt | 12 ++ .../diagram/ConnectionsFacility.kt | 44 +++++- .../controllers/diagram/DiagramController.kt | 3 + .../controllers/diagram/DiagramFacility.kt | 69 ++++----- .../scenes/controllers/diagram/DiagramView.kt | 3 + .../diagram/PortSettingProvider.kt | 19 ++- .../controllers/diagram/TemplateController.kt | 7 + .../diagram/{ => entry}/ConnectionEntry.kt | 8 +- .../controllers/diagram/entry/PortEntry.kt | 36 +++++ .../diagram/entry/PortTemplateEntry.kt | 39 +++++ 17 files changed, 447 insertions(+), 84 deletions(-) create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockPortTemplateView.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/TemplateController.kt rename code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/{ => entry}/ConnectionEntry.kt (91%) create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortEntry.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortTemplateEntry.kt diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/ecc/ECCViewAdapter.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/ecc/ECCViewAdapter.kt index b5c91a073..9f8f4a648 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/ecc/ECCViewAdapter.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/ecc/ECCViewAdapter.kt @@ -20,6 +20,10 @@ class ECCViewAdapter( return HashSet(ecc.transitions) } + override fun portsTemplates(component: StateDeclaration): Set { + return emptySet() + } + override fun addEdge(sourcePort: StateDeclaration, targetPort: StateDeclaration): StateTransition { val transition = factory.createStateTransition() transition.sourceReference.setTarget(sourcePort) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/ecc/ECPortSettingProvider.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/ecc/ECPortSettingProvider.kt index 7f1e19511..b34e5334b 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/ecc/ECPortSettingProvider.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/ecc/ECPortSettingProvider.kt @@ -8,7 +8,7 @@ import java.awt.Rectangle import java.util.function.Function class ECPortSettingProvider(private val mapper: Function) : - PortSettingProvider { + PortSettingProvider { override fun getBounds(componentForm: Point, port: StateDeclaration): Rectangle { val controller = mapper.apply(port) val bounds = Rectangle(controller.getBounds(componentForm)) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkComponentController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkComponentController.kt index b3220c778..6b42a0335 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkComponentController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkComponentController.kt @@ -10,6 +10,10 @@ interface FBNetworkComponentController { return getBounds(position) } + fun getFBPortTemplates(): Set { + return emptySet() + } + fun getPortCoordinates(port: NetworkPortView, position: Point): Point fun getPortBounds(port: NetworkPortView, position: Point): Rectangle fun isSource(port: NetworkPortView): Boolean @@ -20,4 +24,16 @@ interface FBNetworkComponentController { fun canBeTargetedAt(port: NetworkPortView, position: Point): Boolean { return !isSource(port) } + + fun getTemplateBounds(template: NetworkPortView, modelForm: Point): Rectangle { + return Rectangle(0, 0) + } + + fun getTemplatePosition(template: NetworkPortView, modelForm: Point): Point { + return Point(0, 0) + } + + fun createPort(source: NetworkPortView, template: NetworkPortView): NetworkPortView? { + return null + } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBPortSettingProvider.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBPortSettingProvider.kt index bdf99501e..d9d3c9ac9 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBPortSettingProvider.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBPortSettingProvider.kt @@ -8,8 +8,9 @@ import java.awt.Point import java.awt.Rectangle import java.util.function.Function -class FBPortSettingProvider(private val myMapper: Function) : - PortSettingProvider { +class FBPortSettingProvider( + private val myMapper: Function +) : PortSettingProvider { override fun getBounds(componentForm: Point, port: NetworkPortView): Rectangle { val component = port.component val controller = myMapper.apply(component) @@ -22,6 +23,10 @@ class FBPortSettingProvider(private val myMapper: Function { + return myMapper.apply(componentForm).getFBPortTemplates() + } + override fun canBeSourcedAt(componentForm: Point, port: NetworkPortView, x: Int, y: Int): Boolean { val component = port.component val controller = myMapper.apply(component) @@ -39,4 +44,24 @@ class FBPortSettingProvider(private val myMapper: Function, FBNetworkComponentController { private val myNameProperty: EditorCell_Property @@ -145,6 +148,87 @@ class FunctionBlockController( return functionBlockPort.isSource } + override fun getTemplateBounds(template: NetworkPortView, modelForm: Point): Rectangle { + if (!editedController.isEdited(view)) { + return super.getTemplateBounds(template, modelForm) + } + + val buttons = (fbCell as FBTypeEditCellComponent).buttons[template.kind] + template as FunctionBlockPortView + val button = (if (template.isSource) buttons?.cells?.last() else buttons?.cells?.first()) + val bounds = Rectangle(button?.x ?: 0, button?.y ?: 0, button?.width ?: 0, (button?.height ?: 0)) + //bounds.translate(modelForm.x, modelForm.y + getVerticalOffset()) + return bounds + } + + override fun getTemplatePosition(template: NetworkPortView, modelForm: Point): Point { + if (!editedController.isEdited(view)) { + return super.getTemplatePosition(template, modelForm) + } + + val buttons = (fbCell as FBTypeEditCellComponent).buttons[template.kind] + template as FunctionBlockPortView + val button = (if (template.isSource) buttons?.cells?.last() else buttons?.cells?.first()) + val bounds = Rectangle(button?.width ?: 0, (button?.height ?: 0) + getVerticalOffset()) + val x = bounds.x + if (template.isSource) bounds.width else 0 + val y = bounds.y + bounds.height / 2 + val point = Point(x, y) + point.translate(modelForm.x, modelForm.y + getVerticalOffset()) + return point + } + + override fun createPort(source: NetworkPortView, template: NetworkPortView): NetworkPortView? { + require(!(template !is FunctionBlockPortView || source !is FunctionBlockPortView)) { "invalid port" } + + if (template.isSource == source.isSource) return null + + val declaration = view.type.declaration + + if (declaration !is FBInterfaceDeclaration) return null + + when(template.kind) { + EntryKind.EVENT -> { + val list = if (template.isSource) declaration.outputEvents else declaration.inputEvents + val identifier = PortActionFactory.IDENTIFIER_FACTORY("E", list.map { it.name }).get() + val nEvent = iec61499Factory.createEventDeclaration(identifier) + list.add(nEvent) + (fbCell as FBTypeEditCellComponent).addPort(if (template.isSource) view.type.eventOutputPorts.last() else view.type.eventInputPorts.last()) + return FunctionBlockPortView(template.component, list.size - 1, EntryKind.EVENT, template.isSource, nEvent) + } + EntryKind.DATA -> { + val list = if (template.isSource) declaration.outputParameters else declaration.inputParameters + val identifier = PortActionFactory.IDENTIFIER_FACTORY("P", list.map { it.name }).get() + val nParameter = iec61499Factory.createParameterDeclaration(identifier) + nParameter.type = (source.target as ParameterDeclaration).type + list.add(nParameter) + (fbCell as FBTypeEditCellComponent).addPort(if (template.isSource) view.type.dataOutputPorts.last() else view.type.dataInputPorts.last()) + return FunctionBlockPortView(template.component, list.size - 1, EntryKind.DATA, template.isSource, nParameter) + } + EntryKind.ADAPTER -> { + if (declaration !is FBInterfaceDeclarationWithAdapters) { + return null + } + if (template.isSource) { + val list = declaration.plugs + val identifier = PortActionFactory.IDENTIFIER_FACTORY("P", list.map { it.name }).get() + val nParameter = iec61499Factory.createPlugDeclaration(identifier) + val dec = source.target as PlugDeclaration + nParameter.typeReference.setTarget(dec.typeReference.getTarget()!!) + list.add(nParameter) + (fbCell as FBTypeEditCellComponent).addPort(if (template.isSource) view.type.plugPorts.last() else view.type.socketPorts.last()) + return FunctionBlockPortView(template.component, list.size - 1, EntryKind.ADAPTER, template.isSource, nParameter) + } + val list = declaration.sockets + val identifier = PortActionFactory.IDENTIFIER_FACTORY("S", list.map { it.name }).get() + val nParameter = iec61499Factory.createSocketDeclaration(identifier) + val dec = source.target as SocketDeclaration + nParameter.typeReference.setTarget(dec.typeReference.getTarget()!!) + list.add(nParameter) + return FunctionBlockPortView(template.component, list.size - 1, EntryKind.DATA, template.isSource, nParameter) + } + } + } + private fun assertMine(port: NetworkPortView): FunctionBlockPortView { require(!(port.component != view || port !is FunctionBlockPortView)) { "invalid port" } return port @@ -177,6 +261,14 @@ class FunctionBlockController( private val lineSize: Int get() = getLineSize(cellCollection.style) + override fun getFBPortTemplates(): Set { + if (!editedController.isEdited(view)) { + return super.getFBPortTemplates() + } + + return (fbCell as FBTypeEditCellComponent).getPortTemplates(view) + } + init { val node = view.associatedNode cellCollection = createRootCell(context, node) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt index 525a8672a..aa4060cc6 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt @@ -7,6 +7,7 @@ import jetbrains.mps.editor.runtime.style.StyleAttributes import jetbrains.mps.nodeEditor.MPSColors import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Horizontal import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Vertical +import jetbrains.mps.nodeEditor.cells.EditorCell_Basic import jetbrains.mps.nodeEditor.cells.EditorCell_Collection import jetbrains.mps.nodeEditor.cells.EditorCell_Property import jetbrains.mps.nodeEditor.cells.ParentSettings @@ -18,18 +19,15 @@ import jetbrains.mps.openapi.editor.style.StyleAttribute import org.fbme.ide.iec61499.repository.PlatformElement import org.fbme.ide.richediting.adapters.fbnetwork.FBConnectionPathPainter import org.fbme.ide.richediting.adapters.fbnetwork.actions.cell.DeclarationNameAccessor -import org.fbme.ide.richediting.adapters.fbnetwork.port.Port -import org.fbme.ide.richediting.adapters.fbnetwork.port.PortActionFactory -import org.fbme.ide.richediting.adapters.fbnetwork.port.PortWithEditableLabel -import org.fbme.ide.richediting.adapters.fbnetwork.port.PortWithLabelAndType +import org.fbme.ide.richediting.adapters.fbnetwork.port.* import org.fbme.ide.richediting.editor.NetworkInstanceNavigationSupport import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.ide.richediting.viewmodel.FunctionBlockPortView +import org.fbme.ide.richediting.viewmodel.FunctionBlockView +import org.fbme.ide.richediting.viewmodel.NetworkPortView import org.fbme.lib.iec61499.DeclarationsScope import org.fbme.lib.iec61499.IEC61499Factory -import org.fbme.lib.iec61499.declarations.FBInterfaceDeclaration -import org.fbme.lib.iec61499.declarations.FBInterfaceDeclarationWithAdapters -import org.fbme.lib.iec61499.declarations.ParameterDeclaration -import org.fbme.lib.iec61499.declarations.SocketPluginDeclaration +import org.fbme.lib.iec61499.declarations.* import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.descriptors.FBTypeDescriptor import org.fbme.lib.iec61499.fbnetwork.EntryKind @@ -57,7 +55,7 @@ class FBTypeEditCellComponent( private val typeNameLabel: EditorCell_Property override val rootCell: EditorCell_Collection - private val buttons: EnumMap + val buttons: EnumMap private val eventPortsContainer: EditorCell_Collection private val dataPortsContainer: EditorCell_Collection private val otherPortsContainer: EditorCell_Collection @@ -177,6 +175,40 @@ class FBTypeEditCellComponent( return block } + fun addPort(port: FBPortDescriptor) { + when (port.connectionKind) { + EntryKind.EVENT -> { + val value = PortWithEditableLabel(context, node, port, fbType.declaration) + if (port.isInput) { + (eventPortsContainer.cells.first() as EditorCell_Collection).addEditorCell(value.label) + inputEventPorts.add(value) + } else { + (eventPortsContainer.cells.last() as EditorCell_Collection).addEditorCell(value.label) + outputEventPorts.add(value) + } + } + EntryKind.DATA -> { + val typeDeclaration = port.declaration as ParameterDeclaration + val value = PortWithLabelAndType(context, node, port, fbType.declaration, typeDeclaration.type?.stringify(), getDataTypeSuggestions(typeDeclaration)) + if (port.isInput) { + (dataPortsContainer.cells.first() as EditorCell_Collection).addEditorCell(value.cell) + inputDataPorts.add(value) + } else { + (dataPortsContainer.cells.last() as EditorCell_Collection).addEditorCell(value.cell) + outputDataPorts.add(value) + } + } + EntryKind.ADAPTER -> { + val types = scope.findAllAdapterTypeDeclarations() + if (port.isInput) { + addPlugSocketPort(port, socketPorts, otherPortsContainer.cells.first() as EditorCell_Collection, types, CellAlign.LEFT, StyleAttributes.PADDING_LEFT) + } else { + addPlugSocketPort(port, plugPorts, otherPortsContainer.cells.last() as EditorCell_Collection, types, CellAlign.RIGHT, StyleAttributes.PADDING_RIGHT) + } + } + } + } + private fun createDataPortBlock( portsDescriptors: List, ports: MutableList, @@ -187,19 +219,7 @@ class FBTypeEditCellComponent( for (port in portsDescriptors) { val typeDeclaration = port.declaration as ParameterDeclaration - val items = DataTypeUtil.getBasicTypes().map { - object : CompletionItem { - override fun getMatchingText(pattern: String?): String = it.stringify() - - override val descriptionText: String = "" - - override fun doSubstitute(editorContext: EditorContext?, pattern: String?): SNode? { - typeDeclaration.type = it - return null - } - } - } - val portWithLabel = PortWithLabelAndType(context, node, port, fbType.declaration, typeDeclaration.type?.stringify(), items) + val portWithLabel = PortWithLabelAndType(context, node, port, fbType.declaration, typeDeclaration.type?.stringify(), getDataTypeSuggestions(typeDeclaration)) portWithLabel.label.style.set(StyleAttributes.HORIZONTAL_ALIGN, horizontalAlign) portWithLabel.label.style.set(padding, Padding(INNER_BORDER_PADDING.toDouble(), Measure.PIXELS)) ports.add(portWithLabel) @@ -209,6 +229,21 @@ class FBTypeEditCellComponent( return block } + fun getDataTypeSuggestions(typeDeclaration: ParameterDeclaration): List { + return DataTypeUtil.getBasicTypes().map { + object : CompletionItem { + override fun getMatchingText(pattern: String?): String = it.stringify() + + override val descriptionText: String = "" + + override fun doSubstitute(editorContext: EditorContext?, pattern: String?): SNode? { + typeDeclaration.type = it + return null + } + } + } + } + private fun createPlugSocketPortBlock( portsDescriptors: List, ports: MutableList, @@ -219,27 +254,32 @@ class FBTypeEditCellComponent( val types = scope.findAllAdapterTypeDeclarations() for (port in portsDescriptors) { - val typeDeclaration = port.declaration as SocketPluginDeclaration - val items = types.map { - object : CompletionItem { - override fun getMatchingText(pattern: String?): String = it.name + addPlugSocketPort(port, ports, block, types, horizontalAlign, padding) + } + + return block + } + + fun addPlugSocketPort(port: FBPortDescriptor, ports: MutableList, block: EditorCell_Collection, types: List, horizontalAlign: CellAlign, + padding: StyleAttribute) { + val typeDeclaration = port.declaration as SocketPluginDeclaration + val items = types.map { + object : CompletionItem { + override fun getMatchingText(pattern: String?): String = it.name - override val descriptionText: String = "" + override val descriptionText: String = "" - override fun doSubstitute(editorContext: EditorContext?, pattern: String?): SNode? { - typeDeclaration.typeReference.setTarget(it) - return null - } + override fun doSubstitute(editorContext: EditorContext?, pattern: String?): SNode? { + typeDeclaration.typeReference.setTarget(it) + return null } } - val portWithLabel = PortWithLabelAndType(context, node, port, fbType.declaration, typeDeclaration.typeReference.presentation, items) - portWithLabel.label.style.set(StyleAttributes.HORIZONTAL_ALIGN, horizontalAlign) - portWithLabel.label.style.set(padding, Padding(INNER_BORDER_PADDING.toDouble(), Measure.PIXELS)) - ports.add(portWithLabel) - block.addEditorCell(portWithLabel.cell) } - - return block + val portWithLabel = PortWithLabelAndType(context, node, port, fbType.declaration, typeDeclaration.typeReference.presentation, items) + portWithLabel.label.style.set(StyleAttributes.HORIZONTAL_ALIGN, horizontalAlign) + portWithLabel.label.style.set(padding, Padding(INNER_BORDER_PADDING.toDouble(), Measure.PIXELS)) + ports.add(portWithLabel) + block.addEditorCell(portWithLabel.cell) } private fun createRootCell(): EditorCell_Collection { @@ -449,6 +489,24 @@ class FBTypeEditCellComponent( left.moveTo(0, left.y + cell.height - left.height) } + fun getPortTemplates(view: FunctionBlockView): Set { + val result = mutableSetOf() + + if (fbType.declaration is FBInterfaceDeclaration) { + result.add(FunctionBlockPortView(view, -1, EntryKind.EVENT, true, fbType.declaration!!)) + result.add(FunctionBlockPortView(view, -1, EntryKind.EVENT, false, fbType.declaration!!)) + result.add(FunctionBlockPortView(view, -1, EntryKind.DATA, true, fbType.declaration!!)) + result.add(FunctionBlockPortView(view, -1, EntryKind.DATA, false, fbType.declaration!!)) + } + + if (fbType.declaration is FBInterfaceDeclarationWithAdapters) { + result.add(FunctionBlockPortView(view, -1, EntryKind.ADAPTER, true, fbType.declaration!!)) + result.add(FunctionBlockPortView(view, -1, EntryKind.ADAPTER, false, fbType.declaration!!)) + } + + return result + } + companion object { private const val CENTER_PADDING = 20 private const val INNER_BORDER_PADDING = 2 diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockPortTemplateView.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockPortTemplateView.kt new file mode 100644 index 000000000..021cd54e2 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockPortTemplateView.kt @@ -0,0 +1,12 @@ +package org.fbme.ide.richediting.viewmodel + +import org.fbme.lib.common.Declaration +import org.fbme.lib.iec61499.fbnetwork.EntryKind + +data class FunctionBlockPortTemplateView( + override val component: FunctionBlockView, + val position: Int, + override val kind: EntryKind, + val isSource: Boolean, + val target: Declaration, +) : NetworkPortView diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/NetworkView.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/NetworkView.kt index ce3af9c34..2bb2f1e59 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/NetworkView.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/NetworkView.kt @@ -15,6 +15,7 @@ class NetworkView(private val myFactory: IEC61499Factory, private val myNetwork: private val myMainComponents: MutableSet = HashSet() private val myAuxComponents: MutableMap> = HashMap() private val myComponentToPorts: MutableMap> = HashMap() + private val myComponentToPortTemplates: MutableMap> = HashMap() private val myPorts: MutableMap = HashMap() private val myConnectionSources: MutableMap = HashMap() private val myConnectionDestinations: MutableMap = HashMap() @@ -207,6 +208,7 @@ class NetworkView(private val myFactory: IEC61499Factory, private val myNetwork: myPortModelMap[PortPath.createPortPath(functionBlock, EntryKind.ADAPTER, plug.declaration!!)] = port myPorts[port] = view } + //TODO: add ports templates } fun addConnection(connection: FBNetworkConnection, editable: Boolean): NetworkConnectionView? { @@ -250,6 +252,10 @@ class NetworkView(private val myFactory: IEC61499Factory, private val myNetwork: return myConnectionSources.keys } + override fun portsTemplates(component: NetworkComponentView): Set { + return myComponentToPortTemplates[component] ?: emptySet() + } + override fun ports(component: NetworkComponentView): Set { return myComponentToPorts[component]!! } @@ -292,6 +298,10 @@ class NetworkView(private val myFactory: IEC61499Factory, private val myNetwork: return null } + override fun addPort(port: NetworkPortView, component: NetworkComponentView) { + myPorts[port] = component + } + override fun removeEdge(edge: NetworkConnectionView) { val connection = edge.connection if (connection != null && edge.isEditable) { @@ -315,6 +325,8 @@ class NetworkView(private val myFactory: IEC61499Factory, private val myNetwork: return null } + + override val isEditable: Boolean get() = this@NetworkView.isEditable } diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt index 02bf1050c..55562d300 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt @@ -6,6 +6,7 @@ import jetbrains.mps.openapi.editor.EditorContext import jetbrains.mps.openapi.editor.cells.CellAction import jetbrains.mps.openapi.editor.cells.CellActionType import org.fbme.scenes.controllers.* +import org.fbme.scenes.controllers.diagram.entry.ConnectionEntry import org.fbme.scenes.controllers.scene.* import java.awt.Graphics import java.awt.Graphics2D @@ -113,10 +114,10 @@ class ConnectionsFacility( } private fun changePath( - entry: ConnectionEntry, - connectionView: ConnT, - translatedPath: PathT, - completed: Boolean + entry: ConnectionEntry, + connectionView: ConnT, + translatedPath: PathT, + completed: Boolean ) { if (completed) { connectionSynchronizer.setPath(connectionView, translatedPath) @@ -339,7 +340,25 @@ class ConnectionsFacility( connectionSynchronizer.setPath(edge, newPath) } } + } else { + val template = diagramController.findPortTemplate(x, y) + if (template != null) { + val templateController = diagramController.getTemplateController(template) + if (templateController.canBeTargetedAt(x, y)) { + scene.editorContext.repository.modelAccess.executeCommandInEDT { + val nTarget = templateController.createPort(source) ?: return@executeCommandInEDT + val targetSettings = diagramController.getPortController(nTarget) + diagramController.addPort(nTarget) + val edge = diagramController.addEdge(source, nTarget) ?: return@executeCommandInEDT + val newPath = newPathFactory.apply(sourceLocation, targetSettings.modelEndpointPosition) + connectionSynchronizer.setPath(edge, newPath) + scene.editorContext.editorComponent.updater.update() + } + } + + } } + newConnectionPath = null scene.fireRepaint() } @@ -369,6 +388,23 @@ class ConnectionsFacility( connectionSynchronizer.setPath(edge, newPath) } } + } else { + val template = diagramController.findPortTemplate(x, y) + if (template != null) { + val templateController = diagramController.getTemplateController(template) + if (templateController.canBeTargetedAt(x, y)) { + scene.editorContext.repository.modelAccess.executeCommandInEDT { + val nTarget = templateController.createPort(target) ?: return@executeCommandInEDT + val targetSettings = diagramController.getPortController(nTarget) + diagramController.addPort(nTarget) + val edge = diagramController.addEdge(nTarget, target) ?: return@executeCommandInEDT + val newPath = newPathFactory.apply(targetLocation, targetSettings.modelEndpointPosition) + connectionSynchronizer.setPath(edge, newPath) + scene.editorContext.editorComponent.updater.update() + } + } + + } } newConnectionPath = null scene.fireRepaint() diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramController.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramController.kt index 89131e92e..4036f4519 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramController.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramController.kt @@ -3,7 +3,9 @@ package org.fbme.scenes.controllers.diagram interface DiagramController { val isDiagramEditable: Boolean fun getPortController(port: PortT): PortController + fun getTemplateController(template: PortT): TemplateController fun findPort(x: Int, y: Int): PortT? + fun findPortTemplate(x: Int, y: Int): PortT? val components: Set val connections: Set fun getPorts(component: CompT): Set @@ -14,4 +16,5 @@ interface DiagramController { fun setTarget(edge: ConnT, port: PortT) fun removeEdge(edge: ConnT) fun addEdge(sourcePort: PortT, targetPort: PortT): ConnT? + fun addPort(port: PortT) } diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt index 0b25ab078..41be21476 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt @@ -1,11 +1,12 @@ package org.fbme.scenes.controllers.diagram -import java.awt.Point -import java.awt.Rectangle +import org.fbme.scenes.controllers.diagram.entry.PortEntry +import org.fbme.scenes.controllers.diagram.entry.PortTemplateEntry + class DiagramFacility( private val diagramModel: DiagramView, - private val portSettingProvider: PortSettingProvider, + private val portSettingProvider: PortSettingProvider, private val componentSettings: DiagramComponentSettingProvider ) { private val components: MutableSet = HashSet() @@ -14,7 +15,9 @@ class DiagramFacility( private val portToComponent: MutableMap = HashMap() private val connectionToSource: MutableMap = HashMap() private val connectionToTarget: MutableMap = HashMap() - private val ports: MutableMap = HashMap() + private val portTemplates: MutableList = mutableListOf() + private val portTemplatesToComponent: MutableMap, CompT> = HashMap() + private val ports: MutableMap> = HashMap() val diagramController: DiagramController = MyDiagramController() private fun init() { @@ -23,9 +26,18 @@ class DiagramFacility( val ports = HashSet(diagramModel.ports(component)) componentToPorts[component] = ports for (port in ports) { - this.ports.computeIfAbsent(port) { PortEntry(it) } + this.ports.computeIfAbsent(port) { + PortEntry(it, component, componentSettings, portSettingProvider ) + } portToComponent[port] = component } + + val templates = portSettingProvider.getPortTemplates(component) + portTemplates.addAll(templates) + templates.forEach { + val template = PortTemplateEntry(it, component, this.portToComponent, this.ports, componentSettings, portSettingProvider) + portTemplatesToComponent[template] = component + } } for (edge in diagramModel.edges()) { edges.add(edge) @@ -37,11 +49,20 @@ class DiagramFacility( private inner class MyDiagramController : DiagramController { override val isDiagramEditable: Boolean get() = diagramModel.isEditable + + override fun getTemplateController(template: PortT): TemplateController { + return portTemplatesToComponent.keys.find { it.template == template }!! + } + override val components: Set get() = this@DiagramFacility.components override val connections: Set get() = edges + override fun addPort(port: PortT) { + diagramModel.addPort(port, portToComponent[port]!!) + } + override fun getComponent(port: PortT): CompT { return portToComponent[port] ?: error("Component not found") } @@ -59,6 +80,15 @@ class DiagramFacility( return null } + override fun findPortTemplate(x: Int, y: Int): PortT? { + for (entry in portTemplatesToComponent.keys) { + if (entry.bounds.contains(x, y)) { + return entry.template + } + } + return null + } + override fun getPorts(component: CompT): Set { return componentToPorts[component] ?: error("Ports not found") } @@ -88,35 +118,6 @@ class DiagramFacility( } } - private inner class PortEntry(val port: PortT) : PortController { - override val bounds: Rectangle - get() { - val component = portToComponent[port] ?: error("Component not found") - return portSettingProvider.getBounds(componentSettings.getModelForm(component), port) - } - override val modelEndpointPosition: Point - get() { - val component = portToComponent[port] ?: error("Component not found") - return portSettingProvider.getEndpointPosition(componentSettings.getModelForm(component), port) - } - override val transformedEndpointPosition: Point? - get() { - val component = portToComponent[port] ?: error("Component not found") - val transformedForm = componentSettings.getTransformedForm(component) ?: return null - return portSettingProvider.getEndpointPosition(transformedForm, port) - } - - override fun canBeSourcedAt(x: Int, y: Int): Boolean { - val component = portToComponent[port] ?: error("Component not found") - return portSettingProvider.canBeSourcedAt(componentSettings.getModelForm(component), port, x, y) - } - - override fun canBeTargetedAt(x: Int, y: Int): Boolean { - val component = portToComponent[port] ?: error("Component not found") - return portSettingProvider.canBeTargetedAt(componentSettings.getModelForm(component), port, x, y) - } - } - init { init() } diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramView.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramView.kt index 8256e7848..ce6835283 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramView.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramView.kt @@ -5,6 +5,7 @@ interface DiagramView { fun components(): Set fun edges(): Set fun ports(component: C): Set

+ fun portsTemplates(component: C): Set

fun component(port: P): C fun sourcePort(edge: E): P fun setSourcePort(edge: E, port: P) @@ -12,4 +13,6 @@ interface DiagramView { fun setTargetPort(edge: E, port: P) fun removeEdge(edge: E) fun addEdge(sourcePort: P, targetPort: P): E? + fun addPort(port: P, component: C) { + } } diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/PortSettingProvider.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/PortSettingProvider.kt index 7f34393fc..e370564d4 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/PortSettingProvider.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/PortSettingProvider.kt @@ -3,9 +3,14 @@ package org.fbme.scenes.controllers.diagram import java.awt.Point import java.awt.Rectangle -interface PortSettingProvider { +interface PortSettingProvider { fun getBounds(componentForm: CFormT, port: PortT): Rectangle fun getEndpointPosition(componentForm: CFormT, port: PortT): Point + + fun getPortTemplates(componentForm: CompT): Set { + return emptySet() + } + fun canBeSourcedAt(componentForm: CFormT, port: PortT, x: Int, y: Int): Boolean { return true } @@ -13,4 +18,16 @@ interface PortSettingProvider { fun canBeTargetedAt(componentForm: CFormT, port: PortT, x: Int, y: Int): Boolean { return true } + + fun getTemplateBounds(modelForm: CFormT, template: PortT): Rectangle { + return Rectangle(0, 0) + } + + fun getTemplateEndpointPosition(modelForm: CFormT, template: PortT): Point { + return Point(0, 0) + } + + fun createPort(source: PortT, template: PortT): PortT? { + return null + } } diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/TemplateController.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/TemplateController.kt new file mode 100644 index 000000000..e1e33ac31 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/TemplateController.kt @@ -0,0 +1,7 @@ +package org.fbme.scenes.controllers.diagram + +interface TemplateController { + fun canBeSourcedAt(x: Int, y: Int): Boolean + fun canBeTargetedAt(x: Int, y: Int): Boolean + fun createPort(source: PortT): PortT? +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionEntry.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/ConnectionEntry.kt similarity index 91% rename from code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionEntry.kt rename to code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/ConnectionEntry.kt index 057c0c25e..b54c73ee1 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionEntry.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/ConnectionEntry.kt @@ -1,11 +1,13 @@ -package org.fbme.scenes.controllers.diagram +package org.fbme.scenes.controllers.diagram.entry +import org.fbme.scenes.controllers.diagram.ConnectionController +import org.fbme.scenes.controllers.diagram.ConnectionsFacility import java.awt.Point import java.awt.Rectangle internal class ConnectionEntry( - private val connectionsFacility: ConnectionsFacility, - val connection: ConnT + private val connectionsFacility: ConnectionsFacility, + val connection: ConnT ) { val controller: ConnectionController = connectionsFacility.controllerFactory.create(connectionsFacility.scene.editorContext, connection) diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortEntry.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortEntry.kt new file mode 100644 index 000000000..ff1e3612c --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortEntry.kt @@ -0,0 +1,36 @@ +package org.fbme.scenes.controllers.diagram.entry + +import org.fbme.scenes.controllers.diagram.DiagramComponentSettingProvider +import org.fbme.scenes.controllers.diagram.PortController +import org.fbme.scenes.controllers.diagram.PortSettingProvider +import java.awt.Point +import java.awt.Rectangle + +class PortEntry( + val port: PortT, + val component: CompT, + private val componentSettings: DiagramComponentSettingProvider, + private val portSettingProvider: PortSettingProvider, +) : PortController { + override val bounds: Rectangle + get() { + return portSettingProvider.getBounds(componentSettings.getModelForm(component), port) + } + override val modelEndpointPosition: Point + get() { + return portSettingProvider.getEndpointPosition(componentSettings.getModelForm(component), port) + } + override val transformedEndpointPosition: Point? + get() { + val transformedForm = componentSettings.getTransformedForm(component) ?: return null + return portSettingProvider.getEndpointPosition(transformedForm, port) + } + + override fun canBeSourcedAt(x: Int, y: Int): Boolean { + return portSettingProvider.canBeSourcedAt(componentSettings.getModelForm(component), port, x, y) + } + + override fun canBeTargetedAt(x: Int, y: Int): Boolean { + return portSettingProvider.canBeTargetedAt(componentSettings.getModelForm(component), port, x, y) + } +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortTemplateEntry.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortTemplateEntry.kt new file mode 100644 index 000000000..426fec7d2 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortTemplateEntry.kt @@ -0,0 +1,39 @@ +package org.fbme.scenes.controllers.diagram.entry + +import org.fbme.scenes.controllers.diagram.DiagramComponentSettingProvider +import org.fbme.scenes.controllers.diagram.PortController +import org.fbme.scenes.controllers.diagram.PortSettingProvider +import org.fbme.scenes.controllers.diagram.TemplateController +import java.awt.Point +import java.awt.Rectangle + +class PortTemplateEntry( + val template: PortT, + val component: CompT, + val portToComponent: MutableMap, + val ports: MutableMap>, + private val componentSettings: DiagramComponentSettingProvider, + private val portSettingProvider: PortSettingProvider, +) : PortController, TemplateController { + override val bounds: Rectangle + get() = portSettingProvider.getTemplateBounds(componentSettings.getModelForm(component), template) + override val modelEndpointPosition: Point + get() = portSettingProvider.getTemplateEndpointPosition(componentSettings.getModelForm(component), template) + override val transformedEndpointPosition: Point? + get() = TODO("Not yet implemented") + + override fun canBeSourcedAt(x: Int, y: Int): Boolean { + return true + } + + override fun canBeTargetedAt(x: Int, y: Int): Boolean { + return true + } + + override fun createPort(source: PortT): PortT? { + val nPort = portSettingProvider.createPort(source, template) ?: return null + ports.computeIfAbsent(nPort) { PortEntry(nPort, component, componentSettings, portSettingProvider) } + portToComponent[nPort] = component + return nPort + } +} \ No newline at end of file From 731a2c87eb55bb44ef30fa1b9bcc389e99eda630 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Fri, 26 May 2023 19:49:58 +0200 Subject: [PATCH 13/66] Add converting type --- .../richediting/actions/ChangeTypeAction.kt | 80 ++++++++++++ .../fbnetwork/EditedComponentsController.kt | 28 ++--- .../adapters/fbnetwork/FBNetworkEditors.kt | 34 ++++-- .../fbnetwork/FunctionBlockController.kt | 47 ++++---- .../fbnetwork/actions/ChangeTypeAction.kt | 114 ++++++++++++++++++ .../fbnetwork/actions/CollapseAction.kt | 2 +- .../fbnetwork/actions/ExpandAction.kt | 2 +- ...OrCollapseAction.kt => FBNetworkAction.kt} | 17 ++- ...CellComponent.kt => EditableFBTypeCell.kt} | 30 ++--- ...hEditableLabel.kt => EditablePortLabel.kt} | 2 +- ...ype.kt => EditablePortWithTypeAndLabel.kt} | 4 +- .../editor/RichEditorStyleAttributes.kt | 11 +- .../viewmodel/FunctionBlockPortView.kt | 6 +- .../viewmodel/FunctionBlockView.kt | 3 +- .../viewmodel/InterfaceEndpointView.kt | 6 +- .../richediting/viewmodel/NetworkPortView.kt | 6 + .../src/main/resources/META-INF/plugin.xml | 10 ++ .../controllers/DefaultSelectionModel.kt | 2 + .../components/ComponentsFacility.kt | 19 +-- .../diagram/ConnectionsFacility.kt | 23 ++-- .../controllers/diagram/DiagramFacility.kt | 1 - .../scenes/controllers/edited/EditedModel.kt | 9 ++ .../{ => selection}/SelectionModel.kt | 2 +- .../{ => selection}/SelectionModelBase.kt | 2 +- 24 files changed, 360 insertions(+), 100 deletions(-) create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeTypeAction.kt create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/{ExpandOrCollapseAction.kt => FBNetworkAction.kt} (79%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/{FBTypeEditCellComponent.kt => EditableFBTypeCell.kt} (93%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/{PortWithEditableLabel.kt => EditablePortLabel.kt} (96%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/{PortWithLabelAndType.kt => EditablePortWithTypeAndLabel.kt} (96%) create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/controllers/edited/EditedModel.kt rename code/scenes/src/main/kotlin/org/fbme/scenes/controllers/{ => selection}/SelectionModel.kt (90%) rename code/scenes/src/main/kotlin/org/fbme/scenes/controllers/{ => selection}/SelectionModelBase.kt (92%) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeTypeAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeTypeAction.kt new file mode 100644 index 000000000..05332dc55 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeTypeAction.kt @@ -0,0 +1,80 @@ +package org.fbme.ide.richediting.actions + +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.project.DumbAware +import jetbrains.mps.ide.editor.MPSEditorDataKeys +import org.fbme.ide.richediting.adapters.fbnetwork.actions.ChangeTypeAction +import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.lib.iec61499.declarations.BasicFBTypeDeclaration +import org.fbme.lib.iec61499.declarations.CompositeFBTypeDeclaration + +class ChangeTypeAction : AnAction(), DumbAware { + override fun update(event: AnActionEvent) { + val project = event.getData(MPSEditorDataKeys.MPS_PROJECT) + val cell = event.getData(MPSEditorDataKeys.EDITOR_CELL) + + if (project == null || cell == null) { + notApplicable(event) + return + } + + val editedFBS = cell.style.get(RichEditorStyleAttributes.EDITED_FBS).editedComponents + val fbCell = editedFBS.find { it.associatedNode == cell.sNode } + + if (fbCell == null) { + notApplicable(event) + return + } + + when (val declaration = fbCell.type.declaration) { + is CompositeFBTypeDeclaration -> { + event.presentation.text = TO_BASIC_FB_TYPE + event.presentation.isEnabled = checkCompositeBlock(declaration) + } + + is BasicFBTypeDeclaration -> { + event.presentation.text = TO_COMPOSITE_FB_TYPE + event.presentation.isEnabled = checkBasicBlock(declaration) + } + + else -> { + notApplicable(event) + } + } + } + + private fun checkBasicBlock(declaration: BasicFBTypeDeclaration): Boolean { + if (declaration.ecc.states.isNotEmpty()) { + return false + } + + if (declaration.ecc.transitions.isNotEmpty()) { + return false + } + + return declaration.algorithms.isEmpty() + } + + private fun checkCompositeBlock(declaration: CompositeFBTypeDeclaration): Boolean { + return declaration.network.allComponents.isEmpty() + } + + private fun notApplicable(event: AnActionEvent) { + event.presentation.isEnabledAndVisible = false + } + + override fun actionPerformed(event: AnActionEvent) { + event.modelAccess.executeCommandInEDT { + ChangeTypeAction( + event.getRequiredData(MPSEditorDataKeys.EDITOR_CELL), + event.getRequiredData(MPSEditorDataKeys.MPS_PROJECT) + ).apply() + } + } + + companion object { + const val TO_BASIC_FB_TYPE = "Change type to basic" + const val TO_COMPOSITE_FB_TYPE = "Change type to composite" + } +} \ No newline at end of file diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/EditedComponentsController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/EditedComponentsController.kt index f2ce2e6a3..2a227739b 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/EditedComponentsController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/EditedComponentsController.kt @@ -2,28 +2,28 @@ package org.fbme.ide.richediting.adapters.fbnetwork import org.fbme.ide.richediting.viewmodel.FunctionBlockView import org.fbme.scenes.cells.EditorCell_Scene +import org.fbme.scenes.controllers.edited.EditedModel import org.fbme.scenes.controllers.scene.SceneStateKey -class EditedComponentsController(val scene: EditorCell_Scene) { - private val inEditFBs: MutableList +class EditedComponentsController(val scene: EditorCell_Scene) : EditedModel { + override val editedComponents: MutableList = scene.loadState(EDITED_FBS_KEY) + ?: mutableListOf() - init { - inEditFBs = scene.loadState(EDITED_FBS_KEY) ?: mutableListOf() - scene.storeState(EDITED_FBS_KEY, inEditFBs) - } + override fun setEdited(component: FunctionBlockView, edited: Boolean) { + if (edited) { + editedComponents.add(component) + return + } - fun addFB( - functionBlock: FunctionBlockView, - ) { - inEditFBs.add(functionBlock) + editedComponents.remove(component) } - fun removeFB(functionBlock: FunctionBlockView) { - inEditFBs.remove(functionBlock) + override fun isEdited(component: FunctionBlockView): Boolean { + return editedComponents.contains(component) } - fun isEdited(functionBlock: FunctionBlockView): Boolean { - return inEditFBs.contains(functionBlock) + init { + scene.storeState(EDITED_FBS_KEY, editedComponents) } companion object { diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt index 6aef79483..5affc34c6 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt @@ -18,6 +18,7 @@ import org.fbme.lib.common.Declaration import org.fbme.lib.common.StringIdentifier import org.fbme.lib.iec61499.DeclarationsScope import org.fbme.lib.iec61499.IEC61499Factory +import org.fbme.lib.iec61499.declarations.FBTypeDeclaration import org.fbme.lib.iec61499.declarations.ParameterAssignment import org.fbme.lib.iec61499.fbnetwork.FBNetwork import org.fbme.lib.iec61499.instances.Instance @@ -27,6 +28,7 @@ import org.fbme.scenes.cells.SceneStyleAttributes.SCENE_BACKGROUND import org.fbme.scenes.controllers.* import org.fbme.scenes.controllers.components.* import org.fbme.scenes.controllers.diagram.* +import org.fbme.scenes.controllers.edited.EditedModel import org.fbme.scenes.controllers.scene.* import org.fbme.scenes.viewmodel.PositionalCompletionItem import org.jetbrains.mps.openapi.model.SNode @@ -135,7 +137,7 @@ object FBNetworkEditors { val project = context.operationContext.project val repository = PlatformRepositoryProvider.getInstance(project) try { - val isEditable = networkInstance.parent == null + val isEditable = true val networkView = NetworkView(repository.iec61499Factory, networkDeclaration, isEditable) val backgroundLayer = scene.createLayer(0f) val tracesLayer = scene.createLayer(1f) @@ -160,7 +162,8 @@ object FBNetworkEditors { style.set(RichEditorStyleAttributes.SELECTED_FBS, componentsSelection) val componentsLayout = DefaultLayoutModel(context.repository) val expandedComponentsController = ExpandedComponentsController(scene, context) - val editedComponentsController = EditedComponentsController(scene) + val editedComponentsController: EditedModel = EditedComponentsController(scene) + style.set(RichEditorStyleAttributes.EDITED_FBS, editedComponentsController) val componentsFacility = ComponentsFacility( scene, networkView.componentsView, @@ -261,7 +264,7 @@ object FBNetworkEditors { fun getComponentControllerFactory( instance: NetworkInstance, expandedComponentsController: ExpandedComponentsController, - editedComponentsController: EditedComponentsController, + editedComponentsController: EditedModel, iec61499Factory: IEC61499Factory, scope: DeclarationsScope ): ComponentControllerFactory { @@ -284,7 +287,7 @@ object FBNetworkEditors { fbNetwork: FBNetwork, scale: Float ): List { - val completionList = mutableListOf(); + val completionList = mutableListOf() scope.findAllFBTypeDeclarations().forEach { type -> completionList.add( @@ -299,8 +302,8 @@ object FBNetworkEditors { } completionList.add(createPositionalCompletionItem( - "New functional block", - "Empty block for creating definition") { _: String?, x: Int, y: Int -> + "New composite FB", + "Empty composite FB") { _: String?, x: Int, y: Int -> val identifier = createNewCompositeBlock(scope, fbNetwork, factory) val declaration = factory.createFunctionBlockDeclaration(identifier) declaration.x = (x / scale).toInt() @@ -312,6 +315,20 @@ object FBNetworkEditors { fbNetwork.functionBlocks.add(declaration) }) + completionList.add(createPositionalCompletionItem( + "New basic FB", + "Empty basic FB") { _: String?, x: Int, y: Int -> + val identifier = createNewCompositeBlock(scope, fbNetwork, factory, false) + val declaration = factory.createFunctionBlockDeclaration(identifier) + declaration.x = (x / scale).toInt() + declaration.y = (y / scale).toInt() + val type = scope.findAllFBTypeDeclarations().find { + it.name == identifier.value + } ?: error("Can't create empty block") + declaration.typeReference.setTarget(type) + fbNetwork.functionBlocks.add(declaration) + }) + return completionList } @@ -339,7 +356,8 @@ object FBNetworkEditors { private fun createNewCompositeBlock( scope: DeclarationsScope, fbNetwork: FBNetwork, - factory: IEC61499Factory + factory: IEC61499Factory, + composite: Boolean = true ): StringIdentifier { val getName: (Int?) -> String = { ind -> val baseName = "Empty block" @@ -361,7 +379,7 @@ object FBNetworkEditors { val networkNode = (fbNetwork as PlatformElement).node val networkModel = networkNode.model - val newFbType = factory.createCompositeFBTypeDeclaration(identifier) + val newFbType: FBTypeDeclaration = if (composite) factory.createCompositeFBTypeDeclaration(identifier) else factory.createBasicFBTypeDeclaration(identifier) val fbTypeNode = (newFbType as PlatformElement).node networkModel!!.addRootNode(fbTypeNode) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt index 31d8c6ff3..52b474146 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt @@ -16,13 +16,10 @@ import jetbrains.mps.openapi.editor.cells.CellActionType import org.fbme.ide.richediting.adapters.fbnetwork.fb.FBCell import org.fbme.ide.richediting.adapters.fbnetwork.fb.FBSceneCell import org.fbme.ide.richediting.adapters.fbnetwork.fb.FBTypeCellComponent -import org.fbme.ide.richediting.adapters.fbnetwork.fb.FBTypeEditCellComponent +import org.fbme.ide.richediting.adapters.fbnetwork.fb.EditableFBTypeCell import org.fbme.ide.richediting.adapters.fbnetwork.port.PortActionFactory import org.fbme.ide.richediting.editor.RichEditorStyleAttributes -import org.fbme.ide.richediting.viewmodel.FunctionBlockPortView -import org.fbme.ide.richediting.viewmodel.FunctionBlockView -import org.fbme.ide.richediting.viewmodel.NetworkPortView -import org.fbme.lib.common.StringIdentifier +import org.fbme.ide.richediting.viewmodel.* import org.fbme.lib.iec61499.DeclarationsScope import org.fbme.lib.iec61499.IEC61499Factory import org.fbme.lib.iec61499.declarations.* @@ -34,6 +31,7 @@ import org.fbme.scenes.cells.button.TickButton import org.fbme.scenes.cells.button.EditButton import org.fbme.scenes.controllers.LayoutUtil.getLineSize import org.fbme.scenes.controllers.components.ComponentController +import org.fbme.scenes.controllers.edited.EditedModel import org.jetbrains.mps.openapi.model.SNode import java.awt.* import java.util.function.Function @@ -43,7 +41,7 @@ class FunctionBlockController( private val view: FunctionBlockView, networkInstance: NetworkInstance, val expandedComponentsController: ExpandedComponentsController, - val editedController: EditedComponentsController, + private val editedController: EditedModel, val iec61499Factory: IEC61499Factory, scope: DeclarationsScope, ) : ComponentController, FBNetworkComponentController { @@ -88,7 +86,7 @@ class FunctionBlockController( } private fun initializeFBEditCell(iec61499Factory: IEC61499Factory, scope: DeclarationsScope): FBCell { - return FBTypeEditCellComponent(cellCollection.context, view.type, view.associatedNode, iec61499Factory, scope, isEditable) + return EditableFBTypeCell(cellCollection.context, view.type, view.associatedNode, iec61499Factory, scope, isEditable) } private fun getEditButton(context: EditorContext, node: SNode): EditorCell_Button { @@ -120,7 +118,6 @@ class FunctionBlockController( EntryKind.DATA -> if (isSource) fbCell.getOutputDataPortPosition(index) else fbCell.getInputDataPortPosition(index) EntryKind.ADAPTER -> if (isSource) fbCell.getPlugPortPosition(index) else fbCell.getSocketPortPosition(index) - else -> error("") } coordinates.translate(position.x, position.y + getVerticalOffset()) return coordinates @@ -153,11 +150,10 @@ class FunctionBlockController( return super.getTemplateBounds(template, modelForm) } - val buttons = (fbCell as FBTypeEditCellComponent).buttons[template.kind] + val buttons = (fbCell as EditableFBTypeCell).buttons[template.kind] template as FunctionBlockPortView val button = (if (template.isSource) buttons?.cells?.last() else buttons?.cells?.first()) val bounds = Rectangle(button?.x ?: 0, button?.y ?: 0, button?.width ?: 0, (button?.height ?: 0)) - //bounds.translate(modelForm.x, modelForm.y + getVerticalOffset()) return bounds } @@ -166,7 +162,7 @@ class FunctionBlockController( return super.getTemplatePosition(template, modelForm) } - val buttons = (fbCell as FBTypeEditCellComponent).buttons[template.kind] + val buttons = (fbCell as EditableFBTypeCell).buttons[template.kind] template as FunctionBlockPortView val button = (if (template.isSource) buttons?.cells?.last() else buttons?.cells?.first()) val bounds = Rectangle(button?.width ?: 0, (button?.height ?: 0) + getVerticalOffset()) @@ -178,30 +174,31 @@ class FunctionBlockController( } override fun createPort(source: NetworkPortView, template: NetworkPortView): NetworkPortView? { - require(!(template !is FunctionBlockPortView || source !is FunctionBlockPortView)) { "invalid port" } + require(template is FunctionBlockPortView && (source is NetworkPortViewAdd)) { "invalid port" } if (template.isSource == source.isSource) return null val declaration = view.type.declaration if (declaration !is FBInterfaceDeclaration) return null + val name = source.target.name when(template.kind) { EntryKind.EVENT -> { val list = if (template.isSource) declaration.outputEvents else declaration.inputEvents - val identifier = PortActionFactory.IDENTIFIER_FACTORY("E", list.map { it.name }).get() + val identifier = PortActionFactory.IDENTIFIER_FACTORY(name, list.map { it.name }).get() val nEvent = iec61499Factory.createEventDeclaration(identifier) list.add(nEvent) - (fbCell as FBTypeEditCellComponent).addPort(if (template.isSource) view.type.eventOutputPorts.last() else view.type.eventInputPorts.last()) + (fbCell as EditableFBTypeCell).addPort(if (template.isSource) view.type.eventOutputPorts.last() else view.type.eventInputPorts.last()) return FunctionBlockPortView(template.component, list.size - 1, EntryKind.EVENT, template.isSource, nEvent) } EntryKind.DATA -> { val list = if (template.isSource) declaration.outputParameters else declaration.inputParameters - val identifier = PortActionFactory.IDENTIFIER_FACTORY("P", list.map { it.name }).get() + val identifier = PortActionFactory.IDENTIFIER_FACTORY(name, list.map { it.name }).get() val nParameter = iec61499Factory.createParameterDeclaration(identifier) nParameter.type = (source.target as ParameterDeclaration).type list.add(nParameter) - (fbCell as FBTypeEditCellComponent).addPort(if (template.isSource) view.type.dataOutputPorts.last() else view.type.dataInputPorts.last()) + (fbCell as EditableFBTypeCell).addPort(if (template.isSource) view.type.dataOutputPorts.last() else view.type.dataInputPorts.last()) return FunctionBlockPortView(template.component, list.size - 1, EntryKind.DATA, template.isSource, nParameter) } EntryKind.ADAPTER -> { @@ -210,20 +207,21 @@ class FunctionBlockController( } if (template.isSource) { val list = declaration.plugs - val identifier = PortActionFactory.IDENTIFIER_FACTORY("P", list.map { it.name }).get() + val identifier = PortActionFactory.IDENTIFIER_FACTORY(name, list.map { it.name }).get() val nParameter = iec61499Factory.createPlugDeclaration(identifier) val dec = source.target as PlugDeclaration nParameter.typeReference.setTarget(dec.typeReference.getTarget()!!) list.add(nParameter) - (fbCell as FBTypeEditCellComponent).addPort(if (template.isSource) view.type.plugPorts.last() else view.type.socketPorts.last()) + (fbCell as EditableFBTypeCell).addPort(view.type.plugPorts.last()) return FunctionBlockPortView(template.component, list.size - 1, EntryKind.ADAPTER, template.isSource, nParameter) } val list = declaration.sockets - val identifier = PortActionFactory.IDENTIFIER_FACTORY("S", list.map { it.name }).get() + val identifier = PortActionFactory.IDENTIFIER_FACTORY(name, list.map { it.name }).get() val nParameter = iec61499Factory.createSocketDeclaration(identifier) val dec = source.target as SocketDeclaration nParameter.typeReference.setTarget(dec.typeReference.getTarget()!!) list.add(nParameter) + (fbCell as EditableFBTypeCell).addPort(view.type.socketPorts.last()) return FunctionBlockPortView(template.component, list.size - 1, EntryKind.DATA, template.isSource, nParameter) } } @@ -251,7 +249,12 @@ class FunctionBlockController( override fun updateCellSelection(selected: Boolean) { myNameProperty.style.set(StyleAttributes.FONT_STYLE, if (selected) Font.BOLD else Font.PLAIN) - editButton.style.set(StyleAttributes.TRANSPARENT, selected) + if (selected) { + cellCollection.addEditorCellBefore(editButton, myNameProperty) + } else if (cellCollection.containsCell(editButton)) { + cellCollection.removeCell(editButton) + } + //editButton.style.set(StyleAttributes.TRANSPARENT, selected) } override fun paintTrace(g: Graphics?, form: Point) { @@ -266,7 +269,7 @@ class FunctionBlockController( return super.getFBPortTemplates() } - return (fbCell as FBTypeEditCellComponent).getPortTemplates(view) + return (fbCell as EditableFBTypeCell).getPortTemplates(view) } init { @@ -308,7 +311,7 @@ class FunctionBlockController( override fun canExecute(context: EditorContext): Boolean = true override fun execute(context: EditorContext) { - if (editedController.isEdited(view)) editedController.removeFB(view) else editedController.addFB(view) + editedController.setEdited(view, !editedController.isEdited(view)) context.editorComponent.updater.update() } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt new file mode 100644 index 000000000..3f3a15a77 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt @@ -0,0 +1,114 @@ +package org.fbme.ide.richediting.adapters.fbnetwork.actions + +import com.intellij.notification.NotificationGroupManager +import com.intellij.notification.NotificationType +import com.intellij.util.alsoIfNull +import jetbrains.mps.openapi.editor.cells.EditorCell +import jetbrains.mps.project.MPSProject +import org.fbme.ide.iec61499.repository.PlatformElement +import org.fbme.ide.iec61499.repository.PlatformRepositoryProvider +import org.fbme.ide.richediting.viewmodel.FunctionBlockView +import org.fbme.lib.common.Identifier +import org.fbme.lib.common.StringIdentifier +import org.fbme.lib.iec61499.declarations.BasicFBTypeDeclaration +import org.fbme.lib.iec61499.declarations.CompositeFBTypeDeclaration +import org.fbme.lib.iec61499.declarations.FBTypeDeclaration + +class ChangeTypeAction(cell: EditorCell, val project: MPSProject) : FBNetworkAction(cell) { + fun apply() { + val funBlock = editedFBs.find { it.associatedNode == cell.sNode }.alsoIfNull{ + showNotification(CANT_GET_FB_CELL) + } ?: return + + when (val declaration = funBlock.type.declaration) { + is CompositeFBTypeDeclaration -> convertToBasicFB(funBlock, declaration) + is BasicFBTypeDeclaration -> convertToComposite(funBlock, declaration) + } + + cell.editorComponent.updater.update() + } + + private fun convertFB( + oldFB: FunctionBlockView, + oldDeclaration: FBTypeDeclaration, + creator: (identity: Identifier) -> FBTypeDeclaration + ) { + val identifier = StringIdentifier(oldDeclaration.name + TMP_SUFFIX) + + val network = networkInstance.networkDeclaration + val repository = PlatformRepositoryProvider.getInstance(project) + val factory = repository.iec61499Factory + + val networkModel = (network as PlatformElement).node.model.alsoIfNull { + showNotification("""Can't convert ${oldDeclaration.name} to basic functional block!""") + } ?: return + val scope = repository.getDeclarationScopeFor(networkModel) + + val createdFB = creator(identifier) + + val fbTypeNode = (createdFB as PlatformElement).node + networkModel.addRootNode(fbTypeNode) + + val createdDeclaration = factory.createFunctionBlockDeclaration(identifier) + + createdDeclaration.x = oldFB.component.x + createdDeclaration.y = oldFB.component.y + + val type = scope.findAllFBTypeDeclarations().find { + it.name == identifier.value + }.alsoIfNull { + showNotification("Can't find new basic FB declaration ${oldDeclaration.name} in scope!") + } ?: return + + createdDeclaration.typeReference.setTarget(type) + network.functionBlocks.replaceAll { + if (oldFB.component.type.typeName == it.type.typeName) createdDeclaration else it + } + + oldDeclaration.inputEvents.copyTo(type.inputEvents) + oldDeclaration.outputEvents.copyTo(type.outputEvents) + oldDeclaration.inputParameters.copyTo(type.inputParameters) + oldDeclaration.outputParameters.copyTo(type.outputParameters) + oldDeclaration.plugs.copyTo(type.plugs) + oldDeclaration.sockets.copyTo(type.sockets) + + networkModel.removeRootNode((oldDeclaration as PlatformElement).node) + + createdDeclaration.name = oldFB.component.name + type.name = type.name.substringBeforeLast(TMP_SUFFIX) + editedFBsController.setEdited(FunctionBlockView(createdDeclaration, true), true) + } + + private fun MutableList.copyTo(newList: MutableList) { + this.toList().forEach { + newList.add(it) + } + } + + private fun convertToBasicFB(funBlock: FunctionBlockView, declaration: CompositeFBTypeDeclaration) { + val repository = PlatformRepositoryProvider.getInstance(project) + val factory = repository.iec61499Factory + + convertFB(funBlock, declaration, factory::createBasicFBTypeDeclaration) + } + + private fun convertToComposite(funBlock: FunctionBlockView, declaration: BasicFBTypeDeclaration) { + val repository = PlatformRepositoryProvider.getInstance(project) + val factory = repository.iec61499Factory + + convertFB(funBlock, declaration, factory::createCompositeFBTypeDeclaration) + } + + private fun showNotification(message: String) { + NotificationGroupManager + .getInstance() + .getNotificationGroup("Custom") + .createNotification(message, NotificationType.WARNING) + .notify(project.project) + } + + companion object { + const val CANT_GET_FB_CELL = "Couldn't find functional block!" + const val TMP_SUFFIX = "_tmp" + } +} \ No newline at end of file diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/CollapseAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/CollapseAction.kt index 0160a912a..a03f33cc4 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/CollapseAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/CollapseAction.kt @@ -4,7 +4,7 @@ import jetbrains.mps.openapi.editor.cells.EditorCell import org.fbme.ide.richediting.adapters.fbnetwork.FunctionBlockController import org.fbme.ide.richediting.viewmodel.FunctionBlockView -class CollapseAction(cell: EditorCell) : ExpandOrCollapseAction(cell.parent) { +class CollapseAction(cell: EditorCell) : FBNetworkAction(cell.parent) { fun apply() { collapse(selectedFBs.filterIsInstance()) } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ExpandAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ExpandAction.kt index cf15c357a..4b24cf9cb 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ExpandAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ExpandAction.kt @@ -16,7 +16,7 @@ import org.jetbrains.mps.openapi.module.SRepository import java.awt.Point import java.awt.Rectangle -class ExpandAction(cell: EditorCell) : ExpandOrCollapseAction(cell) { +class ExpandAction(cell: EditorCell) : FBNetworkAction(cell) { fun apply() { val functionBlock = selectedFBs.filterIsInstance().last() functionBlock.expand() diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ExpandOrCollapseAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/FBNetworkAction.kt similarity index 79% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ExpandOrCollapseAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/FBNetworkAction.kt index e29431ae1..4c6c43854 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ExpandOrCollapseAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/FBNetworkAction.kt @@ -6,20 +6,32 @@ import org.fbme.ide.richediting.adapters.fbnetwork.FBConnectionPath import org.fbme.ide.richediting.adapters.fbnetwork.FBConnectionPathSynchronizer import org.fbme.ide.richediting.adapters.fbnetwork.FBNetworkComponentSynchronizer import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.ide.richediting.viewmodel.FunctionBlockView import org.fbme.ide.richediting.viewmodel.NetworkComponentView import org.fbme.ide.richediting.viewmodel.NetworkConnectionView import org.fbme.ide.richediting.viewmodel.NetworkPortView +import org.fbme.lib.iec61499.instances.NetworkInstance import org.fbme.scenes.controllers.SceneViewpoint import org.fbme.scenes.controllers.components.ComponentsFacility import org.fbme.scenes.controllers.diagram.ConnectionsFacility import org.fbme.scenes.controllers.diagram.DiagramController import org.fbme.scenes.controllers.diagram.DiagramFacility +import org.fbme.scenes.controllers.edited.EditedModel import java.awt.Point -abstract class ExpandOrCollapseAction protected constructor(cell: EditorCell) { +abstract class FBNetworkAction protected constructor(protected val cell: EditorCell) { @JvmField protected val selectedFBs: Set + @JvmField + protected val editedFBs: List + + @JvmField + protected val editedFBsController: EditedModel + + @JvmField + protected val networkInstance: NetworkInstance + @JvmField protected val componentsFacility: ComponentsFacility @@ -44,6 +56,9 @@ abstract class ExpandOrCollapseAction protected constructor(cell: EditorCell) { init { val style = cell.style selectedFBs = style.get(RichEditorStyleAttributes.SELECTED_FBS).selectedComponents + editedFBs = style.get(RichEditorStyleAttributes.EDITED_FBS).editedComponents + editedFBsController = style.get(RichEditorStyleAttributes.EDITED_FBS) + networkInstance = style.get(RichEditorStyleAttributes.NETWORK_INSTANCE) componentsFacility = style.get(RichEditorStyleAttributes.COMPONENTS_FACILITY) as ComponentsFacility connectionsFacility = style.get(RichEditorStyleAttributes.CONNECTIONS_FACILITY) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt similarity index 93% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt index aa4060cc6..efc9e1d87 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeEditCellComponent.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt @@ -7,7 +7,6 @@ import jetbrains.mps.editor.runtime.style.StyleAttributes import jetbrains.mps.nodeEditor.MPSColors import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Horizontal import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Vertical -import jetbrains.mps.nodeEditor.cells.EditorCell_Basic import jetbrains.mps.nodeEditor.cells.EditorCell_Collection import jetbrains.mps.nodeEditor.cells.EditorCell_Property import jetbrains.mps.nodeEditor.cells.ParentSettings @@ -20,7 +19,6 @@ import org.fbme.ide.iec61499.repository.PlatformElement import org.fbme.ide.richediting.adapters.fbnetwork.FBConnectionPathPainter import org.fbme.ide.richediting.adapters.fbnetwork.actions.cell.DeclarationNameAccessor import org.fbme.ide.richediting.adapters.fbnetwork.port.* -import org.fbme.ide.richediting.editor.NetworkInstanceNavigationSupport import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.ide.richediting.viewmodel.FunctionBlockPortView import org.fbme.ide.richediting.viewmodel.FunctionBlockView @@ -43,7 +41,7 @@ import java.awt.geom.GeneralPath import java.util.* import kotlin.math.max -class FBTypeEditCellComponent( +class EditableFBTypeCell( context: EditorContext, fbType: FBTypeDescriptor, node: SNode, @@ -165,7 +163,7 @@ class FBTypeEditCellComponent( val block = object : EditorCell_Collection(context, node, CellLayout_Vertical()) {} for (port in portsDescriptors) { - val portWithLabel = PortWithEditableLabel(context, node, port, fbType.declaration) + val portWithLabel = EditablePortLabel(context, node, port, fbType.declaration) portWithLabel.label.style.set(StyleAttributes.HORIZONTAL_ALIGN, horizontalAlign) portWithLabel.label.style.set(padding, Padding(INNER_BORDER_PADDING.toDouble(), Measure.PIXELS)) ports.add(portWithLabel) @@ -178,7 +176,7 @@ class FBTypeEditCellComponent( fun addPort(port: FBPortDescriptor) { when (port.connectionKind) { EntryKind.EVENT -> { - val value = PortWithEditableLabel(context, node, port, fbType.declaration) + val value = EditablePortLabel(context, node, port, fbType.declaration) if (port.isInput) { (eventPortsContainer.cells.first() as EditorCell_Collection).addEditorCell(value.label) inputEventPorts.add(value) @@ -189,7 +187,7 @@ class FBTypeEditCellComponent( } EntryKind.DATA -> { val typeDeclaration = port.declaration as ParameterDeclaration - val value = PortWithLabelAndType(context, node, port, fbType.declaration, typeDeclaration.type?.stringify(), getDataTypeSuggestions(typeDeclaration)) + val value = EditablePortWithTypeAndLabel(context, node, port, fbType.declaration, typeDeclaration.type?.stringify(), getDataTypeSuggestions(typeDeclaration)) if (port.isInput) { (dataPortsContainer.cells.first() as EditorCell_Collection).addEditorCell(value.cell) inputDataPorts.add(value) @@ -219,7 +217,7 @@ class FBTypeEditCellComponent( for (port in portsDescriptors) { val typeDeclaration = port.declaration as ParameterDeclaration - val portWithLabel = PortWithLabelAndType(context, node, port, fbType.declaration, typeDeclaration.type?.stringify(), getDataTypeSuggestions(typeDeclaration)) + val portWithLabel = EditablePortWithTypeAndLabel(context, node, port, fbType.declaration, typeDeclaration.type?.stringify(), getDataTypeSuggestions(typeDeclaration)) portWithLabel.label.style.set(StyleAttributes.HORIZONTAL_ALIGN, horizontalAlign) portWithLabel.label.style.set(padding, Padding(INNER_BORDER_PADDING.toDouble(), Measure.PIXELS)) ports.add(portWithLabel) @@ -275,7 +273,7 @@ class FBTypeEditCellComponent( } } } - val portWithLabel = PortWithLabelAndType(context, node, port, fbType.declaration, typeDeclaration.typeReference.presentation, items) + val portWithLabel = EditablePortWithTypeAndLabel(context, node, port, fbType.declaration, typeDeclaration.typeReference.presentation, items) portWithLabel.label.style.set(StyleAttributes.HORIZONTAL_ALIGN, horizontalAlign) portWithLabel.label.style.set(padding, Padding(INNER_BORDER_PADDING.toDouble(), Measure.PIXELS)) ports.add(portWithLabel) @@ -292,7 +290,7 @@ class FBTypeEditCellComponent( override fun paintContent(g: Graphics, parentSettings: ParentSettings) { - this@FBTypeEditCellComponent.paint(g.create() as Graphics2D) + this@EditableFBTypeCell.paint(g.create() as Graphics2D) } override fun paintSelection(g: Graphics, c: Color, drawBorder: Boolean, parentSettings: ParentSettings) { // do noting @@ -330,7 +328,7 @@ class FBTypeEditCellComponent( private fun drawPortIcons(graphics: Graphics2D, x: Int, ports: Set, color: Color?) { for (port in ports) { - val portWithLabel = port as PortWithEditableLabel + val portWithLabel = port as EditablePortLabel val y = portWithLabel.label.y + portWithLabel.label.height / 2 - scale(PORT_SIZE) / 2 val form = Rectangle(x, y, scale(PORT_SIZE), scale(PORT_SIZE)) @@ -393,8 +391,10 @@ class FBTypeEditCellComponent( if (child != null) { val childNetworkInstance = child.containedNetwork if (childNetworkInstance is NetworkInstance) { - val navigationStub = NetworkInstanceNavigationSupport.getNavigationStub(rootCell.context.operationContext.project, childNetworkInstance) - style.set(StyleAttributes.NAVIGATABLE_NODE, navigationStub) + //val navigationStub = NetworkInstanceNavigationSupport.getNavigationStub(rootCell.context.operationContext.project, childNetworkInstance) + val typeDeclaration = style.get(RichEditorStyleAttributes.TYPE).declaration + //style.set(StyleAttributes.NAVIGATABLE_NODE, navigationStub) + style.set(StyleAttributes.NAVIGATABLE_NODE, (typeDeclaration as PlatformElement).node) return } } @@ -406,14 +406,14 @@ class FBTypeEditCellComponent( } override fun paintTrace(g: Graphics2D, x: Int, y: Int) { - val shape = getComponentShape(x, y) + val shape = getComponentShape(x, rootCell.y) g.paint = MPSColors.GRAY FBConnectionPathPainter.setupShadowPathPaint(g, scale(1).toFloat()) g.draw(shape) } private fun getPortBounds(port: Port, isOutput: Boolean = false): Rectangle { - val editablePort = port as PortWithEditableLabel + val editablePort = port as EditablePortLabel val width = editablePort.label.width + scale(INNER_BORDER_PADDING) val y = editablePort.label.y - rootCell.y @@ -513,7 +513,7 @@ class FBTypeEditCellComponent( private const val PLUS_BUTTON_SIZE = 15 private fun portsColumnWidth(ports: Collection): Int { - return ports.maxOfOrNull { if (it is PortWithLabelAndType) it.cell.width else (it as PortWithEditableLabel).label.width } + return ports.maxOfOrNull { if (it is EditablePortWithTypeAndLabel) it.cell.width else (it as EditablePortLabel).label.width } ?: 0 } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/EditablePortLabel.kt similarity index 96% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/EditablePortLabel.kt index 769de6097..96f883855 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithEditableLabel.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/EditablePortLabel.kt @@ -9,7 +9,7 @@ import org.fbme.lib.common.Declaration import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.jetbrains.mps.openapi.model.SNode -open class PortWithEditableLabel( +open class EditablePortLabel( context: EditorContext, node: SNode, port: FBPortDescriptor, diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithLabelAndType.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/EditablePortWithTypeAndLabel.kt similarity index 96% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithLabelAndType.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/EditablePortWithTypeAndLabel.kt index d203559d1..1683e6e09 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortWithLabelAndType.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/EditablePortWithTypeAndLabel.kt @@ -17,14 +17,14 @@ import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.scenes.viewmodel.CompletionItem import org.jetbrains.mps.openapi.model.SNode -class PortWithLabelAndType( +class EditablePortWithTypeAndLabel( context: EditorContext, node: SNode, port: FBPortDescriptor, val declaration: Declaration?, typeName: String?, items: List, -) : PortWithEditableLabel(context, node, port, declaration) { +) : EditablePortLabel(context, node, port, declaration) { val cell: EditorCell_Collection val typeLabel: EditorCell_SceneLabel diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/editor/RichEditorStyleAttributes.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/editor/RichEditorStyleAttributes.kt index 23a4eff54..69e3d1d02 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/editor/RichEditorStyleAttributes.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/editor/RichEditorStyleAttributes.kt @@ -2,13 +2,11 @@ package org.fbme.ide.richediting.editor import jetbrains.mps.editor.runtime.style.InheritableStyleAttribute import jetbrains.mps.editor.runtime.style.SimpleStyleAttribute -import jetbrains.mps.nodeEditor.cells.EditorCell_Collection import jetbrains.mps.openapi.editor.style.StyleAttribute import org.fbme.ide.richediting.adapters.ecc.cell.ActionBlock import org.fbme.ide.richediting.inspections.NetworkInspectionsFacility +import org.fbme.ide.richediting.viewmodel.FunctionBlockView import org.fbme.ide.richediting.viewmodel.NetworkComponentView -import org.fbme.lib.iec61499.declarations.AlgorithmDeclaration -import org.fbme.lib.iec61499.declarations.EventDeclaration import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.descriptors.FBTypeDescriptor import org.fbme.lib.iec61499.ecc.ECC @@ -18,10 +16,11 @@ import org.fbme.lib.iec61499.fbnetwork.FBNetwork import org.fbme.lib.iec61499.fbnetwork.FunctionBlockDeclarationBase import org.fbme.lib.iec61499.instances.NetworkInstance import org.fbme.scenes.controllers.SceneViewpoint -import org.fbme.scenes.controllers.SelectionModel import org.fbme.scenes.controllers.components.ComponentsFacility import org.fbme.scenes.controllers.diagram.ConnectionsFacility import org.fbme.scenes.controllers.diagram.DiagramFacility +import org.fbme.scenes.controllers.edited.EditedModel +import org.fbme.scenes.controllers.selection.SelectionModel object RichEditorStyleAttributes { @JvmField @@ -42,6 +41,9 @@ object RichEditorStyleAttributes { @JvmField val SELECTED_FBS: StyleAttribute> = InheritableStyleAttribute("selected-fbs") + @JvmField + val EDITED_FBS: StyleAttribute> = InheritableStyleAttribute("edited-fbs") + @JvmField val STATE_ACTION: StyleAttribute = InheritableStyleAttribute("state-action") @@ -80,6 +82,7 @@ object RichEditorStyleAttributes { TYPE.register() FB.register() SELECTED_FBS.register() + EDITED_FBS.register() STATE_ACTION.register() ACTIONS.register() STATE_DECLARATION.register() diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockPortView.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockPortView.kt index a3e40f63a..3aeabedea 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockPortView.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockPortView.kt @@ -7,6 +7,6 @@ data class FunctionBlockPortView( override val component: FunctionBlockView, val position: Int, override val kind: EntryKind, - val isSource: Boolean, - val target: Declaration -) : NetworkPortView + override val isSource: Boolean, + override val target: Declaration +) : NetworkPortViewAdd diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockView.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockView.kt index 1c6b08c02..9691167f4 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockView.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockView.kt @@ -7,7 +7,7 @@ import org.jetbrains.mps.openapi.model.SNode class FunctionBlockView(val component: FunctionBlockDeclarationBase, isEditable: Boolean) : NetworkComponentView { val associatedNode: SNode = (component as PlatformElement).node - private val myTypeDescriptor: TypeDescriptorAdapter + private val myTypeDescriptor: TypeDescriptorAdapter = TypeDescriptorAdapter(component.type) override val isEditable: Boolean val type: FBTypeDescriptor @@ -30,7 +30,6 @@ class FunctionBlockView(val component: FunctionBlockDeclarationBase, isEditable: } init { - myTypeDescriptor = TypeDescriptorAdapter(component.type) this.isEditable = isEditable } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/InterfaceEndpointView.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/InterfaceEndpointView.kt index 4ce344fd4..9ff2dec6b 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/InterfaceEndpointView.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/InterfaceEndpointView.kt @@ -11,9 +11,9 @@ data class InterfaceEndpointView( private val endpointCoordinate: EndpointCoordinate, val position: Int, override val kind: EntryKind, - val isSource: Boolean, - val target: Declaration -) : NetworkComponentView, NetworkPortView { + override val isSource: Boolean, + override val target: Declaration +) : NetworkComponentView, NetworkPortViewAdd { val associatedNode = (target as PlatformElement).node val name = target.name diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/NetworkPortView.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/NetworkPortView.kt index 8023eb8c7..d88c693a0 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/NetworkPortView.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/NetworkPortView.kt @@ -1,8 +1,14 @@ package org.fbme.ide.richediting.viewmodel +import org.fbme.lib.common.Declaration import org.fbme.lib.iec61499.fbnetwork.EntryKind interface NetworkPortView { val kind: EntryKind val component: NetworkComponentView } + +interface NetworkPortViewAdd: NetworkPortView { + val isSource: Boolean + val target: Declaration +} diff --git a/code/richediting/src/main/resources/META-INF/plugin.xml b/code/richediting/src/main/resources/META-INF/plugin.xml index ae49df50a..23ac59fa6 100644 --- a/code/richediting/src/main/resources/META-INF/plugin.xml +++ b/code/richediting/src/main/resources/META-INF/plugin.xml @@ -11,6 +11,7 @@ + @@ -32,6 +33,15 @@ + + + diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/DefaultSelectionModel.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/DefaultSelectionModel.kt index 8288ccf17..8309178ef 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/DefaultSelectionModel.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/DefaultSelectionModel.kt @@ -1,5 +1,7 @@ package org.fbme.scenes.controllers +import org.fbme.scenes.controllers.selection.SelectionModelBase + class DefaultSelectionModel : SelectionModelBase() { override val selectedComponents: MutableSet = HashSet() diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt index 759ce6546..08212d02f 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/components/ComponentsFacility.kt @@ -6,21 +6,22 @@ import jetbrains.mps.openapi.editor.cells.CellAction import jetbrains.mps.openapi.editor.cells.CellActionType import org.fbme.scenes.controllers.* import org.fbme.scenes.controllers.scene.* +import org.fbme.scenes.controllers.selection.SelectionModel import org.fbme.scenes.viewmodel.ComponentsView import java.awt.Graphics2D import java.awt.Point import java.awt.Rectangle class ComponentsFacility( - val editor: SceneEditor, - val view: ComponentsView, - val controllerFactory: ComponentControllerFactory, - val componentSynchronizer: ComponentSynchronizer, - val layout: LayoutModel, - val selection: SelectionModel, - val sceneFocus: SceneFocusModel, - componentsLayer: Layer, - tracesLayer: Layer + val editor: SceneEditor, + val view: ComponentsView, + val controllerFactory: ComponentControllerFactory, + val componentSynchronizer: ComponentSynchronizer, + val layout: LayoutModel, + val selection: SelectionModel, + val sceneFocus: SceneFocusModel, + componentsLayer: Layer, + tracesLayer: Layer ) { var components: MutableMap> = HashMap() diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt index 55562d300..60d1ebe10 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt @@ -8,6 +8,7 @@ import jetbrains.mps.openapi.editor.cells.CellActionType import org.fbme.scenes.controllers.* import org.fbme.scenes.controllers.diagram.entry.ConnectionEntry import org.fbme.scenes.controllers.scene.* +import org.fbme.scenes.controllers.selection.SelectionModel import java.awt.Graphics import java.awt.Graphics2D import java.awt.Point @@ -17,17 +18,17 @@ import java.util.function.BiFunction import java.util.function.Function class ConnectionsFacility( - val scene: SceneEditor, - val controllerFactory: ConnectionControllerFactory, - private val newPathFactory: BiFunction, - private val newPathPainter: BiConsumer, - val connectionSynchronizer: ConnectionPathSynchronizer, - componentsLayout: ROLayoutModel, - val componentsSelection: SelectionModel, - val diagramController: DiagramController, - connectionsLayer: Layer, - tracesLayer: Layer, - val sceneFocus: SceneFocusModel + val scene: SceneEditor, + val controllerFactory: ConnectionControllerFactory, + private val newPathFactory: BiFunction, + private val newPathPainter: BiConsumer, + val connectionSynchronizer: ConnectionPathSynchronizer, + componentsLayout: ROLayoutModel, + val componentsSelection: SelectionModel, + val diagramController: DiagramController, + connectionsLayer: Layer, + tracesLayer: Layer, + val sceneFocus: SceneFocusModel ) { private val connections: MutableMap> = HashMap() val connectionsSelection: MutableSet = HashSet() diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt index 41be21476..9a9bc5cf9 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt @@ -3,7 +3,6 @@ package org.fbme.scenes.controllers.diagram import org.fbme.scenes.controllers.diagram.entry.PortEntry import org.fbme.scenes.controllers.diagram.entry.PortTemplateEntry - class DiagramFacility( private val diagramModel: DiagramView, private val portSettingProvider: PortSettingProvider, diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/edited/EditedModel.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/edited/EditedModel.kt new file mode 100644 index 000000000..5ca73b604 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/edited/EditedModel.kt @@ -0,0 +1,9 @@ +package org.fbme.scenes.controllers.edited + +interface EditedModel { + val editedComponents: List + + fun setEdited(component: T, edited: Boolean) + + fun isEdited(component: T): Boolean +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/SelectionModel.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/selection/SelectionModel.kt similarity index 90% rename from code/scenes/src/main/kotlin/org/fbme/scenes/controllers/SelectionModel.kt rename to code/scenes/src/main/kotlin/org/fbme/scenes/controllers/selection/SelectionModel.kt index e17db034b..a6c19b6e6 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/SelectionModel.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/selection/SelectionModel.kt @@ -1,4 +1,4 @@ -package org.fbme.scenes.controllers +package org.fbme.scenes.controllers.selection interface SelectionModel { val selectedComponents: Set diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/SelectionModelBase.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/selection/SelectionModelBase.kt similarity index 92% rename from code/scenes/src/main/kotlin/org/fbme/scenes/controllers/SelectionModelBase.kt rename to code/scenes/src/main/kotlin/org/fbme/scenes/controllers/selection/SelectionModelBase.kt index e66578afa..150f9707d 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/SelectionModelBase.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/selection/SelectionModelBase.kt @@ -1,4 +1,4 @@ -package org.fbme.scenes.controllers +package org.fbme.scenes.controllers.selection abstract class SelectionModelBase : SelectionModel { private val listeners: MutableSet> = HashSet() From 6807b434c3a00292a1d1f12672daecdc8e722f62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sat, 27 May 2023 12:36:47 +0200 Subject: [PATCH 14/66] Fix connections issue --- .../fbnetwork/actions/ChangeTypeAction.kt | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt index 3f3a15a77..81befb9d2 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt @@ -8,11 +8,15 @@ import jetbrains.mps.project.MPSProject import org.fbme.ide.iec61499.repository.PlatformElement import org.fbme.ide.iec61499.repository.PlatformRepositoryProvider import org.fbme.ide.richediting.viewmodel.FunctionBlockView +import org.fbme.lib.common.CompositeReference import org.fbme.lib.common.Identifier import org.fbme.lib.common.StringIdentifier import org.fbme.lib.iec61499.declarations.BasicFBTypeDeclaration import org.fbme.lib.iec61499.declarations.CompositeFBTypeDeclaration import org.fbme.lib.iec61499.declarations.FBTypeDeclaration +import org.fbme.lib.iec61499.fbnetwork.EntryKind +import org.fbme.lib.iec61499.fbnetwork.FunctionBlockDeclarationBase +import org.fbme.lib.iec61499.fbnetwork.PortPath class ChangeTypeAction(cell: EditorCell, val project: MPSProject) : FBNetworkAction(cell) { fun apply() { @@ -65,6 +69,21 @@ class ChangeTypeAction(cell: EditorCell, val project: MPSProject) : FBNetworkAct if (oldFB.component.type.typeName == it.type.typeName) createdDeclaration else it } + network.eventConnections.forEach { + it.sourceReference.updateTarget(oldFB.component, createdDeclaration, EntryKind.EVENT) + it.targetReference.updateTarget(oldFB.component, createdDeclaration, EntryKind.EVENT) + } + + network.dataConnections.forEach { + it.sourceReference.updateTarget(oldFB.component, createdDeclaration, EntryKind.DATA) + it.targetReference.updateTarget(oldFB.component, createdDeclaration, EntryKind.DATA) + } + + network.adapterConnections.forEach { + it.sourceReference.updateTarget(oldFB.component, createdDeclaration, EntryKind.ADAPTER) + it.targetReference.updateTarget(oldFB.component, createdDeclaration, EntryKind.ADAPTER) + } + oldDeclaration.inputEvents.copyTo(type.inputEvents) oldDeclaration.outputEvents.copyTo(type.outputEvents) oldDeclaration.inputParameters.copyTo(type.inputParameters) @@ -85,6 +104,18 @@ class ChangeTypeAction(cell: EditorCell, val project: MPSProject) : FBNetworkAct } } + private fun CompositeReference>.updateTarget( + old: FunctionBlockDeclarationBase, + created: FunctionBlockDeclarationBase, + kind: EntryKind + ) { + val target = this.getTarget() ?: return + + if (target.functionBlock?.equals(old) == true) { + this.setTarget(PortPath.createPortPath(created, kind, target.portTarget)) + } + } + private fun convertToBasicFB(funBlock: FunctionBlockView, declaration: CompositeFBTypeDeclaration) { val repository = PlatformRepositoryProvider.getInstance(project) val factory = repository.iec61499Factory @@ -111,4 +142,4 @@ class ChangeTypeAction(cell: EditorCell, val project: MPSProject) : FBNetworkAct const val CANT_GET_FB_CELL = "Couldn't find functional block!" const val TMP_SUFFIX = "_tmp" } -} \ No newline at end of file +} From 2262a0ee6a5df603536aed8c5d9bea72f9216ca5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sat, 27 May 2023 13:03:36 +0200 Subject: [PATCH 15/66] Refactor action folder --- .../actions/{ => ecc}/AddStateActionAction.kt | 3 +- .../AlgorithmBodyVisibilityAction.kt | 3 +- .../AllAlgorithmBodyVisibilityAction.kt | 4 ++- .../AllStateActionVisibilityAction.kt | 4 ++- .../{ => ecc}/ChangeAlgorithmAction.kt | 4 +-- .../{ => ecc}/ChangeAlgorithmActionGroup.kt | 4 ++- .../actions/{ => ecc}/ChangeOutputAction.kt | 4 +-- .../{ => ecc}/ChangeOutputActionGroup.kt | 4 ++- .../{ => ecc}/DeleteStateActionAction.kt | 3 +- .../actions/{ => ecc}/NewAlgorithmAction.kt | 3 +- .../{ => network}/AddConstantToPortAction.kt | 4 ++- .../actions/{ => network}/ChangeTypeAction.kt | 3 +- .../{ => network/expand}/CollapseAction.kt | 3 +- .../{ => network/expand}/ExpandAction.kt | 3 +- .../src/main/resources/META-INF/plugin.xml | 32 +++++++++---------- 15 files changed, 49 insertions(+), 32 deletions(-) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/{ => ecc}/AddStateActionAction.kt (90%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/{ => ecc}/AlgorithmBodyVisibilityAction.kt (94%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/{ => ecc}/AllAlgorithmBodyVisibilityAction.kt (91%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/{ => ecc}/AllStateActionVisibilityAction.kt (90%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/{ => ecc}/ChangeAlgorithmAction.kt (89%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/{ => ecc}/ChangeAlgorithmActionGroup.kt (89%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/{ => ecc}/ChangeOutputAction.kt (90%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/{ => ecc}/ChangeOutputActionGroup.kt (88%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/{ => ecc}/DeleteStateActionAction.kt (89%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/{ => ecc}/NewAlgorithmAction.kt (94%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/{ => network}/AddConstantToPortAction.kt (90%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/{ => network}/ChangeTypeAction.kt (96%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/{ => network/expand}/CollapseAction.kt (84%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/{ => network/expand}/ExpandAction.kt (84%) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AddStateActionAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/AddStateActionAction.kt similarity index 90% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AddStateActionAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/AddStateActionAction.kt index ca929c094..01ae02b3f 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AddStateActionAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/AddStateActionAction.kt @@ -1,10 +1,11 @@ -package org.fbme.ide.richediting.actions +package org.fbme.ide.richediting.actions.ecc import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys import org.fbme.ide.iec61499.repository.PlatformRepositoryProvider +import org.fbme.ide.richediting.actions.executeWriteActionInEditor import org.fbme.ide.richediting.editor.RichEditorStyleAttributes class AddStateActionAction : AnAction(), DumbAware { diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AlgorithmBodyVisibilityAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/AlgorithmBodyVisibilityAction.kt similarity index 94% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AlgorithmBodyVisibilityAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/AlgorithmBodyVisibilityAction.kt index 08b6be3f1..a00f26dc9 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AlgorithmBodyVisibilityAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/AlgorithmBodyVisibilityAction.kt @@ -1,9 +1,10 @@ -package org.fbme.ide.richediting.actions +package org.fbme.ide.richediting.actions.ecc import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys +import org.fbme.ide.richediting.actions.executeReadActionInEditor import org.fbme.ide.richediting.adapters.ecc.ECCEditors import org.fbme.ide.richediting.adapters.ecc.cell.AlgorithmCell import org.fbme.ide.richediting.editor.RichEditorStyleAttributes diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AllAlgorithmBodyVisibilityAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/AllAlgorithmBodyVisibilityAction.kt similarity index 91% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AllAlgorithmBodyVisibilityAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/AllAlgorithmBodyVisibilityAction.kt index 88a47abe2..0bf0aa4b4 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AllAlgorithmBodyVisibilityAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/AllAlgorithmBodyVisibilityAction.kt @@ -1,9 +1,11 @@ -package org.fbme.ide.richediting.actions +package org.fbme.ide.richediting.actions.ecc import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys +import org.fbme.ide.richediting.actions.element +import org.fbme.ide.richediting.actions.executeReadActionInEditor import org.fbme.ide.richediting.adapters.ecc.ECCEditors import org.fbme.lib.iec61499.declarations.BasicFBTypeDeclaration import org.fbme.scenes.cells.EditorCell_Scene diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AllStateActionVisibilityAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/AllStateActionVisibilityAction.kt similarity index 90% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AllStateActionVisibilityAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/AllStateActionVisibilityAction.kt index c1105e8a8..1c3b142ff 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AllStateActionVisibilityAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/AllStateActionVisibilityAction.kt @@ -1,9 +1,11 @@ -package org.fbme.ide.richediting.actions +package org.fbme.ide.richediting.actions.ecc import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys +import org.fbme.ide.richediting.actions.element +import org.fbme.ide.richediting.actions.executeReadActionInEditor import org.fbme.ide.richediting.adapters.ecc.ECCEditors import org.fbme.lib.iec61499.declarations.BasicFBTypeDeclaration import org.fbme.scenes.cells.EditorCell_Scene diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeAlgorithmAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/ChangeAlgorithmAction.kt similarity index 89% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeAlgorithmAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/ChangeAlgorithmAction.kt index 604e09e3e..b6e5766e6 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeAlgorithmAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/ChangeAlgorithmAction.kt @@ -1,10 +1,10 @@ -package org.fbme.ide.richediting.actions +package org.fbme.ide.richediting.actions.ecc import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys -import org.fbme.ide.richediting.adapters.ecc.cell.AlgorithmCell +import org.fbme.ide.richediting.actions.executeWriteActionInEditor import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.lib.iec61499.declarations.AlgorithmDeclaration diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeAlgorithmActionGroup.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/ChangeAlgorithmActionGroup.kt similarity index 89% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeAlgorithmActionGroup.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/ChangeAlgorithmActionGroup.kt index 413785574..89962d1de 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeAlgorithmActionGroup.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/ChangeAlgorithmActionGroup.kt @@ -1,10 +1,12 @@ -package org.fbme.ide.richediting.actions +package org.fbme.ide.richediting.actions.ecc import com.intellij.openapi.actionSystem.ActionGroup import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys +import org.fbme.ide.richediting.actions.element +import org.fbme.ide.richediting.actions.executeReadAction import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.lib.iec61499.declarations.BasicFBTypeDeclaration diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeOutputAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/ChangeOutputAction.kt similarity index 90% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeOutputAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/ChangeOutputAction.kt index d74c99be2..bc5c616f2 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeOutputAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/ChangeOutputAction.kt @@ -1,10 +1,10 @@ -package org.fbme.ide.richediting.actions +package org.fbme.ide.richediting.actions.ecc import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys -import org.fbme.ide.richediting.adapters.ecc.cell.AlgorithmCell +import org.fbme.ide.richediting.actions.executeWriteActionInEditor import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.lib.iec61499.declarations.EventDeclaration import org.fbme.lib.iec61499.fbnetwork.PortPath.Companion.createEventPortPath diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeOutputActionGroup.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/ChangeOutputActionGroup.kt similarity index 88% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeOutputActionGroup.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/ChangeOutputActionGroup.kt index ee529190d..d7a7bea69 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeOutputActionGroup.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/ChangeOutputActionGroup.kt @@ -1,10 +1,12 @@ -package org.fbme.ide.richediting.actions +package org.fbme.ide.richediting.actions.ecc import com.intellij.openapi.actionSystem.ActionGroup import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys +import org.fbme.ide.richediting.actions.element +import org.fbme.ide.richediting.actions.executeReadAction import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.lib.iec61499.declarations.BasicFBTypeDeclaration diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/DeleteStateActionAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/DeleteStateActionAction.kt similarity index 89% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/DeleteStateActionAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/DeleteStateActionAction.kt index 48cc64d00..1ec743667 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/DeleteStateActionAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/DeleteStateActionAction.kt @@ -1,9 +1,10 @@ -package org.fbme.ide.richediting.actions +package org.fbme.ide.richediting.actions.ecc import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys +import org.fbme.ide.richediting.actions.executeWriteActionInEditor import org.fbme.ide.richediting.editor.RichEditorStyleAttributes class DeleteStateActionAction : AnAction(), DumbAware { diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/NewAlgorithmAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/NewAlgorithmAction.kt similarity index 94% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/NewAlgorithmAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/NewAlgorithmAction.kt index 87b5610ab..a54195725 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/NewAlgorithmAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ecc/NewAlgorithmAction.kt @@ -1,10 +1,11 @@ -package org.fbme.ide.richediting.actions +package org.fbme.ide.richediting.actions.ecc import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys import org.fbme.ide.iec61499.repository.PlatformRepositoryProvider +import org.fbme.ide.richediting.actions.executeWriteActionInEditor import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.lib.common.StringIdentifier import org.fbme.lib.iec61499.declarations.AlgorithmLanguage diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AddConstantToPortAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AddConstantToPortAction.kt similarity index 90% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AddConstantToPortAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AddConstantToPortAction.kt index a7fbd6ae7..bc8f2ae5b 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/AddConstantToPortAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AddConstantToPortAction.kt @@ -1,10 +1,12 @@ -package org.fbme.ide.richediting.actions +package org.fbme.ide.richediting.actions.network import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys import org.fbme.ide.iec61499.repository.PlatformElement +import org.fbme.ide.richediting.actions.executeWriteActionInEditor +import org.fbme.ide.richediting.actions.repository import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.lib.iec61499.declarations.ParameterDeclaration import org.fbme.lib.iec61499.fbnetwork.EntryKind diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeTypeAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/ChangeTypeAction.kt similarity index 96% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeTypeAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/ChangeTypeAction.kt index 05332dc55..c2352fa6c 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ChangeTypeAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/ChangeTypeAction.kt @@ -1,9 +1,10 @@ -package org.fbme.ide.richediting.actions +package org.fbme.ide.richediting.actions.network import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys +import org.fbme.ide.richediting.actions.modelAccess import org.fbme.ide.richediting.adapters.fbnetwork.actions.ChangeTypeAction import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.lib.iec61499.declarations.BasicFBTypeDeclaration diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/CollapseAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/CollapseAction.kt similarity index 84% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/CollapseAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/CollapseAction.kt index 3d40e4d28..274f5cb76 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/CollapseAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/CollapseAction.kt @@ -1,9 +1,10 @@ -package org.fbme.ide.richediting.actions +package org.fbme.ide.richediting.actions.network.expand import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys +import org.fbme.ide.richediting.actions.executeReadActionInEditor import org.fbme.ide.richediting.adapters.fbnetwork.actions.CollapseAction class CollapseAction : AnAction(), DumbAware { diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ExpandAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/ExpandAction.kt similarity index 84% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ExpandAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/ExpandAction.kt index f8b074dee..2835dd0e4 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/ExpandAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/ExpandAction.kt @@ -1,9 +1,10 @@ -package org.fbme.ide.richediting.actions +package org.fbme.ide.richediting.actions.network.expand import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys +import org.fbme.ide.richediting.actions.executeReadActionInEditor import org.fbme.ide.richediting.adapters.fbnetwork.actions.ExpandAction class ExpandAction : AnAction(), DumbAware { diff --git a/code/richediting/src/main/resources/META-INF/plugin.xml b/code/richediting/src/main/resources/META-INF/plugin.xml index 23ac59fa6..13f9f662b 100644 --- a/code/richediting/src/main/resources/META-INF/plugin.xml +++ b/code/richediting/src/main/resources/META-INF/plugin.xml @@ -17,56 +17,56 @@ + class="org.fbme.ide.richediting.actions.ecc.AlgorithmBodyVisibilityAction"/> From 0e4fde5c17ecac8f3aa011993590dbd912b7c9c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sat, 27 May 2023 13:38:10 +0200 Subject: [PATCH 16/66] Extract abstract class --- .../actions/network/AbstractEditFBAction.kt | 43 +++++++++++++++++++ .../actions/network/ChangeTypeAction.kt | 39 ++++++----------- .../actions/network/CreateViewAction.kt | 17 ++++++++ .../fbnetwork/actions/ChangeTypeAction.kt | 7 +-- .../fbme/ide/richediting/utils/Notifier.kt | 17 ++++++++ .../src/main/resources/META-INF/plugin.xml | 6 +-- 6 files changed, 94 insertions(+), 35 deletions(-) create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AbstractEditFBAction.kt create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AbstractEditFBAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AbstractEditFBAction.kt new file mode 100644 index 000000000..6ba73629a --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AbstractEditFBAction.kt @@ -0,0 +1,43 @@ +package org.fbme.ide.richediting.actions.network + +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.project.DumbAware +import jetbrains.mps.ide.editor.MPSEditorDataKeys +import jetbrains.mps.openapi.editor.cells.EditorCell +import jetbrains.mps.project.MPSProject +import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.ide.richediting.viewmodel.FunctionBlockView + +abstract class AbstractEditFBAction: AnAction(), DumbAware { + override fun update(event: AnActionEvent) { + val project = event.getData(MPSEditorDataKeys.MPS_PROJECT) + val cell = event.getData(MPSEditorDataKeys.EDITOR_CELL) + + if (project == null || cell == null) { + notApplicable(event) + return + } + + val editedFBS = cell.style.get(RichEditorStyleAttributes.EDITED_FBS).editedComponents + val fbCell = editedFBS.find { it.associatedNode == cell.sNode } + + if (fbCell == null) { + notApplicable(event) + return + } + + internalConditionCheck(event, fbCell, cell, project) + } + + protected abstract fun internalConditionCheck( + event: AnActionEvent, + fbCell: FunctionBlockView, + cell: EditorCell, + project: MPSProject + ) + + protected fun notApplicable(event: AnActionEvent) { + event.presentation.isEnabledAndVisible = false + } +} diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/ChangeTypeAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/ChangeTypeAction.kt index c2352fa6c..b6fda17f1 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/ChangeTypeAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/ChangeTypeAction.kt @@ -1,33 +1,22 @@ package org.fbme.ide.richediting.actions.network -import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys +import jetbrains.mps.openapi.editor.cells.EditorCell +import jetbrains.mps.project.MPSProject import org.fbme.ide.richediting.actions.modelAccess import org.fbme.ide.richediting.adapters.fbnetwork.actions.ChangeTypeAction -import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.ide.richediting.viewmodel.FunctionBlockView import org.fbme.lib.iec61499.declarations.BasicFBTypeDeclaration import org.fbme.lib.iec61499.declarations.CompositeFBTypeDeclaration -class ChangeTypeAction : AnAction(), DumbAware { - override fun update(event: AnActionEvent) { - val project = event.getData(MPSEditorDataKeys.MPS_PROJECT) - val cell = event.getData(MPSEditorDataKeys.EDITOR_CELL) - - if (project == null || cell == null) { - notApplicable(event) - return - } - - val editedFBS = cell.style.get(RichEditorStyleAttributes.EDITED_FBS).editedComponents - val fbCell = editedFBS.find { it.associatedNode == cell.sNode } - - if (fbCell == null) { - notApplicable(event) - return - } - +class ChangeTypeAction : AbstractEditFBAction() { + override fun internalConditionCheck( + event: AnActionEvent, + fbCell: FunctionBlockView, + cell: EditorCell, + project: MPSProject + ) { when (val declaration = fbCell.type.declaration) { is CompositeFBTypeDeclaration -> { event.presentation.text = TO_BASIC_FB_TYPE @@ -46,7 +35,7 @@ class ChangeTypeAction : AnAction(), DumbAware { } private fun checkBasicBlock(declaration: BasicFBTypeDeclaration): Boolean { - if (declaration.ecc.states.isNotEmpty()) { + if (declaration.ecc.states.size > 1) { return false } @@ -61,10 +50,6 @@ class ChangeTypeAction : AnAction(), DumbAware { return declaration.network.allComponents.isEmpty() } - private fun notApplicable(event: AnActionEvent) { - event.presentation.isEnabledAndVisible = false - } - override fun actionPerformed(event: AnActionEvent) { event.modelAccess.executeCommandInEDT { ChangeTypeAction( @@ -78,4 +63,4 @@ class ChangeTypeAction : AnAction(), DumbAware { const val TO_BASIC_FB_TYPE = "Change type to basic" const val TO_COMPOSITE_FB_TYPE = "Change type to composite" } -} \ No newline at end of file +} diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt new file mode 100644 index 000000000..4976d96bd --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt @@ -0,0 +1,17 @@ +package org.fbme.ide.richediting.actions.network + +import com.intellij.openapi.actionSystem.AnAction +import com.intellij.openapi.actionSystem.AnActionEvent +import com.intellij.openapi.project.DumbAware +import jetbrains.mps.ide.editor.MPSEditorDataKeys +import org.fbme.ide.richediting.utils.Notifier + +class CreateViewAction : AnAction(), DumbAware { + override fun update(e: AnActionEvent) { + + } + + override fun actionPerformed(event: AnActionEvent) { + Notifier.showWarning("Boo", event.getRequiredData(MPSEditorDataKeys.MPS_PROJECT).project) + } +} \ No newline at end of file diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt index 81befb9d2..f93decf98 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt @@ -7,6 +7,7 @@ import jetbrains.mps.openapi.editor.cells.EditorCell import jetbrains.mps.project.MPSProject import org.fbme.ide.iec61499.repository.PlatformElement import org.fbme.ide.iec61499.repository.PlatformRepositoryProvider +import org.fbme.ide.richediting.utils.Notifier import org.fbme.ide.richediting.viewmodel.FunctionBlockView import org.fbme.lib.common.CompositeReference import org.fbme.lib.common.Identifier @@ -131,11 +132,7 @@ class ChangeTypeAction(cell: EditorCell, val project: MPSProject) : FBNetworkAct } private fun showNotification(message: String) { - NotificationGroupManager - .getInstance() - .getNotificationGroup("Custom") - .createNotification(message, NotificationType.WARNING) - .notify(project.project) + Notifier.showWarning(message, project.project) } companion object { diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt new file mode 100644 index 000000000..12d8b752a --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt @@ -0,0 +1,17 @@ +package org.fbme.ide.richediting.utils + +import com.intellij.notification.NotificationGroupManager +import com.intellij.notification.NotificationType +import com.intellij.openapi.project.Project + +object Notifier { + private const val NOTIFICATION_GROUP = "Custom" + + fun showWarning(message: String, project: Project) { + NotificationGroupManager + .getInstance() + .getNotificationGroup(NOTIFICATION_GROUP) + .createNotification(message, NotificationType.WARNING) + .notify(project) + } +} diff --git a/code/richediting/src/main/resources/META-INF/plugin.xml b/code/richediting/src/main/resources/META-INF/plugin.xml index 13f9f662b..0bfe91dcd 100644 --- a/code/richediting/src/main/resources/META-INF/plugin.xml +++ b/code/richediting/src/main/resources/META-INF/plugin.xml @@ -11,7 +11,7 @@ - + @@ -40,8 +40,8 @@ class="org.fbme.ide.richediting.actions.network.expand.ExpandAction" text="Extract Network"/> + class="org.fbme.ide.richediting.actions.network.CreateViewAction" + text="Create View"/> From 98b0e88d3256e2bd95e79fb2275f8437f5cf1826 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 28 May 2023 18:24:12 +0200 Subject: [PATCH 17/66] Add creating view for block --- .../models/org.fbme.debugger.plugin.mps | 5 +- .../fbme/lib/iec61499/fbnetwork/FBNetwork.kt | 23 ++++ .../fbnetwork/FunctionBlockDeclarationBase.kt | 11 ++ .../org.fbme.integration.nxt.plugin.mps | 10 +- .../org.fbme.ide.richediting.plugin.mps | 11 +- ...ditFBAction.kt => AbstractFBEditAction.kt} | 2 +- .../actions/network/ChangeTypeAction.kt | 2 +- .../actions/network/CreateViewAction.kt | 33 +++++- .../actions/network/expand/CollapseAction.kt | 7 +- .../actions/network/expand/ExpandAction.kt | 7 +- .../fbnetwork/actions/ChangeTypeAction.kt | 91 ++++----------- .../fbnetwork/actions/CreateViewAction.kt | 107 +++++++++++++++++ .../fbnetwork/actions/FBNetworkAction.kt | 8 +- .../actions/{ => expand}/CollapseAction.kt | 6 +- .../actions/{ => expand}/ExpandAction.kt | 6 +- .../fbme/ide/richediting/utils/Notifier.kt | 8 ++ .../ide/richediting/utils/ProjectProvider.kt | 29 +++++ .../utils/exceptions/CreationException.kt | 9 ++ .../utils/exceptions/FBMEException.kt | 9 ++ .../ide/richediting/utils/fb/FBFactory.kt | 48 ++++++++ .../fbme/ide/richediting/utils/fb/FBUtils.kt | 108 ++++++++++++++++++ .../src/main/resources/META-INF/plugin.xml | 2 +- 22 files changed, 442 insertions(+), 100 deletions(-) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/{AbstractEditFBAction.kt => AbstractFBEditAction.kt} (95%) create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/CreateViewAction.kt rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/{ => expand}/CollapseAction.kt (76%) rename code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/{ => expand}/ExpandAction.kt (94%) create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/ProjectProvider.kt create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/exceptions/CreationException.kt create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/exceptions/FBMEException.kt create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBFactory.kt create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBUtils.kt diff --git a/code/debugger/solutions/org.fbme.debugger/models/org.fbme.debugger.plugin.mps b/code/debugger/solutions/org.fbme.debugger/models/org.fbme.debugger.plugin.mps index 409594761..d2fce4640 100644 --- a/code/debugger/solutions/org.fbme.debugger/models/org.fbme.debugger.plugin.mps +++ b/code/debugger/solutions/org.fbme.debugger/models/org.fbme.debugger.plugin.mps @@ -38,7 +38,7 @@ - + @@ -60,6 +60,7 @@ + @@ -6202,7 +6203,7 @@ - + diff --git a/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FBNetwork.kt b/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FBNetwork.kt index e5c999aee..c94897af2 100644 --- a/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FBNetwork.kt +++ b/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FBNetwork.kt @@ -3,6 +3,7 @@ package org.fbme.lib.iec61499.fbnetwork import org.fbme.lib.common.Declaration import org.fbme.lib.common.Element import org.fbme.lib.iec61499.declarations.* +import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import java.util.* interface FBNetwork : Element { @@ -44,6 +45,28 @@ interface FBNetwork : Element { return components } + fun getAllPorts(): List { + val result: MutableList = mutableListOf() + + this.contextDataSources.forEachIndexed { index, it -> + result.add(FBPortDescriptor(it.name, EntryKind.DATA, index, true, true, it)) + } + + this.contextEventSources.forEachIndexed { index, it -> + result.add(FBPortDescriptor(it.name, EntryKind.EVENT, index, true, true, it)) + } + + this.contextDataDestinations.forEachIndexed { index, it -> + result.add(FBPortDescriptor(it.name, EntryKind.DATA, index, false, true, it)) + } + + this.contextEventDestinations.forEachIndexed { index, it -> + result.add(FBPortDescriptor(it.name, EntryKind.EVENT, index, false, true, it)) + } + + return result + } + companion object { @JvmStatic fun extractNetwork(declaration: Declaration?): FBNetwork? { diff --git a/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FunctionBlockDeclarationBase.kt b/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FunctionBlockDeclarationBase.kt index bfc3c0f79..fb794383a 100644 --- a/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FunctionBlockDeclarationBase.kt +++ b/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FunctionBlockDeclarationBase.kt @@ -26,6 +26,17 @@ interface FunctionBlockDeclarationBase : Declaration, ContainedElement { generatePorts(result, this, type.plugPorts) return result } + + fun getAllPorts(): List { + return type.eventInputPorts + .union(type.eventOutputPorts) + .union(type.dataInputPorts) + .union(type.dataOutputPorts) + .union(type.socketPorts) + .union(type.plugPorts) + .toList() + } + var x: Int var y: Int diff --git a/code/nxt-integration/solutions/org.fbme.integration.nxt/models/org.fbme.integration.nxt.plugin.mps b/code/nxt-integration/solutions/org.fbme.integration.nxt/models/org.fbme.integration.nxt.plugin.mps index f8856b44e..bbf7d07a1 100644 --- a/code/nxt-integration/solutions/org.fbme.integration.nxt/models/org.fbme.integration.nxt.plugin.mps +++ b/code/nxt-integration/solutions/org.fbme.integration.nxt/models/org.fbme.integration.nxt.plugin.mps @@ -14,7 +14,7 @@ - + @@ -46,6 +46,7 @@ + @@ -433,7 +434,7 @@ - + @@ -498,7 +499,7 @@ - + @@ -682,7 +683,7 @@ - + @@ -701,7 +702,6 @@ - diff --git a/code/richediting/solutions/org.fbme.ide.richediting/models/org.fbme.ide.richediting.plugin.mps b/code/richediting/solutions/org.fbme.ide.richediting/models/org.fbme.ide.richediting.plugin.mps index 2527e4cc0..b0a6e541b 100644 --- a/code/richediting/solutions/org.fbme.ide.richediting/models/org.fbme.ide.richediting.plugin.mps +++ b/code/richediting/solutions/org.fbme.ide.richediting/models/org.fbme.ide.richediting.plugin.mps @@ -56,8 +56,9 @@ + + - @@ -2056,7 +2057,7 @@ - + @@ -2096,7 +2097,7 @@ - + @@ -2235,7 +2236,7 @@ - + @@ -2302,7 +2303,7 @@ - + diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AbstractEditFBAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AbstractFBEditAction.kt similarity index 95% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AbstractEditFBAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AbstractFBEditAction.kt index 6ba73629a..752554c35 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AbstractEditFBAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AbstractFBEditAction.kt @@ -9,7 +9,7 @@ import jetbrains.mps.project.MPSProject import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.ide.richediting.viewmodel.FunctionBlockView -abstract class AbstractEditFBAction: AnAction(), DumbAware { +abstract class AbstractFBEditAction: AnAction(), DumbAware { override fun update(event: AnActionEvent) { val project = event.getData(MPSEditorDataKeys.MPS_PROJECT) val cell = event.getData(MPSEditorDataKeys.EDITOR_CELL) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/ChangeTypeAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/ChangeTypeAction.kt index b6fda17f1..a73254685 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/ChangeTypeAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/ChangeTypeAction.kt @@ -10,7 +10,7 @@ import org.fbme.ide.richediting.viewmodel.FunctionBlockView import org.fbme.lib.iec61499.declarations.BasicFBTypeDeclaration import org.fbme.lib.iec61499.declarations.CompositeFBTypeDeclaration -class ChangeTypeAction : AbstractEditFBAction() { +class ChangeTypeAction : AbstractFBEditAction() { override fun internalConditionCheck( event: AnActionEvent, fbCell: FunctionBlockView, diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt index 4976d96bd..1f9bc129f 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt @@ -1,17 +1,38 @@ package org.fbme.ide.richediting.actions.network -import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys -import org.fbme.ide.richediting.utils.Notifier +import jetbrains.mps.openapi.editor.cells.EditorCell +import jetbrains.mps.project.MPSProject +import org.fbme.ide.richediting.actions.modelAccess +import org.fbme.ide.richediting.adapters.fbnetwork.actions.CreateViewAction +import org.fbme.ide.richediting.viewmodel.FunctionBlockView +import org.fbme.lib.iec61499.declarations.CompositeFBTypeDeclaration -class CreateViewAction : AnAction(), DumbAware { - override fun update(e: AnActionEvent) { +class CreateViewAction : AbstractFBEditAction() { + override fun internalConditionCheck( + event: AnActionEvent, + fbCell: FunctionBlockView, + cell: EditorCell, + project: MPSProject + ) { + when (fbCell.type.declaration) { + is CompositeFBTypeDeclaration -> { + event.presentation.isEnabled = false + } + else -> { + event.presentation.isEnabled = true + } + } } override fun actionPerformed(event: AnActionEvent) { - Notifier.showWarning("Boo", event.getRequiredData(MPSEditorDataKeys.MPS_PROJECT).project) + event.modelAccess.executeCommandInEDT { + CreateViewAction( + event.getRequiredData(MPSEditorDataKeys.EDITOR_CELL), + event.getRequiredData(MPSEditorDataKeys.MPS_PROJECT) + ).apply() + } } } \ No newline at end of file diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/CollapseAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/CollapseAction.kt index 274f5cb76..a080b7eee 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/CollapseAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/CollapseAction.kt @@ -5,7 +5,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys import org.fbme.ide.richediting.actions.executeReadActionInEditor -import org.fbme.ide.richediting.adapters.fbnetwork.actions.CollapseAction +import org.fbme.ide.richediting.adapters.fbnetwork.actions.expand.CollapseAction class CollapseAction : AnAction(), DumbAware { @@ -15,7 +15,10 @@ class CollapseAction : AnAction(), DumbAware { override fun actionPerformed(event: AnActionEvent) { event.executeReadActionInEditor { - CollapseAction(event.getRequiredData(MPSEditorDataKeys.EDITOR_CELL)).apply() + CollapseAction( + event.getRequiredData(MPSEditorDataKeys.EDITOR_CELL), + event.getRequiredData(MPSEditorDataKeys.MPS_PROJECT) + ).apply() } } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/ExpandAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/ExpandAction.kt index 2835dd0e4..c6e2a026f 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/ExpandAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/ExpandAction.kt @@ -5,7 +5,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys import org.fbme.ide.richediting.actions.executeReadActionInEditor -import org.fbme.ide.richediting.adapters.fbnetwork.actions.ExpandAction +import org.fbme.ide.richediting.adapters.fbnetwork.actions.expand.ExpandAction class ExpandAction : AnAction(), DumbAware { @@ -15,7 +15,10 @@ class ExpandAction : AnAction(), DumbAware { override fun actionPerformed(event: AnActionEvent) { event.executeReadActionInEditor { - ExpandAction(event.getRequiredData(MPSEditorDataKeys.EDITOR_CELL)).apply() + ExpandAction( + event.getRequiredData(MPSEditorDataKeys.EDITOR_CELL), + event.getRequiredData(MPSEditorDataKeys.MPS_PROJECT) + ).apply() } } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt index f93decf98..8bcbbb6ac 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ChangeTypeAction.kt @@ -1,25 +1,22 @@ package org.fbme.ide.richediting.adapters.fbnetwork.actions -import com.intellij.notification.NotificationGroupManager -import com.intellij.notification.NotificationType import com.intellij.util.alsoIfNull +import jetbrains.mps.openapi.editor.EditorContext import jetbrains.mps.openapi.editor.cells.EditorCell import jetbrains.mps.project.MPSProject import org.fbme.ide.iec61499.repository.PlatformElement import org.fbme.ide.iec61499.repository.PlatformRepositoryProvider import org.fbme.ide.richediting.utils.Notifier +import org.fbme.ide.richediting.utils.exceptions.CreationException +import org.fbme.ide.richediting.utils.fb.FBFactory +import org.fbme.ide.richediting.utils.fb.FBUtils import org.fbme.ide.richediting.viewmodel.FunctionBlockView -import org.fbme.lib.common.CompositeReference -import org.fbme.lib.common.Identifier import org.fbme.lib.common.StringIdentifier import org.fbme.lib.iec61499.declarations.BasicFBTypeDeclaration import org.fbme.lib.iec61499.declarations.CompositeFBTypeDeclaration import org.fbme.lib.iec61499.declarations.FBTypeDeclaration -import org.fbme.lib.iec61499.fbnetwork.EntryKind -import org.fbme.lib.iec61499.fbnetwork.FunctionBlockDeclarationBase -import org.fbme.lib.iec61499.fbnetwork.PortPath -class ChangeTypeAction(cell: EditorCell, val project: MPSProject) : FBNetworkAction(cell) { +class ChangeTypeAction(cell: EditorCell, project: MPSProject) : FBNetworkAction(cell, project) { fun apply() { val funBlock = editedFBs.find { it.associatedNode == cell.sNode }.alsoIfNull{ showNotification(CANT_GET_FB_CELL) @@ -30,13 +27,15 @@ class ChangeTypeAction(cell: EditorCell, val project: MPSProject) : FBNetworkAct is BasicFBTypeDeclaration -> convertToComposite(funBlock, declaration) } + Notifier.showInformation("Successfully change type!", project.project) + cell.editorComponent.updater.update() } private fun convertFB( oldFB: FunctionBlockView, oldDeclaration: FBTypeDeclaration, - creator: (identity: Identifier) -> FBTypeDeclaration + supplier: (name: String, context: EditorContext) -> FBTypeDeclaration ) { val identifier = StringIdentifier(oldDeclaration.name + TMP_SUFFIX) @@ -47,50 +46,22 @@ class ChangeTypeAction(cell: EditorCell, val project: MPSProject) : FBNetworkAct val networkModel = (network as PlatformElement).node.model.alsoIfNull { showNotification("""Can't convert ${oldDeclaration.name} to basic functional block!""") } ?: return - val scope = repository.getDeclarationScopeFor(networkModel) - - val createdFB = creator(identifier) - val fbTypeNode = (createdFB as PlatformElement).node - networkModel.addRootNode(fbTypeNode) + val type = supplier(identifier.value, cell.context) val createdDeclaration = factory.createFunctionBlockDeclaration(identifier) createdDeclaration.x = oldFB.component.x createdDeclaration.y = oldFB.component.y - val type = scope.findAllFBTypeDeclarations().find { - it.name == identifier.value - }.alsoIfNull { - showNotification("Can't find new basic FB declaration ${oldDeclaration.name} in scope!") - } ?: return - createdDeclaration.typeReference.setTarget(type) network.functionBlocks.replaceAll { if (oldFB.component.type.typeName == it.type.typeName) createdDeclaration else it } - network.eventConnections.forEach { - it.sourceReference.updateTarget(oldFB.component, createdDeclaration, EntryKind.EVENT) - it.targetReference.updateTarget(oldFB.component, createdDeclaration, EntryKind.EVENT) - } - - network.dataConnections.forEach { - it.sourceReference.updateTarget(oldFB.component, createdDeclaration, EntryKind.DATA) - it.targetReference.updateTarget(oldFB.component, createdDeclaration, EntryKind.DATA) - } - - network.adapterConnections.forEach { - it.sourceReference.updateTarget(oldFB.component, createdDeclaration, EntryKind.ADAPTER) - it.targetReference.updateTarget(oldFB.component, createdDeclaration, EntryKind.ADAPTER) - } + FBUtils.copyInterface(oldDeclaration, type, factory) - oldDeclaration.inputEvents.copyTo(type.inputEvents) - oldDeclaration.outputEvents.copyTo(type.outputEvents) - oldDeclaration.inputParameters.copyTo(type.inputParameters) - oldDeclaration.outputParameters.copyTo(type.outputParameters) - oldDeclaration.plugs.copyTo(type.plugs) - oldDeclaration.sockets.copyTo(type.sockets) + FBUtils.replaceFBInConnections(network, oldFB.component, createdDeclaration) networkModel.removeRootNode((oldDeclaration as PlatformElement).node) @@ -99,40 +70,20 @@ class ChangeTypeAction(cell: EditorCell, val project: MPSProject) : FBNetworkAct editedFBsController.setEdited(FunctionBlockView(createdDeclaration, true), true) } - private fun MutableList.copyTo(newList: MutableList) { - this.toList().forEach { - newList.add(it) - } - } - - private fun CompositeReference>.updateTarget( - old: FunctionBlockDeclarationBase, - created: FunctionBlockDeclarationBase, - kind: EntryKind - ) { - val target = this.getTarget() ?: return - - if (target.functionBlock?.equals(old) == true) { - this.setTarget(PortPath.createPortPath(created, kind, target.portTarget)) - } - } - private fun convertToBasicFB(funBlock: FunctionBlockView, declaration: CompositeFBTypeDeclaration) { - val repository = PlatformRepositoryProvider.getInstance(project) - val factory = repository.iec61499Factory - - convertFB(funBlock, declaration, factory::createBasicFBTypeDeclaration) + try { + convertFB(funBlock, declaration, FBFactory::createBasicFunBlock) + } catch (e: CreationException) { + showNotification("Can't change type of block to basic! Exception: ${e.message}") + } } private fun convertToComposite(funBlock: FunctionBlockView, declaration: BasicFBTypeDeclaration) { - val repository = PlatformRepositoryProvider.getInstance(project) - val factory = repository.iec61499Factory - - convertFB(funBlock, declaration, factory::createCompositeFBTypeDeclaration) - } - - private fun showNotification(message: String) { - Notifier.showWarning(message, project.project) + try { + convertFB(funBlock, declaration, FBFactory::createCompositeFunBlock) + } catch (e: CreationException) { + showNotification("Can't change type of block to composite! Exception: ${e.message}") + } } companion object { diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/CreateViewAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/CreateViewAction.kt new file mode 100644 index 000000000..985e1cd2f --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/CreateViewAction.kt @@ -0,0 +1,107 @@ +package org.fbme.ide.richediting.adapters.fbnetwork.actions + +import com.intellij.util.alsoIfNull +import jetbrains.mps.openapi.editor.cells.EditorCell +import jetbrains.mps.project.MPSProject +import org.fbme.ide.iec61499.repository.PlatformRepositoryProvider +import org.fbme.ide.richediting.utils.Notifier +import org.fbme.ide.richediting.utils.fb.FBFactory +import org.fbme.ide.richediting.utils.fb.FBUtils +import org.fbme.ide.richediting.viewmodel.FunctionBlockView +import org.fbme.lib.common.StringIdentifier +import org.fbme.lib.iec61499.declarations.FBInterfaceDeclaration +import org.fbme.lib.iec61499.fbnetwork.ConnectionPath +import org.fbme.lib.iec61499.fbnetwork.EntryKind +import org.fbme.lib.iec61499.fbnetwork.PortPath + +class CreateViewAction(cell: EditorCell, project: MPSProject) : FBNetworkAction(cell, project) { + fun apply() { + val funBlock = editedFBs.find { it.associatedNode == cell.sNode }.alsoIfNull{ + showNotification(CANT_GET_FB_CELL) + } ?: return + + createView(funBlock) + + cell.editorComponent.updater.update() + } + + private fun createView(functionBlockView: FunctionBlockView) { + val repository = PlatformRepositoryProvider.getInstance(project) + val factory = repository.iec61499Factory + val network = networkInstance.networkDeclaration + val oldNetworkComponent = functionBlockView.component + + val oldDeclaration = functionBlockView.type.declaration.alsoIfNull { + showNotification("Declaration of function block is null!") + } ?: return + + if (oldDeclaration !is FBInterfaceDeclaration) { + showNotification("Declaration of this is block isn't acceptable. Block should have interface!") + return + } + + val identifier = StringIdentifier(oldDeclaration.name + VIEW_SUFFIX) + + val viewType = FBFactory.createCompositeFunBlock(identifier.value, cell.context) + + val createdView = factory.createFunctionBlockDeclaration(identifier) + + createdView.typeReference.setTarget(viewType) + createdView.x = oldNetworkComponent.x + createdView.y = oldNetworkComponent.y + + network.functionBlocks.add(createdView) + + FBUtils.copyInterface(oldDeclaration, viewType, factory) + FBUtils.replaceFBInConnections(network, oldNetworkComponent, createdView) + + val oldFBDeclaration = network.functionBlocks.find { it == oldNetworkComponent } ?: return + network.functionBlocks.remove(oldFBDeclaration) + + createdView.name = oldNetworkComponent.name + VIEW_SUFFIX + + val oldFBDeclarationInNewNetwork = factory + .createFunctionBlockDeclaration(StringIdentifier(oldNetworkComponent.name)) + oldFBDeclarationInNewNetwork.x = 500 + oldFBDeclarationInNewNetwork.y = 250 + val originType = oldFBDeclaration.typeReference.getTarget() ?: return + oldFBDeclarationInNewNetwork.typeReference.setTarget(originType) + viewType.network.functionBlocks.add(oldFBDeclarationInNewNetwork) + + val oldPorts = oldFBDeclarationInNewNetwork.getAllPorts() + viewType.network.getAllPorts().forEach { + val newConnection = factory.createFBNetworkConnection(it.connectionKind) + val otherPort = oldPorts.find { + port -> FBUtils.PORT_COMPARATOR(it, port) + }?.declaration!! + + val fb = PortPath.createPortPath(oldFBDeclarationInNewNetwork, it.connectionKind, otherPort) + val view = PortPath.createPortPath(null, it.connectionKind, it.declaration!!) + + if (it.isInput) { + newConnection.sourceReference.setTarget(view) + newConnection.targetReference.setTarget(fb) + } else { + newConnection.sourceReference.setTarget(fb) + newConnection.targetReference.setTarget(view) + } + + newConnection.path = ConnectionPath(200) + + when (it.connectionKind) { + EntryKind.EVENT -> viewType.network.eventConnections.add(newConnection) + EntryKind.DATA -> viewType.network.dataConnections.add(newConnection) + EntryKind.ADAPTER -> viewType.network.adapterConnections.add(newConnection) + } + } + + editedFBsController.setEdited(FunctionBlockView(createdView, true), true) + + Notifier.showInformation("View has been created!", project.project) + } + + companion object { + const val CANT_GET_FB_CELL = "Couldn't find functional block!" + const val VIEW_SUFFIX = "View" + } +} diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/FBNetworkAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/FBNetworkAction.kt index 4c6c43854..4e548480d 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/FBNetworkAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/FBNetworkAction.kt @@ -1,11 +1,13 @@ package org.fbme.ide.richediting.adapters.fbnetwork.actions import jetbrains.mps.openapi.editor.cells.EditorCell +import jetbrains.mps.project.MPSProject import org.fbme.ide.richediting.adapters.fbnetwork.FBConnectionCursor import org.fbme.ide.richediting.adapters.fbnetwork.FBConnectionPath import org.fbme.ide.richediting.adapters.fbnetwork.FBConnectionPathSynchronizer import org.fbme.ide.richediting.adapters.fbnetwork.FBNetworkComponentSynchronizer import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.ide.richediting.utils.Notifier import org.fbme.ide.richediting.viewmodel.FunctionBlockView import org.fbme.ide.richediting.viewmodel.NetworkComponentView import org.fbme.ide.richediting.viewmodel.NetworkConnectionView @@ -19,7 +21,7 @@ import org.fbme.scenes.controllers.diagram.DiagramFacility import org.fbme.scenes.controllers.edited.EditedModel import java.awt.Point -abstract class FBNetworkAction protected constructor(protected val cell: EditorCell) { +abstract class FBNetworkAction protected constructor(protected val cell: EditorCell, protected val project: MPSProject) { @JvmField protected val selectedFBs: Set @@ -53,6 +55,10 @@ abstract class FBNetworkAction protected constructor(protected val cell: EditorC @JvmField protected val connectionSynchronizer: FBConnectionPathSynchronizer + protected fun showNotification(message: String) { + Notifier.showWarning(message, project.project) + } + init { val style = cell.style selectedFBs = style.get(RichEditorStyleAttributes.SELECTED_FBS).selectedComponents diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/CollapseAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/expand/CollapseAction.kt similarity index 76% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/CollapseAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/expand/CollapseAction.kt index a03f33cc4..070189ac2 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/CollapseAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/expand/CollapseAction.kt @@ -1,10 +1,12 @@ -package org.fbme.ide.richediting.adapters.fbnetwork.actions +package org.fbme.ide.richediting.adapters.fbnetwork.actions.expand import jetbrains.mps.openapi.editor.cells.EditorCell +import jetbrains.mps.project.MPSProject import org.fbme.ide.richediting.adapters.fbnetwork.FunctionBlockController +import org.fbme.ide.richediting.adapters.fbnetwork.actions.FBNetworkAction import org.fbme.ide.richediting.viewmodel.FunctionBlockView -class CollapseAction(cell: EditorCell) : FBNetworkAction(cell.parent) { +class CollapseAction(cell: EditorCell, project: MPSProject) : FBNetworkAction(cell.parent, project) { fun apply() { collapse(selectedFBs.filterIsInstance()) } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ExpandAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/expand/ExpandAction.kt similarity index 94% rename from code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ExpandAction.kt rename to code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/expand/ExpandAction.kt index 4b24cf9cb..c3934782f 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/ExpandAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/expand/ExpandAction.kt @@ -1,10 +1,12 @@ -package org.fbme.ide.richediting.adapters.fbnetwork.actions +package org.fbme.ide.richediting.adapters.fbnetwork.actions.expand import jetbrains.mps.editor.runtime.HeadlessEditorComponent import jetbrains.mps.openapi.editor.cells.EditorCell import jetbrains.mps.openapi.editor.style.Style +import jetbrains.mps.project.MPSProject import org.fbme.ide.iec61499.repository.PlatformElement import org.fbme.ide.richediting.adapters.fbnetwork.FunctionBlockController +import org.fbme.ide.richediting.adapters.fbnetwork.actions.FBNetworkAction import org.fbme.ide.richediting.viewmodel.FunctionBlockView import org.fbme.ide.richediting.viewmodel.InterfaceEndpointView import org.fbme.ide.richediting.viewmodel.NetworkComponentView @@ -16,7 +18,7 @@ import org.jetbrains.mps.openapi.module.SRepository import java.awt.Point import java.awt.Rectangle -class ExpandAction(cell: EditorCell) : FBNetworkAction(cell) { +class ExpandAction(cell: EditorCell, project: MPSProject) : FBNetworkAction(cell, project) { fun apply() { val functionBlock = selectedFBs.filterIsInstance().last() functionBlock.expand() diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt index 12d8b752a..bb83a34f2 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt @@ -14,4 +14,12 @@ object Notifier { .createNotification(message, NotificationType.WARNING) .notify(project) } + + fun showInformation(message: String, project: Project) { + NotificationGroupManager + .getInstance() + .getNotificationGroup(NOTIFICATION_GROUP) + .createNotification(message, NotificationType.INFORMATION) + .notify(project) + } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/ProjectProvider.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/ProjectProvider.kt new file mode 100644 index 000000000..9d572aa55 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/ProjectProvider.kt @@ -0,0 +1,29 @@ +package org.fbme.ide.richediting.utils + +import com.intellij.ide.DataManager +import jetbrains.mps.ide.project.ProjectHelper +import jetbrains.mps.openapi.editor.EditorContext +import jetbrains.mps.project.MPSProject +import jetbrains.mps.workbench.MPSDataKeys +import java.awt.Component + +object ProjectProvider { + /** + * This solution doesn't work if component is headless and doesn't belong to UI hierarchy. + */ + fun getInstance(context: EditorContext): MPSProject? { + val component: Component = context.editorComponent as Component + return MPSDataKeys.MPS_PROJECT.getData(DataManager.getInstance().getDataContext(component)) + } + + /** + * This solution depends on project with which repository have been initialized. + */ + fun getInstanceFromRepository(context: EditorContext): MPSProject? { + return ProjectHelper.getProject(context.repository)?.let { project -> + ProjectHelper.toIdeaProject(project)?.let {ideaProject -> + ProjectHelper.fromIdeaProject(ideaProject) + } + } + } +} diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/exceptions/CreationException.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/exceptions/CreationException.kt new file mode 100644 index 000000000..8088b79e5 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/exceptions/CreationException.kt @@ -0,0 +1,9 @@ +package org.fbme.ide.richediting.utils.exceptions + +class CreationException : Exception { + constructor() : super() + + constructor(message: String?) : super(message) + + constructor(message: String?, cause: Throwable?) : super(message, cause) +} diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/exceptions/FBMEException.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/exceptions/FBMEException.kt new file mode 100644 index 000000000..cf0062861 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/exceptions/FBMEException.kt @@ -0,0 +1,9 @@ +package org.fbme.ide.richediting.utils.exceptions + +class FBMEException : RuntimeException { + constructor() : super() + + constructor(message: String) : super(message) + + constructor(message: String, cause: Throwable) : super(message, cause) +} diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBFactory.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBFactory.kt new file mode 100644 index 000000000..2a34ae96a --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBFactory.kt @@ -0,0 +1,48 @@ +package org.fbme.ide.richediting.utils.fb + +import jetbrains.mps.openapi.editor.EditorContext +import org.fbme.ide.iec61499.repository.PlatformElement +import org.fbme.ide.iec61499.repository.PlatformRepositoryProvider +import org.fbme.ide.richediting.utils.ProjectProvider +import org.fbme.ide.richediting.utils.exceptions.CreationException +import org.fbme.lib.common.Identifier +import org.fbme.lib.common.StringIdentifier +import org.fbme.lib.iec61499.IEC61499Factory +import org.fbme.lib.iec61499.declarations.BasicFBTypeDeclaration +import org.fbme.lib.iec61499.declarations.CompositeFBTypeDeclaration +import kotlin.jvm.Throws + +object FBFactory { + @Throws(CreationException::class) + fun createCompositeFunBlock(name: String, context: EditorContext): CompositeFBTypeDeclaration { + return createBlock(name, context) { + iec61499Factory, identifier -> iec61499Factory.createCompositeFBTypeDeclaration(identifier) + } + } + + @Throws(CreationException::class) + fun createBasicFunBlock(name: String, context: EditorContext): BasicFBTypeDeclaration { + return createBlock(name, context) { + iec61499Factory, identifier -> iec61499Factory.createBasicFBTypeDeclaration(identifier) + } + } + + @Throws(CreationException::class) + private fun createBlock( + name: String, + context: EditorContext, + creator: (iec61499Factory: IEC61499Factory, identifier: Identifier) -> T + ) : T { + val identifier = StringIdentifier(name) + + val project = ProjectProvider.getInstance(context) ?: throw CreationException("Can't get project from context") + + val repository = PlatformRepositoryProvider.getInstance(project) + val model = context.model + + val createdType = creator(repository.iec61499Factory, identifier) + model.addRootNode((createdType as PlatformElement).node) + + return createdType + } +} diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBUtils.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBUtils.kt new file mode 100644 index 000000000..c1cb66140 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBUtils.kt @@ -0,0 +1,108 @@ +package org.fbme.ide.richediting.utils.fb + +import org.fbme.lib.common.CompositeReference +import org.fbme.lib.common.StringIdentifier +import org.fbme.lib.iec61499.IEC61499Factory +import org.fbme.lib.iec61499.declarations.* +import org.fbme.lib.iec61499.descriptors.FBPortDescriptor +import org.fbme.lib.iec61499.fbnetwork.* + +object FBUtils { + fun copyInterface(oldFB: T, newFB: T, factory: IEC61499Factory) { + oldFB.inputEvents.copyTo(newFB.inputEvents) { + factory.createEventDeclaration(StringIdentifier(it.name)) + } + oldFB.outputEvents.copyTo(newFB.outputEvents) { + factory.createEventDeclaration(StringIdentifier(it.name)) + } + oldFB.inputParameters.copyTo(newFB.inputParameters) { + val port = factory.createParameterDeclaration(StringIdentifier(it.name)) + port.type = it.type + port + } + oldFB.outputParameters.copyTo(newFB.outputParameters) { + val port = factory.createParameterDeclaration(StringIdentifier(it.name)) + port.type = it.type + port + } + + if (oldFB is FBInterfaceDeclarationWithAdapters && newFB is FBInterfaceDeclarationWithAdapters) { + oldFB.plugs.copyTo(newFB.plugs) { + val port = factory.createPlugDeclaration(StringIdentifier(it.name)) + val target = it.typeReference.getTarget() + if (target != null) { + port.typeReference.setTarget(target) + } + port + } + oldFB.sockets.copyTo(newFB.sockets) { + val port = factory.createSocketDeclaration(StringIdentifier(it.name)) + val target = it.typeReference.getTarget() + if (target != null) { + port.typeReference.setTarget(target) + } + port + } + } + } + + private fun MutableList.copyTo(newList: MutableList, transformer: (i: T) -> T) { + this.toList().forEach { + newList.add(transformer(it)) + } + } + + fun replaceFBInConnections( + network: FBNetwork, + oldFB: FunctionBlockDeclarationBase, + newFB: FunctionBlockDeclarationBase + ) { + val newPortsDescriptors = newFB.getAllPorts() + val oldPortsDescriptors = oldFB.getAllPorts() + + listOf( + network.eventConnections to EntryKind.EVENT, + network.dataConnections to EntryKind.DATA, + network.adapterConnections to EntryKind.ADAPTER + ).forEach { (connections, kind) -> + connections.forEach { + it.sourceReference.updateTarget(oldFB, newFB, kind, newPortsDescriptors, oldPortsDescriptors) + it.targetReference.updateTarget(oldFB, newFB, kind, newPortsDescriptors, oldPortsDescriptors) + } + } + } + + private fun CompositeReference>.updateTarget( + old: FunctionBlockDeclarationBase, + created: FunctionBlockDeclarationBase, + kind: EntryKind, + newPortsDescriptors: List, + oldPortsDescriptors: List + ) { + val target = this.getTarget() ?: return + + if (target.functionBlock?.equals(old) == true) { + val oldDescriptor = oldPortsDescriptors.find { + it.declaration?.equals(target.portTarget) == true + } ?: return + + val newDeclaration = newPortsDescriptors.find { + PORT_COMPARATOR(it, oldDescriptor) + }?.declaration ?: return + + this.setTarget(PortPath.createPortPath(created, kind, newDeclaration)) + } + } + + val PORT_COMPARATOR: (a: FBPortDescriptor, b: FBPortDescriptor) -> Boolean = { + a: FBPortDescriptor, b: FBPortDescriptor -> + val aDeclaration = a.declaration + val bDeclaration = b.declaration + (a.isInput == b.isInput) + && (a.connectionKind == b.connectionKind) + && (a.name == b.name) + && (((aDeclaration is EventDeclaration) && (bDeclaration is EventDeclaration)) + || (aDeclaration is ParameterDeclaration && bDeclaration is ParameterDeclaration && aDeclaration.type == bDeclaration.type) + || (aDeclaration is SocketPluginDeclaration && bDeclaration is SocketPluginDeclaration && aDeclaration.typeReference.getTarget() == bDeclaration.typeReference.getTarget())) + } +} diff --git a/code/richediting/src/main/resources/META-INF/plugin.xml b/code/richediting/src/main/resources/META-INF/plugin.xml index 0bfe91dcd..58b8bf4b3 100644 --- a/code/richediting/src/main/resources/META-INF/plugin.xml +++ b/code/richediting/src/main/resources/META-INF/plugin.xml @@ -11,7 +11,7 @@ - + From 4d2ee8be31ca64a1ebc395299fd497bc666e8d4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 28 May 2023 19:38:18 +0200 Subject: [PATCH 18/66] Fix small bug --- .../ide/richediting/actions/network/AbstractFBEditAction.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AbstractFBEditAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AbstractFBEditAction.kt index 752554c35..8b61af16a 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AbstractFBEditAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/AbstractFBEditAction.kt @@ -19,8 +19,8 @@ abstract class AbstractFBEditAction: AnAction(), DumbAware { return } - val editedFBS = cell.style.get(RichEditorStyleAttributes.EDITED_FBS).editedComponents - val fbCell = editedFBS.find { it.associatedNode == cell.sNode } + val editedFBS = cell.style.get(RichEditorStyleAttributes.EDITED_FBS)?.editedComponents + val fbCell = editedFBS?.find { it.associatedNode == cell.sNode } if (fbCell == null) { notApplicable(event) From 659f70f849c3b415f5cca297592d1df2dbcd2a56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 29 May 2023 12:43:44 +0200 Subject: [PATCH 19/66] Add comlition provider object --- .../adapters/fbnetwork/FBNetworkEditors.kt | 29 +++-- .../fbme/ide/richediting/utils/Notifier.kt | 12 +- .../utils/fb/FBCompletionProvider.kt | 122 ++++++++++++++++++ 3 files changed, 153 insertions(+), 10 deletions(-) create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBCompletionProvider.kt diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt index 5affc34c6..3567ea7f9 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt @@ -1,5 +1,8 @@ package org.fbme.ide.richediting.adapters.fbnetwork +import com.intellij.openapi.project.Project +import com.intellij.openapi.ui.Messages +import com.intellij.util.alsoIfNull import jetbrains.mps.nodeEditor.EditorComponent import jetbrains.mps.nodeEditor.MPSColors import jetbrains.mps.nodeEditor.cells.EditorCell @@ -13,6 +16,9 @@ import org.fbme.ide.richediting.RicheditingMpsBridge import org.fbme.ide.richediting.editor.RichEditorDataKeys import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.ide.richediting.inspections.NetworkInspectionsFacility +import org.fbme.ide.richediting.utils.Notifier +import org.fbme.ide.richediting.utils.ProjectProvider +import org.fbme.ide.richediting.utils.fb.FBCompletionProvider import org.fbme.ide.richediting.viewmodel.* import org.fbme.lib.common.Declaration import org.fbme.lib.common.StringIdentifier @@ -58,8 +64,10 @@ object FBNetworkEditors { compController: ComponentController ): ComponentExtController { require(!(extView !is InlineValueView || compController !is FunctionBlockController)) - val repository: PlatformElementsOwner = - PlatformRepositoryProvider.getInstance(context.operationContext.project) + val project = ProjectProvider.getInstance(context).alsoIfNull { + Notifier.showError("Can't get project from context!") + } ?: error("Project missing") + val repository: PlatformElementsOwner = PlatformRepositoryProvider.getInstance(project) val node = extView.associatedNode.parent val parameter = repository.getAdapter(node, ParameterAssignment::class.java) ?: error("Parameter assignment is null") @@ -135,6 +143,7 @@ object FBNetworkEditors { style.set(SCENE_BACKGROUND, MPSColors.WHITE) val component = context.editorComponent as EditorComponent val project = context.operationContext.project + val nProject = ProjectProvider.getInstance(context) ?: error("Can't get project") val repository = PlatformRepositoryProvider.getInstance(project) try { val isEditable = true @@ -179,7 +188,8 @@ object FBNetworkEditors { val completionScope = repository.getDeclarationScopeFor(model) val factory = repository.iec61499Factory val provider: SceneCompletionProvider = CompletionProviderByViewpoint(viewpoint) { - getCompletion(completionScope, factory, networkDeclaration, scale) + FBCompletionProvider.getCompletionItems(networkInstance, context) + //getCompletion(completionScope, factory, networkDeclaration, scale, nProject.project) } scene.addCompletionProvider(provider) val inlineValuesView = networkView.extensionsView @@ -285,7 +295,8 @@ object FBNetworkEditors { scope: DeclarationsScope, factory: IEC61499Factory, fbNetwork: FBNetwork, - scale: Float + scale: Float, + project: Project ): List { val completionList = mutableListOf() @@ -304,7 +315,7 @@ object FBNetworkEditors { completionList.add(createPositionalCompletionItem( "New composite FB", "Empty composite FB") { _: String?, x: Int, y: Int -> - val identifier = createNewCompositeBlock(scope, fbNetwork, factory) + val identifier = createNewCompositeBlock(project, scope, fbNetwork, factory) val declaration = factory.createFunctionBlockDeclaration(identifier) declaration.x = (x / scale).toInt() declaration.y = (y / scale).toInt() @@ -318,7 +329,7 @@ object FBNetworkEditors { completionList.add(createPositionalCompletionItem( "New basic FB", "Empty basic FB") { _: String?, x: Int, y: Int -> - val identifier = createNewCompositeBlock(scope, fbNetwork, factory, false) + val identifier = createNewCompositeBlock(project, scope, fbNetwork, factory, false) val declaration = factory.createFunctionBlockDeclaration(identifier) declaration.x = (x / scale).toInt() declaration.y = (y / scale).toInt() @@ -354,13 +365,15 @@ object FBNetworkEditors { } private fun createNewCompositeBlock( + project: Project, scope: DeclarationsScope, fbNetwork: FBNetwork, factory: IEC61499Factory, composite: Boolean = true ): StringIdentifier { + val name = Messages.showInputDialog(project, "Enter name for functional block", "Naming", Messages.getQuestionIcon()) val getName: (Int?) -> String = { ind -> - val baseName = "Empty block" + val baseName = "Empty_block" if (ind == null) { baseName } else { @@ -375,7 +388,7 @@ object FBNetworkEditors { prefix = (prefix ?: 0) + 1 } - val identifier = StringIdentifier(getName(prefix)) + val identifier = StringIdentifier(name ?: getName(prefix)) val networkNode = (fbNetwork as PlatformElement).node val networkModel = networkNode.model diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt index bb83a34f2..e2dc4d466 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt @@ -7,7 +7,7 @@ import com.intellij.openapi.project.Project object Notifier { private const val NOTIFICATION_GROUP = "Custom" - fun showWarning(message: String, project: Project) { + fun showWarning(message: String, project: Project? = null) { NotificationGroupManager .getInstance() .getNotificationGroup(NOTIFICATION_GROUP) @@ -15,11 +15,19 @@ object Notifier { .notify(project) } - fun showInformation(message: String, project: Project) { + fun showInformation(message: String, project: Project? = null) { NotificationGroupManager .getInstance() .getNotificationGroup(NOTIFICATION_GROUP) .createNotification(message, NotificationType.INFORMATION) .notify(project) } + + fun showError(message: String, project: Project? = null) { + NotificationGroupManager + .getInstance() + .getNotificationGroup(NOTIFICATION_GROUP) + .createNotification(message, NotificationType.ERROR) + .notify(project) + } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBCompletionProvider.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBCompletionProvider.kt new file mode 100644 index 000000000..ccdba9ab0 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBCompletionProvider.kt @@ -0,0 +1,122 @@ +package org.fbme.ide.richediting.utils.fb + +import com.intellij.openapi.project.Project +import com.intellij.openapi.ui.InputValidator +import com.intellij.openapi.ui.Messages +import com.intellij.util.alsoIfNull +import jetbrains.mps.openapi.editor.EditorContext +import org.fbme.ide.iec61499.repository.PlatformElement +import org.fbme.ide.iec61499.repository.PlatformRepositoryProvider +import org.fbme.ide.richediting.RicheditingMpsBridge +import org.fbme.ide.richediting.utils.Notifier +import org.fbme.ide.richediting.utils.ProjectProvider +import org.fbme.ide.richediting.utils.exceptions.CreationException +import org.fbme.lib.common.StringIdentifier +import org.fbme.lib.iec61499.declarations.FBTypeDeclaration +import org.fbme.lib.iec61499.instances.NetworkInstance +import org.fbme.scenes.viewmodel.PositionalCompletionItem +import java.util.LinkedList + +object FBCompletionProvider { + fun getCompletionItems( + networkInstance: NetworkInstance, + context: EditorContext + ): List { + val result: MutableList = LinkedList() + + val project = ProjectProvider.getInstance(context).alsoIfNull { + Notifier.showWarning("Can't get project from context!") + } ?: return result + + val scale = RicheditingMpsBridge.getEditorScale(project) + val repository = PlatformRepositoryProvider.getInstance(project) + val factory = repository.iec61499Factory + val network = networkInstance.networkDeclaration + val scope = repository.getDeclarationScopeFor( + (network as PlatformElement).node.model + ) + + val allFBTypes = scope.findAllFBTypeDeclarations() + val existedFBNames = allFBTypes.map { it.name }.toSet() + + val invokeFun: (type: FBTypeDeclaration) -> (String?, Int, Int) -> Unit = { type -> + { _: String?, x: Int, y: Int -> + val declaration = factory.createFunctionBlockDeclaration(StringIdentifier(type.name)) + declaration.x = (x / scale).toInt() + declaration.y = (y / scale).toInt() + declaration.typeReference.setTarget(type) + network.functionBlocks.add(declaration) + } + } + + val createNewType: ( + type: String, + factory: (name: String, context: EditorContext) -> FBTypeDeclaration + ) -> PositionalCompletionItem = { + typeName, factoryFun -> + createPositionalCompletionItem( + "New $typeName FB", + "Creates empty $typeName FB" + ){ + parameter: String?, x: Int, y: Int -> + val type = createNewCompositeBlock( + project.project, + context, + existedFBNames, + factoryFun + ) ?: return@createPositionalCompletionItem + invokeFun(type)(parameter, x, y) + } + } + + allFBTypes.sortedBy { it.name }.forEach { type -> + result.add(createPositionalCompletionItem(type.name, invokeFun = invokeFun(type))) + } + + result.add(createNewType("basic", FBFactory::createBasicFunBlock)) + result.add(createNewType("composite", FBFactory::createCompositeFunBlock)) + + return result + } + + private fun createNewCompositeBlock( + project: Project, + context: EditorContext, + existedFBNames: Set, + factory: (name: String, context: EditorContext) -> FBTypeDeclaration + ): FBTypeDeclaration? { + val inputValidator = object : InputValidator { + override fun checkInput(text: String?): Boolean = !existedFBNames.contains(text) + + override fun canClose(text: String?): Boolean = true + } + val name = Messages.showInputDialog( + project, + "Enter name for new functional block", + null, Messages.getQuestionIcon(), + null, + inputValidator + ) ?: return null + + return try { + factory(name, context) + } catch (e: CreationException) { + Notifier.showWarning("Can't create new functional block!", project) + null + } + } + + private fun createPositionalCompletionItem( + name: String, + description: String? = null, + invokeFun: (pattern: String?, x: Int, y: Int) -> Unit + ): PositionalCompletionItem { + return object : PositionalCompletionItem { + override fun getMatchingText(pattern: String?): String = name + + override val descriptionText: String = description ?: "" + + override fun invoke(pattern: String?, x: Int, y: Int) = invokeFun(pattern, x, y) + } + } +} From 85c1e00a3ee5b73dd2cc271b92d87894c8c8dd22 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 29 May 2023 15:58:35 +0200 Subject: [PATCH 20/66] Refactor network example --- .../adapters/fbnetwork/FBNetworkEditors.kt | 145 +++--------------- 1 file changed, 22 insertions(+), 123 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt index 3567ea7f9..f5ae74872 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt @@ -1,7 +1,5 @@ package org.fbme.ide.richediting.adapters.fbnetwork -import com.intellij.openapi.project.Project -import com.intellij.openapi.ui.Messages import com.intellij.util.alsoIfNull import jetbrains.mps.nodeEditor.EditorComponent import jetbrains.mps.nodeEditor.MPSColors @@ -21,12 +19,9 @@ import org.fbme.ide.richediting.utils.ProjectProvider import org.fbme.ide.richediting.utils.fb.FBCompletionProvider import org.fbme.ide.richediting.viewmodel.* import org.fbme.lib.common.Declaration -import org.fbme.lib.common.StringIdentifier import org.fbme.lib.iec61499.DeclarationsScope import org.fbme.lib.iec61499.IEC61499Factory -import org.fbme.lib.iec61499.declarations.FBTypeDeclaration import org.fbme.lib.iec61499.declarations.ParameterAssignment -import org.fbme.lib.iec61499.fbnetwork.FBNetwork import org.fbme.lib.iec61499.instances.Instance import org.fbme.lib.iec61499.instances.NetworkInstance import org.fbme.scenes.cells.EditorCell_Scene @@ -36,13 +31,13 @@ import org.fbme.scenes.controllers.components.* import org.fbme.scenes.controllers.diagram.* import org.fbme.scenes.controllers.edited.EditedModel import org.fbme.scenes.controllers.scene.* -import org.fbme.scenes.viewmodel.PositionalCompletionItem import org.jetbrains.mps.openapi.model.SNode import java.awt.Point object FBNetworkEditors { @JvmField - val CONNECTION_CONTROLLER_FACTORY: ConnectionControllerFactory = + val CONNECTION_CONTROLLER_FACTORY: + ConnectionControllerFactory = object : ConnectionControllerFactory { override fun create( context: EditorContext, @@ -120,7 +115,8 @@ object FBNetworkEditors { editorShift: Point = Point() ): EditorCell { val scene = EditorCell_Scene(context, node!!, layout) - val repository: PlatformElementsOwner = PlatformRepositoryProvider.getInstance(context.operationContext.project) + val project = ProjectProvider.getInstance(context) ?: error("Can't get project instance from context!") + val repository: PlatformElementsOwner = PlatformRepositoryProvider.getInstance(project) val declaration = repository.getAdapter(node, Declaration::class.java) ?: error("Error when creating NetworkCell: Declaration is null") val networkInstance = NetworkInstance.createForDeclaration(declaration, parent) @@ -142,8 +138,8 @@ object FBNetworkEditors { style.set(RichEditorStyleAttributes.NETWORK_INSTANCE, networkInstance) style.set(SCENE_BACKGROUND, MPSColors.WHITE) val component = context.editorComponent as EditorComponent - val project = context.operationContext.project - val nProject = ProjectProvider.getInstance(context) ?: error("Can't get project") + //val project = context.operationContext.project + val project = ProjectProvider.getInstance(context) ?: error("Can't get project") val repository = PlatformRepositoryProvider.getInstance(project) try { val isEditable = true @@ -176,7 +172,13 @@ object FBNetworkEditors { val componentsFacility = ComponentsFacility( scene, networkView.componentsView, - getComponentControllerFactory(networkInstance, expandedComponentsController, editedComponentsController, repository.iec61499Factory, repository.getDeclarationScopeFor(model)), + getComponentControllerFactory( + networkInstance, + expandedComponentsController, + editedComponentsController, + repository.iec61499Factory, + repository.getDeclarationScopeFor(model) + ), FBNetworkComponentSynchronizer(viewpoint, scale, expandedComponentsController), componentsLayout, componentsSelection, @@ -185,11 +187,8 @@ object FBNetworkEditors { tracesLayer ) style.set(RichEditorStyleAttributes.COMPONENTS_FACILITY, componentsFacility) - val completionScope = repository.getDeclarationScopeFor(model) - val factory = repository.iec61499Factory val provider: SceneCompletionProvider = CompletionProviderByViewpoint(viewpoint) { FBCompletionProvider.getCompletionItems(networkInstance, context) - //getCompletion(completionScope, factory, networkDeclaration, scale, nProject.project) } scene.addCompletionProvider(provider) val inlineValuesView = networkView.extensionsView @@ -281,7 +280,15 @@ object FBNetworkEditors { return object : ComponentControllerFactory { override fun create(context: EditorContext, view: NetworkComponentView): ComponentController? { if (view is FunctionBlockView) { - return FunctionBlockController(context, view, instance, expandedComponentsController, editedComponentsController, iec61499Factory, scope) + return FunctionBlockController( + context, + view, + instance, + expandedComponentsController, + editedComponentsController, + iec61499Factory, + scope + ) } if (view is InterfaceEndpointView) { return EndpointPortController(context, view) @@ -290,112 +297,4 @@ object FBNetworkEditors { } } } - - private fun getCompletion( - scope: DeclarationsScope, - factory: IEC61499Factory, - fbNetwork: FBNetwork, - scale: Float, - project: Project - ): List { - val completionList = mutableListOf() - - scope.findAllFBTypeDeclarations().forEach { type -> - completionList.add( - createPositionalCompletionItem(type.name, "Create function block") { _: String?, x: Int, y: Int -> - val declaration = factory.createFunctionBlockDeclaration(StringIdentifier(type.name)) - declaration.x = (x / scale).toInt() - declaration.y = (y / scale).toInt() - declaration.typeReference.setTarget(type) - fbNetwork.functionBlocks.add(declaration) - } - ) - } - - completionList.add(createPositionalCompletionItem( - "New composite FB", - "Empty composite FB") { _: String?, x: Int, y: Int -> - val identifier = createNewCompositeBlock(project, scope, fbNetwork, factory) - val declaration = factory.createFunctionBlockDeclaration(identifier) - declaration.x = (x / scale).toInt() - declaration.y = (y / scale).toInt() - val type = scope.findAllFBTypeDeclarations().find { - it.name == identifier.value - } ?: error("Can't create empty block") - declaration.typeReference.setTarget(type) - fbNetwork.functionBlocks.add(declaration) - }) - - completionList.add(createPositionalCompletionItem( - "New basic FB", - "Empty basic FB") { _: String?, x: Int, y: Int -> - val identifier = createNewCompositeBlock(project, scope, fbNetwork, factory, false) - val declaration = factory.createFunctionBlockDeclaration(identifier) - declaration.x = (x / scale).toInt() - declaration.y = (y / scale).toInt() - val type = scope.findAllFBTypeDeclarations().find { - it.name == identifier.value - } ?: error("Can't create empty block") - declaration.typeReference.setTarget(type) - fbNetwork.functionBlocks.add(declaration) - }) - - return completionList - } - - private fun createPositionalCompletionItem( - name: String, - description: String, - invokeFun: (pattern: String?, x: Int, y: Int) -> Unit - ): PositionalCompletionItem { - return object : PositionalCompletionItem { - override fun getMatchingText(pattern: String?): String { - return name - } - - override val descriptionText: String - get() { - return description - } - - override fun invoke(pattern: String?, x: Int, y: Int) { - invokeFun(pattern, x, y) - } - } - } - - private fun createNewCompositeBlock( - project: Project, - scope: DeclarationsScope, - fbNetwork: FBNetwork, - factory: IEC61499Factory, - composite: Boolean = true - ): StringIdentifier { - val name = Messages.showInputDialog(project, "Enter name for functional block", "Naming", Messages.getQuestionIcon()) - val getName: (Int?) -> String = { ind -> - val baseName = "Empty_block" - if (ind == null) { - baseName - } else { - "$baseName $ind" - } - } - - var prefix: Int? = null - val names = scope.findAllFBTypeDeclarations().map { it.name }.toSet() - - while (names.contains(getName(prefix))) { - prefix = (prefix ?: 0) + 1 - } - - val identifier = StringIdentifier(name ?: getName(prefix)) - - val networkNode = (fbNetwork as PlatformElement).node - val networkModel = networkNode.model - val newFbType: FBTypeDeclaration = if (composite) factory.createCompositeFBTypeDeclaration(identifier) else factory.createBasicFBTypeDeclaration(identifier) - val fbTypeNode = (newFbType as PlatformElement).node - networkModel!!.addRootNode(fbTypeNode) - - return identifier - } } From 895af9fe488e3b50844ccb3d16eb6c602170d1a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Tue, 30 May 2023 12:15:29 +0200 Subject: [PATCH 21/66] Added port type on connecting in editor mode --- .../fbnetwork/FBNetworkComponentController.kt | 3 +++ .../fbnetwork/FBPortSettingProvider.kt | 5 ++++ .../fbnetwork/FunctionBlockController.kt | 26 ++++++++++++++++--- .../diagram/ConnectionsFacility.kt | 2 ++ .../controllers/diagram/DiagramController.kt | 2 +- .../controllers/diagram/DiagramFacility.kt | 2 +- .../controllers/diagram/PortController.kt | 3 ++- .../diagram/PortSettingProvider.kt | 3 +++ .../controllers/diagram/entry/PortEntry.kt | 6 ++++- .../diagram/entry/PortTemplateEntry.kt | 6 ++++- 10 files changed, 49 insertions(+), 9 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkComponentController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkComponentController.kt index 6b42a0335..201921bcf 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkComponentController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkComponentController.kt @@ -36,4 +36,7 @@ interface FBNetworkComponentController { fun createPort(source: NetworkPortView, template: NetworkPortView): NetworkPortView? { return null } + + fun connectTo(port: NetworkPortView, source: NetworkPortView) { + } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBPortSettingProvider.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBPortSettingProvider.kt index d9d3c9ac9..4f51aee37 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBPortSettingProvider.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBPortSettingProvider.kt @@ -64,4 +64,9 @@ class FBPortSettingProvider( val controller = myMapper.apply(component) return controller.getTemplatePosition(template, modelForm) } + + override fun connectPortTo(source: NetworkPortView, port: NetworkPortView) { + val component = port.component + myMapper.apply(component).connectTo(port, source) + } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt index 52b474146..42a295f24 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt @@ -4,6 +4,7 @@ import jetbrains.mps.editor.runtime.style.CellAlign import jetbrains.mps.editor.runtime.style.Measure import jetbrains.mps.editor.runtime.style.Padding import jetbrains.mps.editor.runtime.style.StyleAttributes +import jetbrains.mps.findUsages.FindUsagesManager import jetbrains.mps.nodeEditor.MPSColors import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Vertical import jetbrains.mps.nodeEditor.cells.EditorCell @@ -134,7 +135,6 @@ class FunctionBlockController( EntryKind.DATA -> if (isSource) fbCell.getOutputDataPortBounds(index) else fbCell.getInputDataPortBounds(index) EntryKind.ADAPTER -> if (isSource) fbCell.getPlugPortBounds(index) else fbCell.getSocketPortBounds(index) - else -> error("Unknown port kind") } bounds.translate(position.x, position.y + getVerticalOffset()) return bounds @@ -227,6 +227,21 @@ class FunctionBlockController( } } + override fun connectTo(port: NetworkPortView, source: NetworkPortView) { + if (!editedController.isEdited(view)) return + if (port.kind != source.kind || port.kind == EntryKind.EVENT) return + if (source !is FunctionBlockPortView) return + + val myPort = assertMine(port) + + if (myPort.target is ParameterDeclaration && source.target is ParameterDeclaration) { + myPort.target.type = source.target.type + } else if (myPort.target is SocketPluginDeclaration && source.target is SocketPluginDeclaration) { + val target = source.target.typeReference.getTarget() ?: return + myPort.target.typeReference.setTarget(target) + } + } + private fun assertMine(port: NetworkPortView): FunctionBlockPortView { require(!(port.component != view || port !is FunctionBlockPortView)) { "invalid port" } return port @@ -277,13 +292,13 @@ class FunctionBlockController( cellCollection = createRootCell(context, node) cellCollection.style.set(RichEditorStyleAttributes.FB, view.component) cellCollection.isBig = true - this.networkInstance = networkInstance //edit button + this.networkInstance = networkInstance editButton = getEditButton(context, node) editButton.style.set(StyleAttributes.HORIZONTAL_ALIGN, CellAlign.RIGHT) editButton.setAction(CellActionType.CLICK, toEditModeAction()) editButton.style.set(StyleAttributes.PADDING_BOTTOM, Padding(EditorCell_Button.OY_OFFSET.toDouble(), Measure.PIXELS)) editButton.style.set(StyleAttributes.TRANSPARENT, true) - cellCollection.addEditorCell(editButton) //name property + cellCollection.addEditorCell(editButton) myNameProperty = getNameProperty(context, view, node) myNameProperty.style.set(StyleAttributes.TEXT_COLOR, if (isEditable) MPSColors.BLACK else MPSColors.DARK_GRAY) myNameProperty.style.set(StyleAttributes.HORIZONTAL_ALIGN, CellAlign.CENTER) @@ -308,7 +323,10 @@ class FunctionBlockController( override fun executeInCommand(): Boolean = true - override fun canExecute(context: EditorContext): Boolean = true + override fun canExecute(context: EditorContext): Boolean { + //FindUsagesManager + return true + } override fun execute(context: EditorContext) { editedController.setEdited(view, !editedController.isEdited(view)) diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt index 60d1ebe10..4da46759b 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt @@ -336,6 +336,7 @@ class ConnectionsFacility( val targetSettings = diagramController.getPortController(target) if (targetSettings.canBeTargetedAt(x, y)) { scene.editorContext.repository.modelAccess.executeCommandInEDT { + targetSettings.connectTo(source) val edge = diagramController.addEdge(source, target) ?: return@executeCommandInEDT val newPath = newPathFactory.apply(sourceLocation, targetSettings.modelEndpointPosition) connectionSynchronizer.setPath(edge, newPath) @@ -384,6 +385,7 @@ class ConnectionsFacility( val sourceSettings = diagramController.getPortController(source) if (sourceSettings.canBeSourcedAt(x, y)) { scene.editorContext.repository.modelAccess.executeCommandInEDT { + sourceSettings.connectTo(target) val edge = diagramController.addEdge(source, target) ?: return@executeCommandInEDT val newPath = newPathFactory.apply(sourceSettings.modelEndpointPosition, targetLocation) connectionSynchronizer.setPath(edge, newPath) diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramController.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramController.kt index 4036f4519..98cf08c24 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramController.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramController.kt @@ -2,7 +2,7 @@ package org.fbme.scenes.controllers.diagram interface DiagramController { val isDiagramEditable: Boolean - fun getPortController(port: PortT): PortController + fun getPortController(port: PortT): PortController fun getTemplateController(template: PortT): TemplateController fun findPort(x: Int, y: Int): PortT? fun findPortTemplate(x: Int, y: Int): PortT? diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt index 9a9bc5cf9..8c93c9242 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt @@ -66,7 +66,7 @@ class DiagramFacility( return portToComponent[port] ?: error("Component not found") } - override fun getPortController(port: PortT): PortController { + override fun getPortController(port: PortT): PortController { return ports[port] ?: error("Port controller not found") } diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/PortController.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/PortController.kt index c622e938a..1e9567833 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/PortController.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/PortController.kt @@ -3,10 +3,11 @@ package org.fbme.scenes.controllers.diagram import java.awt.Point import java.awt.Rectangle -interface PortController { +interface PortController { val bounds: Rectangle val modelEndpointPosition: Point val transformedEndpointPosition: Point? fun canBeSourcedAt(x: Int, y: Int): Boolean fun canBeTargetedAt(x: Int, y: Int): Boolean + fun connectTo(port: PortT) } diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/PortSettingProvider.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/PortSettingProvider.kt index e370564d4..fe4f874c6 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/PortSettingProvider.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/PortSettingProvider.kt @@ -30,4 +30,7 @@ interface PortSettingProvider { fun createPort(source: PortT, template: PortT): PortT? { return null } + + fun connectPortTo(source: PortT, port: PortT) { + } } diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortEntry.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortEntry.kt index ff1e3612c..e34a4df52 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortEntry.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortEntry.kt @@ -11,7 +11,7 @@ class PortEntry( val component: CompT, private val componentSettings: DiagramComponentSettingProvider, private val portSettingProvider: PortSettingProvider, -) : PortController { +) : PortController { override val bounds: Rectangle get() { return portSettingProvider.getBounds(componentSettings.getModelForm(component), port) @@ -33,4 +33,8 @@ class PortEntry( override fun canBeTargetedAt(x: Int, y: Int): Boolean { return portSettingProvider.canBeTargetedAt(componentSettings.getModelForm(component), port, x, y) } + + override fun connectTo(source: PortT) { + portSettingProvider.connectPortTo(source, port) + } } \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortTemplateEntry.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortTemplateEntry.kt index 426fec7d2..08111245e 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortTemplateEntry.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/PortTemplateEntry.kt @@ -14,7 +14,7 @@ class PortTemplateEntry( val ports: MutableMap>, private val componentSettings: DiagramComponentSettingProvider, private val portSettingProvider: PortSettingProvider, -) : PortController, TemplateController { +) : PortController, TemplateController { override val bounds: Rectangle get() = portSettingProvider.getTemplateBounds(componentSettings.getModelForm(component), template) override val modelEndpointPosition: Point @@ -30,6 +30,10 @@ class PortTemplateEntry( return true } + override fun connectTo(port: PortT) { + //TODO + } + override fun createPort(source: PortT): PortT? { val nPort = portSettingProvider.createPort(source, template) ?: return null ports.computeIfAbsent(nPort) { PortEntry(nPort, component, componentSettings, portSettingProvider) } From 03c27128e52ccbf0b5c72db5cddde108936f4305 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Tue, 30 May 2023 22:42:45 +0200 Subject: [PATCH 22/66] Add network extractor --- .../fbme/lib/iec61499/fbnetwork/FBNetwork.kt | 3 + .../actions/network/CreateViewAction.kt | 2 +- .../actions/network/NetworkExtractorAction.kt | 43 ++++ .../actions/network/expand/CollapseAction.kt | 21 +- .../actions/network/expand/ExpandAction.kt | 19 +- .../adapters/fbnetwork/FBNetworkEditors.kt | 1 + .../actions/NetworkExtractorAction.kt | 206 ++++++++++++++++++ .../editor/RichEditorStyleAttributes.kt | 6 + .../src/main/resources/META-INF/plugin.xml | 2 +- 9 files changed, 290 insertions(+), 13 deletions(-) create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/NetworkExtractorAction.kt create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/NetworkExtractorAction.kt diff --git a/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FBNetwork.kt b/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FBNetwork.kt index c94897af2..84272dbb9 100644 --- a/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FBNetwork.kt +++ b/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FBNetwork.kt @@ -45,6 +45,9 @@ interface FBNetwork : Element { return components } + val allConnections: List + get() = eventConnections.union(dataConnections).union(adapterConnections).toList() + fun getAllPorts(): List { val result: MutableList = mutableListOf() diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt index 1f9bc129f..12522e230 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt @@ -35,4 +35,4 @@ class CreateViewAction : AbstractFBEditAction() { ).apply() } } -} \ No newline at end of file +} diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/NetworkExtractorAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/NetworkExtractorAction.kt new file mode 100644 index 000000000..8c6b9cc14 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/NetworkExtractorAction.kt @@ -0,0 +1,43 @@ +package org.fbme.ide.richediting.actions.network + +import com.intellij.openapi.actionSystem.AnActionEvent +import jetbrains.mps.ide.editor.MPSEditorDataKeys +import jetbrains.mps.openapi.editor.cells.EditorCell +import jetbrains.mps.project.MPSProject +import org.fbme.ide.richediting.actions.modelAccess +import org.fbme.ide.richediting.viewmodel.FunctionBlockView +import org.fbme.ide.richediting.adapters.fbnetwork.actions.NetworkExtractorAction +import org.fbme.lib.iec61499.declarations.CompositeFBTypeDeclaration + +class NetworkExtractorAction : AbstractFBEditAction() { + override fun internalConditionCheck( + event: AnActionEvent, + fbCell: FunctionBlockView, + cell: EditorCell, + project: MPSProject + ) { + when (val declaration = fbCell.type.declaration) { + is CompositeFBTypeDeclaration -> { + event.modelAccess.runReadAction { + event.presentation.isEnabled = + declaration.network.functionBlocks.isNotEmpty() + && declaration.sockets.isEmpty() + && declaration.plugs.isEmpty() + } + } + + else -> { + notApplicable(event) + } + } + } + + override fun actionPerformed(event: AnActionEvent) { + event.modelAccess.executeCommandInEDT { + NetworkExtractorAction( + event.getRequiredData(MPSEditorDataKeys.EDITOR_CELL), + event.getRequiredData(MPSEditorDataKeys.MPS_PROJECT) + ).apply() + } + } +} diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/CollapseAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/CollapseAction.kt index a080b7eee..f19467891 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/CollapseAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/CollapseAction.kt @@ -1,18 +1,27 @@ package org.fbme.ide.richediting.actions.network.expand -import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys +import jetbrains.mps.openapi.editor.cells.EditorCell +import jetbrains.mps.project.MPSProject import org.fbme.ide.richediting.actions.executeReadActionInEditor +import org.fbme.ide.richediting.actions.network.AbstractFBEditAction import org.fbme.ide.richediting.adapters.fbnetwork.actions.expand.CollapseAction +import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.ide.richediting.viewmodel.FunctionBlockView -class CollapseAction : AnAction(), DumbAware { - - override fun update(event: AnActionEvent) { - event.presentation.isEnabledAndVisible = event.getData(MPSEditorDataKeys.EDITOR_CELL) != null +class CollapseAction : AbstractFBEditAction() { + override fun internalConditionCheck( + event: AnActionEvent, + fbCell: FunctionBlockView, + cell: EditorCell, + project: MPSProject + ) { + event.presentation.isEnabled = + cell.style.get(RichEditorStyleAttributes.EXPANDED_COMPONENTS_CONTROLLER)?.isExpanded(fbCell) ?: false } + override fun actionPerformed(event: AnActionEvent) { event.executeReadActionInEditor { CollapseAction( diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/ExpandAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/ExpandAction.kt index c6e2a026f..a6433b7fb 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/ExpandAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/expand/ExpandAction.kt @@ -1,16 +1,25 @@ package org.fbme.ide.richediting.actions.network.expand -import com.intellij.openapi.actionSystem.AnAction import com.intellij.openapi.actionSystem.AnActionEvent -import com.intellij.openapi.project.DumbAware import jetbrains.mps.ide.editor.MPSEditorDataKeys +import jetbrains.mps.openapi.editor.cells.EditorCell +import jetbrains.mps.project.MPSProject import org.fbme.ide.richediting.actions.executeReadActionInEditor +import org.fbme.ide.richediting.actions.network.AbstractFBEditAction import org.fbme.ide.richediting.adapters.fbnetwork.actions.expand.ExpandAction +import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.ide.richediting.viewmodel.FunctionBlockView -class ExpandAction : AnAction(), DumbAware { +class ExpandAction : AbstractFBEditAction() { - override fun update(event: AnActionEvent) { - event.presentation.isEnabledAndVisible = event.getData(MPSEditorDataKeys.EDITOR_CELL) != null + override fun internalConditionCheck( + event: AnActionEvent, + fbCell: FunctionBlockView, + cell: EditorCell, + project: MPSProject + ) { + event.presentation.isEnabled = + cell.style.get(RichEditorStyleAttributes.EXPANDED_COMPONENTS_CONTROLLER)?.isExpanded(fbCell) == false } override fun actionPerformed(event: AnActionEvent) { diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt index f5ae74872..fd15b56ef 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt @@ -167,6 +167,7 @@ object FBNetworkEditors { style.set(RichEditorStyleAttributes.SELECTED_FBS, componentsSelection) val componentsLayout = DefaultLayoutModel(context.repository) val expandedComponentsController = ExpandedComponentsController(scene, context) + style.set(RichEditorStyleAttributes.EXPANDED_COMPONENTS_CONTROLLER, expandedComponentsController) val editedComponentsController: EditedModel = EditedComponentsController(scene) style.set(RichEditorStyleAttributes.EDITED_FBS, editedComponentsController) val componentsFacility = ComponentsFacility( diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/NetworkExtractorAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/NetworkExtractorAction.kt new file mode 100644 index 000000000..59d449ed0 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/NetworkExtractorAction.kt @@ -0,0 +1,206 @@ +package org.fbme.ide.richediting.adapters.fbnetwork.actions + +import com.intellij.util.alsoIfNull +import jetbrains.mps.openapi.editor.cells.EditorCell +import jetbrains.mps.project.MPSProject +import org.fbme.ide.iec61499.repository.PlatformRepositoryProvider +import org.fbme.ide.richediting.utils.Notifier +import org.fbme.ide.richediting.viewmodel.FunctionBlockView +import org.fbme.lib.common.Declaration +import org.fbme.lib.common.StringIdentifier +import org.fbme.lib.iec61499.IEC61499Factory +import org.fbme.lib.iec61499.fbnetwork.* + +class NetworkExtractorAction(cell: EditorCell, project: MPSProject) : FBNetworkAction(cell, project) { + fun apply() { + val funBlock = editedFBs.find { it.associatedNode == cell.sNode }.alsoIfNull{ + showNotification(CANT_GET_FB_CELL) + } ?: return + + extractNetwork(funBlock) + + cell.editorComponent.updater.update() + } + + private fun extractNetwork(funBlock: FunctionBlockView) { + val network = networkInstance.networkDeclaration + val repository = PlatformRepositoryProvider.getInstance(project) + val factory = repository.iec61499Factory + + val declaration = + repository + .declarationsScope + .findCompositeFBTypeDeclaration(funBlock.component.type.declaration!!.identifier).alsoIfNull { + Notifier.showWarning("Couldn't find composite block to deconstruct!") + } ?: return + + val compositeNetwork = declaration.network + + //Add blocks from composite blocks to network + val blocksViews = addBlocksFromComposite(funBlock, compositeNetwork, network, factory) + + //Add connections to added blocks + val creatingConnections: MutableList = mutableListOf() + val connectionsToComposite: MutableList = mutableListOf() + + addConnectionsToInternalNetwork( + network, + funBlock, + connectionsToComposite, + compositeNetwork, + factory, + blocksViews, + creatingConnections + ) + + network.eventConnections.addAll(creatingConnections.filter { it.kind == EntryKind.EVENT }) + network.dataConnections.addAll(creatingConnections.filter { it.kind == EntryKind.DATA }) + network.adapterConnections.addAll(creatingConnections.filter { it.kind == EntryKind.ADAPTER }) + + //Delete old connections to composite block + network.eventConnections.removeAll(connectionsToComposite) + network.dataConnections.removeAll(connectionsToComposite) + network.adapterConnections.removeAll(connectionsToComposite) + + //Delete composite block from network + network.functionBlocks.remove(funBlock.component) + } + + private fun addConnectionsToInternalNetwork( + network: FBNetwork, + funBlock: FunctionBlockView, + connectionsToComposite: MutableList, + compositeNetwork: FBNetwork, + factory: IEC61499Factory, + blocksViews: Map, + creatingConnections: MutableList + ) { + val map: MutableMap>> = HashMap() + + network.allConnections.forEach { + if (it.targetReference.getTarget()?.functionBlock == funBlock.component + || it.sourceReference.getTarget()?.functionBlock == funBlock.component) { + connectionsToComposite.add(it) + } + } + + compositeNetwork.allConnections.forEach { + val target = it.targetReference.getTarget() ?: return@forEach + val source = it.sourceReference.getTarget() ?: return@forEach + + if (source.functionBlock == null && target.functionBlock == null) return@forEach + + if (source.functionBlock != null && target.functionBlock != null) { + val newConnection = factory.createFBNetworkConnection(it.kind) + newConnection.targetReference.setTarget( + PortPath.createPortPath(blocksViews[target.functionBlock]!!, it.kind, target.portTarget)) + newConnection.sourceReference.setTarget( + PortPath.createPortPath(blocksViews[source.functionBlock]!!, it.kind, source.portTarget)) + newConnection.path = it.path + creatingConnections.add(newConnection) + } + + if (source.functionBlock == null) { + if (map[source.portTarget] == null) { + map[source.portTarget] = mutableListOf() + } + + map[source.portTarget]!!.add(target.portTarget to (target.functionBlock as FunctionBlockDeclaration)) + + connectionsToComposite.filterNot { + it.sourceReference.getTarget()?.functionBlock == it.targetReference.getTarget()?.functionBlock + }.forEach { connToComposite -> + val cTarget = connToComposite.targetReference.getTarget() + val cSource = connToComposite.sourceReference.getTarget() + + if (cTarget?.portTarget == source.portTarget && cSource != null) { + val newConnection = factory.createFBNetworkConnection(it.kind) + newConnection.targetReference.setTarget( + PortPath.createPortPath(blocksViews[target.functionBlock]!!, it.kind, target.portTarget) + ) + newConnection.path = it.path + newConnection.sourceReference.setTarget( + PortPath.createPortPath(cSource.functionBlock, it.kind, cSource.portTarget) + ) + creatingConnections.add(newConnection) + } + } + } + + if (target.functionBlock == null) { + if (map[target.portTarget] == null) { + map[target.portTarget] = mutableListOf() + } + + map[target.portTarget]!!.add(source.portTarget to (source.functionBlock as FunctionBlockDeclaration)) + + connectionsToComposite.filterNot { + it.sourceReference.getTarget()?.functionBlock == it.targetReference.getTarget()?.functionBlock + }.forEach { connToComposite -> + val cSource = connToComposite.sourceReference.getTarget() + val cTarget = connToComposite.targetReference.getTarget() + + if (cSource?.portTarget == target.portTarget && cTarget != null) { + val newConnection = factory.createFBNetworkConnection(it.kind) + newConnection.sourceReference.setTarget( + PortPath.createPortPath(blocksViews[target.functionBlock]!!, it.kind, target.portTarget) + ) + newConnection.path = it.path + newConnection.targetReference.setTarget( + PortPath.createPortPath(cTarget.functionBlock, it.kind, cTarget.portTarget)) + creatingConnections.add(newConnection) + } + } + } + } + + connectionsToComposite.filter { + it.sourceReference.getTarget()?.functionBlock == it.targetReference.getTarget()?.functionBlock + }.forEach { + val source = it.sourceReference.getTarget() ?: return@forEach + val target = it.targetReference.getTarget() ?: return@forEach + val targetList = map[target.portTarget] + val sourceList = map[source.portTarget] + + targetList?.forEach{(tPort, tFb) -> + sourceList?.forEach {(sPort, sFb) -> + val newConnection = factory.createFBNetworkConnection(it.kind) + newConnection.sourceReference.setTarget( + PortPath.createPortPath(blocksViews[sFb]!!, it.kind, sPort) + ) + newConnection.targetReference.setTarget( + PortPath.createPortPath(blocksViews[tFb]!!, it.kind, tPort) + ) + newConnection.path = ConnectionPath(30, 300, 30) + creatingConnections.add(newConnection) + } + } + } + } + + private fun addBlocksFromComposite( + funBlock: FunctionBlockView, + compositeNetwork: FBNetwork, + network: FBNetwork, + factory: IEC61499Factory + ): Map { + val blocksViews = compositeNetwork.functionBlocks.associateWith { + val identifier = StringIdentifier("${funBlock.component.name}_${it.name}") + val newView = factory.createFunctionBlockDeclaration(identifier) + newView.typeReference.setTarget(it.typeReference.getTarget()!!) + newView.x = it.x + funBlock.component.x + newView.y = it.y + funBlock.component.y + newView + } + + blocksViews.values.forEach { + network.functionBlocks.add(it) + } + + return blocksViews + } + + companion object { + const val CANT_GET_FB_CELL = "Couldn't find functional block!" + } +} diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/editor/RichEditorStyleAttributes.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/editor/RichEditorStyleAttributes.kt index 69e3d1d02..15f47c32b 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/editor/RichEditorStyleAttributes.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/editor/RichEditorStyleAttributes.kt @@ -4,6 +4,7 @@ import jetbrains.mps.editor.runtime.style.InheritableStyleAttribute import jetbrains.mps.editor.runtime.style.SimpleStyleAttribute import jetbrains.mps.openapi.editor.style.StyleAttribute import org.fbme.ide.richediting.adapters.ecc.cell.ActionBlock +import org.fbme.ide.richediting.adapters.fbnetwork.ExpandedComponentsController import org.fbme.ide.richediting.inspections.NetworkInspectionsFacility import org.fbme.ide.richediting.viewmodel.FunctionBlockView import org.fbme.ide.richediting.viewmodel.NetworkComponentView @@ -44,6 +45,10 @@ object RichEditorStyleAttributes { @JvmField val EDITED_FBS: StyleAttribute> = InheritableStyleAttribute("edited-fbs") + @JvmField + val EXPANDED_COMPONENTS_CONTROLLER: StyleAttribute = + InheritableStyleAttribute("expanded-controller") + @JvmField val STATE_ACTION: StyleAttribute = InheritableStyleAttribute("state-action") @@ -92,5 +97,6 @@ object RichEditorStyleAttributes { INSPECTIONS_FACILITY.register() VIEWPOINT.register() ECC.register() + EXPANDED_COMPONENTS_CONTROLLER.register() } } diff --git a/code/richediting/src/main/resources/META-INF/plugin.xml b/code/richediting/src/main/resources/META-INF/plugin.xml index 58b8bf4b3..1f52e099e 100644 --- a/code/richediting/src/main/resources/META-INF/plugin.xml +++ b/code/richediting/src/main/resources/META-INF/plugin.xml @@ -37,7 +37,7 @@ class="org.fbme.ide.richediting.actions.network.ChangeTypeAction" text="ChangeType"/> Date: Wed, 31 May 2023 18:16:00 +0200 Subject: [PATCH 23/66] Fix deleting connections on deleting port --- .../org/fbme/lib/iec61499/fbnetwork/FBNetwork.kt | 8 ++++++++ .../adapters/fbnetwork/FBNetworkEditors.kt | 1 - .../actions/cell/port/DeletePortAction.kt | 15 ++++++++++++--- .../adapters/fbnetwork/port/EditablePortLabel.kt | 2 +- .../adapters/fbnetwork/port/PortActionFactory.kt | 5 +++-- .../inspections/NetworkInspectionsFacility.kt | 1 - 6 files changed, 24 insertions(+), 8 deletions(-) diff --git a/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FBNetwork.kt b/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FBNetwork.kt index 84272dbb9..26242174a 100644 --- a/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FBNetwork.kt +++ b/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FBNetwork.kt @@ -70,6 +70,14 @@ interface FBNetwork : Element { return result } + fun getConnections(kind: EntryKind): MutableList { + return when (kind) { + EntryKind.EVENT -> this.eventConnections + EntryKind.DATA -> this.dataConnections + EntryKind.ADAPTER -> this.adapterConnections + } + } + companion object { @JvmStatic fun extractNetwork(declaration: Declaration?): FBNetwork? { diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt index fd15b56ef..9d32d9f7d 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkEditors.kt @@ -138,7 +138,6 @@ object FBNetworkEditors { style.set(RichEditorStyleAttributes.NETWORK_INSTANCE, networkInstance) style.set(SCENE_BACKGROUND, MPSColors.WHITE) val component = context.editorComponent as EditorComponent - //val project = context.operationContext.project val project = ProjectProvider.getInstance(context) ?: error("Can't get project") val repository = PlatformRepositoryProvider.getInstance(project) try { diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/port/DeletePortAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/port/DeletePortAction.kt index d04c23dcd..053f2c014 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/port/DeletePortAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/actions/cell/port/DeletePortAction.kt @@ -1,13 +1,16 @@ package org.fbme.ide.richediting.adapters.fbnetwork.actions.cell.port import jetbrains.mps.openapi.editor.EditorContext +import jetbrains.mps.openapi.editor.style.Style import org.fbme.ide.richediting.adapters.fbnetwork.actions.cell.DefaultAction +import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.lib.common.Declaration import org.fbme.lib.iec61499.descriptors.FBPortDescriptor class DeletePortAction( private val port: FBPortDescriptor, - private val ports: MutableList + private val ports: MutableList, + private val style: Style ): DefaultAction(canExecute = false, executeInCommand = true) { override fun getDescriptionText(): String = "Delete port" @@ -17,10 +20,16 @@ class DeletePortAction( override fun execute(context: EditorContext?) { context ?: return + val networkInstance = style.get(RichEditorStyleAttributes.NETWORK_INSTANCE) ?: return + + context.repository.modelAccess.executeCommandInEDT { + networkInstance.networkDeclaration.getConnections(port.connectionKind).removeAll { + val reference = if (port.isInput) it.targetReference else it.sourceReference + reference.getTarget()?.portTarget == port.declaration + } - context.repository.modelAccess.runWriteInEDT { ports.remove(port.declaration) context.editorComponent.updater.update() } } -} \ No newline at end of file +} diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/EditablePortLabel.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/EditablePortLabel.kt index 96f883855..8591df85f 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/EditablePortLabel.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/EditablePortLabel.kt @@ -19,7 +19,7 @@ open class EditablePortLabel( init { label = EditorCell_Property(context, DeclarationNameAccessor(port.declaration) { true }, node) - label.setAction(CellActionType.BACKSPACE, PortActionFactory.deletePortAction(port, declaration)) + label.setAction(CellActionType.BACKSPACE, PortActionFactory.deletePortAction(port, declaration, label.style)) label.style.set(RichEditorStyleAttributes.PORT, port) } } \ No newline at end of file diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt index 47ebeaf8e..eda77f03d 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt @@ -1,6 +1,7 @@ package org.fbme.ide.richediting.adapters.fbnetwork.port import jetbrains.mps.openapi.editor.cells.CellAction +import jetbrains.mps.openapi.editor.style.Style import org.fbme.lib.common.Identifier import org.fbme.lib.common.StringIdentifier import org.fbme.lib.iec61499.IEC61499Factory @@ -85,7 +86,7 @@ object PortActionFactory { ) } - fun deletePortAction(port: FBPortDescriptor, fbTypeDeclaration: Declaration?) : CellAction? { + fun deletePortAction(port: FBPortDescriptor, fbTypeDeclaration: Declaration?, style: Style) : CellAction? { fbTypeDeclaration ?: return null if (fbTypeDeclaration !is FBInterfaceDeclaration) { @@ -108,7 +109,7 @@ object PortActionFactory { } } - return DeletePortAction(port, ports) + return DeletePortAction(port, ports, style) } val IDENTIFIER_FACTORY: (prefix: String, values: List) -> Supplier = { prefix, names -> diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/inspections/NetworkInspectionsFacility.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/inspections/NetworkInspectionsFacility.kt index 5f9aa1847..08391be94 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/inspections/NetworkInspectionsFacility.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/inspections/NetworkInspectionsFacility.kt @@ -1,6 +1,5 @@ package org.fbme.ide.richediting.inspections -import jetbrains.mps.editor.runtime.style.Padding import jetbrains.mps.editor.runtime.style.StyleAttributes import jetbrains.mps.nodeEditor.EditorSettings import jetbrains.mps.nodeEditor.MPSColors From 37226ff2ec2c6f5332adcca247a3b9e976d3512b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Thu, 1 Jun 2023 18:43:16 +0200 Subject: [PATCH 24/66] Add notification user if block uses in several places --- .../fbnetwork/FunctionBlockDeclarationBase.kt | 5 ++- .../fbnetwork/FunctionBlockController.kt | 20 ++++++++++-- .../ide/richediting/utils/fb/FBUsageFinder.kt | 31 +++++++++++++++++++ 3 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBUsageFinder.kt diff --git a/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FunctionBlockDeclarationBase.kt b/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FunctionBlockDeclarationBase.kt index fb794383a..78c69dd18 100644 --- a/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FunctionBlockDeclarationBase.kt +++ b/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/FunctionBlockDeclarationBase.kt @@ -27,15 +27,14 @@ interface FunctionBlockDeclarationBase : Declaration, ContainedElement { return result } - fun getAllPorts(): List { - return type.eventInputPorts + fun getAllPorts(): List = + type.eventInputPorts .union(type.eventOutputPorts) .union(type.dataInputPorts) .union(type.dataOutputPorts) .union(type.socketPorts) .union(type.plugPorts) .toList() - } var x: Int var y: Int diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt index 42a295f24..79f90edf3 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt @@ -4,7 +4,6 @@ import jetbrains.mps.editor.runtime.style.CellAlign import jetbrains.mps.editor.runtime.style.Measure import jetbrains.mps.editor.runtime.style.Padding import jetbrains.mps.editor.runtime.style.StyleAttributes -import jetbrains.mps.findUsages.FindUsagesManager import jetbrains.mps.nodeEditor.MPSColors import jetbrains.mps.nodeEditor.cellLayout.CellLayout_Vertical import jetbrains.mps.nodeEditor.cells.EditorCell @@ -20,6 +19,9 @@ import org.fbme.ide.richediting.adapters.fbnetwork.fb.FBTypeCellComponent import org.fbme.ide.richediting.adapters.fbnetwork.fb.EditableFBTypeCell import org.fbme.ide.richediting.adapters.fbnetwork.port.PortActionFactory import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.ide.richediting.utils.Notifier +import org.fbme.ide.richediting.utils.ProjectProvider +import org.fbme.ide.richediting.utils.fb.FBUsageFinder import org.fbme.ide.richediting.viewmodel.* import org.fbme.lib.iec61499.DeclarationsScope import org.fbme.lib.iec61499.IEC61499Factory @@ -324,7 +326,21 @@ class FunctionBlockController( override fun executeInCommand(): Boolean = true override fun canExecute(context: EditorContext): Boolean { - //FindUsagesManager + val project = ProjectProvider.getInstance(context)!! + val res = FBUsageFinder + .findUsages(project, view.component.type.declaration!!) + .filter { + it.key.identifier != networkInstance.declaration.identifier + }.map { + it.key + } + if (res.isNotEmpty()) { + Notifier.showWarning( + "This function block uses also in " + + res.joinToString { it.name } + "!", + project.project + ) + } return true } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBUsageFinder.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBUsageFinder.kt new file mode 100644 index 000000000..9c531caf1 --- /dev/null +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBUsageFinder.kt @@ -0,0 +1,31 @@ +package org.fbme.ide.richediting.utils.fb + +import jetbrains.mps.findUsages.FindUsagesManager +import jetbrains.mps.project.MPSProject +import org.fbme.ide.iec61499.repository.PlatformElement +import org.fbme.ide.iec61499.repository.PlatformRepositoryProvider +import org.fbme.lib.common.Declaration +import org.jetbrains.mps.openapi.model.SNode + +object FBUsageFinder { + fun findUsages(project: MPSProject, fbBlock: Declaration) + : Map { + val manager = project.getComponent(FindUsagesManager::class.java) + val platformElement = (fbBlock as PlatformElement) + val nodes = manager.findUsages(project.scope, mutableSetOf(platformElement.node), null) + val repository = PlatformRepositoryProvider.getInstance(project) + + val result: MutableMap = HashMap() + nodes.mapNotNull { + it.sourceNode.parent + }.forEach { + val declaration = repository.getAdapter(it, Declaration::class.java) + + if (declaration != null) { + result[declaration] = it + } + } + + return result + } +} From 718552187b1858f679be2873d934756e64bd6148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 4 Jun 2023 21:17:39 +0200 Subject: [PATCH 25/66] Extract common logic from magnetize function --- .../fbnetwork/FBConnectionController.kt | 35 ++++++++----------- 1 file changed, 14 insertions(+), 21 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBConnectionController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBConnectionController.kt index 27fe94e7c..daa5c6dc5 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBConnectionController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBConnectionController.kt @@ -146,26 +146,19 @@ class FBConnectionController(context: EditorContext, view: NetworkConnectionView } private fun magnetizeHorizontal(index: Int, bendPoints: MutableList) { - if (index >= bendPoints.size) { - return - } - val u = bendPoints[index - 1] - val v = bendPoints[index] - val uPrev = bendPoints[index - 2] - val vNext = bendPoints[index + 1] - if (abs(vNext.y - v.y) < scale(SELECTION_PADDING)) { - u.y = vNext.y - bendPoints.removeAt(index + 1) - bendPoints.removeAt(index) - } - if (abs(u.y - uPrev.y) < scale(SELECTION_PADDING)) { - v.y = uPrev.y - bendPoints.removeAt(index - 1) - bendPoints.removeAt(index - 2) - } + magnetize(index, bendPoints, { p -> p.y }, { p, v -> p.y = v }) } private fun magnetizeVertical(index: Int, bendPoints: MutableList) { + magnetize(index, bendPoints, { p -> p.x }, { p, v -> p.x = v }) + } + + private fun magnetize( + index: Int, + bendPoints: MutableList, + extractor: (p: Point) -> Int, + setter: (p: Point, x: Int) -> Unit + ) { if (index >= bendPoints.size) { return } @@ -173,13 +166,13 @@ class FBConnectionController(context: EditorContext, view: NetworkConnectionView val v = bendPoints[index] val uPrev = if (index - 2 >= 0) bendPoints[index - 2] else null val vNext = if (index + 1 < bendPoints.size) bendPoints[index + 1] else null - if (vNext != null && abs(vNext.x - v.x) < scale(SELECTION_PADDING)) { - u.x = vNext.x + if (vNext != null && abs(extractor(vNext) - extractor(v)) < scale(SELECTION_PADDING)) { + setter(u, extractor(vNext)) bendPoints.removeAt(index + 1) bendPoints.removeAt(index) } - if (uPrev != null && abs(u.x - uPrev.x) < scale(SELECTION_PADDING)) { - v.x = uPrev.x + if (uPrev != null && abs(extractor(u) - extractor(uPrev)) < scale(SELECTION_PADDING)) { + setter(v, extractor(uPrev)) bendPoints.removeAt(index - 1) bendPoints.removeAt(index - 2) } From 3d209dfa461eac079e391923007df05f61c7c596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 4 Jun 2023 21:20:24 +0200 Subject: [PATCH 26/66] Add custom notifier in scenes --- .../fbme/ide/richediting/utils/Notifier.kt | 2 +- .../src/main/resources/META-INF/plugin.xml | 2 +- .../kotlin/org/fbme/scenes/utils/Notifier.kt | 33 +++++++++++++++++++ .../src/main/resources/META-INF/plugin.xml | 1 + 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/utils/Notifier.kt diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt index e2dc4d466..e4241c078 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/Notifier.kt @@ -5,7 +5,7 @@ import com.intellij.notification.NotificationType import com.intellij.openapi.project.Project object Notifier { - private const val NOTIFICATION_GROUP = "Custom" + private const val NOTIFICATION_GROUP = "Custom-richediting" fun showWarning(message: String, project: Project? = null) { NotificationGroupManager diff --git a/code/richediting/src/main/resources/META-INF/plugin.xml b/code/richediting/src/main/resources/META-INF/plugin.xml index 1f52e099e..2ffc9da06 100644 --- a/code/richediting/src/main/resources/META-INF/plugin.xml +++ b/code/richediting/src/main/resources/META-INF/plugin.xml @@ -11,7 +11,7 @@ - + diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/utils/Notifier.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/utils/Notifier.kt new file mode 100644 index 000000000..c0784d89f --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/utils/Notifier.kt @@ -0,0 +1,33 @@ +package org.fbme.scenes.utils + +import com.intellij.notification.NotificationGroupManager +import com.intellij.notification.NotificationType +import com.intellij.openapi.project.Project + +object Notifier { + private const val NOTIFICATION_GROUP = "Custom-scenes" + + fun showWarning(message: String, project: Project? = null) { + NotificationGroupManager + .getInstance() + .getNotificationGroup(NOTIFICATION_GROUP) + .createNotification(message, NotificationType.WARNING) + .notify(project) + } + + fun showInformation(message: String, project: Project? = null) { + NotificationGroupManager + .getInstance() + .getNotificationGroup(NOTIFICATION_GROUP) + .createNotification(message, NotificationType.INFORMATION) + .notify(project) + } + + fun showError(message: String, project: Project? = null) { + NotificationGroupManager + .getInstance() + .getNotificationGroup(NOTIFICATION_GROUP) + .createNotification(message, NotificationType.ERROR) + .notify(project) + } +} diff --git a/code/scenes/src/main/resources/META-INF/plugin.xml b/code/scenes/src/main/resources/META-INF/plugin.xml index b0a61eb9d..89be27770 100644 --- a/code/scenes/src/main/resources/META-INF/plugin.xml +++ b/code/scenes/src/main/resources/META-INF/plugin.xml @@ -11,6 +11,7 @@ + From 11b269b6bf9e3fbad0870ab3e6b6845fa58bd9ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 4 Jun 2023 21:22:08 +0200 Subject: [PATCH 27/66] Add exceptions in scenes --- .../org/fbme/scenes/exceptions/InitializationException.kt | 6 ++++++ .../kotlin/org/fbme/scenes/exceptions/NoEntityException.kt | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/exceptions/InitializationException.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/exceptions/NoEntityException.kt diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/exceptions/InitializationException.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/exceptions/InitializationException.kt new file mode 100644 index 000000000..b10736d02 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/exceptions/InitializationException.kt @@ -0,0 +1,6 @@ +package org.fbme.scenes.exceptions + +class InitializationException : Exception { + constructor(message: String?) : super(message) + constructor(message: String?, cause: Throwable?) : super(message, cause) +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/exceptions/NoEntityException.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/exceptions/NoEntityException.kt new file mode 100644 index 000000000..92f04d2d8 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/exceptions/NoEntityException.kt @@ -0,0 +1,6 @@ +package org.fbme.scenes.exceptions + +class NoEntityException : Exception { + constructor(message: String?) : super(message) + constructor(message: String?, cause: Throwable?) : super(message, cause) +} \ No newline at end of file From 61a6331b45e08e5b2177b7999119888e5bb8bf95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 4 Jun 2023 21:31:00 +0200 Subject: [PATCH 28/66] Return unresolved files .name, codeStyle --- .idea/.name | 1 + .idea/codeStyles/codeStyleConfig.xml | 5 +++++ 2 files changed, 6 insertions(+) create mode 100644 .idea/.name create mode 100644 .idea/codeStyles/codeStyleConfig.xml diff --git a/.idea/.name b/.idea/.name new file mode 100644 index 000000000..dae8a134b --- /dev/null +++ b/.idea/.name @@ -0,0 +1 @@ +FBME \ No newline at end of file diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml new file mode 100644 index 000000000..a55e7a179 --- /dev/null +++ b/.idea/codeStyles/codeStyleConfig.xml @@ -0,0 +1,5 @@ + + + + \ No newline at end of file From 774de34c91e7b2f438fb6e47f7cc8a452fd8d4c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 4 Jun 2023 21:33:36 +0200 Subject: [PATCH 29/66] Return compiler file --- .idea/compiler.xml | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 .idea/compiler.xml diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 000000000..58d13c02c --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From e174eaeb5d08b1ccdd32b47a2ede252b2db59d5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 4 Jun 2023 21:37:46 +0200 Subject: [PATCH 30/66] Return jarRepositories and encodings file --- .idea/encodings.xml | 4 +++ .idea/jarRepositories.xml | 70 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 000000000..c2c0496ed --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 000000000..dc08c64af --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 1a2bc2aefe74bc03ae7d0d3a4b4f38fab1b2428e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 4 Jun 2023 21:39:26 +0200 Subject: [PATCH 31/66] Fix encodings tab --- .idea/encodings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/encodings.xml b/.idea/encodings.xml index c2c0496ed..15a15b218 100644 --- a/.idea/encodings.xml +++ b/.idea/encodings.xml @@ -1,4 +1,4 @@ - + \ No newline at end of file From 147a40e1871810d7ab544e69cee1065ef9bbf6ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 4 Jun 2023 21:42:13 +0200 Subject: [PATCH 32/66] Return vcs file --- .idea/vcs.xml | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 .idea/vcs.xml diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..5fc092178 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,11 @@ + + + + + + + + + \ No newline at end of file From f579a69d2a25a024b5b597905ad4c4546f16ddfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 4 Jun 2023 22:23:52 +0200 Subject: [PATCH 33/66] Return Kotlin scripting file --- .idea/kotlinScripting.xml | 6 ++++++ .idea/kotlinc.xml | 6 ++++++ 2 files changed, 12 insertions(+) create mode 100644 .idea/kotlinScripting.xml create mode 100644 .idea/kotlinc.xml diff --git a/.idea/kotlinScripting.xml b/.idea/kotlinScripting.xml new file mode 100644 index 000000000..a6fe551d0 --- /dev/null +++ b/.idea/kotlinScripting.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 000000000..7e340a776 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file From 299502b3ff4b9f3f03aac62c08d4159f7a28f473 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 4 Jun 2023 22:26:28 +0200 Subject: [PATCH 34/66] Return misc file --- .idea/misc.xml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .idea/misc.xml diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 000000000..4981e477a --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + \ No newline at end of file From fa856f29887f36fc5ed7066623c6dca6e2730fe4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Sun, 4 Jun 2023 23:11:36 +0200 Subject: [PATCH 35/66] Remove from using deprecated api --- .../richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt index 1f6f29958..f5e7d4148 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/FBTypeCellComponent.kt @@ -16,6 +16,7 @@ import org.fbme.ide.richediting.adapters.fbnetwork.port.Port import org.fbme.ide.richediting.adapters.fbnetwork.port.PortWithLabel import org.fbme.ide.richediting.editor.NetworkInstanceNavigationSupport import org.fbme.ide.richediting.editor.RichEditorStyleAttributes +import org.fbme.ide.richediting.utils.ProjectProvider import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.descriptors.FBTypeDescriptor import org.fbme.lib.iec61499.instances.NetworkInstance @@ -259,8 +260,7 @@ class FBTypeCellComponent(context: EditorContext, fbType: FBTypeDescriptor, node val childNetworkInstance = child.containedNetwork if (childNetworkInstance is NetworkInstance) { val navigationStub = NetworkInstanceNavigationSupport.getNavigationStub( - rootCell.context.operationContext.project, - childNetworkInstance + ProjectProvider.getInstance(rootCell.context)!!, childNetworkInstance ) style.set(StyleAttributes.NAVIGATABLE_NODE, navigationStub) return From 3b87e611dfec71e76b84cc6ba6af5843b2110f38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 5 Jun 2023 23:17:21 +0200 Subject: [PATCH 36/66] Refactor TypeDescriptorAdapter: add broken ports, extract common logic from getters --- .../viewmodel/TypeDescriptorAdapter.kt | 99 ++++++++----------- 1 file changed, 40 insertions(+), 59 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/TypeDescriptorAdapter.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/TypeDescriptorAdapter.kt index 51761eb9e..714ef30ef 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/TypeDescriptorAdapter.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/TypeDescriptorAdapter.kt @@ -17,65 +17,35 @@ class TypeDescriptorAdapter(private val myOriginal: FBTypeDescriptor) : FBTypeDe return myOriginal.declaration } override val eventInputPorts: List - get() { - val ports = myOriginal.eventInputPorts - val list = ArrayList(ports) - var i = ports.size - for (eventName in brokenPorts.inputEvents) { - list.add(FBPortDescriptor(eventName, EntryKind.EVENT, i++, true, false, null)) - } - return list - } + get() = getPorts(myOriginal.eventInputPorts, brokenPorts.inputEvents) override val eventOutputPorts: List - get() { - val ports = myOriginal.eventOutputPorts - val list = ArrayList(ports) - var i = ports.size - for (eventName in brokenPorts.outputEvents) { - list.add(FBPortDescriptor(eventName, EntryKind.EVENT, i++, false, false, null)) - } - return list - } + get() = getPorts(myOriginal.eventOutputPorts, brokenPorts.outputEvents) override val dataInputPorts: List - get() { - val ports = myOriginal.dataInputPorts - val list = ArrayList(ports) - var i = ports.size - for (eventName in brokenPorts.inputDatas) { - list.add(FBPortDescriptor(eventName, EntryKind.DATA, i++, true, false, null)) - } - return list - } + get() = getPorts(myOriginal.dataInputPorts, brokenPorts.inputDatas) override val dataOutputPorts: List - get() { - val ports = myOriginal.dataOutputPorts - val list = ArrayList(ports) - var i = ports.size - for (eventName in brokenPorts.outputDatas) { - list.add(FBPortDescriptor(eventName, EntryKind.DATA, i++, false, false, null)) - } - return list - } + get() = getPorts(myOriginal.dataOutputPorts, brokenPorts.outputDatas) override val socketPorts: List - get() { - val ports = myOriginal.socketPorts - val list = ArrayList(ports) - var i = ports.size - for (eventName in brokenPorts.sockets) { - list.add(FBPortDescriptor(eventName, EntryKind.ADAPTER, i++, true, false, null)) - } - return list - } + get() = getPorts(myOriginal.socketPorts, brokenPorts.sockets) override val plugPorts: List - get() { - val ports = myOriginal.plugPorts - val list = ArrayList(ports) - var i = ports.size - for (eventName in brokenPorts.plugs) { - list.add(FBPortDescriptor(eventName, EntryKind.ADAPTER, i++, true, false, null)) - } - return list + get() = getPorts(myOriginal.plugPorts, brokenPorts.plugs) + + private fun getPorts( + validPorts: List, + brokenPorts: List + ): List { + val result = ArrayList(validPorts) + brokenPorts.forEach { + result.add(FBPortDescriptor( + it.name, + it.connectionKind, + validPorts.size + (- it.position), + it.isInput, + it.isValid, + it.declaration) + ) } + return result + } override fun getAssociatedVariablesForInputEvent(eventNumber: Int): List { return myOriginal.getAssociatedVariablesForInputEvent(eventNumber) @@ -87,22 +57,33 @@ class TypeDescriptorAdapter(private val myOriginal: FBTypeDescriptor) : FBTypeDe class BrokenPorts { @JvmField - val inputEvents: List = ArrayList() + val inputEvents: MutableList = ArrayList() @JvmField - val outputEvents: List = ArrayList() + val outputEvents: MutableList = ArrayList() @JvmField - val inputDatas: List = ArrayList() + val inputDatas: MutableList = ArrayList() @JvmField - val outputDatas: List = ArrayList() + val outputDatas: MutableList = ArrayList() @JvmField - val plugs: List = ArrayList() + val plugs: MutableList = ArrayList() @JvmField - val sockets: List = ArrayList() + val sockets: MutableList = ArrayList() + + fun addPort(name: String, kind: EntryKind, isInput: Boolean) : FBPortDescriptor { + val list = when (kind) { + EntryKind.EVENT -> if (isInput) inputDatas else outputEvents + EntryKind.DATA -> if (isInput) inputDatas else outputDatas + EntryKind.ADAPTER -> if (isInput) sockets else plugs + } + val entry = FBPortDescriptor(name, kind, -list.size, isInput, false, null) + list.add(entry) + return entry + } } init { From 4ab763f093d4a11b7a434fbed1921da7396bca7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 5 Jun 2023 23:21:31 +0200 Subject: [PATCH 37/66] Refactor FBNetworkComponentController --- .../fbnetwork/FBNetworkComponentController.kt | 38 ++++--------------- 1 file changed, 8 insertions(+), 30 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkComponentController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkComponentController.kt index 201921bcf..b7146d31a 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkComponentController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FBNetworkComponentController.kt @@ -6,37 +6,15 @@ import java.awt.Rectangle interface FBNetworkComponentController { fun getBounds(position: Point): Rectangle - fun getFBCellBounds(position: Point): Rectangle { - return getBounds(position) - } - - fun getFBPortTemplates(): Set { - return emptySet() - } - + fun getFBCellBounds(position: Point): Rectangle = getBounds(position) + fun getFBPortTemplates(): Set = emptySet() fun getPortCoordinates(port: NetworkPortView, position: Point): Point fun getPortBounds(port: NetworkPortView, position: Point): Rectangle fun isSource(port: NetworkPortView): Boolean - fun canBeSourcedAt(port: NetworkPortView, position: Point): Boolean { - return isSource(port) - } - - fun canBeTargetedAt(port: NetworkPortView, position: Point): Boolean { - return !isSource(port) - } - - fun getTemplateBounds(template: NetworkPortView, modelForm: Point): Rectangle { - return Rectangle(0, 0) - } - - fun getTemplatePosition(template: NetworkPortView, modelForm: Point): Point { - return Point(0, 0) - } - - fun createPort(source: NetworkPortView, template: NetworkPortView): NetworkPortView? { - return null - } - - fun connectTo(port: NetworkPortView, source: NetworkPortView) { - } + fun canBeSourcedAt(port: NetworkPortView, position: Point): Boolean = isSource(port) + fun canBeTargetedAt(port: NetworkPortView, position: Point): Boolean = !isSource(port) + fun getTemplateBounds(template: NetworkPortView, modelForm: Point): Rectangle = Rectangle(0, 0) + fun getTemplatePosition(template: NetworkPortView, modelForm: Point): Point = Point(0, 0) + fun createPort(source: NetworkPortView, template: NetworkPortView): NetworkPortView? = null + fun connectTo(port: NetworkPortView, source: NetworkPortView) {} } From f763ddf1fa285e439dfe0600c869c3dadd3f7221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 5 Jun 2023 23:22:58 +0200 Subject: [PATCH 38/66] Refactor DiagramView --- .../kotlin/org/fbme/scenes/controllers/diagram/DiagramView.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramView.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramView.kt index ce6835283..2a91ec63f 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramView.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramView.kt @@ -13,6 +13,5 @@ interface DiagramView { fun setTargetPort(edge: E, port: P) fun removeEdge(edge: E) fun addEdge(sourcePort: P, targetPort: P): E? - fun addPort(port: P, component: C) { - } + fun addPort(port: P, component: C) {} } From e6d77cec7894001039b9eede1dee2b8f529c252f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 5 Jun 2023 23:25:51 +0200 Subject: [PATCH 39/66] Replace error with exception in DiagramFacility --- .../controllers/diagram/DiagramFacility.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt index 8c93c9242..6b01c5469 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/DiagramFacility.kt @@ -2,6 +2,7 @@ package org.fbme.scenes.controllers.diagram import org.fbme.scenes.controllers.diagram.entry.PortEntry import org.fbme.scenes.controllers.diagram.entry.PortTemplateEntry +import org.fbme.scenes.exceptions.NoEntityException class DiagramFacility( private val diagramModel: DiagramView, @@ -26,7 +27,7 @@ class DiagramFacility( componentToPorts[component] = ports for (port in ports) { this.ports.computeIfAbsent(port) { - PortEntry(it, component, componentSettings, portSettingProvider ) + PortEntry(it, component, componentSettings, portSettingProvider) } portToComponent[port] = component } @@ -34,7 +35,14 @@ class DiagramFacility( val templates = portSettingProvider.getPortTemplates(component) portTemplates.addAll(templates) templates.forEach { - val template = PortTemplateEntry(it, component, this.portToComponent, this.ports, componentSettings, portSettingProvider) + val template = PortTemplateEntry( + it, + component, + this.portToComponent, + this.ports, + componentSettings, + portSettingProvider + ) portTemplatesToComponent[template] = component } } @@ -63,11 +71,11 @@ class DiagramFacility( } override fun getComponent(port: PortT): CompT { - return portToComponent[port] ?: error("Component not found") + return portToComponent[port] ?: throw NoEntityException("Can't find component") } override fun getPortController(port: PortT): PortController { - return ports[port] ?: error("Port controller not found") + return ports[port] ?: throw NoEntityException("Can't find port controller") } override fun findPort(x: Int, y: Int): PortT? { @@ -89,7 +97,7 @@ class DiagramFacility( } override fun getPorts(component: CompT): Set { - return componentToPorts[component] ?: error("Ports not found") + return componentToPorts[component] ?: throw NoEntityException("Can't find port!") } override fun getSource(edge: ConnT): PortT? { From f49f9dadecd087458762ec1302c775ebf2c9de7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 5 Jun 2023 23:28:53 +0200 Subject: [PATCH 40/66] Add handling exception while creating edges layer --- .../scenes/controllers/diagram/ConnectionsFacility.kt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt index 4da46759b..5b115a953 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/ConnectionsFacility.kt @@ -9,6 +9,8 @@ import org.fbme.scenes.controllers.* import org.fbme.scenes.controllers.diagram.entry.ConnectionEntry import org.fbme.scenes.controllers.scene.* import org.fbme.scenes.controllers.selection.SelectionModel +import org.fbme.scenes.exceptions.InitializationException +import org.fbme.scenes.utils.Notifier import java.awt.Graphics import java.awt.Graphics2D import java.awt.Point @@ -63,7 +65,11 @@ class ConnectionsFacility( private fun init() { val viewConnections = diagramController.connections for (connection in viewConnections) { - connections[connection] = ConnectionEntry(this@ConnectionsFacility, connection) + try { + connections[connection] = ConnectionEntry(this@ConnectionsFacility, connection) + } catch (e: InitializationException) { + Notifier.showError(e.message ?: "Can't initialize connection entry!") + } } } From ff7051353f9b5b9c5c3d7d6f432c425088ba67fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 5 Jun 2023 23:31:35 +0200 Subject: [PATCH 41/66] Replace error with exception while creating ConnectionEntry --- .../controllers/diagram/entry/ConnectionEntry.kt | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/ConnectionEntry.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/ConnectionEntry.kt index b54c73ee1..69e6e0a1f 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/ConnectionEntry.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/controllers/diagram/entry/ConnectionEntry.kt @@ -2,6 +2,8 @@ package org.fbme.scenes.controllers.diagram.entry import org.fbme.scenes.controllers.diagram.ConnectionController import org.fbme.scenes.controllers.diagram.ConnectionsFacility +import org.fbme.scenes.exceptions.InitializationException +import org.fbme.scenes.exceptions.NoEntityException import java.awt.Point import java.awt.Rectangle @@ -59,10 +61,13 @@ internal class ConnectionEntry( init { val diagramController = connectionsFacility.diagramController - val sourcePort = diagramController.getSource(connection) ?: error("Source not found") - val targetPort = diagramController.getTarget(connection) ?: error("Target not found") - val sourcePortController = diagramController.getPortController(sourcePort) - val targetPortController = diagramController.getPortController(targetPort) + val sourcePort = diagramController.getSource(connection) ?: throw InitializationException("Source not found") + val targetPort = diagramController.getTarget(connection) ?: throw InitializationException("Target not found") + val (sourcePortController, targetPortController) = try { + diagramController.getPortController(sourcePort) to diagramController.getPortController(targetPort) + } catch (e: NoEntityException) { + throw InitializationException(e.message, e) + } modelPath = pathProvider(sourcePortController.modelEndpointPosition, targetPortController.modelEndpointPosition) } } From 65fac58c9e92ac230fe9693c533ed063ca62eefb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 5 Jun 2023 23:38:38 +0200 Subject: [PATCH 42/66] Revert changes in delivery service --- .../DeliveryServices.app | 64 +++++++++---------- 1 file changed, 32 insertions(+), 32 deletions(-) diff --git a/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.enas/DeliveryServices.app b/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.enas/DeliveryServices.app index 482d196f9..f46fb79bb 100644 --- a/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.enas/DeliveryServices.app +++ b/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.enas/DeliveryServices.app @@ -55,49 +55,49 @@ - + - + - + - + - + - - - - - - + + + + + + - + - + - - - - - + + + + + @@ -107,9 +107,9 @@ - + - + @@ -119,28 +119,28 @@ - + - - + + - - + + - - - - + + + + - - - + + + From 69dcb0678d7fe3bc7c00651b78aa4d353a1e9a0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 5 Jun 2023 23:42:20 +0200 Subject: [PATCH 43/66] Revert changes in blinky samples --- ....fbme.ide.iec61499.lang.sandbox.blinky.mps | 40 +++++++++---------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.blinky.mps b/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.blinky.mps index b3940b5a3..77ad4dbfb 100644 --- a/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.blinky.mps +++ b/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.blinky.mps @@ -299,10 +299,10 @@ - - - - + + + + @@ -314,10 +314,10 @@ - - - - + + + + @@ -329,9 +329,7 @@ - - - + @@ -342,32 +340,30 @@ - - - + - - + + - - + + - - + + @@ -379,8 +375,8 @@ - - + + From 502753a6ff73c5ecfe308d3d65f0cc8a49434134 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Tue, 6 Jun 2023 10:00:13 +0200 Subject: [PATCH 44/66] Return dictionaries files --- .idea/dictionaries/IEC_61499_Terms.xml | 7 +++++++ .idea/dictionaries/default.xml | 7 +++++++ .idea/dictionaries/project_dictionary.xml | 7 +++++++ 3 files changed, 21 insertions(+) create mode 100644 .idea/dictionaries/IEC_61499_Terms.xml create mode 100644 .idea/dictionaries/default.xml create mode 100644 .idea/dictionaries/project_dictionary.xml diff --git a/.idea/dictionaries/IEC_61499_Terms.xml b/.idea/dictionaries/IEC_61499_Terms.xml new file mode 100644 index 000000000..97a1283bd --- /dev/null +++ b/.idea/dictionaries/IEC_61499_Terms.xml @@ -0,0 +1,7 @@ + + + + subapplication + + + \ No newline at end of file diff --git a/.idea/dictionaries/default.xml b/.idea/dictionaries/default.xml new file mode 100644 index 000000000..459e72842 --- /dev/null +++ b/.idea/dictionaries/default.xml @@ -0,0 +1,7 @@ + + + + mbeddr + + + \ No newline at end of file diff --git a/.idea/dictionaries/project_dictionary.xml b/.idea/dictionaries/project_dictionary.xml new file mode 100644 index 000000000..8ad2401b9 --- /dev/null +++ b/.idea/dictionaries/project_dictionary.xml @@ -0,0 +1,7 @@ + + + + fbme + + + \ No newline at end of file From 84d4e8a971fe8d9b73a9bbee91099c9366bfdb13 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Tue, 6 Jun 2023 10:41:15 +0200 Subject: [PATCH 45/66] Return uidesiger file --- .idea/uiDesigner.xml | 124 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 124 insertions(+) create mode 100644 .idea/uiDesigner.xml diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml new file mode 100644 index 000000000..e96534fb2 --- /dev/null +++ b/.idea/uiDesigner.xml @@ -0,0 +1,124 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file From 847e19d9c34e43dd7bc14bbd62e4c8c61c9517f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 19 Jun 2023 13:02:58 +0200 Subject: [PATCH 46/66] Rename SocketPluginDeclaration.kt to AdapterDeclaration --- ...inDeclaration.kt => AdapterDeclaration.kt} | 4 ++-- .../iec61499/declarations/PlugDeclaration.kt | 2 +- .../declarations/SocketDeclaration.kt | 2 +- .../fbnetwork/FunctionBlockController.kt | 19 ++++++++++++++++++- .../fbnetwork/fb/EditableFBTypeCell.kt | 2 +- .../port/EditablePortWithTypeAndLabel.kt | 2 -- .../fbme/ide/richediting/utils/fb/FBUtils.kt | 2 +- 7 files changed, 24 insertions(+), 9 deletions(-) rename code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/{SocketPluginDeclaration.kt => AdapterDeclaration.kt} (79%) diff --git a/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketPluginDeclaration.kt b/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/AdapterDeclaration.kt similarity index 79% rename from code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketPluginDeclaration.kt rename to code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/AdapterDeclaration.kt index d20bf7d10..a087a44ee 100644 --- a/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketPluginDeclaration.kt +++ b/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/AdapterDeclaration.kt @@ -3,7 +3,7 @@ package org.fbme.lib.iec61499.declarations import org.fbme.lib.common.Reference import org.fbme.lib.iec61499.fbnetwork.FunctionBlockDeclarationBase -interface SocketPluginDeclaration : FunctionBlockDeclarationBase { +interface AdapterDeclaration : FunctionBlockDeclarationBase { override val container: FBInterfaceDeclarationWithAdapters? val typeReference: Reference -} \ No newline at end of file +} diff --git a/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/PlugDeclaration.kt b/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/PlugDeclaration.kt index 22f910ebc..7ca44abe4 100644 --- a/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/PlugDeclaration.kt +++ b/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/PlugDeclaration.kt @@ -1,3 +1,3 @@ package org.fbme.lib.iec61499.declarations -interface PlugDeclaration : SocketPluginDeclaration +interface PlugDeclaration : AdapterDeclaration diff --git a/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketDeclaration.kt b/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketDeclaration.kt index 16205f1a3..027227883 100644 --- a/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketDeclaration.kt +++ b/code/library/src/main/kotlin/org/fbme/lib/iec61499/declarations/SocketDeclaration.kt @@ -1,3 +1,3 @@ package org.fbme.lib.iec61499.declarations -interface SocketDeclaration : SocketPluginDeclaration +interface SocketDeclaration : AdapterDeclaration diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt index 79f90edf3..76aaa4ee1 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt @@ -26,6 +26,7 @@ import org.fbme.ide.richediting.viewmodel.* import org.fbme.lib.iec61499.DeclarationsScope import org.fbme.lib.iec61499.IEC61499Factory import org.fbme.lib.iec61499.declarations.* +import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.fbnetwork.EntryKind import org.fbme.lib.iec61499.instances.FunctionBlockInstance import org.fbme.lib.iec61499.instances.NetworkInstance @@ -35,6 +36,7 @@ import org.fbme.scenes.cells.button.EditButton import org.fbme.scenes.controllers.LayoutUtil.getLineSize import org.fbme.scenes.controllers.components.ComponentController import org.fbme.scenes.controllers.edited.EditedModel +import org.fbme.scenes.exceptions.NoEntityException import org.jetbrains.mps.openapi.model.SNode import java.awt.* import java.util.function.Function @@ -238,17 +240,32 @@ class FunctionBlockController( if (myPort.target is ParameterDeclaration && source.target is ParameterDeclaration) { myPort.target.type = source.target.type - } else if (myPort.target is SocketPluginDeclaration && source.target is SocketPluginDeclaration) { + } else if (myPort.target is AdapterDeclaration && source.target is AdapterDeclaration) { val target = source.target.typeReference.getTarget() ?: return myPort.target.typeReference.setTarget(target) } } private fun assertMine(port: NetworkPortView): FunctionBlockPortView { + if (port is BrokenPortView && port.component == view) { + val descriptor = view.findPort(port.declaration!!.name, port.declaration.kind, port.isInput) + ?: throw NoEntityException("Port doesn't belong fb!") + return FunctionBlockPortView.create(view, port.declaration, descriptor) + } require(!(port.component != view || port !is FunctionBlockPortView)) { "invalid port" } return port } + private fun FunctionBlockView.findPort(name: String, kind: EntryKind, isInput: Boolean): FBPortDescriptor? { + val ports = when (kind) { + EntryKind.EVENT -> this.type.eventInputPorts to this.type.eventOutputPorts + EntryKind.DATA -> this.type.dataInputPorts to this.type.dataOutputPorts + EntryKind.ADAPTER -> this.type.socketPorts to this.type.plugPorts + } + + return (if (isInput) ports.first else ports.second).find { it.name == name } + } + override fun translateForm(originalForm: Point, dx: Int, dy: Int): Point { val position = Point(originalForm) position.translate(dx, dy) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt index efc9e1d87..bbbc0bccc 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt @@ -260,7 +260,7 @@ class EditableFBTypeCell( fun addPlugSocketPort(port: FBPortDescriptor, ports: MutableList, block: EditorCell_Collection, types: List, horizontalAlign: CellAlign, padding: StyleAttribute) { - val typeDeclaration = port.declaration as SocketPluginDeclaration + val typeDeclaration = port.declaration as AdapterDeclaration val items = types.map { object : CompletionItem { override fun getMatchingText(pattern: String?): String = it.name diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/EditablePortWithTypeAndLabel.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/EditablePortWithTypeAndLabel.kt index 1683e6e09..56c90d784 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/EditablePortWithTypeAndLabel.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/EditablePortWithTypeAndLabel.kt @@ -36,8 +36,6 @@ class EditablePortWithTypeAndLabel( ): EditorCell_SceneLabel { val typeLabel = object : EditorCell_SceneLabel(context, node, typeName ?: TYPE_DEFAULT_NAME, typeName.isNullOrEmpty()) { - override fun setSelected(selected: Boolean) { //do nothing - } } //set style diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBUtils.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBUtils.kt index c1cb66140..94ac24181 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBUtils.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBUtils.kt @@ -103,6 +103,6 @@ object FBUtils { && (a.name == b.name) && (((aDeclaration is EventDeclaration) && (bDeclaration is EventDeclaration)) || (aDeclaration is ParameterDeclaration && bDeclaration is ParameterDeclaration && aDeclaration.type == bDeclaration.type) - || (aDeclaration is SocketPluginDeclaration && bDeclaration is SocketPluginDeclaration && aDeclaration.typeReference.getTarget() == bDeclaration.typeReference.getTarget())) + || (aDeclaration is AdapterDeclaration && bDeclaration is AdapterDeclaration && aDeclaration.typeReference.getTarget() == bDeclaration.typeReference.getTarget())) } } From bd271a6160a70c425049691359a7172a2976e3ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 19 Jun 2023 13:05:51 +0200 Subject: [PATCH 47/66] Delete port button --- .../richediting/adapters/fbnetwork/port/PortButton.kt | 10 ---------- 1 file changed, 10 deletions(-) delete mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortButton.kt diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortButton.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortButton.kt deleted file mode 100644 index e53cd1b3b..000000000 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortButton.kt +++ /dev/null @@ -1,10 +0,0 @@ -package org.fbme.ide.richediting.adapters.fbnetwork.port - -/* -import jetbrains.mps.openapi.editor.EditorContext -import org.fbme.scenes.cells.EditorCell_SceneLabel -import org.jetbrains.mps.openapi.model.SNode - -class PortButton(context: EditorContext, node: SNode) : EditorCell_SceneLabel(context, node) { - -}*/ From cefa1e89edee2942c53a02815955394fbb7b8432 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 19 Jun 2023 13:59:23 +0200 Subject: [PATCH 48/66] Remove DataTypeUtil.kt --- .../src/main/kotlin/org/fbme/lib/st/types/DataType.kt | 7 +++++++ .../src/main/kotlin/org/fbme/lib/st/types/DataTypeUtil.kt | 7 ------- .../adapters/fbnetwork/fb/EditableFBTypeCell.kt | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) delete mode 100644 code/library/src/main/kotlin/org/fbme/lib/st/types/DataTypeUtil.kt diff --git a/code/library/src/main/kotlin/org/fbme/lib/st/types/DataType.kt b/code/library/src/main/kotlin/org/fbme/lib/st/types/DataType.kt index fe3182f3e..894b44c00 100644 --- a/code/library/src/main/kotlin/org/fbme/lib/st/types/DataType.kt +++ b/code/library/src/main/kotlin/org/fbme/lib/st/types/DataType.kt @@ -2,4 +2,11 @@ package org.fbme.lib.st.types interface DataType { fun stringify(): String + + companion object { + @JvmStatic + fun getAllValues(): List { + return listOf(*GenericType.values(), *ElementaryType.values()) + } + } } diff --git a/code/library/src/main/kotlin/org/fbme/lib/st/types/DataTypeUtil.kt b/code/library/src/main/kotlin/org/fbme/lib/st/types/DataTypeUtil.kt deleted file mode 100644 index 9eedb1c97..000000000 --- a/code/library/src/main/kotlin/org/fbme/lib/st/types/DataTypeUtil.kt +++ /dev/null @@ -1,7 +0,0 @@ -package org.fbme.lib.st.types - -object DataTypeUtil { - fun getBasicTypes(): List { - return listOf(*GenericType.values(), *ElementaryType.values()) - } -} \ No newline at end of file diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt index bbbc0bccc..6d86ef811 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt @@ -30,7 +30,7 @@ import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.descriptors.FBTypeDescriptor import org.fbme.lib.iec61499.fbnetwork.EntryKind import org.fbme.lib.iec61499.instances.NetworkInstance -import org.fbme.lib.st.types.DataTypeUtil +import org.fbme.lib.st.types.DataType import org.fbme.scenes.cells.EditorCell_Button import org.fbme.scenes.cells.button.PlusButton import org.fbme.scenes.viewmodel.CompletionItem @@ -227,8 +227,8 @@ class EditableFBTypeCell( return block } - fun getDataTypeSuggestions(typeDeclaration: ParameterDeclaration): List { - return DataTypeUtil.getBasicTypes().map { + private fun getDataTypeSuggestions(typeDeclaration: ParameterDeclaration): List { + return DataType.getAllValues().map { object : CompletionItem { override fun getMatchingText(pattern: String?): String = it.stringify() From 7da6057d847c1c6142747cafa5805404bd61e74d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 19 Jun 2023 14:10:22 +0200 Subject: [PATCH 49/66] Simplify condition --- .../richediting/actions/network/CreateViewAction.kt | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt index 12522e230..4c34e9d35 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/CreateViewAction.kt @@ -16,15 +16,7 @@ class CreateViewAction : AbstractFBEditAction() { cell: EditorCell, project: MPSProject ) { - when (fbCell.type.declaration) { - is CompositeFBTypeDeclaration -> { - event.presentation.isEnabled = false - } - - else -> { - event.presentation.isEnabled = true - } - } + event.presentation.isEnabled = fbCell.type.declaration !is CompositeFBTypeDeclaration } override fun actionPerformed(event: AnActionEvent) { From 09f5963fbc286ee724d318ede8320e9957785540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 19 Jun 2023 14:20:56 +0200 Subject: [PATCH 50/66] Simplified condition NetworkExtractorAction --- .../actions/network/NetworkExtractorAction.kt | 22 ++++++++----------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/NetworkExtractorAction.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/NetworkExtractorAction.kt index 8c6b9cc14..54af0fb47 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/NetworkExtractorAction.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/actions/network/NetworkExtractorAction.kt @@ -16,19 +16,15 @@ class NetworkExtractorAction : AbstractFBEditAction() { cell: EditorCell, project: MPSProject ) { - when (val declaration = fbCell.type.declaration) { - is CompositeFBTypeDeclaration -> { - event.modelAccess.runReadAction { - event.presentation.isEnabled = - declaration.network.functionBlocks.isNotEmpty() - && declaration.sockets.isEmpty() - && declaration.plugs.isEmpty() - } - } - - else -> { - notApplicable(event) - } + val declaration = fbCell.type.declaration + if (declaration !is CompositeFBTypeDeclaration) { + notApplicable(event) + return + } + event.modelAccess.runReadAction { + event.presentation.isEnabled = declaration.network.functionBlocks.isNotEmpty() + && declaration.sockets.isEmpty() + && declaration.plugs.isEmpty() } } From 82754ca78085965b155001c2817de2466e374a4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 19 Jun 2023 14:24:30 +0200 Subject: [PATCH 51/66] Delete unused exception --- .../ide/richediting/utils/exceptions/FBMEException.kt | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/exceptions/FBMEException.kt diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/exceptions/FBMEException.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/exceptions/FBMEException.kt deleted file mode 100644 index cf0062861..000000000 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/exceptions/FBMEException.kt +++ /dev/null @@ -1,9 +0,0 @@ -package org.fbme.ide.richediting.utils.exceptions - -class FBMEException : RuntimeException { - constructor() : super() - - constructor(message: String) : super(message) - - constructor(message: String, cause: Throwable) : super(message, cause) -} From 606a481bbb99bc7e8d0b29305c0238d9f9c3aafe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 19 Jun 2023 14:32:10 +0200 Subject: [PATCH 52/66] Extract common code --- .../repository/PlatformDeclarationsScope.kt | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/code/language/src/main/kotlin/org/fbme/ide/iec61499/repository/PlatformDeclarationsScope.kt b/code/language/src/main/kotlin/org/fbme/ide/iec61499/repository/PlatformDeclarationsScope.kt index 167bb3470..d94630316 100644 --- a/code/language/src/main/kotlin/org/fbme/ide/iec61499/repository/PlatformDeclarationsScope.kt +++ b/code/language/src/main/kotlin/org/fbme/ide/iec61499/repository/PlatformDeclarationsScope.kt @@ -49,19 +49,13 @@ internal class PlatformDeclarationsScope( return myRepository.getAdapter(findNode(identifier), FunctionBlockDeclaration::class.java) } - override fun findAllFBTypeDeclarations(): List { - return myRepository.mpsRepository.modules - .flatMap { it.models } - .filter { - myModel == null || - myModel.reference == it.reference || - ModelImports(myModel).importedModels.contains(it.reference) - } - .flatMap { it.rootNodes } - .mapNotNull { myRepository.getAdapter(it, FBTypeDeclaration::class.java) } - } + override fun findAllFBTypeDeclarations(): List = + findAllTypeDeclarations(FBTypeDeclaration::class.java) + + override fun findAllAdapterTypeDeclarations(): List = + findAllTypeDeclarations(AdapterTypeDeclaration::class.java) - override fun findAllAdapterTypeDeclarations(): List { + private fun findAllTypeDeclarations(clazz: Class): List { return myRepository.mpsRepository.modules .flatMap { it.models } .filter { @@ -70,7 +64,7 @@ internal class PlatformDeclarationsScope( ModelImports(myModel).importedModels.contains(it.reference) } .flatMap { it.rootNodes } - .mapNotNull { myRepository.getAdapter(it, AdapterTypeDeclaration::class.java) } + .mapNotNull { myRepository.getAdapter(it, clazz) } } private fun findNode(identifier: Identifier): SNode? { From e2d6328bb44fad74e97d507d851c288419bbd6fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 19 Jun 2023 14:37:52 +0200 Subject: [PATCH 53/66] Make just function for supplier --- .../fbnetwork/port/PortActionFactory.kt | 41 ++++++++++++++----- 1 file changed, 30 insertions(+), 11 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt index eda77f03d..7babf4877 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/port/PortActionFactory.kt @@ -17,7 +17,10 @@ object PortActionFactory { fun createInputEventAction( declaration: FBInterfaceDeclaration, iec61499Factory: IEC61499Factory, - identifierFactory: Supplier = IDENTIFIER_FACTORY("Ievent", declaration.inputEvents.map { it.name }), + identifierFactory: Supplier = identifierSupplier( + "Ievent", + declaration.inputEvents.map { it.name } + ), ): AddPortAction { return AddPortAction( "Add input event port", @@ -29,7 +32,10 @@ object PortActionFactory { fun createOutputEventAction( declaration: FBInterfaceDeclaration, iec61499Factory: IEC61499Factory, - identifierFactory: Supplier = IDENTIFIER_FACTORY("Oevent", declaration.outputEvents.map { it.name }), + identifierFactory: Supplier = identifierSupplier( + "Oevent", + declaration.outputEvents.map { it.name } + ), ): AddPortAction { return AddPortAction( "Add output event port", @@ -41,7 +47,10 @@ object PortActionFactory { fun createInputParameterAction( declaration: FBInterfaceDeclaration, iec61499Factory: IEC61499Factory, - identifierFactory: Supplier = IDENTIFIER_FACTORY("Idata", declaration.inputParameters.map { it.name }), + identifierFactory: Supplier = identifierSupplier( + "Idata", + declaration.inputParameters.map { it.name } + ), ) : AddPortAction { return AddPortAction( "Add input data port", @@ -53,7 +62,10 @@ object PortActionFactory { fun createOutputParameterAction( declaration: FBInterfaceDeclaration, iec61499Factory: IEC61499Factory, - identifierFactory: Supplier = IDENTIFIER_FACTORY("Odata", declaration.outputParameters.map { it.name }), + identifierFactory: Supplier = identifierSupplier( + "Odata", + declaration.outputParameters.map { it.name } + ), ) : AddPortAction { return AddPortAction( "Add output data port", @@ -65,7 +77,10 @@ object PortActionFactory { fun createSocketAction( declaration: FBInterfaceDeclarationWithAdapters, iec61499Factory: IEC61499Factory, - identifierFactory: Supplier = IDENTIFIER_FACTORY("Socket", declaration.sockets.map { it.name }), + identifierFactory: Supplier = identifierSupplier( + "Socket", + declaration.sockets.map { it.name } + ), ) : AddPortAction { return AddPortAction( "Add socket port", @@ -77,7 +92,10 @@ object PortActionFactory { fun createPluginAction( declaration: FBInterfaceDeclarationWithAdapters, iec61499Factory: IEC61499Factory, - identifierFactory: Supplier = IDENTIFIER_FACTORY("Plugin", declaration.plugs.map { it.name }), + identifierFactory: Supplier = identifierSupplier( + "Plugin", + declaration.plugs.map { it.name } + ), ) : AddPortAction { return AddPortAction( "Add plugin port", @@ -95,7 +113,8 @@ object PortActionFactory { val ports: MutableList = when (port.connectionKind) { EntryKind.EVENT -> if (port.isInput) fbTypeDeclaration.inputEvents else fbTypeDeclaration.outputEvents - EntryKind.DATA -> if (port.isInput) fbTypeDeclaration.inputParameters else fbTypeDeclaration.outputParameters + EntryKind.DATA -> if (port.isInput) fbTypeDeclaration.inputParameters + else fbTypeDeclaration.outputParameters EntryKind.ADAPTER -> { if (fbTypeDeclaration !is FBInterfaceDeclarationWithAdapters) { return null @@ -112,19 +131,19 @@ object PortActionFactory { return DeletePortAction(port, ports, style) } - val IDENTIFIER_FACTORY: (prefix: String, values: List) -> Supplier = { prefix, names -> + fun identifierSupplier(prefix: String, values: List): Supplier { var index: Int? = null val getName: () -> String = { "${prefix}${index ?: ""}" } - Supplier { - while (names.contains(getName())) { + return Supplier { + while (values.contains(getName())) { index = (index ?: 0) + 1 } StringIdentifier(getName()) } } -} \ No newline at end of file +} From cca90d6737db7bd4c2826b5af414582d0aa04b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 19 Jun 2023 14:53:17 +0200 Subject: [PATCH 54/66] Make local functions in fb completion provider --- .../utils/fb/FBCompletionProvider.kt | 49 +++++++++---------- 1 file changed, 22 insertions(+), 27 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBCompletionProvider.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBCompletionProvider.kt index ccdba9ab0..372663755 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBCompletionProvider.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/utils/fb/FBCompletionProvider.kt @@ -15,7 +15,7 @@ import org.fbme.lib.common.StringIdentifier import org.fbme.lib.iec61499.declarations.FBTypeDeclaration import org.fbme.lib.iec61499.instances.NetworkInstance import org.fbme.scenes.viewmodel.PositionalCompletionItem -import java.util.LinkedList +import java.util.* object FBCompletionProvider { fun getCompletionItems( @@ -39,35 +39,30 @@ object FBCompletionProvider { val allFBTypes = scope.findAllFBTypeDeclarations() val existedFBNames = allFBTypes.map { it.name }.toSet() - val invokeFun: (type: FBTypeDeclaration) -> (String?, Int, Int) -> Unit = { type -> - { _: String?, x: Int, y: Int -> - val declaration = factory.createFunctionBlockDeclaration(StringIdentifier(type.name)) - declaration.x = (x / scale).toInt() - declaration.y = (y / scale).toInt() - declaration.typeReference.setTarget(type) - network.functionBlocks.add(declaration) - } + fun invokeFun(type: FBTypeDeclaration): (String?, Int, Int) -> Unit = { _: String?, x: Int, y: Int -> + val declaration = factory.createFunctionBlockDeclaration(StringIdentifier(type.name)) + declaration.x = (x / scale).toInt() + declaration.y = (y / scale).toInt() + declaration.typeReference.setTarget(type) + network.functionBlocks.add(declaration) } - val createNewType: ( - type: String, + fun createNewType( + typeName: String, factory: (name: String, context: EditorContext) -> FBTypeDeclaration - ) -> PositionalCompletionItem = { - typeName, factoryFun -> - createPositionalCompletionItem( - "New $typeName FB", - "Creates empty $typeName FB" - ){ - parameter: String?, x: Int, y: Int -> - val type = createNewCompositeBlock( - project.project, - context, - existedFBNames, - factoryFun - ) ?: return@createPositionalCompletionItem - invokeFun(type)(parameter, x, y) - } - } + ): PositionalCompletionItem = + createPositionalCompletionItem( + "New $typeName FB", + "Creates empty $typeName FB" + ) { parameter: String?, x: Int, y: Int -> + val type = createNewCompositeBlock( + project.project, + context, + existedFBNames, + factory + ) ?: return@createPositionalCompletionItem + invokeFun(type)(parameter, x, y) + } allFBTypes.sortedBy { it.name }.forEach { type -> result.add(createPositionalCompletionItem(type.name, invokeFun = invokeFun(type))) From 7ebea668154e6534a60017d797d712f97051590a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Mon, 19 Jun 2023 16:05:29 +0200 Subject: [PATCH 55/66] Renamed reference --- .../adapters/fbnetwork/FunctionBlockController.kt | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt index 76aaa4ee1..f092dc365 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt @@ -190,7 +190,7 @@ class FunctionBlockController( when(template.kind) { EntryKind.EVENT -> { val list = if (template.isSource) declaration.outputEvents else declaration.inputEvents - val identifier = PortActionFactory.IDENTIFIER_FACTORY(name, list.map { it.name }).get() + val identifier = PortActionFactory.identifierSupplier(name, list.map { it.name }).get() val nEvent = iec61499Factory.createEventDeclaration(identifier) list.add(nEvent) (fbCell as EditableFBTypeCell).addPort(if (template.isSource) view.type.eventOutputPorts.last() else view.type.eventInputPorts.last()) @@ -198,7 +198,7 @@ class FunctionBlockController( } EntryKind.DATA -> { val list = if (template.isSource) declaration.outputParameters else declaration.inputParameters - val identifier = PortActionFactory.IDENTIFIER_FACTORY(name, list.map { it.name }).get() + val identifier = PortActionFactory.identifierSupplier(name, list.map { it.name }).get() val nParameter = iec61499Factory.createParameterDeclaration(identifier) nParameter.type = (source.target as ParameterDeclaration).type list.add(nParameter) @@ -211,7 +211,7 @@ class FunctionBlockController( } if (template.isSource) { val list = declaration.plugs - val identifier = PortActionFactory.IDENTIFIER_FACTORY(name, list.map { it.name }).get() + val identifier = PortActionFactory.identifierSupplier(name, list.map { it.name }).get() val nParameter = iec61499Factory.createPlugDeclaration(identifier) val dec = source.target as PlugDeclaration nParameter.typeReference.setTarget(dec.typeReference.getTarget()!!) @@ -220,7 +220,7 @@ class FunctionBlockController( return FunctionBlockPortView(template.component, list.size - 1, EntryKind.ADAPTER, template.isSource, nParameter) } val list = declaration.sockets - val identifier = PortActionFactory.IDENTIFIER_FACTORY(name, list.map { it.name }).get() + val identifier = PortActionFactory.identifierSupplier(name, list.map { it.name }).get() val nParameter = iec61499Factory.createSocketDeclaration(identifier) val dec = source.target as SocketDeclaration nParameter.typeReference.setTarget(dec.typeReference.getTarget()!!) From 282b9d847c2726da98ab8bed27e0e9d2c75b06a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Fri, 21 Jul 2023 10:42:11 +0300 Subject: [PATCH 56/66] Add port icons --- .../fbme/lib/iec61499/fbnetwork/PortPath.kt | 15 ++++++--- .../fbnetwork/FunctionBlockController.kt | 2 +- .../fbnetwork/fb/EditableFBTypeCell.kt | 27 ++++++++++----- .../fbme/scenes/cells/EditorCell_Button.kt | 15 ++++----- .../org/fbme/scenes/cells/button/Button.kt | 8 +++-- .../fbme/scenes/cells/button/EditButton.kt | 33 +------------------ .../fbme/scenes/cells/button/IconButton.kt | 20 +++++++++++ .../fbme/scenes/cells/button/MinusButton.kt | 11 ------- .../org/fbme/scenes/cells/button/MyIcons.kt | 14 ++++++++ .../fbme/scenes/cells/button/PlusButton.kt | 11 ++----- .../fbme/scenes/cells/button/SquareButton.kt | 27 --------------- .../fbme/scenes/cells/button/TickButton.kt | 29 +--------------- code/scenes/src/main/resources/icons/add.svg | 5 +++ .../src/main/resources/icons/add_dark.svg | 5 +++ code/scenes/src/main/resources/icons/pen.svg | 4 +++ code/scenes/src/main/resources/icons/tick.svg | 5 +++ 16 files changed, 99 insertions(+), 132 deletions(-) create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/IconButton.kt delete mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MinusButton.kt create mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MyIcons.kt delete mode 100644 code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/SquareButton.kt create mode 100644 code/scenes/src/main/resources/icons/add.svg create mode 100644 code/scenes/src/main/resources/icons/add_dark.svg create mode 100644 code/scenes/src/main/resources/icons/pen.svg create mode 100644 code/scenes/src/main/resources/icons/tick.svg diff --git a/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/PortPath.kt b/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/PortPath.kt index ef8749c91..ad6a5804a 100644 --- a/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/PortPath.kt +++ b/code/library/src/main/kotlin/org/fbme/lib/iec61499/fbnetwork/PortPath.kt @@ -37,7 +37,7 @@ class PortPath private constructor( @JvmStatic fun createEventPortPath( functionBlock: FunctionBlockDeclarationBase?, - portTarget: EventDeclaration + portTarget: EventDeclaration, ): PortPath { return PortPath(functionBlock, portTarget) } @@ -45,7 +45,7 @@ class PortPath private constructor( @JvmStatic fun createDataPortPath( functionBlock: FunctionBlockDeclarationBase?, - portTarget: ParameterDeclaration + portTarget: ParameterDeclaration, ): PortPath { return PortPath(functionBlock, portTarget) } @@ -53,7 +53,7 @@ class PortPath private constructor( @JvmStatic fun createPlugPortPath( functionBlock: FunctionBlockDeclarationBase?, - portTarget: PlugDeclaration + portTarget: PlugDeclaration, ): PortPath { return PortPath(functionBlock, portTarget) } @@ -61,7 +61,7 @@ class PortPath private constructor( @JvmStatic fun createSocketPortPath( functionBlock: FunctionBlockDeclarationBase?, - portTarget: SocketDeclaration + portTarget: SocketDeclaration, ): PortPath { return PortPath(functionBlock, portTarget) } @@ -83,5 +83,12 @@ class PortPath private constructor( } } } + + @JvmStatic + fun createBrokenPortPath( + functionBlock: FunctionBlockDeclarationBase?, + kind: EntryKind, + portName: String + ): PortPath = PortPath(functionBlock, BrokenPortDeclaration(portName, kind, functionBlock)) } } diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt index f092dc365..e30cdc215 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/FunctionBlockController.kt @@ -95,7 +95,7 @@ class FunctionBlockController( } private fun getEditButton(context: EditorContext, node: SNode): EditorCell_Button { - return EditorCell_Button(context, node, if (!editedController.isEdited(view)) EditButton(18) else TickButton(18)) + return EditorCell_Button(context, node, if (!editedController.isEdited(view)) EditButton() else TickButton()) } val fbInstance: FunctionBlockInstance? diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt index 6d86ef811..9ddcc083f 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/adapters/fbnetwork/fb/EditableFBTypeCell.kt @@ -18,7 +18,10 @@ import jetbrains.mps.openapi.editor.style.StyleAttribute import org.fbme.ide.iec61499.repository.PlatformElement import org.fbme.ide.richediting.adapters.fbnetwork.FBConnectionPathPainter import org.fbme.ide.richediting.adapters.fbnetwork.actions.cell.DeclarationNameAccessor -import org.fbme.ide.richediting.adapters.fbnetwork.port.* +import org.fbme.ide.richediting.adapters.fbnetwork.port.EditablePortLabel +import org.fbme.ide.richediting.adapters.fbnetwork.port.EditablePortWithTypeAndLabel +import org.fbme.ide.richediting.adapters.fbnetwork.port.Port +import org.fbme.ide.richediting.adapters.fbnetwork.port.PortActionFactory import org.fbme.ide.richediting.editor.RichEditorStyleAttributes import org.fbme.ide.richediting.viewmodel.FunctionBlockPortView import org.fbme.ide.richediting.viewmodel.FunctionBlockView @@ -122,7 +125,7 @@ class EditableFBTypeCell( } private fun createButton(cellAction: CellAction): EditorCell { - val button = EditorCell_Button(context, node, PlusButton(PLUS_BUTTON_SIZE)) + val button = EditorCell_Button(context, node, PlusButton()) button.setAction(CellActionType.CLICK, cellAction) @@ -176,7 +179,7 @@ class EditableFBTypeCell( fun addPort(port: FBPortDescriptor) { when (port.connectionKind) { EntryKind.EVENT -> { - val value = EditablePortLabel(context, node, port, fbType.declaration) + val value = EditablePortLabel(context, node, port, fbType.declaration) if (port.isInput) { (eventPortsContainer.cells.first() as EditorCell_Collection).addEditorCell(value.label) inputEventPorts.add(value) @@ -185,6 +188,7 @@ class EditableFBTypeCell( outputEventPorts.add(value) } } + EntryKind.DATA -> { val typeDeclaration = port.declaration as ParameterDeclaration val value = EditablePortWithTypeAndLabel(context, node, port, fbType.declaration, typeDeclaration.type?.stringify(), getDataTypeSuggestions(typeDeclaration)) @@ -196,6 +200,7 @@ class EditableFBTypeCell( outputDataPorts.add(value) } } + EntryKind.ADAPTER -> { val types = scope.findAllAdapterTypeDeclarations() if (port.isInput) { @@ -364,8 +369,8 @@ class EditableFBTypeCell( val yTop = y + height val yCenterB = typeNameLabel.y - lineSize / 2 val yCenterT = typeNameLabel.y + lineSize / 2 - val xLeftS = x + lineSize - val xRightS = xRight - lineSize + val xLeftS = x + PLUS_BUTTON_SIZE.toDouble() + val xRightS = xRight - PLUS_BUTTON_SIZE.toDouble() shape.moveTo(x.toDouble(), y.toDouble()) shape.lineTo(x.toDouble(), yCenterB) shape.lineTo(xLeftS, yCenterB) @@ -485,7 +490,7 @@ class EditableFBTypeCell( private fun addGapForButtons(width: Int, cell: EditorCell_Collection) { val left = cell.cells.first() val right = cell.cells.last() - right.moveTo(width - 15, right.y + cell.height - right.height) + right.moveTo(width - PLUS_BUTTON_SIZE, right.y + cell.height - right.height) left.moveTo(0, left.y + cell.height - left.height) } @@ -510,11 +515,15 @@ class EditableFBTypeCell( companion object { private const val CENTER_PADDING = 20 private const val INNER_BORDER_PADDING = 2 - private const val PLUS_BUTTON_SIZE = 15 + private const val PLUS_BUTTON_SIZE = 16 private fun portsColumnWidth(ports: Collection): Int { - return ports.maxOfOrNull { if (it is EditablePortWithTypeAndLabel) it.cell.width else (it as EditablePortLabel).label.width } - ?: 0 + return ports.maxOfOrNull { + if (it is EditablePortWithTypeAndLabel) + it.cell.width + else + (it as EditablePortLabel).label.width + } ?: 0 } } } diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt index 1f4a3ad17..e688b7837 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/EditorCell_Button.kt @@ -1,7 +1,7 @@ package org.fbme.scenes.cells -import com.intellij.util.ui.StartupUiUtil -import jetbrains.mps.nodeEditor.cells.* +import jetbrains.mps.nodeEditor.cells.EditorCell_Basic +import jetbrains.mps.nodeEditor.cells.ParentSettings import jetbrains.mps.openapi.editor.EditorContext import org.fbme.scenes.cells.button.Button import org.jetbrains.mps.openapi.model.SNode @@ -13,15 +13,13 @@ class EditorCell_Button( context: EditorContext, node: SNode?, private val button: Button -): EditorCell_Basic(context, node) { - val isDark = StartupUiUtil.isUnderDarcula() - +) : EditorCell_Basic(context, node) { override fun paintContent(g: Graphics, p1: ParentSettings) { - button.paint(g.create() as Graphics2D, myX, myY, isDark) + button.paint(this.editor, g.create() as Graphics2D, myX, myY) } - override fun paintSelection(g: Graphics?, c: Color?, drawBorder: Boolean, parentSettings: ParentSettings?) { - //do nothing + override fun paintSelection(g: Graphics, c: Color?, drawBorder: Boolean, parentSettings: ParentSettings?) { + button.paintSelection(this.editor, g.create() as Graphics2D, myX, myY) } init { @@ -31,5 +29,6 @@ class EditorCell_Button( companion object { const val OY_OFFSET = -5 + const val DEFAULT_SIZE = 14 } } diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/Button.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/Button.kt index 45504f3cb..aff78aff6 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/Button.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/Button.kt @@ -1,9 +1,11 @@ package org.fbme.scenes.cells.button +import java.awt.Component import java.awt.Graphics2D interface Button { - val height: Int val width: Int - fun paint(g: Graphics2D, x: Int, y: Int, isDark: Boolean) -} \ No newline at end of file + val height: Int + fun paint(c: Component, g: Graphics2D, x: Int, y: Int) + fun paintSelection(c: Component, g: Graphics2D, x: Int, y: Int) +} diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/EditButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/EditButton.kt index 5ebb0b689..4fc933db3 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/EditButton.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/EditButton.kt @@ -1,34 +1,3 @@ package org.fbme.scenes.cells.button -import java.awt.Color -import java.awt.Graphics2D -import java.awt.geom.RoundRectangle2D - -class EditButton(private val size: Int): Button { - override val height: Int - get() = size - override val width: Int - get() = size - - override fun paint(g: Graphics2D, x: Int, y: Int, isDark: Boolean) { - val color = if (isDark) ON_DARK_COLOR else ON_LIGHT_COLOR - g.color = color - g.draw(RoundRectangle2D.Double(x.toDouble(), y.toDouble(), size.toDouble(), size.toDouble(), (size / 4).toDouble(), (size / 4).toDouble())) - paintPen(g, x + 3, y + 3, size - 6, color) - } - - private fun paintPen(g: Graphics2D, x: Int, y: Int, size: Int, color: Color) { - g.color = color - g.drawLine(x, y + size, x + 2 * size / 5, y + size) //- - g.drawLine(x, y + size, x, y + 3 * size / 5) // | - g.drawLine(x, y + 3 * size / 5, x + 2 * size / 5, y + size)// |_\ - g.drawLine(x + 2 * size / 5, y + size, x + size, y + size / 5) // / - g.drawLine(x, y + 3 * size / 5, x + 4 * size / 5, y) // // - g.drawLine(x + size, y + size / 5, x + 4 * size / 5, y) - } - - companion object { - val ON_DARK_COLOR = Color.WHITE - val ON_LIGHT_COLOR = Color.BLACK - } -} \ No newline at end of file +class EditButton : IconButton({ MyIcons.EditIcon }) diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/IconButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/IconButton.kt new file mode 100644 index 000000000..8408dddd3 --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/IconButton.kt @@ -0,0 +1,20 @@ +package org.fbme.scenes.cells.button + +import java.awt.Component +import java.awt.Graphics2D +import javax.swing.Icon + +abstract class IconButton(private val icon: () -> Icon) : Button { + override val width: Int + get() = icon().iconWidth + override val height: Int + get() = icon().iconHeight + + override fun paint(c: Component, g: Graphics2D, x: Int, y: Int) { + icon().paintIcon(c, g, x, y) + } + + override fun paintSelection(c: Component, g: Graphics2D, x: Int, y: Int) { + icon().paintIcon(c, g, x, y) + } +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MinusButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MinusButton.kt deleted file mode 100644 index 5454e5ea8..000000000 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MinusButton.kt +++ /dev/null @@ -1,11 +0,0 @@ -package org.fbme.scenes.cells.button - -import java.awt.Color -import java.awt.Graphics2D - -class MinusButton(size: Int): SquareButton(size) { - override fun paintInside(g: Graphics2D, x: Int, y: Int, color: Color) { - g.color = color - g.drawLine(x + INNER_PADDING, y + height / 2, x + width - INNER_PADDING, y + height / 2) - } -} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MyIcons.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MyIcons.kt new file mode 100644 index 000000000..6c8e8407e --- /dev/null +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/MyIcons.kt @@ -0,0 +1,14 @@ +package org.fbme.scenes.cells.button + +import com.intellij.openapi.util.IconLoader + +object MyIcons { + @JvmField + val EditIcon = IconLoader.getIcon("/icons/pen.svg", javaClass) + @JvmField + val AddIcon = IconLoader.getIcon("/icons/add.svg", javaClass) + @JvmField + val AddIcon_Dark = IconLoader.getIcon("/icons/add_dark.svg", javaClass) + @JvmField + val TickIcon = IconLoader.getIcon("/icons/tick.svg", javaClass) +} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/PlusButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/PlusButton.kt index 958fa80d5..9d4a9b102 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/PlusButton.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/PlusButton.kt @@ -1,12 +1,5 @@ package org.fbme.scenes.cells.button -import java.awt.Color -import java.awt.Graphics2D +import com.intellij.util.ui.UIUtil -class PlusButton(size: Int): SquareButton(size) { - override fun paintInside(g: Graphics2D, x: Int, y: Int, color: Color) { - g.color = color - g.drawLine(x + width / 2, y + INNER_PADDING, x + width / 2, y + height - INNER_PADDING) - g.drawLine(x + INNER_PADDING, y + height / 2, x + width - INNER_PADDING, y + height / 2) - } -} \ No newline at end of file +class PlusButton : IconButton({ if (UIUtil.isUnderDarcula()) MyIcons.AddIcon_Dark else MyIcons.AddIcon }) diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/SquareButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/SquareButton.kt deleted file mode 100644 index 5b542e1e8..000000000 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/SquareButton.kt +++ /dev/null @@ -1,27 +0,0 @@ -package org.fbme.scenes.cells.button - -import com.intellij.openapi.rd.fill2DRect -import jetbrains.mps.nodeEditor.MPSColors -import java.awt.Color -import java.awt.Graphics2D -import java.awt.Rectangle - -abstract class SquareButton(private val size: Int) : Button { - override val height: Int - get() = size - override val width: Int - get() = size - - override fun paint(g: Graphics2D, x: Int, y: Int, isDark: Boolean) { - g.fill2DRect(Rectangle(x, y, size, size), if (isDark) ON_DARK_COLOR else ON_LIGHT_COLOR) - paintInside(g, x, y, if (!isDark) ON_DARK_COLOR else ON_LIGHT_COLOR) - } - - protected abstract fun paintInside(g: Graphics2D, x: Int, y: Int, color: Color) - - companion object { - const val INNER_PADDING: Int = 2 - val ON_DARK_COLOR = Color.WHITE - val ON_LIGHT_COLOR = Color.BLACK - } -} \ No newline at end of file diff --git a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/TickButton.kt b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/TickButton.kt index ec64fc5c8..654c186d0 100644 --- a/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/TickButton.kt +++ b/code/scenes/src/main/kotlin/org/fbme/scenes/cells/button/TickButton.kt @@ -1,30 +1,3 @@ package org.fbme.scenes.cells.button -import java.awt.Color -import java.awt.Graphics2D -import java.awt.geom.RoundRectangle2D - -class TickButton(private val size: Int): Button { - override val height: Int - get() = size - override val width: Int - get() = size - - override fun paint(g: Graphics2D, x: Int, y: Int, isDark: Boolean) { - val color = if (isDark) ON_DARK_COLOR else ON_LIGHT_COLOR - g.color = color - g.draw(RoundRectangle2D.Double(x.toDouble(), y.toDouble(), size.toDouble(), size.toDouble(), (size / 4).toDouble(), (size / 4).toDouble())) - drawCross(g, x + 3, y + 3, size - 6, color) - } - - private fun drawCross(g: Graphics2D, x: Int, y: Int, size: Int, color: Color) { - g.color = color - g.drawLine(x, y + 2 * size / 3, x + size / 3, y + size) - g.drawLine(x + size / 3, y + size, x + size, y) - } - - companion object { - val ON_DARK_COLOR = Color.WHITE - val ON_LIGHT_COLOR = Color.BLACK - } -} \ No newline at end of file +class TickButton : IconButton({ MyIcons.TickIcon }) diff --git a/code/scenes/src/main/resources/icons/add.svg b/code/scenes/src/main/resources/icons/add.svg new file mode 100644 index 000000000..19eb5a038 --- /dev/null +++ b/code/scenes/src/main/resources/icons/add.svg @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/code/scenes/src/main/resources/icons/add_dark.svg b/code/scenes/src/main/resources/icons/add_dark.svg new file mode 100644 index 000000000..3c65e2b33 --- /dev/null +++ b/code/scenes/src/main/resources/icons/add_dark.svg @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/code/scenes/src/main/resources/icons/pen.svg b/code/scenes/src/main/resources/icons/pen.svg new file mode 100644 index 000000000..132b31694 --- /dev/null +++ b/code/scenes/src/main/resources/icons/pen.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/code/scenes/src/main/resources/icons/tick.svg b/code/scenes/src/main/resources/icons/tick.svg new file mode 100644 index 000000000..32743d9d1 --- /dev/null +++ b/code/scenes/src/main/resources/icons/tick.svg @@ -0,0 +1,5 @@ + + + + \ No newline at end of file From 9d36fc1e7bf44775aa73d23b8a658ac09281e093 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Fri, 21 Jul 2023 10:43:39 +0300 Subject: [PATCH 57/66] Add broken ports base --- .../org.fbme.ide.iec61499.adapter.ecc.mps | 4 +- ...rg.fbme.ide.iec61499.adapter.fbnetwork.mps | 667 +++++++++++++----- .../richediting/viewmodel/BrokenPortView.kt | 9 +- .../viewmodel/FunctionBlockPortView.kt | 26 +- .../ide/richediting/viewmodel/NetworkView.kt | 133 ++-- 5 files changed, 615 insertions(+), 224 deletions(-) diff --git a/code/language/solutions/org.fbme.ide.iec61499.adapter/models/org.fbme.ide.iec61499.adapter.ecc.mps b/code/language/solutions/org.fbme.ide.iec61499.adapter/models/org.fbme.ide.iec61499.adapter.ecc.mps index 69bc1d52f..c2786151f 100644 --- a/code/language/solutions/org.fbme.ide.iec61499.adapter/models/org.fbme.ide.iec61499.adapter.ecc.mps +++ b/code/language/solutions/org.fbme.ide.iec61499.adapter/models/org.fbme.ide.iec61499.adapter.ecc.mps @@ -1127,8 +1127,8 @@ - + @@ -1816,8 +1816,8 @@ - + diff --git a/code/language/solutions/org.fbme.ide.iec61499.adapter/models/org.fbme.ide.iec61499.adapter.fbnetwork.mps b/code/language/solutions/org.fbme.ide.iec61499.adapter/models/org.fbme.ide.iec61499.adapter.fbnetwork.mps index a96f9933b..3f83322d9 100644 --- a/code/language/solutions/org.fbme.ide.iec61499.adapter/models/org.fbme.ide.iec61499.adapter.fbnetwork.mps +++ b/code/language/solutions/org.fbme.ide.iec61499.adapter/models/org.fbme.ide.iec61499.adapter.fbnetwork.mps @@ -68,6 +68,7 @@ + @@ -111,7 +112,6 @@ - @@ -137,6 +137,9 @@ + + + @@ -198,6 +201,9 @@ + + + @@ -210,6 +216,12 @@ + + + + + + @@ -217,6 +229,7 @@ + @@ -399,25 +412,53 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + - + - + @@ -425,28 +466,55 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + - @@ -479,8 +547,8 @@ - + @@ -611,25 +679,53 @@ - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + - - + + - + - + - + @@ -637,23 +733,51 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + @@ -689,8 +813,8 @@ - + @@ -804,25 +928,53 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - + + - + - + - + @@ -830,23 +982,51 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + @@ -1916,25 +2096,53 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - + + - + - + - + @@ -1942,28 +2150,55 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + - @@ -1996,8 +2231,8 @@ - + @@ -2128,25 +2363,53 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - + + - + - + - + @@ -2154,23 +2417,51 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + @@ -2321,25 +2612,53 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - + + - + - + - + @@ -2347,23 +2666,51 @@ - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - + + + + + + + + + + + + + + + diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/BrokenPortView.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/BrokenPortView.kt index d94ac1572..a4035bbe1 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/BrokenPortView.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/BrokenPortView.kt @@ -1,8 +1,13 @@ package org.fbme.ide.richediting.viewmodel +import org.fbme.lib.iec61499.fbnetwork.BrokenPortDeclaration import org.fbme.lib.iec61499.fbnetwork.EntryKind -class BrokenPortView : NetworkComponentView, NetworkPortView { +class BrokenPortView( + val isInput: Boolean, + val declaration: BrokenPortDeclaration? = null, + private val myComponent: NetworkComponentView? = null +) : NetworkComponentView, NetworkPortView { private var myOpposite: NetworkPortView? = null override val kind: EntryKind @@ -10,7 +15,7 @@ class BrokenPortView : NetworkComponentView, NetworkPortView { override val isEditable: Boolean get() = false override val component: NetworkComponentView - get() = this + get() = myComponent ?: this override fun equals(other: Any?): Boolean { if (this === other) { diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockPortView.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockPortView.kt index 3aeabedea..b78056e18 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockPortView.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/FunctionBlockPortView.kt @@ -1,12 +1,26 @@ package org.fbme.ide.richediting.viewmodel import org.fbme.lib.common.Declaration +import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.fbnetwork.EntryKind data class FunctionBlockPortView( - override val component: FunctionBlockView, - val position: Int, - override val kind: EntryKind, - override val isSource: Boolean, - override val target: Declaration -) : NetworkPortViewAdd + override val component: FunctionBlockView, + val position: Int, + override val kind: EntryKind, + override val isSource: Boolean, + override val target: Declaration +) : NetworkPortViewAdd { + companion object { + @JvmStatic + fun create(component: FunctionBlockView, declaration: Declaration, descriptor: FBPortDescriptor): FunctionBlockPortView { + return FunctionBlockPortView( + component, + descriptor.position, + descriptor.connectionKind, + !descriptor.isInput, + declaration + ) + } + } +} diff --git a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/NetworkView.kt b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/NetworkView.kt index 2bb2f1e59..a3c03df83 100644 --- a/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/NetworkView.kt +++ b/code/richediting/src/main/kotlin/org/fbme/ide/richediting/viewmodel/NetworkView.kt @@ -4,6 +4,7 @@ import org.fbme.lib.common.Declaration import org.fbme.lib.common.Element import org.fbme.lib.iec61499.IEC61499Factory import org.fbme.lib.iec61499.declarations.FBInterfaceDeclaration +import org.fbme.lib.iec61499.descriptors.FBPortDescriptor import org.fbme.lib.iec61499.fbnetwork.* import org.fbme.lib.iec61499.fbnetwork.subapp.SubappNetwork import org.fbme.scenes.controllers.diagram.DiagramView @@ -114,14 +115,8 @@ class NetworkView(private val myFactory: IEC61499Factory, private val myNetwork: } private fun initConnections(network: FBNetwork, editable: Boolean) { - for (connection in network.eventConnections) { - addConnection(connection, editable) - } - for (connection in network.dataConnections) { - addConnection(connection, editable) - } - for (connection in network.adapterConnections) { - addConnection(connection, editable) + network.allConnections.forEach { + addConnection(it, editable) } } @@ -150,8 +145,7 @@ class NetworkView(private val myFactory: IEC61499Factory, private val myNetwork: myAuxComponents[view] = exts for (parameter in functionBlock.parameters) { val parameterDeclaration = parameter.parameterReference.getTarget() - ?: // TODO handle broken parameters - continue + ?: /*TODO handle broken parameters */continue val declaration = parameterDeclaration.container as FBInterfaceDeclaration? val index = declaration!!.inputParameters.indexOf(parameterDeclaration) val oppositePortView = FunctionBlockPortView(view, index, EntryKind.DATA, false, parameterDeclaration) @@ -164,51 +158,33 @@ class NetworkView(private val myFactory: IEC61499Factory, private val myNetwork: myConnectionSources[parameterConnectionView] = inlineValueView myConnectionDestinations[parameterConnectionView] = oppositePortView } + val ports = HashSet() - var i = 0 myComponentToPorts[view] = ports - for (dataInput in type.dataInputPorts) { - val port = FunctionBlockPortView(view, i++, EntryKind.DATA, false, dataInput.declaration!!) - ports.add(port) - myPortModelMap[PortPath.createPortPath(functionBlock, EntryKind.DATA, dataInput.declaration!!)] = port - myPorts[port] = view - } - i = 0 - for (dataOutput in type.dataOutputPorts) { - val port = FunctionBlockPortView(view, i++, EntryKind.DATA, true, dataOutput.declaration!!) - ports.add(port) - myPortModelMap[PortPath.createPortPath(functionBlock, EntryKind.DATA, dataOutput.declaration!!)] = port - myPorts[port] = view - } - i = 0 - for (dataInput in type.eventInputPorts) { - val port = FunctionBlockPortView(view, i++, EntryKind.EVENT, false, dataInput.declaration!!) - ports.add(port) - myPortModelMap[PortPath.createPortPath(functionBlock, EntryKind.EVENT, dataInput.declaration!!)] = port - myPorts[port] = view - } - i = 0 - for (dataOutput in type.eventOutputPorts) { - val port = FunctionBlockPortView(view, i++, EntryKind.EVENT, true, dataOutput.declaration!!) - ports.add(port) - myPortModelMap[PortPath.createPortPath(functionBlock, EntryKind.EVENT, dataOutput.declaration!!)] = port - myPorts[port] = view - } - i = 0 - for (socket in type.socketPorts) { - val port = FunctionBlockPortView(view, i++, EntryKind.ADAPTER, false, socket.declaration!!) - ports.add(port) - myPortModelMap[PortPath.createPortPath(functionBlock, EntryKind.ADAPTER, socket.declaration!!)] = port - myPorts[port] = view - } - i = 0 - for (plug in type.plugPorts) { - val port = FunctionBlockPortView(view, i++, EntryKind.ADAPTER, true, plug.declaration!!) + + addPortView(type.dataInputPorts, view, ports) + addPortView(type.dataOutputPorts, view, ports) + addPortView(type.eventInputPorts, view, ports) + addPortView(type.eventOutputPorts, view, ports) + addPortView(type.socketPorts, view, ports) + addPortView(type.plugPorts, view, ports) + //TODO: add ports templates + } + + private fun addPortView( + typePorts: List, + view: FunctionBlockView, + ports: HashSet + ) { + typePorts.forEachIndexed { index, fbPortDescriptor -> + val declaration = fbPortDescriptor.declaration!! + val port = FunctionBlockPortView( + view, index, fbPortDescriptor.connectionKind, !fbPortDescriptor.isInput, declaration + ) ports.add(port) - myPortModelMap[PortPath.createPortPath(functionBlock, EntryKind.ADAPTER, plug.declaration!!)] = port + myPortModelMap[PortPath.createPortPath(view.component, fbPortDescriptor.connectionKind, declaration)] = port myPorts[port] = view } - //TODO: add ports templates } fun addConnection(connection: FBNetworkConnection, editable: Boolean): NetworkConnectionView? { @@ -216,14 +192,21 @@ class NetworkView(private val myFactory: IEC61499Factory, private val myNetwork: myConnectionModelMap[connection] = view val source = connection.sourceReference.getTarget() val target = connection.targetReference.getTarget() + val targetPort = target?.portTarget + val sourcePort = source?.portTarget val targetView: NetworkPortView? - val sourceView: NetworkPortView? = if (source != null) { + val sourceView: NetworkPortView? = if (source != null && sourcePort !is BrokenPortDeclaration) { myPortModelMap[source] } else { view.shrink() - BrokenPortView() + + if (sourcePort is BrokenPortDeclaration) { + BrokenPortView(false, sourcePort, myElementModelMap[sourcePort.functionBlock]) + } else { + BrokenPortView(false) + } } - if (target != null) { + if (target != null && targetPort !is BrokenPortDeclaration) { targetView = myPortModelMap[target] if (sourceView is BrokenPortView) { sourceView.setOpposite(targetView) @@ -233,15 +216,57 @@ class NetworkView(private val myFactory: IEC61499Factory, private val myNetwork: return null } view.shrink() - val portView = BrokenPortView() + val portView = if (targetPort is BrokenPortDeclaration) { + BrokenPortView(true, targetPort, myElementModelMap[targetPort.functionBlock]) + } else { + BrokenPortView(true) + } + (targetPort as BrokenPortDeclaration).functionBlock portView.setOpposite(sourceView) targetView = portView } + + if (sourcePort is BrokenPortDeclaration) { + val fb = myElementModelMap[sourcePort.functionBlock] + if (fb is FunctionBlockView) { + fb.brokenPorts.addPort(sourcePort.name, sourcePort.kind, false) + val port = fb.findPort(sourcePort.name, sourcePort.kind, false) + if (port != null) { + myPortModelMap[source] = sourceView!! + myPorts[sourceView] = fb + (myComponentToPorts[fb] as HashSet).add(sourceView) + } + } + } + + if (targetPort is BrokenPortDeclaration) { + val fb = myElementModelMap[targetPort.functionBlock] + if (fb is FunctionBlockView) { + fb.brokenPorts.addPort(targetPort.name, targetPort.kind, true) + val port = fb.findPort(targetPort.name, targetPort.kind, true) + if (port != null) { + myPortModelMap[source] = targetView!! + myPorts[targetView] = fb + (myComponentToPorts[fb] as HashSet).add(targetView) + } + } + } + myConnectionSources[view] = sourceView myConnectionDestinations[view] = targetView return view } + private fun FunctionBlockView.findPort(name: String, kind: EntryKind, isInput: Boolean): FBPortDescriptor? { + val ports = when (kind) { + EntryKind.EVENT -> this.type.eventInputPorts to this.type.eventOutputPorts + EntryKind.DATA -> this.type.dataInputPorts to this.type.dataOutputPorts + EntryKind.ADAPTER -> this.type.socketPorts to this.type.plugPorts + } + + return (if (isInput) ports.first else ports.second).find { it.name == name } + } + val diagramView: DiagramView = object : DiagramView { override fun components(): Set { From dcf905b25e3b19aa14aba872574c87b1adb9ba3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Fri, 21 Jul 2023 10:54:43 +0300 Subject: [PATCH 58/66] Restore idea files --- .idea/inspectionProfiles/Project_Default.xml | 7 +++ .idea/inspectionProfiles/Project_check.xml | 13 +++++ .idea/jarRepositories.xml | 48 +++++++++---------- .idea/runConfigurations/Remote_debug_MPS.xml | 15 ++++++ ...Test_Teamcity_configuration_generation.xml | 27 +++++++++++ .idea/scopes/Checked_source_files.xml | 3 ++ 6 files changed, 89 insertions(+), 24 deletions(-) create mode 100644 .idea/inspectionProfiles/Project_Default.xml create mode 100644 .idea/inspectionProfiles/Project_check.xml create mode 100644 .idea/runConfigurations/Remote_debug_MPS.xml create mode 100644 .idea/runConfigurations/Test_Teamcity_configuration_generation.xml create mode 100644 .idea/scopes/Checked_source_files.xml diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 000000000..2269f6b7d --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_check.xml b/.idea/inspectionProfiles/Project_check.xml new file mode 100644 index 000000000..36e04539b --- /dev/null +++ b/.idea/inspectionProfiles/Project_check.xml @@ -0,0 +1,13 @@ + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml index dc08c64af..d3aee7f54 100644 --- a/.idea/jarRepositories.xml +++ b/.idea/jarRepositories.xml @@ -6,41 +6,26 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -1542,6 +1572,13 @@ + + + + + + + @@ -1554,43 +1591,20 @@ - - - - - - - - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + @@ -1624,9 +1638,66 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 6df620633b3b95b18f6542a3b4335ad8c7516a42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Fri, 21 Jul 2023 10:58:58 +0300 Subject: [PATCH 60/66] Restore code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib --- .../events/ARTimeOut.adp | 43 +++++-- .../iec61499.4diac.stdlib/events/ATimeOut.adp | 43 +++++-- .../iec61499.4diac.stdlib/events/E_CTD.fbt | 61 ++++----- .../iec61499.4diac.stdlib/events/E_CTU.fbt | 60 ++++----- .../iec61499.4diac.stdlib/events/E_CTUD.fbt | 117 ++++++++--------- .../iec61499.4diac.stdlib/events/E_CYCLE.fbt | 33 ++--- .../iec61499.4diac.stdlib/events/E_DELAY.fbt | 22 ++-- .../iec61499.4diac.stdlib/events/E_DEMUX.fbt | 65 +++++----- .../iec61499.4diac.stdlib/events/E_D_FF.fbt | 42 +++---- .../iec61499.4diac.stdlib/events/E_F_TRIG.fbt | 33 ++--- .../iec61499.4diac.stdlib/events/E_MERGE.fbt | 30 ++--- .../iec61499.4diac.stdlib/events/E_PERMIT.fbt | 29 ++--- .../iec61499.4diac.stdlib/events/E_RDELAY.fbt | 48 +++++-- .../iec61499.4diac.stdlib/events/E_REND.fbt | 44 +++---- .../iec61499.4diac.stdlib/events/E_RS.fbt | 45 +++---- .../iec61499.4diac.stdlib/events/E_R_TRIG.fbt | 33 ++--- .../iec61499.4diac.stdlib/events/E_SELECT.fbt | 35 +++--- .../iec61499.4diac.stdlib/events/E_SPLIT.fbt | 30 ++--- .../iec61499.4diac.stdlib/events/E_SR.fbt | 45 +++---- .../iec61499.4diac.stdlib/events/E_SWITCH.fbt | 39 +++--- .../iec61499.4diac.stdlib/events/E_TABLE.fbt | 50 ++++---- .../iec61499.4diac.stdlib/events/E_TRAIN.fbt | 54 ++++---- .../iec61499.4diac.stdlib/events/E_T_FF.fbt | 33 ++--- .../models/iec61499.4diac.stdlib/io/ID.fbt | 44 +++---- .../models/iec61499.4diac.stdlib/io/IW.fbt | 45 +++---- .../models/iec61499.4diac.stdlib/io/IX.fbt | 54 ++++---- .../models/iec61499.4diac.stdlib/io/QD.fbt | 109 ++++++++++++---- .../models/iec61499.4diac.stdlib/io/QW.fbt | 110 ++++++++++++---- .../models/iec61499.4diac.stdlib/io/QX.fbt | 111 ++++++++++++---- .../iec61499.4diac.stdlib/math/FB_RANDOM.fbt | 53 ++++---- .../iec61499.4diac.stdlib/net/CLIENT_1.fbt | 48 +++---- .../iec61499.4diac.stdlib/net/CLIENT_2_1.fbt | 52 ++++---- .../iec61499.4diac.stdlib/net/PUBLISH_0.fbt | 40 +++--- .../iec61499.4diac.stdlib/net/PUBLISH_1.fbt | 44 +++---- .../iec61499.4diac.stdlib/net/PUBLISH_10.fbt | 76 +++++------ .../iec61499.4diac.stdlib/net/PUBLISH_2.fbt | 48 +++---- .../iec61499.4diac.stdlib/net/PUBLISH_3.fbt | 52 ++++---- .../iec61499.4diac.stdlib/net/PUBLISH_4.fbt | 56 ++++----- .../iec61499.4diac.stdlib/net/PUBLISH_5.fbt | 60 ++++----- .../iec61499.4diac.stdlib/net/PUBLISH_6.fbt | 64 +++++----- .../iec61499.4diac.stdlib/net/PUBLISH_7.fbt | 68 +++++----- .../iec61499.4diac.stdlib/net/PUBLISH_8.fbt | 72 +++++------ .../iec61499.4diac.stdlib/net/PUBLISH_9.fbt | 80 ++++++------ .../iec61499.4diac.stdlib/net/SERVER_1.fbt | 48 +++---- .../iec61499.4diac.stdlib/net/SERVER_1_2.fbt | 52 ++++---- .../iec61499.4diac.stdlib/net/SUBSCRIBE_0.fbt | 40 +++--- .../iec61499.4diac.stdlib/net/SUBSCRIBE_1.fbt | 44 +++---- .../net/SUBSCRIBE_10.fbt | 81 ++++++------ .../iec61499.4diac.stdlib/net/SUBSCRIBE_2.fbt | 48 +++---- .../iec61499.4diac.stdlib/net/SUBSCRIBE_3.fbt | 52 ++++---- .../iec61499.4diac.stdlib/net/SUBSCRIBE_4.fbt | 56 ++++----- .../iec61499.4diac.stdlib/net/SUBSCRIBE_5.fbt | 60 ++++----- .../iec61499.4diac.stdlib/net/SUBSCRIBE_6.fbt | 64 +++++----- .../iec61499.4diac.stdlib/net/SUBSCRIBE_7.fbt | 68 +++++----- .../iec61499.4diac.stdlib/net/SUBSCRIBE_8.fbt | 72 +++++------ .../iec61499.4diac.stdlib/net/SUBSCRIBE_9.fbt | 76 +++++------ .../utils/APPEND_STRING_2.fbt | 26 ++-- .../utils/APPEND_STRING_3.fbt | 30 ++--- .../utils/ARRAY2ARRAY_2_LREAL.fbt | 23 ++-- .../utils/ARRAY2VALUES_2_LREAL.fbt | 26 ++-- .../utils/CSV_WRITER_1.fbt | 44 +++---- .../utils/CSV_WRITER_10.fbt | 118 ++++++++++++------ .../utils/CSV_WRITER_2.fbt | 48 +++---- .../utils/CSV_WRITER_3.fbt | 52 ++++---- .../utils/CSV_WRITER_4.fbt | 56 ++++----- .../utils/CSV_WRITER_5.fbt | 60 ++++----- .../utils/CSV_WRITER_6.fbt | 64 +++++----- .../utils/CSV_WRITER_7.fbt | 68 +++++----- .../utils/CSV_WRITER_8.fbt | 72 +++++------ .../utils/CSV_WRITER_9.fbt | 114 +++++++++++------ .../iec61499.4diac.stdlib/utils/F_MUX_2_1.fbt | 37 +++--- .../iec61499.4diac.stdlib/utils/F_MUX_2_2.fbt | 48 +++---- .../utils/GET_AT_INDEX.fbt | 30 ++--- .../utils/OUT_ANY_CONSOLE.fbt | 33 ++--- .../utils/SET_AT_INDEX.fbt | 34 ++--- .../iec61499.4diac.stdlib/utils/STEST_END.fbt | 18 ++- .../utils/VALUES2ARRAY_2_LREAL.fbt | 26 ++-- 77 files changed, 2246 insertions(+), 1862 deletions(-) diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ARTimeOut.adp b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ARTimeOut.adp index 241e4efd0..a1db20d5e 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ARTimeOut.adp +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ARTimeOut.adp @@ -1,20 +1,43 @@ - - - - + + + + + - + - - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ATimeOut.adp b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ATimeOut.adp index 98cedb509..3f1e31e83 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ATimeOut.adp +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/ATimeOut.adp @@ -1,20 +1,43 @@ - - - - + + + + + - + - - + + - + + - + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTD.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTD.fbt index befb80a3c..4009ff2af 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTD.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTD.fbt @@ -1,52 +1,53 @@ - - - - + + + + + + - - - + + + - - - + + + - - - + + + - + - - + + - - - + + + - - + + - - - - + + + + - - + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTU.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTU.fbt index d589e50e1..b25d18607 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTU.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTU.fbt @@ -1,52 +1,52 @@ - - - - + + + + + - - + + - + - - - + + + - - - + + + - + - - + + - - - + + + - - + + - - - - + + + + - - + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTUD.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTUD.fbt index b8e951a30..4d25a82e0 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTUD.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CTUD.fbt @@ -1,87 +1,88 @@ - - - - + + + + + + - - + + - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + + - + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - + + + - - - - - - - - + + + + + + + + - - + + - - + + - - + + - - + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CYCLE.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CYCLE.fbt index fb489a591..d9cf7d0c5 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CYCLE.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_CYCLE.fbt @@ -1,32 +1,33 @@ - - - - + + + + + - - + + - + - + - + + - + - + - - - - + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DELAY.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DELAY.fbt index 4ff104963..1c946292f 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DELAY.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DELAY.fbt @@ -1,20 +1,22 @@ - - - - + + + + + - - + + - + - + - + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DEMUX.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DEMUX.fbt index 7eb1d6054..37b71de45 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DEMUX.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_DEMUX.fbt @@ -1,50 +1,51 @@ - - - - + + + + + - - + + - - - - + + + + - + + - - - - + + + + - - + + - - + + - - + + - - - - - - - - - - + + + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_D_FF.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_D_FF.fbt index f7de52036..17088f6e5 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_D_FF.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_D_FF.fbt @@ -1,41 +1,41 @@ - - - - + + + + + - - + + - - + + - + - + - - - + + + - - + + - - - + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_F_TRIG.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_F_TRIG.fbt index 14fe1a40c..ddb8d1385 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_F_TRIG.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_F_TRIG.fbt @@ -1,32 +1,33 @@ - - - - + + + + + - - + + - + - + + - - + + - - + + - - - + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_MERGE.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_MERGE.fbt index 0b1daf198..38d301c6d 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_MERGE.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_MERGE.fbt @@ -1,26 +1,28 @@ - - - - + + + + + - - + + - + + + - - - + + + - - - + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_PERMIT.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_PERMIT.fbt index 12ef92e95..e25cf44ae 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_PERMIT.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_PERMIT.fbt @@ -1,29 +1,30 @@ - - - - + + + + + - - + + - + - + + - - - + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RDELAY.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RDELAY.fbt index fdf4785b5..8a9a6e731 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RDELAY.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RDELAY.fbt @@ -1,20 +1,48 @@ - - - - + + + + + - - + + - + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_REND.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_REND.fbt index 1e3d8064f..ee243fe7e 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_REND.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_REND.fbt @@ -1,33 +1,35 @@ - - - - + + + + + - - - + + + - + + + - - - - + + + + - - - - - - - - + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RS.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RS.fbt index 84b71ed8d..93e7f0729 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RS.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_RS.fbt @@ -1,40 +1,41 @@ - - - - + + + + + - - + + - - + + + - + - - - + + + - - + + - - - + + + - - + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_R_TRIG.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_R_TRIG.fbt index a869162db..ef5bf7f0a 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_R_TRIG.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_R_TRIG.fbt @@ -1,32 +1,33 @@ - - - - + + + + + - - + + - + - + + - - + + - - + + - - - + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SELECT.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SELECT.fbt index 26f8e3b80..952f0a944 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SELECT.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SELECT.fbt @@ -1,33 +1,34 @@ - - - - + + + + + - - + + - - + + - + - + + - - - + + + - - - + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SPLIT.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SPLIT.fbt index 00c703b82..fe05f3082 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SPLIT.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SPLIT.fbt @@ -1,26 +1,28 @@ - - - - + + + + + - + - - + + + + - - - - + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SR.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SR.fbt index 7dc6604a7..7abea8e07 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SR.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SR.fbt @@ -1,40 +1,41 @@ - - - - + + + + + - - + + - - + + + - + - - - + + + - - + + - - - + + + - - + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SWITCH.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SWITCH.fbt index 5021cc9ac..0baa676f4 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SWITCH.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_SWITCH.fbt @@ -1,35 +1,36 @@ - - - - + + + + + - - + + - - + + - + + - - - + + + - - + + - - - - + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TABLE.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TABLE.fbt index f4fab690b..71165d7a3 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TABLE.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TABLE.fbt @@ -1,44 +1,44 @@ - - - - + + + + + - - - + + + - + - - + + - - + + - + - - + + - - - - + + + + - - - - - + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TRAIN.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TRAIN.fbt index cf6c563bf..b3275bf54 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TRAIN.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_TRAIN.fbt @@ -1,47 +1,47 @@ - - - - + + + + + - - + + - - + + - - + + - - + + - + - - - + + + - - - - + + + + - - - - - - + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_T_FF.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_T_FF.fbt index f14cbb562..a707553f1 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_T_FF.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/events/E_T_FF.fbt @@ -1,32 +1,33 @@ - - - - + + + + + - + - - + + + - + - - - + + + - - + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/ID.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/ID.fbt index dfb168333..a9e323a10 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/ID.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/ID.fbt @@ -1,37 +1,37 @@ - - - - + + + + + - - - + + + - - + + - - - + + + - - - - + + + + - - + + - - - + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IW.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IW.fbt index 2e6876b7e..7a814ffd7 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IW.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IW.fbt @@ -1,37 +1,38 @@ - - - - + + + + + + - - - + + + - - + + - - - + + + - - - - + + + + - - + + - - - + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IX.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IX.fbt index 3976f99d0..5e18120a4 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IX.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/IX.fbt @@ -1,42 +1,44 @@ - - - - + + + + + + + - - - + + + - - + + - - - + + + - - - - + + + + - - - - + + + + - - + + - - - + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QD.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QD.fbt index 79e123d4d..81ae3f259 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QD.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QD.fbt @@ -1,37 +1,102 @@ - - - - + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QW.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QW.fbt index 6b02e35d9..daaa10218 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QW.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QW.fbt @@ -1,37 +1,103 @@ - - - - + + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QX.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QX.fbt index 591f6c75a..e74bbfc75 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QX.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/io/QX.fbt @@ -1,37 +1,104 @@ - - - - + + + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/math/FB_RANDOM.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/math/FB_RANDOM.fbt index f809fa6cd..001488292 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/math/FB_RANDOM.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/math/FB_RANDOM.fbt @@ -1,47 +1,48 @@ - - - - + + + + + - - + + - + - - - + + + - + - + - - - + + + - - + + - - - - + + + + - - + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_1.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_1.fbt index f0e7fb376..2d8ffdd75 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_1.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_1.fbt @@ -1,39 +1,39 @@ - - - - + + + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_2_1.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_2_1.fbt index 92c3e8b21..babd5aac3 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_2_1.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/CLIENT_2_1.fbt @@ -1,41 +1,41 @@ - - - - + + + + + - - - + + + - - - - + + + + - - - + + + - - - - + + + + - - - - + + + + - - - + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_0.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_0.fbt index 2e1be9cc8..d0d4bfeb6 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_0.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_0.fbt @@ -1,35 +1,35 @@ - - - - + + + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_1.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_1.fbt index eb2a06134..278a67253 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_1.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_1.fbt @@ -1,37 +1,37 @@ - - - - + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_10.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_10.fbt index cc7b8884c..536beceb4 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_10.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_10.fbt @@ -1,53 +1,53 @@ - - - - + + + + + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_2.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_2.fbt index 5c10b2aba..a842da09d 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_2.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_2.fbt @@ -1,39 +1,39 @@ - - - - + + + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - - + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_3.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_3.fbt index a2e341c8a..6fbcb5d90 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_3.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_3.fbt @@ -1,41 +1,41 @@ - - - - + + + + + - - - + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_4.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_4.fbt index 69937a261..609b7a2ff 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_4.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_4.fbt @@ -1,43 +1,43 @@ - - - - + + + + + - - - + + + - - - - - - + + + + + + - - - + + + - - - + + + - - - - - - + + + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_5.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_5.fbt index 6cc72c38b..5ee1bddbf 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_5.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_5.fbt @@ -1,45 +1,45 @@ - - - - + + + + + - - - + + + - - - - - - - + + + + + + + - - - + + + - - - + + + - - - - - - - + + + + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_6.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_6.fbt index d9a70abfb..a70260c4c 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_6.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_6.fbt @@ -1,47 +1,47 @@ - - - - + + + + + - - - + + + - - - - - - - - + + + + + + + + - - - + + + - - - + + + - - - - - - - - + + + + + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_7.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_7.fbt index 9209dc124..13478dcf1 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_7.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_7.fbt @@ -1,49 +1,49 @@ - - - - + + + + + - - - + + + - - - - - - - - - + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - + + + + + + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_8.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_8.fbt index e3690b4ba..64e1d477b 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_8.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_8.fbt @@ -1,51 +1,51 @@ - - - - + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - + + + + + + + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_9.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_9.fbt index 770e7cdc8..1a96b6856 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_9.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/PUBLISH_9.fbt @@ -1,55 +1,55 @@ - - - - + + + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1.fbt index 2d2634649..f14ea0be0 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1.fbt @@ -1,39 +1,39 @@ - - - - + + + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1_2.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1_2.fbt index 072ae81e0..f8dd0fbd9 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1_2.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SERVER_1_2.fbt @@ -1,41 +1,41 @@ - - - - + + + + + - - - + + + - - - + + + - - - + + + - - - - - + + + + + - - - + + + - - - - + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_0.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_0.fbt index fab48d14c..ebe1f459e 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_0.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_0.fbt @@ -1,35 +1,35 @@ - - - - + + + + + - - - + + + - - + + - - - + + + - - - + + + - - + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_1.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_1.fbt index 7e65c31dd..6788a4a3c 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_1.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_1.fbt @@ -1,37 +1,37 @@ - - - - + + + + + - - - + + + - - + + - - - + + + - - - - + + + + - - + + - - - + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_10.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_10.fbt index 1ada8f98d..bfebc7d4d 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_10.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_10.fbt @@ -1,55 +1,56 @@ - - - - + + + + + - - - + + + - - + + - - - + + + - - - - - - - - - - - - - + + + + + + + + + + + + + - - + + - - - - - - - - - - - - + + + + + + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_2.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_2.fbt index fe543fbae..9ea1363c0 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_2.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_2.fbt @@ -1,39 +1,39 @@ - - - - + + + + + - - - + + + - - + + - - - + + + - - - - - + + + + + - - + + - - - - + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_3.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_3.fbt index 64fe75189..8450323a2 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_3.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_3.fbt @@ -1,41 +1,41 @@ - - - - + + + + + - - - + + + - - + + - - - + + + - - - - - - + + + + + + - - + + - - - - - + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_4.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_4.fbt index ed1d06d7c..8919d0cd2 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_4.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_4.fbt @@ -1,43 +1,43 @@ - - - - + + + + + - - - + + + - - + + - - - + + + - - - - - - - + + + + + + + - - + + - - - - - - + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_5.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_5.fbt index fb0c0dead..748c51066 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_5.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_5.fbt @@ -1,45 +1,45 @@ - - - - + + + + + - - - + + + - - + + - - - + + + - - - - - - - - + + + + + + + + - - + + - - - - - - - + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_6.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_6.fbt index b2be6dffa..30ca78bc1 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_6.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_6.fbt @@ -1,47 +1,47 @@ - - - - + + + + + - - - + + + - - + + - - - + + + - - - - - - - - - + + + + + + + + + - - + + - - - - - - - - + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_7.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_7.fbt index 4be21224c..0ff26cb89 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_7.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_7.fbt @@ -1,49 +1,49 @@ - - - - + + + + + - - - + + + - - + + - - - + + + - - - - - - - - - - + + + + + + + + + + - - + + - - - - - - - - - + + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_8.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_8.fbt index afef3cbe3..d2702e30b 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_8.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_8.fbt @@ -1,51 +1,51 @@ - - - - + + + + + - - - + + + - - + + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - + + - - - - - - - - - - + + + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_9.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_9.fbt index 7977ceaf6..6cfc72066 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_9.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/net/SUBSCRIBE_9.fbt @@ -1,53 +1,53 @@ - - - - + + + + + - - - + + + - - + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + - - + + - - - - - - - - - - - + + + + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_2.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_2.fbt index e528d31ca..90391f9f6 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_2.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_2.fbt @@ -1,26 +1,26 @@ - - - - + + + + + - - - + + + - - + + - - + + - + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_3.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_3.fbt index 021b97a9e..8ae5f2f18 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_3.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/APPEND_STRING_3.fbt @@ -1,28 +1,28 @@ - - - - + + + + + - - - - + + + + - - + + - - - + + + - + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2ARRAY_2_LREAL.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2ARRAY_2_LREAL.fbt index d8d3ef970..c00f7079e 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2ARRAY_2_LREAL.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2ARRAY_2_LREAL.fbt @@ -1,24 +1,25 @@ - - - - + + + + + - - + + - - + + - + - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2VALUES_2_LREAL.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2VALUES_2_LREAL.fbt index 798a8b190..4aa17fa66 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2VALUES_2_LREAL.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/ARRAY2VALUES_2_LREAL.fbt @@ -1,26 +1,26 @@ - - - - + + + + + - - + + - - - + + + - + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_1.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_1.fbt index d64599310..974084c1b 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_1.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_1.fbt @@ -1,37 +1,37 @@ - - - - + + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_10.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_10.fbt index ae4b3a822..78056b948 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_10.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_10.fbt @@ -1,55 +1,93 @@ - - - - + + + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - - - + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_2.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_2.fbt index 76fff65a6..d30d4eec3 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_2.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_2.fbt @@ -1,39 +1,39 @@ - - - - + + + + + - - - + + + - - - - + + + + - - - + + + - - - + + + - - - - + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_3.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_3.fbt index b488f514b..efd08dc20 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_3.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_3.fbt @@ -1,41 +1,41 @@ - - - - + + + + + - - - + + + - - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_4.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_4.fbt index 3dfcbeffd..6bd3fe9d4 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_4.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_4.fbt @@ -1,43 +1,43 @@ - - - - + + + + + - - - + + + - - - - - - + + + + + + - - - + + + - - - + + + - - - - - - + + + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_5.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_5.fbt index 3fa5a89fa..218ff749d 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_5.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_5.fbt @@ -1,45 +1,45 @@ - - - - + + + + + - - - + + + - - - - - - - + + + + + + + - - - + + + - - - + + + - - - - - - - + + + + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_6.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_6.fbt index 662f4fb00..06ecf77ce 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_6.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_6.fbt @@ -1,47 +1,47 @@ - - - - + + + + + - - - + + + - - - - - - - - + + + + + + + + - - - + + + - - - + + + - - - - - - - - + + + + + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_7.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_7.fbt index 7efd7f001..942a5b8c7 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_7.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_7.fbt @@ -1,49 +1,49 @@ - - - - + + + + + - - - + + + - - - - - - - - - + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - + + + + + + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_8.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_8.fbt index 6a3f249e5..155c99ed8 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_8.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_8.fbt @@ -1,51 +1,51 @@ - - - - + + + + + - - - + + + - - - - - - - - - - + + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - + + + + + + + + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_9.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_9.fbt index 3ceec55a3..9f788046c 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_9.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/CSV_WRITER_9.fbt @@ -1,53 +1,91 @@ - - - - + + + + + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - - + + + - - - + + + - - - - - - - - - - - + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_1.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_1.fbt index 1ed6dab6b..7e43b4a51 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_1.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_1.fbt @@ -1,32 +1,33 @@ - - - - + + + + + - - + + - - + + - - - - + + + + - - + + - - - + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_2.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_2.fbt index 41046a868..726bb7549 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_2.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/F_MUX_2_2.fbt @@ -1,38 +1,38 @@ - - - - + + + + + - - - + + + - - - + + + - - - - - + + + + + - - - - + + + + - - - - + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/GET_AT_INDEX.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/GET_AT_INDEX.fbt index 63509b753..e447d1b13 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/GET_AT_INDEX.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/GET_AT_INDEX.fbt @@ -1,28 +1,28 @@ - - - - + + + + + - - - + + + - - - + + + - - + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/OUT_ANY_CONSOLE.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/OUT_ANY_CONSOLE.fbt index 6e60e3fc2..8dba4bd27 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/OUT_ANY_CONSOLE.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/OUT_ANY_CONSOLE.fbt @@ -1,28 +1,31 @@ - - - - + + + + + + + + - - - - + + + + - - + + - - - + + + - + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/SET_AT_INDEX.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/SET_AT_INDEX.fbt index fade1a828..b53a8cbaa 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/SET_AT_INDEX.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/SET_AT_INDEX.fbt @@ -1,30 +1,30 @@ - - - - + + + + + - - - - + + + + - - - + + + - - - + + + - - + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/STEST_END.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/STEST_END.fbt index c1d5417d9..7cd2785e1 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/STEST_END.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/STEST_END.fbt @@ -1,11 +1,17 @@ - - - - + + + + + + + - + + + + + - diff --git a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/VALUES2ARRAY_2_LREAL.fbt b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/VALUES2ARRAY_2_LREAL.fbt index b692b9541..078afd773 100644 --- a/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/VALUES2ARRAY_2_LREAL.fbt +++ b/code/4diac-integration/solutions/stdlib/models/iec61499.4diac.stdlib/utils/VALUES2ARRAY_2_LREAL.fbt @@ -1,26 +1,26 @@ - - - - + + + + + - - - + + + - - + + - - + + - + - From 6e1c66674a7f24bbf70323d1fd6534e30f8aefda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Fri, 21 Jul 2023 11:00:29 +0300 Subject: [PATCH 61/66] Restore fbme.iml --- .idea/modules/fbme.iml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 .idea/modules/fbme.iml diff --git a/.idea/modules/fbme.iml b/.idea/modules/fbme.iml new file mode 100644 index 000000000..e3adbe8b3 --- /dev/null +++ b/.idea/modules/fbme.iml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file From 9b6dd9b78e7afaf72d8682ab914277a394fc642c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Fri, 21 Jul 2023 11:01:07 +0300 Subject: [PATCH 62/66] Restore fbme.iml --- .idea/modules/fbme.iml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.idea/modules/fbme.iml b/.idea/modules/fbme.iml index e3adbe8b3..f49154055 100644 --- a/.idea/modules/fbme.iml +++ b/.idea/modules/fbme.iml @@ -1,8 +1,8 @@ - - - - - + + + + + \ No newline at end of file From 6741bc45de587d2d7111fc1f4ddae32180c0a7ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Fri, 21 Jul 2023 11:05:03 +0300 Subject: [PATCH 63/66] Restore jarRepositories.xml --- .idea/jarRepositories.xml | 48 +++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml index d3aee7f54..dc08c64af 100644 --- a/.idea/jarRepositories.xml +++ b/.idea/jarRepositories.xml @@ -6,26 +6,41 @@ - - - - - - - - - - - - - - - - - - - - - - @@ -1696,8 +1674,5 @@ - - - From 5cfd13c6d2e8cfc6b2cd3ca87af15be6889d549b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9DDmitri?= Date: Fri, 21 Jul 2023 11:23:58 +0300 Subject: [PATCH 66/66] Delete components --- ...e.iec61499.lang.sandbox.mpsPersistence.mps | 171 ++---------------- 1 file changed, 11 insertions(+), 160 deletions(-) diff --git a/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.mpsPersistence.mps b/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.mpsPersistence.mps index 3ab38af3a..9105febc4 100644 --- a/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.mpsPersistence.mps +++ b/samples/sandbox/solutions/org.fbme.ide.sandbox/models/org.fbme.ide.iec61499.lang.sandbox.mpsPersistence.mps @@ -24,7 +24,6 @@ - @@ -32,8 +31,6 @@ - - @@ -56,7 +53,6 @@ - @@ -960,8 +956,8 @@ - - + + @@ -980,8 +976,8 @@ - - + + @@ -993,8 +989,8 @@ - - + + @@ -1018,8 +1014,8 @@ - - + + @@ -1031,7 +1027,7 @@ - + @@ -1057,8 +1053,8 @@ - - + + @@ -1260,47 +1256,6 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -1570,109 +1525,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -