有没有人在 IViewPart 中完全实现 XText 编辑器

发布于 2024-11-17 01:28:50 字数 256 浏览 4 评论 0原文

基本上我需要在 IViewPart 中实现完整的 XText 编辑器。我的大部分工作都是基于XText Forms Integration项目。不幸的是,这不是 XText 编辑器上的完整实现,我想知道是否有人知道更好的起点......甚至完整的实现:-)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

月棠 2024-11-24 01:28:50

从 2.2 开始就有可能(请参阅此线程)。
这段代码对我有用:

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);

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);
归属感 2024-11-24 01:28:50

我有同样的问题,我只是找到这个项目: http:// /xrepl.org/

他们创建了一个自定义控制台命令,所以我认为这离我们需要的更近了一步......:)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文