archimatetool / archi

Archi: ArchiMate Modelling Tool
https://www.archimatetool.com
MIT License
916 stars 267 forks source link

Embedding a newline character in a property (in combination with using the property in a label) #859

Open mikisvandijk opened 1 year ago

mikisvandijk commented 1 year ago

I am creating a set of views each showing one of 18 capabilities we have defined and some information about it.

I'm showing the information in a note, and when I insert the text I want to display, I can format it using newlines. I works fine.

Examle 1 - plain notes

But for clarity in the model and reusability, I prefer to define the text to be shown as a property of the capability. When I connect the note to the capability, I can use a label expression to show the desired information:

$connection:target{property:platform}

But I cannot work out how to use newlines, a feature I certainly need to create something presentable.

I tried entering a \n in the property text, or pasting a text with a newline into the propety, but that doesn't do the job.

Example 2 - notes using a label expression to show a property

Can you please help me by explaining me how to do it, present a workaround or maybe handle this as a feature request. Thanks!

Phillipus commented 1 year ago

Indeed, properties are single lines that don't support newline characters.

There is a ${wordwrap:count:expression} expression that can be used to break the text every count characters.

See https://github.com/archimatetool/archi/wiki/Label-Expressions

Phillipus commented 1 year ago

@jbsarrodie It is possible to render \n characters in PropertiesRenderer if we replace \\n chars with \n

I can't remember if there is a reason for not doing this?

mikisvandijk commented 1 year ago

I think that would solve the issue :-)

jbsarrodie commented 1 year ago

Indeed, properties are single lines that don't support newline characters.

Well, in fact properties support newlines characters, it's just that we don't allow one to add them through the UI (newline is caught to validate the content and removed when pasting content). If you set a property using jArchi you can set it to contain newlines if you want (I use this for multilang models). This is of course a side effect of jArchi, but I've never had any issues but more test should be done to see if it impacts reports/exports.

@jbsarrodie It is possible to render \n characters in PropertiesRenderer if we replace \\n chars with \n I can't remember if there is a reason for not doing this?

The idea was to only replace \n used in label expressions themselves. If we start doing if for properties, then someone will expect it to also work on name, documentation... But if we do it everywhere, then it is no more possible to not render them, while this might be wished if (e.g.) documentation field contains some code sample.

I see two options here:

Phillipus commented 1 year ago

I can see two places where the UI restricts single lines:

User can enter CRs in Documentation/Mult-line fields.

Enable newlines in properties themselves and find a good way to render them in the property UI which is singeline (maybe replace them by some unicode icon-like character like ⤶). This requires a way to edit the content ((maybe by using some combination of keys, or by adding small property content editor).

Isn't entering a \n character in a property table pretty much the same thing?

Phillipus commented 1 year ago

Isn't entering a \n character in a property table pretty much the same thing?

Actually, I understand what you mean - to insert actual newlines (
 in XML)