1

Xtext を使用して生成した DSL 用のテキスト エディターを、Eclipse RCP アプリケーション内のプロパティ ページに含めようとしています。

たとえば、単純な Xtext 文法から始めます。

grammar org.xtext.example.mydsl.MyDsl with org.eclipse.xtext.common.Terminals

generate myDsl "http://www.xtext.org/example/mydsl/MyDsl"

Model:
    greetings+=Greeting*;

Greeting:
    'Hello' name=ID '!';

そこからテキストエディタを生成します。次に、新しいプラグイン プロジェクトでプロパティ ページを作成します。

package com.example.plugin.propertypage.properties;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.dialogs.PropertyPage;

public class SamplePropertyPage extends PropertyPage {

    public SamplePropertyPage() {
        super();
    }

    protected Control createContents(Composite parent) {
        Composite composite = new Composite(parent, SWT.NONE);
        return composite;
    }

    protected void performDefaults() {
        super.performDefaults();
    }

    public boolean performOk() {
        return true;
    }

}

(空の) プロパティ ページは、org.eclipse.core.resources.IFile のすべてのインスタンスのプロパティ ダイアログに表示されます。

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>

   <extension
         point="org.eclipse.ui.propertyPages">
      <page
            name="Sample Page"
            nameFilter="*.*"
            class="com.example.plugin.propertypage.properties.SamplePropertyPage"
            id="com.example.plugin.propertypage.properties.samplePropertyPage">
         <enabledWhen>
            <instanceof
                  value="org.eclipse.core.resources.IFile">
            </instanceof>
         </enabledWhen>
      </page>
   </extension>

</plugin>

生成されたエディターをプロパティ ページに表示するにはどうすればよいですか?

調査中に、Xtext に同梱されており、Xtext User Guideで参照されている Xtext GMF Integration Example を調べました。この例では、ポップアップ Xtext エディターを作成する方法を示します。この例にはいくつかの貴重な情報が含まれている可能性がありますが、これを目的に適合させる方法を理解できませんでした。

どんな助けでも大歓迎です。ありがとう。

4

0 に答える 0