Has anybody fully implemented an XText editor in an IViewPart

前端 未结 2 1069
感动是毒
感动是毒 2021-01-05 07:42

Basically I need to implement a full XText editor in an IViewPart. I have most of it working based on the XText Forms Integration project. Unfortunately, this i

相关标签:
2条回答
  • 2021-01-05 08:22

    I have the same problem, and I just find this project: http://xrepl.org/

    They create a custom console command, so I think is a step closer to what we need... :)

    0 讨论(0)
  • 2021-01-05 08:32

    It is possible since 2.2 (see this thread). This code worked for me:

    IEditedResourceProvider resourceProvider = new IEditedResourceProvider() {
    
            @Override
            public XtextResource createResource() {
                try {
                    MyDslQueryStandaloneSetup.doSetup();
                    ResourceSet resourceSet = new ResourceSetImpl();
                    Resource resource = resourceSet.createResource(URI.createURI("somefile.MyDsl"));
    
                    return (XtextResource) resource;
                } catch (Exception e) {
                    return null;
                }
            }
        };
    
        MyDslActivator activator = MyDslActivator.getInstance();
        Injector injector = activator
                .getInjector(MyDslActivator.QUERYNAME);
        EmbeddedEditorFactory factory = injector.getInstance(EmbeddedEditorFactory.class);
        handle = factory.newEditor(resourceProvider).withParent(
                parent);
    
        // keep the partialEditor as instance var to read / write the edited text
        partialEditor = handle.createPartialEditor(true);
    
    0 讨论(0)
提交回复
热议问题