Has anybody fully implemented an XText editor in an IViewPart
Asked Answered
P

2

7

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 is not a full implementation on an XText editor, and I wondered if anybody are aware of better starting points.. or even complete implementations :-)

Polar answered 23/6, 2011 at 20:59 Comment(4)
What parts are missing to make the Xtext Froms Integration a full implementation?Lowering
@Sebastian (I'm on vacation right now, but of the top of my head..) Line numbers, integration with CMSPolar
Any news on that front? Is there a full implementation available somewhere? ThanksDispart
I have added some of the missing parts to my implementation. Though, my guess is that with Xtext 2, I probably have the re-implement a larger part of the code again.Polar
D
5

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);
Dispart answered 11/1, 2012 at 10:2 Comment(0)
U
0

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... :)

Unravel answered 19/9, 2011 at 13:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.