如何在 Eclipse 属性页上包含 Xtext 生成的编辑器?
我试图在 Eclipse RCP 应用程序的属性页上包含一个 DSL 的文本编辑器,它是我使用 Xtext 生成的。
例如,我从一个简单的 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 GMF 集成示例,该示例随 Xtext 和 Xtext 用户指南中引用。此示例演示如何创建弹出 Xtext 编辑器。这个例子可能包含一些有价值的信息,但我无法弄清楚如何适应我的目的。
任何帮助将不胜感激。谢谢。
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 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;
}
}
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论