How to make a user-defined operation available to all my templates? [message #843784] |
Fri, 13 April 2012 07:09  |
Eclipse User |
|
|
|
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 07:12] by Moderator
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.08768 seconds