Selecting Multiple Buttons from an Enumeration

Hello!
I’m tasked with creating a viewpoint and attempting to get an enumeration-based radiobox (or set of toggle buttons instead of the normal radiobox) that allows multiple options to be selected simultaneously as oppose to only one selection at a time.
While I switched the button type to ‘toggle’ for the enumeration there’s no obvious path of where to allow another selection to be made without the previous selection being removed.

[One method I tried and seemed to make some progress with was adding the ‘old’ user selection to the ‘new’ selection in the default setting of the radiobox ui methodology (see below).


What this did, allowed for me to select and deselect as many elements as I liked.
Success?
No.
When I navigate to any other object in the workspace and return back to my viewpoint element, my selections have disappeared and never seemed to actually be set.]

Does anyone know how to set up an enumeration to allow for multiple option selection simultaneously?
(Any tips or bits of advice are happily received)

Many thanks,
Angus

Hi,

I’m not sure to fully understand your data structure. In order to get what you want you either need to

  • store the checked values into a collection (then have an attribute containing a collection of CheckIt_Enum_Value)
Data test.data {
	Class WithAttributesAndAssociations {
		Attributes:
			CheckItValues enum myEnum [0,*] // Note the cardinality here
	}
	
	Enumeration myEnum { 
		constant1, constant2, constant3, constant4 
	}
}

or

  • have an object containing the “check state” of each enum value as boolean values.

In the first case, in the generated code you will get a getCheckIt method returning the content of your collection instead of the pair of getCheckIt and setCheckIt methods.
You then want your UI code to set the value of this attribute according to your selection of checkboxes.

Does it helps ?

In your code, as the add() method returns null, then checkIt is set to null in the call to eNotify() and if I’m not mistaking it does nothing (because of this null value).

Regards,
Arnaud

Hi Arnaud,
Thank you for your help! I have implemented your first suggestion however when setting the UI fields, the enumeration cannot be mapped to the attribute with a 'radiobox 'or ‘checkbox’. (As seen below)

Do you know why this is/ how to resolve this issue? Your logic for the suggestion is promising but I’m stuck at this point unfortunately.
Can you help?

Many thanks,
Angus

Also, to further qualify using what you provided. I’d like the UI to allow a user to select both ‘constant1’ and ‘constant2’ simultaneously (or more if they wish) however at the moment, if I were to select ‘constant1’ then attempt to select ‘constant2’ as well, the radiobox deselects ‘constant1’ and selects ‘constant2’ instead.
I hope this is more clear!

Yes this is what I thought but I wanted to be sure I understood correctly.

In the Kitalpha/Capella Studio toolset regarding the UI generation side for Enumeration-based values, what is supported is single value not collections of Enumeration values. Thus what you want to implement is not supported out of the box.

So, to get what you want either you specify (in the .data.vptext file) an object that will store all the possible values, generate the UI (the generated .ui plugin) and modify the code setting the values (the generated .model plugin) to get your logic, or to inspire yourself from the code generated for the UI in order to implement your logic and only rely on a collection of enumeration value.

One thing is sure, you will have to code something to get what you want.

Regards,
Arnaud

Understood, Thanks for your help!