Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Creating collections with at least one item
Creating collections with at least one item [message #229464] Tue, 12 May 2009 08:25 Go to next message
Josip Maras is currently offline Josip MarasFriend
Messages: 41
Registered: July 2009
Member
Hi everybody,

Is there an easy way to create the following functionality:

I'm modeling components that have a collection of services. Is there a way
to specify somewhere (in the gmfmap, gmfgraph, ecore, genmodel...) that
this collection has to have at least one item (service) - so when i'm
creating a component it automatically adds one service, and that in any
time at least one service has to exisit??

Thank you
Re: Creating collections with at least one item [message #229474 is a reply to message #229464] Tue, 12 May 2009 08:41 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

I think that you could do it by this way :

- for at least one service : in ecore, you can specify the lower bound of
your element
- for initialing : in gmfmap, on your node mapping you can create a
feature seq initializer

another idea to have at least one service anytime : using validation

Hope it would help you.

Aurélien Pupier


Josip Maras wrote:


> Hi everybody,

> Is there an easy way to create the following functionality:

> I'm modeling components that have a collection of services. Is there a way
> to specify somewhere (in the gmfmap, gmfgraph, ecore, genmodel...) that
> this collection has to have at least one item (service) - so when i'm
> creating a component it automatically adds one service, and that in any
> time at least one service has to exisit??

> Thank you


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: Creating collections with at least one item [message #229485 is a reply to message #229474] Tue, 12 May 2009 08:46 Go to previous messageGo to next message
Josip Maras is currently offline Josip MarasFriend
Messages: 41
Registered: July 2009
Member
Thanks. I'll try it
Re: Creating collections with at least one item [message #229498 is a reply to message #229474] Tue, 12 May 2009 11:04 Go to previous messageGo to next message
Josip Maras is currently offline Josip MarasFriend
Messages: 41
Registered: July 2009
Member
Aurelien Pupier wrote:

> Hi,

> I think that you could do it by this way :

> - for at least one service : in ecore, you can specify the lower bound of
> your element
> - for initialing : in gmfmap, on your node mapping you can create a
> feature seq initializer

> another idea to have at least one service anytime : using validation

> Hope it would help you.

> Aurélien Pupier

Hi, sorry, but i wasn't able to create it with a feature seq initializer.
I've added a Feature Value Spec in the Feature Seq Initializer and i've
selected the services feature. Then i've added the Value Expression and in
it i've tried a lot of things (presumably wrong ones) as Body.

Could you share some tips on how would i add one new Service to the
component's services when the component is created.

Thanks
Re: Creating collections with at least one item [message #229511 is a reply to message #229498] Tue, 12 May 2009 11:20 Go to previous messageGo to next message
Peter Lang is currently offline Peter LangFriend
Messages: 153
Registered: July 2009
Senior Member
Hi,

The "Feature Value Spec" can be used to set an attribute of the element.

What you need is a "Reference New Element Spec" in your "Feature Seq
Initializer". Select your Service as Feature there.

Initializing your new Service if necessary should work too by adding
another "Feature Seq Initializer" to the "Reference New Element Spec".

Hope that helps...


> Hi, sorry, but i wasn't able to create it with a feature seq initializer.
> I've added a Feature Value Spec in the Feature Seq Initializer and i've
> selected the services feature. Then i've added the Value Expression and in
> it i've tried a lot of things (presumably wrong ones) as Body.
Re: Creating collections with at least one item [message #229526 is a reply to message #229511] Tue, 12 May 2009 11:49 Go to previous message
Josip Maras is currently offline Josip MarasFriend
Messages: 41
Registered: July 2009
Member
Thank you, i tried that also but i got the following validation error:
"The feature 'initializers' of Feature Seq Initializer<new Service()> with
0 values must have at least 1 values".

But if ignore this validation error i get the required functionality ->
thank you!

One more thing: how can i fix this error.

My gmf map is simple: I hava a component (Node Mapping). This Node Mapping
has a Feature Label, Child Reference, Compartment Mapping and a Feature
Seq Initalizer set to Component (has a Reference New Element Spec child
set to services and that Reference New Element Spec has a child Feature
seq initilizer set to Service).
I'm pasting my gmfmap nodes part:

<nodes>
<containmentFeature
href="component.ecore#//ComponentDiagram/components"/>
<ownedChild>
<domainMetaElement
href="component.ecore#//Component"/>
<domainInitializer
xsi:type="gmfmap:FeatureSeqInitializer">
<initializers
xsi:type="gmfmap:ReferenceNewElementSpec">
<feature
xsi:type="ecore:EReference"
href="component.ecore#//Component/services"/>
<newElementInitializers/>
</initializers>
</domainInitializer>
<labelMappings
xsi:type="gmfmap:FeatureLabelMapping">
<diagramLabel
href="component.gmfgraph#ComponentName"/>
<features
href="component.ecore#//Component/name"/>
</labelMappings>
<tool
xsi:type="gmftool:CreationTool"
href="component.gmftool#//@palette/@tools.0"/>
<diagramNode
href="component.gmfgraph#ComponentNode"/>
<children
compartment="//@nodes.0/@ownedChild/@compartments.0">
<containmentFeature
href="component.ecore#//Component/services"/>
<ownedChild>
<domainMetaElement
href="component.ecore#//Service"/>
<tool
xsi:type="gmftool:CreationTool"
href="component.gmftool#//@palette/@tools.1"/>
<diagramNode
href="component.gmfgraph#ServiceNode"/>
</ownedChild>
</children>
<compartments
children="//@nodes.0/@ownedChild/@children.0">
<compartment
href="component.gmfgraph#ServiceCompartment"/>
</compartments>
</ownedChild>
</nodes>


Thank you for everything!

Peter Lang wrote:

> Hi,

> The "Feature Value Spec" can be used to set an attribute of the element.

> What you need is a "Reference New Element Spec" in your "Feature Seq
> Initializer". Select your Service as Feature there.

> Initializing your new Service if necessary should work too by adding
> another "Feature Seq Initializer" to the "Reference New Element Spec".

> Hope that helps...
Previous Topic:GMF creates -1 coordinates
Next Topic:Opening diagrams when double-clicking Labels within Top Level Nodes (OpenDiagramEditPolicies)
Goto Forum:
  


Current Time: Mon Sep 23 15:39:26 GMT 2024

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

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

Back to the top