|
|
|
Re: [XText] Attaching a behavioral extension [message #49016 is a reply to message #46857] |
Sun, 07 June 2009 15:33 |
Cédric Vidal Messages: 101 Registered: July 2009 |
Senior Member |
|
|
Hi Sven,
Thanx for the correction. I'll try that as soon as I get the chance.
Regards,
Cédric
Sven Efftinge a écrit :
> As the editor usually is created by guice, there might be some component
> declaring a dependency on XtextEditor. You should change the
> configuration in the ui module instead of changing the contents of
> plugin.xml. We might inject the editor somewhere else.
>
> To do so add a binding like this:
>
> public class MyLanguageUiModule extends AbstractMyLanguageUiModule {
>
> public Class<? extends XtextEditor> bindEditor() {
> return MySpecialEditor.class;
> }
>
> ....
>
> Cheers,
> Sven
>
> Cédric Vidal schrieb:
>> Ok,
>>
>> I found out the following solution. I subclassed XtextEditor:
>>
>> public class MyXtextEditor extends XtextEditor {
>>
>> @Override
>> public void createPartControl(Composite parent) {
>> super.createPartControl(parent);
>> IXtextDocument document = getDocument();
>>
>> document.modify(new IUnitOfWork<Object, XtextResource>() {
>> @Override
>> public Object exec(XtextResource resource) throws Exception {
>> attachBehavior(resource);
>> return null;
>> }
>> });
>>
>> document.addModelListener(new IXtextModelListener() {
>> @Override
>> public void modelChanged(XtextResource resource) {
>> attachBehavior(resource);
>> }
>> });
>> }
>>
>> private void attachBehavior(XtextResource resource) {
>> // attach adaptor
>> }
>>
>> }
>>
>> and changed plugin.xml editor configuration to use mine instead of
>> default XtextEditor.
>>
>> So far it works for me.
>>
>> Kind regards,
>>
>> Cédric
>>
>> Cédric Vidal a écrit :
>>> Hi guys,
>>>
>>> I'm currently trying to add a behavioral extension implemented using
>>> a content adapter to a model managed by XText.
>>>
>>> I already managed to achieve it in an EMF.Edit generated editor and
>>> I'm looking around the TMF XText generated editor to find a place
>>> where to attach my adaptor.
>>>
>>> I would be most greatfull if you could point me to the right place in
>>> the generated code.
>>>
>>> Kind Regards,
>>>
>>> Cédric Vidal
>>>
>>> PS: I'm using TMF Xtext 0.7RC2 bundle from Itemis
>>> http://oaw.itemis.com/openarchitectureware/language=en/2837/ downloads
|
|
|
Powered by
FUDForum. Page generated in 0.03171 seconds