Set Radial Buttons on Capella Studio created Add-On

Hi,

My team are trying to use Python4Capella to set the radial buttons on a custom Capella Studio created add-on, but struggling.

On a given class which extends (for example) fa.AbstractFunction there is a enumerated type.

This enumerated type has several string values which are defined.

How can we set this enumerated type using P4C?

Any help is much appreciated.

Thanks, Josh

1 Like

I’m not really sure to understand what you are trying to achieve.
If you are trying to add buttons to existing views with Python4Capella you can check the tips and tricks page on how to contribute a menu to a tool bar for instance.

For the enumeration I’ll give you an example on the function visibility:

lf = LogicalFunction()
public_enum = get_enum_literal("http://www.polarsys.org/capella/core/core/" + capella_version(), "VisibilityKind", "PROTECTED")
lf.get_java_object().setVisibility(public_enum)

Let me know if this is helpful and give me more details if needed.

2 Likes

Hi @YvanLussaud. Thanks for the response.

To clarify further:

  • We already have an add-on made through Capella Studio
  • This add-on has radial buttons (an enumerated type).
  • We would like to change the enumeration selected using Python4Capella.

A parallel example would be for core Capella:

  • A system function has a Kind. “Duplicate”, “Function”, “Gather”, “Route”, “Select”, Split".
  • This is enumerated data.
  • Using Python4Capella we would like to be able to change the function kind.
  • E.g. change a “Route” function to a “Split” function kind.

It is Python for Capella code to change this enumerated type we are struggling with. I suspect, if we can make it work for this core Capella example, it would also work for our Add-on.

Thanks,

Josh

1 Like

OK this is the same kind of code I used above:

lf = LogicalFunction()
split_enum = get_enum_literal("http://www.polarsys.org/capella/core/fa/" + capella_version(), "FunctionKind", "SPLIT")
lf.get_java_object().setKind(split_enum)

Note that you will need to execute this code in a transaction to apply the modification to the Capella model.

2 Likes

Thanks @YvanLussaud. Using the above example my team has been able to achieve the desired objective. Your help is, as always, much appreciated.

Regards, Josh

2 Likes