Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Default child creation setting for [1] Containment reference
Default child creation setting for [1] Containment reference [message #417165] Thu, 28 February 2008 15:30 Go to next message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi,

I am seeing, in importing a generator model, that for containment
EReferences that have multiplicity 1, the "Edit / Children" and "Edit /
Create Child" properties default to false.

As expected, when I generate my edit plug-in, the item provider for my
EClass doesn't have a new-child-descriptor for this EReference. However,
when I run the generated editor, I get a New Child menu item to create the
contained object in this EReference.

Why does this seem to work? Should I set my Children and Create Child
properties to true anyway? Or would that break something else?

Thanks,

Christian
Re: Default child creation setting for [1] Containment reference [message #417166 is a reply to message #417165] Thu, 28 February 2008 16:05 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33140
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------060804050700040401020102
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit

Christian,

I'm not seeing that. Are you sure you didn't just change the model from
non-containment to containment after the fact? You can verify that the
multiplicity is not considered when initializing a new GenFeature:

| *public **void *initialize(EStructuralFeature eFeature)
{
*if *(eFeature != getEcoreFeature())
{
setEcoreFeature(eFeature);

*if *(eFeature *instanceof *EReference)
{
EReference eReference = (EReference)eFeature;
*if *(!eReference.isContainer() && !eReference.isContainment())
{
setProperty(eFeature.isChangeable() ? GenPropertyKind.EDITABLE_LITERAL : GenPropertyKind.READONLY_LITERAL);
}
*else*
{
setProperty(GenPropertyKind.NONE_LITERAL);
}
setChildren
(eReference.isContainment() &&
(getGenClass().isDocumentRoot() ?
getExtendedMetaData().getFeatureKind(eFeature) == ExtendedMetaData.ELEMENT_FEATURE :
!hasDelegateFeature()));
setCreateChild(isChildren() && isChangeable());
setNotify(isChildren());
}
*else if *(isFeatureMapType())
{
setProperty(GenPropertyKind.NONE_LITERAL);
setChildren(!getGenClass().isDocumentRoot() && !hasDelegateFeature());
setCreateChild(isChildren() && isChangeable());
setNotify(isChildren());
}
*else*
{
setProperty(eFeature.isChangeable() ? GenPropertyKind.EDITABLE_LITERAL : GenPropertyKind.READONLY_LITERAL);
setChildren(*false*);
setCreateChild(*false*);
setNotify(*true*);
}

*if *(getProperty() == GenPropertyKind.EDITABLE_LITERAL && isReferenceType())
{
setPropertySortChoices(*true*);
}
}
}|

You're not having an extended lunch break are you? :-P


Christian W. Damus wrote:
> Hi,
>
> I am seeing, in importing a generator model, that for containment
> EReferences that have multiplicity 1, the "Edit / Children" and "Edit /
> Create Child" properties default to false.
>
> As expected, when I generate my edit plug-in, the item provider for my
> EClass doesn't have a new-child-descriptor for this EReference. However,
> when I run the generated editor, I get a New Child menu item to create the
> contained object in this EReference.
>
> Why does this seem to work? Should I set my Children and Create Child
> properties to true anyway? Or would that break something else?
>
> Thanks,
>
> Christian
>


--------------060804050700040401020102
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Christian,<br>
<br>
I'm not seeing that.&nbsp; Are you sure you didn't just change the model
from non-containment to containment after the fact?&nbsp; You can verify
that the multiplicity is not considered when initializing a new
GenFeature:<br>
<blockquote>
<title></title>
<style type="text/css">
<!--code { font-family: Courier New, Courier; font-size: 10pt; margin: 0px; }-->
</style>
<meta http-equiv="Content-Type"
content="text/html; charset=iso-8859-1">
<!-- ======================================================== --><!-- = Java Sourcecode to HTML automatically converted code = --><!-- = Java2Html Converter 5.0 [2006-02-26] by Markus Gebhard markus@jave.de = -->
<!-- = Further information: http://www.java2html.de = -->
<div class="java" align="left">
<table bgcolor="#ffffff" border="0" cellpadding="3" cellspacing="0">
<tbody>
<tr>
<!-- start source code --> <td align="left" nowrap="nowrap"
valign="top"> <code><font color="#ffffff">&nbsp;&nbsp;</font><font
color="#7f0055"><b>public&nbsp;</b></font><font color="#7f0055"><b>void&nbsp;</b></font><font
color="#000000">initialize</font><font color="#000000">(</font><font
color="#000000">EStructuralFeature&nbsp;eFeature</font ><font color="#000000">)</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">{</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#7f0055"><b>if&nbsp;</b></font><font
color="#000000">(</font><font color="#000000">eFeature&nbsp;!=&nbsp;getEcoreFeature </font><font
color="#000000">())</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">{</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">setEcoreFeature</font><font
color="#000000">(</font><font color="#000000">eFeature</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#7f0055"><b>if&nbsp;</b></font><font
color="#000000">(</font><font color="#000000">eFeature&nbsp;</font><font
color="#7f0055"><b>instanceof&nbsp;</b></font><font color="#000000">EReference</font><font
color="#000000">)</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">{</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">EReference&nbsp;eReference&nbsp;=&nbsp; </font><font
color="#000000">(</font><font color="#000000">EReference</font><font
color="#000000">)</font><font color="#000000">eFeature;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#7f0055"><b>if&nbsp;</b></font><font
color="#000000">(</font><font color="#000000">!eReference.isContainer</font><font
color="#000000">()&nbsp;</font><font color="#000000">&amp;&amp;&nbsp;!eReference.isContainment </font><font
color="#000000">())</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">{</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">setProperty</font><font
color="#000000">(</font><font color="#000000">eFeature.isChangeable</font><font
color="#000000">()&nbsp;</font><font color="#000000"> ?&nbsp;GenPropertyKind.EDITABLE_LITERAL&nbsp;:&n bsp;GenPropertyKind.READONLY_LITERAL </font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">}</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#7f0055"><b>else</b></font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">{</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">setProperty</font><font
color="#000000">(</font><font color="#000000">GenPropertyKind.NONE_LITERAL</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">}</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">setChildren</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">(</font><font
color="#000000">eReference.isContainment</font><font color="#000000">()&nbsp;</font><font
color="#000000">&amp;&amp;&nbsp;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; </font><font color="#000000">(</font><font
color="#000000">getGenClass</font><font color="#000000">()</font><font
color="#000000">.isDocumentRoot</font><font color="#000000">()&nbsp;</font><font
color="#000000">?&nbsp;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; </font><font
color="#000000">getExtendedMetaData</font><font color="#000000">()</font><font
color="#000000">.getFeatureKind</font><font color="#000000">(</font><font
color="#000000">eFeature</font><font color="#000000">)&nbsp;</font><font
color="#000000"> ==&nbsp;ExtendedMetaData.ELEMENT_FEATURE&nbsp;:& nbsp; </font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp;&nbsp; </font><font
color="#000000">!hasDelegateFeature</font><font color="#000000">()))</font><font
color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">setCreateChild</font><font
color="#000000">(</font><font color="#000000">isChildren</font><font
color="#000000">()&nbsp;</font><font color="#000000">&amp;&amp;&nbsp;isChangeable</font ><font
color="#000000">())</font><font color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">setNotify</font><font
color="#000000">(</font><font color="#000000">isChildren</font><font
color="#000000">())</font><font color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">}</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#7f0055"><b>else&nbsp;if&nbsp;</b></font ><font
color="#000000">(</font><font color="#000000">isFeatureMapType</font><font
color="#000000">())</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">{</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">setProperty</font><font
color="#000000">(</font><font color="#000000">GenPropertyKind.NONE_LITERAL</font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">setChildren</font><font
color="#000000">(</font><font color="#000000">!getGenClass</font><font
color="#000000">()</font><font color="#000000">.isDocumentRoot</font><font
color="#000000">()&nbsp;</font><font color="#000000">&amp;&amp;&nbsp;!hasDelegateFeature </font><font
color="#000000">())</font><font color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">setCreateChild</font><font
color="#000000">(</font><font color="#000000">isChildren</font><font
color="#000000">()&nbsp;</font><font color="#000000">&amp;&amp;&nbsp;isChangeable</font ><font
color="#000000">())</font><font color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">setNotify</font><font
color="#000000">(</font><font color="#000000">isChildren</font><font
color="#000000">())</font><font color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">}</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#7f0055"><b>else</b></font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">{</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">setProperty</font><font
color="#000000">(</font><font color="#000000">eFeature.isChangeable</font><font
color="#000000">()&nbsp;</font><font color="#000000"> ?&nbsp;GenPropertyKind.EDITABLE_LITERAL&nbsp;:&n bsp;GenPropertyKind.READONLY_LITERAL </font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">setChildren</font><font
color="#000000">(</font><font color="#7f0055"><b>false</b></font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">setCreateChild</font><font
color="#000000">(</font><font color="#7f0055"><b>false</b></font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">setNotify</font><font
color="#000000">(</font><font color="#7f0055"><b>true</b></font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">}</font><br>
<font color="#ffffff"></font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#7f0055"><b>if&nbsp;</b></font><font
color="#000000">(</font><font color="#000000">getProperty</font><font
color="#000000">()&nbsp;</font><font color="#000000"> ==&nbsp;GenPropertyKind.EDITABLE_LITERAL&nbsp;&a mp;&amp;&nbsp;isReferenceType </font><font
color="#000000">())</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">{</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; </font><font color="#000000">setPropertySortChoices</font><font
color="#000000">(</font><font color="#7f0055"><b>true</b></font><font
color="#000000">)</font><font color="#000000">;</font><br>
<font color="#ffffff"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </font><font color="#000000">}</font><br>
<font color="#ffffff">&nbsp;&nbsp;&nbsp;&nbsp;</font ><font color="#000000">}</font><br>
<font color="#ffffff">&nbsp;&nbsp;</font><font color="#000000">}</font></code>
</td>
<!-- end source code --> </tr>
</tbody>
</table>
</div>
<!-- = END of automatically generated HTML code = -->
<!-- ======================================================== --></blockquote>
You're not having an extended lunch break are you?&nbsp; :-P<br>
<br>
<br>
Christian W. Damus wrote:
<blockquote cite="mid:fq6lk7$tdt$1@build.eclipse.org" type="cite">
<pre wrap="">Hi,

I am seeing, in importing a generator model, that for containment
EReferences that have multiplicity 1, the "Edit / Children" and "Edit /
Create Child" properties default to false.

As expected, when I generate my edit plug-in, the item provider for my
EClass doesn't have a new-child-descriptor for this EReference. However,
when I run the generated editor, I get a New Child menu item to create the
contained object in this EReference.

Why does this seem to work? Should I set my Children and Create Child
properties to true anyway? Or would that break something else?

Thanks,

Christian
</pre>
</blockquote>
<br>
</body>
</html>

--------------060804050700040401020102--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Default child creation setting for [1] Containment reference [message #417181 is a reply to message #417166] Thu, 28 February 2008 19:55 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.ca.ibm.com

Hi, Ed,

I'm batting a pretty low average, lately.

I thought this might have something to do with the UML model importer, but
it's just an extended lunch break, as you say. I must have had this
genmodel before my property changed to composite aggregation, and reloading
the genmodel didn't change the edit attributes.

The funny thing is, that the generated code has providers that don't seem to
create all of the new-child-descriptors that I see in the editor. I guess
something reflective is kicking in to save the day.

I'll fix my genmodel.

Thanks!

Christian


Ed Merks wrote:

> Christian,
>
> I'm not seeing that. Are you sure you didn't just change the model from
> non-containment to containment after the fact? You can verify that the
> multiplicity is not considered when initializing a new GenFeature:

-----8<-----

> You're not having an extended lunch break are you? :-P
>
>
> Christian W. Damus wrote:
>> Hi,
>>
>> I am seeing, in importing a generator model, that for containment
>> EReferences that have multiplicity 1, the "Edit / Children" and "Edit /
>> Create Child" properties default to false.
>>
>> As expected, when I generate my edit plug-in, the item provider for my
>> EClass doesn't have a new-child-descriptor for this EReference. However,
>> when I run the generated editor, I get a New Child menu item to create
>> the contained object in this EReference.
>>
>> Why does this seem to work? Should I set my Children and Create Child
>> properties to true anyway? Or would that break something else?
>>
>> Thanks,
>>
>> Christian
>>
Previous Topic:Load a Model Read Only
Next Topic:Updating the properties view?
Goto Forum:
  


Current Time: Thu Apr 25 12:00:20 GMT 2024

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

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

Back to the top