How to use SetCommand to set multiplicity [message #1806318] |
Tue, 07 May 2019 13:09  |
Eclipse User |
|
|
|
I'd like to create some shortcuts (e.g. on the context menu) that make it quick to set standard cardinalities on Associations. Have managed to get everything working to the point of being able to invoke a SetCommand but am struggling with the multiplicity element as there is the complication of the value type as well as the value itself.
The code I am using in the handler is along the lines of:
TransactionalEditingDomain editingDomain = ServiceUtils.getInstance().getTransactionalEditingDomain(serviceRegistry);
Command command = SetCommand.create(editingDomain, ends.get(0), UMLPackage.Literals.MULTIPLICITY_ELEMENT__UPPER_VALUE, upperSource);
editingDomain.getCommandStack().execute(command);
If I set upperSource to be an Integer.valueOf(-1) then the cardinality becomes * only if it had at some point been set to an unlimited natural. If it started out as an Integer then the command has no effect. Is there a correct way to set MultiplicityElement values such that you can be sure that a * will be a * and a 1 will be a 1?
Many thanks
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.43628 seconds