Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DrawIO: New Line in Transition #425

Open
timscheuermann opened this issue Nov 27, 2024 · 4 comments
Open

DrawIO: New Line in Transition #425

timscheuermann opened this issue Nov 27, 2024 · 4 comments

Comments

@timscheuermann
Copy link

timscheuermann commented Nov 27, 2024

When I add a transition with an Event and a condition from one state to another, i get different code generation results when i add a new line between the Event and the condition.
For example when adding the transition
EVENT_BUTTON_START_CLICKED [m_form.ValidFileSelected() >= 0] in only one line, the event and condition both gets inserted.
But when I do a linebreak the event is ignored and statesmith inserts a DO-Event instead, which seems wrong although nothing really has changed in the diagram except for the new line. This transition looks like this:
EVENT_BUTTON_START_CLICKED
[m_form.ValidFileSelected() >= 0]

As a workaround I insert the opening square bracket in the first line and the rest of the condition in the second line, which gives the expected result:
EVENT_BUTTON_START_CLICKED [
m_form.ValidFileSelected() >= 0]

Is this a bug or is there a better workaround? Because me as a user would not expect this behaviour.

@adamfk
Copy link
Contributor

adamfk commented Nov 27, 2024 via email

@adamfk
Copy link
Contributor

adamfk commented Nov 28, 2024

Hi @timscheuermann. This is currently by design although I'm open to suggestions to improve it. I know I've wanted to split up a long behavior string into multiple lines like you.

There are two use cases that are in conflict right now, but we can probably modify the grammar to satisfy both.

  • Multiple Behaviors Sharing An Edge
  • Guard Clause On Separate Line

Multiple Behaviors Sharing An Edge

Sometimes I have designs where I want multiple events or behaviors to share the same transition to keep the diagram uncluttered.

Below is a made up example. The left hand side shows the draw.io design and the right hand side shows the generated simulator.

image

Guard Clause On Separate Line

When you have long event names, it would be nice to be able to have the guard condition on a separate line from the event like below.

image

The current workaround that you list above isn't too bad.

image

Proposals

We can satisfy both by either adding to the grammar or changing the grammar. If possible, I would prefer to add to the grammar so that we don't break user's existing diagrams. But if we can't find a nice solution, we can modify the grammar. It is probably reasonably minor as I haven't documented the feature of Behaviors sharing a single edge here yet. I've been meaning to get to that #164.

P1 - Change Grammar For Behaviors Sharing Edge

StateSmith currently supports all 3 syntax below, but we could remove "SYNTAX 0" so that guards could be on a separate line from events. It would be a slight breaking change and I'd want to poll the discord group before starting to implement this change.

image

P2 - Add To Grammar To Support Line Breaks

We could keep the grammar as is and do something like supporting backslashes to continue a line. This is fairly common in a number of programming languages.

image

I'm currently not a giant fan of this approach. The UML syntax we follow already has a lot of special characters.

P3 - Leave As Is

Any other ideas?

Thoughts

I'm personally leaning towards P1. I'd like StateSmith to behave as users expect it to. The below syntax feels like it should be one behavior instead of two.

image

Your thoughts?

@timscheuermann
Copy link
Author

First of all, I do not have big experience in Statesmith's behaviour on the different pattern.
My thought is to leave the behaviour as it is and adding a setting which allows the user to switch between multiple possibilities. The default setting would be the current behaviour. This means that all current diagrams will result in the same expected code. If the user wants other behaviour, he just changes it by changing the setting and its on him.

@adamfk
Copy link
Contributor

adamfk commented Nov 29, 2024

This could work. It would also be nice to have a standard syntax though. Then I can look at any StateSmith diagram and not have to worry about the settings.

I'll scan through all the examples this weekend and see if I come across any places that would break. It might not actually affect anyone.

@adamfk adamfk moved this to Will Do in Backlog Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Will Do
Development

No branches or pull requests

2 participants