开发者

How to include an Xtext generated editor on an Eclipse property page?

I'm trying to include a textual editor for my DSL, which I generated using Xtext, on a property page within an Eclipse RCP application.

For example, I start with a simple Xtext grammar:

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 '!';

and generate the textual editor from it. Then, I create a property page wihtin a new plug-in project:

package com.example.plugin.propertypage.properties;

import or开发者_StackOverflow中文版g.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;
    }

}

The (empty) property page will be shown in the properties dialog for every instance of 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>

How can I make the generated editor appear on the property page?

During my research, I had a look at the Xtext GMF Integration Example which is shipped with Xtext and referenced in the Xtext User Guide. This example shows how to create a popup Xtext editor. This example may contain some valuable information, but I was not able to figure out how to adapt this for my purposes.

Any help would be appreciated. Thanks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜