Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » How to make a user-defined operation available to all my templates?
How to make a user-defined operation available to all my templates? [message #843784] Fri, 13 April 2012 11:09 Go to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
I have several user-defined operations that I use in multiple EGL templates. So I would like to have one central location that defines these operations, instead of a copy in each template. (For obvious reasons like fixing bugs in one place)

I found out about OperationContributor, so I created my own:
public class TestOperation extends OperationContributor
{
    @Override
    public boolean contributesTo(Object target) {
        return truel;
    }

    public String getName() {
        return "MyTestName";
    }
}


And added it to my factory:
EglFileGeneratingTemplateFactory factory new EglFileGeneratingTemplateFactory()
OperationContributorRegistry operationContributorRegistry = ((EglContext) factory.getContext()).getOperationContributorRegistry();
operationContributorRegistry.add(new TestOperaion());


But it does not work...
After debugging, I found the EglModule.execute(Formatter postprocessor). It copies the context (containing the methodContibutor field) to the preprocessorModule context:
context.copyInto(preprocessorModule.getContext());

But, the methodContributor field is not copied! So the original one is used, containing only the default OperationContributor objects that are instantiated in the OperationContributorRegistry constructor.

My questions are:

  • Did I use the correct method to define new (default) operations?
  • If so, whether I found a bug that needs reporting or not?
  • Should this be documented in the Epsilon book, as it seems nice to define global available user-defined operations

[Updated on: Fri, 13 April 2012 11:12]

Report message to a moderator

Re: How to make a user-defined operation available to all my templates? [message #843789 is a reply to message #843784] Fri, 13 April 2012 11:15 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Maarten,

Would it perhaps be an option to define your operations using EOL, store them in a file called e.g. util.eol and then import them from EGL using

import "util.eol";

?

The code below looks right at first glance but I'll have a closer look at it to see why it doesn't work as expected.

Cheers,
Dimitris
Re: How to make a user-defined operation available to all my templates? [message #843794 is a reply to message #843789] Fri, 13 April 2012 11:20 Go to previous messageGo to next message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
That would certainly be a solution, although I have several Eclipse plugins that use EGL, so I must somehow make the EOL file accessible for each plugin. But I'll take a look at it.

As far as I can see, the EglContext.copyInto() method is just not copying the context.getOperationContributorRegistry() field. But I do not know whether that is deliberate or not.

[Updated on: Fri, 13 April 2012 11:20]

Report message to a moderator

Re: How to make a user-defined operation available to all my templates? [message #843804 is a reply to message #843794] Fri, 13 April 2012 11:29 Go to previous messageGo to next message
Dimitris Kolovos is currently offline Dimitris KolovosFriend
Messages: 2163
Registered: July 2009
Location: York, UK
Senior Member

Hi Maarten,

Import also accepts full plugin-based URIs so sharing code between different plugins shouldn't be a problem. You're right regarding copyInto(). If you really need this I'll try to implement a quick fix for it otherwise I'm inclined to leave this until I'm back from holiday so that we can discuss with the rest of the team how we could get rid of copying contexts altogether (as hinted by the comment at line 170 of EglModule Smile )

Cheers,
Dimitris
Re: How to make a user-defined operation available to all my templates? [message #843815 is a reply to message #843804] Fri, 13 April 2012 11:44 Go to previous message
Maarten Bezemer is currently offline Maarten BezemerFriend
Messages: 117
Registered: February 2012
Senior Member
Hello Dimitris,

Dimitris Kolovos

Import also accepts full plugin-based URIs so sharing code between different plugins shouldn't be a problem.

I added a variable containing the path to that location, but import only accepts a "STRING". But directly using a plugin-based URI works nice!
Even though the editor shows this error: File platform:/plugin/my.plugin.id/templates/operations.eol not found
(I'll report this in the bug tracker)

Dimitris Kolovos

You're right regarding copyInto(). If you really need this I'll try to implement a quick fix for it otherwise I'm inclined to leave this until I'm back from holiday so that we can discuss with the rest of the team how we could get rid of copying contexts altogether (as hinted by the comment at line 170 of EglModule Smile )


Yes, I saw that hint Smile
It does not have a high priority, as using an EOL file is working fine. So (for now) i'll use that.

Enjoy your holiday!

Cheers,
Maarten
Previous Topic:[EOL] How are models resolved in eol?
Next Topic:Re running Eugenia Example- help required
Goto Forum:
  


Current Time: Sat Apr 20 08:07:19 GMT 2024

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

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

Back to the top