XSWT is an XML-based GUI-description language for SWT. The XSWT engine uses Java reflection to actually construct a user interface, so it is automatically compatible with current and future SWT controls. An eclipse editor for XSWT files is included.
现在开发的产品中用户界面也是用XML定义的,但是界面定义很不灵活。XSWT网站上介绍说XSWT是和SWT元素一一对应的,应该有很大的灵活性。
xswt的下载地址是:http://xswt.sourceforge.net/cgi-bin/xswt/download
也可以使用Eclipse的Update Manager从http://xswt.sourceforge.net/updates 在线更新。
下载了一个试用了一下,总体感觉还好。但是好像项目还没有开发完,文档没有。而且官方网站上说支持Groovy脚本语言的功能好像还没有提供。期待中。。。。
以下是一个我写的示例代码,演示了在XSWT中如何处理事件。
/*******************************************************************************
* $Header$
* $Revision$
* $Date$
*
*==============================================================================
*
* Copyright (c) 2001-2004 XYZ Technologies, Ltd.
* All rights reserved.
*
* Created on 2004-11-27
*******************************************************************************/
import java.io.InputStream;
import java.util.Map;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import com.swtworkbench.community.xswt.XSWT;
/**
* TODO此处填写 class 信息
*
* @author Yanfei (mailto:yanfei@hotmail.com)
*/
/*
* 修改历史
* $Log$
*/
public class XSWTDialogTest {
/**
*
*/
public XSWTDialogTest() {
super();
}
public static void main(String[] args) throws Exception{
Display display = new Display();
final Shell shell = new Shell(display);
shell.setLayout(new GridLayout());
InputStream in = XSWTDialogTest.class.getResource("JavaEditorPreferencePage.xswt").openStream();
Map controls = XSWT.create(shell, in);
Button button1 = (Button) controls.get("button1");
button1.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
MessageDialog.openInformation(shell, "Message", "button1 selected");
}






