Initialize editor for abstract concept with an editor for one of its concrete subconcepts

I have an abstract concept `Rational` for rational numbers. It has two concrete subconcepts, `Decimal` and `Fraction`, which represent two ways of entering rational numbers. I have defined editors for the concrete subconcepts. Now wherever editor for `Rational` is needed, I would like to always start with an editor for `Decimal`. (`Fraction` editor will be reachable by e.g. hitting '/' in the `Decimal` editor.) How would I instruct MPS to use `Decimal` as the default editor for `Rational`?

0
6 comments

In Constraints for Rational you can specify the default concrete sub-concept to use, whenever the abstract concept of Rational is about to be instantiated.

2
Avatar
Permanently deleted user

That works, thank you!

0
Avatar
Permanently deleted user

Turns out that this solution does not work for a `Rational` of cardinality [0..1].

0

It should and does for me. Maybe something else in your language definition has changed?

0
Avatar
Permanently deleted user

Strictly speaking, it does work, but only after the editor for the optional value is instantiated, that is, after first hitting Enter in the placeholder. I guess, after all, this makes sense and is good enough.

In these screenshots, endpoint coordinates are Rationals of cardinality 1, whereas thickness is Rational of cardinality 0..1:

I can start typing numbers for a coordinate into the <no value> placeholder right away, since it is already an editor for Decimal. That's not the case for thickness:

It first needs to be instantiated by hitting Enter - then it turns into an editor for Decimal:

at which point I can start typing in numbers.

0

A custom transformation action would need to be defined in order to instantiate a specific concept as a reaction to typing numeric values.

1

Please sign in to leave a comment.