Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Chilren of a figure
Chilren of a figure [message #482123] Tue, 25 August 2009 12:55 Go to next message
Eclipse UserFriend
Originally posted by: cedric.moonen.fmtc.be

Hello,

I'm creating a kind of expression editor. As a simple example, suppose
that I can create AND and OR expressions and "simple" expressions (which
are basicalyl text). The AND and OR expressions can have other expressions
as children:

(expr1 OR (expr3 AND expr4) ).

In this example, the OR expression contains an AND expression as a child
(but it could be any of the three expression).

In my ecore model, all three specialized expressions (AND, OR and simple)
inherits from an abstract base expression class. The AND and OR
expressions have additionally an association to the base expression which
is called "operands".

I am able to create child expressions into an AND and an OR expressions by
adding a "Child Reference" in the Node Mapping of my AND and OR
expressions. The problem is that I have to specify the exact type of
children, which means I have to add 3 "Child Reference" nodes, one for
each type of expression.
It is ok in the simple example I mentioned but it quickly becomes a hell
to create once the number of expressions grows. Another problem is that it
seems that for each of those child reference, a specific figure is
created, which means that if I would like to modify the code, I have to do
it in multiple figures.

What I would like to have, is able to specify the base expression as the
child type, because in fact any type of expression can be used in the
operands.

Is there any way to do something like that ?
Thanks
Re: Chilren of a figure [message #482573 is a reply to message #482123] Thu, 27 August 2009 07:02 Go to previous message
Eclipse UserFriend
Originally posted by: cedric.moonen.fmtc.be

Hello,

Maybe my first message was not clear enough, I'll try to clarify it a bit.
If you think that what I'm trying to do is not possible, please let me
know.

So, I would like to create an editor to build a complex expression with a
graphical editor. To keep the example simple, I will only use 3
expressions, but in my real case, I have much more than that.

The three expressions are:
- An OR expression
- An AND expression
- A simple text expression

With those 3 expressions, I could create complex expressions like:
(Expr1 AND (Expr2 OR Expr3 OR Expr4))

In this case, the main expression is an AND expression with two operands:
- Expr1
- Expr2 OR Expr3 OR Expr4

The second operand is an OR expression with 3 operands.

So far my ecore model is made of an abstract ExpressionBase with 3 classes
which inherits from this ExpressionBase: the ORExpression, the
ANDExpression and the SimpleExpression.

In my graphical editor, I would like to be able to add children
(sub-expressions) in the AND and OR expressions. So, for instance when I
create an AND expression, it is represented as an empty rectangle in which
I can create sub-expressions. The sub-expressions can of course be of any
expression type (AND, OR or simple).

Currently, I solved this problem by having in my ecore model an
association from my ORExpression and ANDExpression to the BaseExpression
which is called "Operands" and with the lower bounds being 2 and the upper
bound being -1 (infinite).
In this way, in my gmfmap in the node mapping for the ANDExpression and
OREXpression I am able to create 3 "Child Reference" with the "Referenced
Child" pointing to one of the 3 expression and with the "Containement
Feature" being Operands.

Now, this scenario works fine because I am able to create sub-expressions
into an ORExpression and an ANDExpression but the problem is that I have
to specify the exact type of the expression. This quickly becomes a real
mess because any expression can be used for an operand. Furthermore, when
I add more expressions (which can themselves also have operands), I need
to add "Child Reference" nodes in all the existing expressions which
accept sub-expressions. This becomes quickly unmaintainable ( I have quite
a lot of different expression types). If instead of specifying the exact
type of expression (AND, OR, simple), I could specify the BaseExpression
class, this would solve my problem because even if I add new expression
types, I won't need to adapt my existing expressions.

Is there any way to do something like that ?
Thanks for any reply.
Cédric
Previous Topic:Phantom nodes or donno.. confusion..
Next Topic:Question about Property Sections for a metaclass
Goto Forum:
  


Current Time: Fri Apr 19 21:55:58 GMT 2024

Powered by FUDForum. Page generated in 0.03862 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top