How to auto generate the value for an attribute [message #51099] |
Tue, 19 September 2006 09:20  |
Eclipse User |
|
|
|
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 13:19  |
Eclipse User |
|
|
|
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
>
|
|
|
Powered by
FUDForum. Page generated in 0.03669 seconds