Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Customizing EMF.Edit's ItemProviders
Customizing EMF.Edit's ItemProviders [message #494609] Sun, 01 November 2009 05:50 Go to next message
John S. is currently offline John S.Friend
Messages: 22
Registered: October 2009
Junior Member
Hello,

I would like to insert a new line (my own class to store the notificication in a separated model) into the notifyChanged(Notification notification) method of all the ItemProviders. I was told about customizing templates and use this for code generation, but I am not sure what part of the EMF I should use and exactly what type of template I am supposed to write to do these new line insertions. I tried to find some tutorials and examples but I could not find anything related to this. So if someone did something like this or know how to, please drop a line on this.

Best Regards,
John
Re: Customizing EMF.Edit's ItemProviders [message #494615 is a reply to message #494609] Sun, 01 November 2009 08:46 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.
--------------010603040707020002020300
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

John,

Have a look at
< http://wiki.eclipse.org/index.php/EMF/FAQ#What_are_Dynamic_T emplates.3F>

http://wiki.eclipse.org/index.php/EMF/FAQ#What_are_Dynamic_T emplates.3F


John S. wrote:
> Hello,
>
> I would like to insert a new line (my own class to store the
> notificication in a separated model) into the
> notifyChanged(Notification notification) method of all the ItemProviders.
You could just just an EContentAdapter added to your resource set to
handle this separately.
> I was told about customizing templates and use this for code
> generation, but I am not sure what part of the EMF I should use and
> exactly what type of template I am supposed to write to do these new
> line insertions.
You'd modify the ItemProvider.javajet.
> I tried to find some tutorials and examples but I could not find
> anything related to this. So if someone did something like this or
> know how to, please drop a line on this.
>
> Best Regards,
> John

--------------010603040707020002020300
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 7bit

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
John,<br>
<br>
Have a look at<a
href=" http://wiki.eclipse.org/index.php/EMF/FAQ#What_are_Dynamic_T emplates.3F"><br>
</a>
<blockquote><a
href=" http://wiki.eclipse.org/index.php/EMF/FAQ#What_are_Dynamic_T emplates.3F"> http://wiki.eclipse.org/index.php/EMF/FAQ#What_are_Dynamic_T emplates.3F</a><br>
</blockquote>
<br>
John S. wrote:
<blockquote cite="mid:hcj7ik$mjm$1@build.eclipse.org" type="cite">Hello,
<br>
<br>
I would like to insert a new line (my own class to store the
notificication in a separated model) into the
notifyChanged(Notification notification) method of all the
ItemProviders. </blockquote>
You could just just an EContentAdapter added to your resource set to
handle this separately.<br>
<blockquote cite="mid:hcj7ik$mjm$1@build.eclipse.org" type="cite">I was
told about customizing templates and use this for code generation, but
I am not sure what part of the EMF I should use and exactly what type
of template I am supposed to write to do these new line insertions.</blockquote>
You'd modify the ItemProvider.javajet.<br>
<blockquote cite="mid:hcj7ik$mjm$1@build.eclipse.org" type="cite"> I
tried to find some tutorials and examples but I could not find anything
related to this. So if someone did something like this or know how to,
please drop a line on this.
<br>
<br>
Best Regards,
<br>
John </blockquote>
</body>
</html>

--------------010603040707020002020300--


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Customizing EMF.Edit's ItemProviders [message #494714 is a reply to message #494609] Mon, 02 November 2009 10:27 Go to previous message
Dirk Hoffmann is currently offline Dirk HoffmannFriend
Messages: 163
Registered: July 2009
Senior Member
Hi John,

maybe you could insert your own class into the item provider type
hierarchy and override the notifyChange method there. See Ed's reply to
the "Alternate base class for item providers" post from a few days ago.
I suppose changing the templates should only be a last resort.

If you decide to modify the templates backup your source code. If you
happen to generate syntactically wrong code because of some error in
your template you may not be able to repair all the source files by
simply fixing the template as the generator requires the exising source
files to be syntactically correct. That's because it parses the source
files so that is can perform the merge step.

I found exceptions thrown by the generator fairly useless. Look at the
source code of the automatically generated ".JETEmitters" project if the
mdified templates produce correct generator code.

When you invoke the code generator form the .genmodel file don't start
with the root of your model. Instead pick a single model element
(ideally one where you didn't modify the generated source code) and
generate the source code just for this one. If things go wrong you can
simply remove the generated file, fix the template and try again.

Regards,
Dirk

John S. schrieb:
> Hello,
>
> I would like to insert a new line (my own class to store the
> notificication in a separated model) into the notifyChanged(Notification
> notification) method of all the ItemProviders. I was told about
> customizing templates and use this for code generation, but I am not
> sure what part of the EMF I should use and exactly what type of template
> I am supposed to write to do these new line insertions. I tried to find
> some tutorials and examples but I could not find anything related to
> this. So if someone did something like this or know how to, please drop
> a line on this.
>
> Best Regards,
> John
Previous Topic:Alternate base class for item providers
Next Topic:Cross references and Ecore model persistence
Goto Forum:
  


Current Time: Thu Apr 25 13:48:30 GMT 2024

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

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

Back to the top