Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » How to auto generate the value for an attribute
How to auto generate the value for an attribute [message #51099] Tue, 19 September 2006 13:20 Go to next message
Eclipse UserFriend
Originally posted by: john.watson.yahoo.com

Hi,

I want to auto-generate the value for attribute "name" as type_number,
where:
type is the type (class) of the widget
nummber is auto incrementing number
It should work as most of the popular IDEs that generates a value for name.
For example: If I have tho types of widgets - Label and Button:
Label_1
Label_2
Label_3
....
Button_1
Button_2
Button_3
...


I was thinking to use adapters but I don't know how to persist the data
and I want to make it very extensible - if in yhe future I add new widget
to use the already made code customizations.

Any help is appreciated.

I asked the same in EMF group (I was it's EMF issue, but it seems I was
wrong) because the advice that I get from Ed Merks (to specialize the
generated collectNewChildDescriptors) - doesn't help - the method was
never called. And it's seems to me it's GMF issue...

Regards
Re: How to auto generate the value for an attribute [message #52349 is a reply to message #51099] Wed, 20 September 2006 17:19 Go to previous message
Artem Tikhomirov is currently offline Artem TikhomirovFriend
Messages: 222
Registered: July 2009
Senior Member
Not sure how this relates to GMF, nevertheless, you could do this in a
number of ways, with easiest being overriding Label#getName() to return
eClass().getName() + "_" + numberingScheme(). If you really need to persist
this, I'd follow Ed's advice and take a look at collectNewChildDescriptors
of LabelItemProvider and ButtonLabelProvider - just provide initialized
(i.e. with proper name set) instance as a second argument of
createChildParameter() call.

To use same logic for all elements you'll need to modify
ItemProvider.javajet template

Artem

"John Watson" <john.watson@yahoo.com> wrote in message
news:0470a500cd012d60a7bf5d9fd26bfd89$1@www.eclipse.org...
> Hi,
>
> I want to auto-generate the value for attribute "name" as type_number,
> where:
> type is the type (class) of the widget
> nummber is auto incrementing number
> It should work as most of the popular IDEs that generates a value for
> name.
> For example: If I have tho types of widgets - Label and Button:
> Label_1
> Label_2
> Label_3
> ...
> Button_1
> Button_2
> Button_3
> ..
>
>
> I was thinking to use adapters but I don't know how to persist the data
> and I want to make it very extensible - if in yhe future I add new widget
> to use the already made code customizations.
>
> Any help is appreciated.
>
> I asked the same in EMF group (I was it's EMF issue, but it seems I was
> wrong) because the advice that I get from Ed Merks (to specialize the
> generated collectNewChildDescriptors) - doesn't help - the method was
> never called. And it's seems to me it's GMF issue...
>
> Regards
>
Previous Topic:injecting layout information to an ecore model to generate a diagram
Next Topic:"Duplicate" item in popup-menu
Goto Forum:
  


Current Time: Fri Nov 08 23:11:47 GMT 2024

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

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

Back to the top