服务热线:13616026886

技术文档 欢迎使用技术文档,我们为你提供从新手到专业开发者的所有资源,你也可以通过它日益精进

位置:首页 > 技术文档 > JAVA > 新手入门 > 基础入门 > 查看文档

eclipse新特性--jface data binding

  现在eclipse m4已经出来了,其中一个最cool的非ui特性就是jface data binding framework.
在m5发布的时候jface binding小组会结束data binding api的开发.

  到现在为止,大量我们可以用到jface data binding的例子在test包里。

  关于jface data binding framework,在下面的网址可以找到具体的文档.

http://wiki.eclipse.org/index.php/jface_data_binding

http://wiki.eclipse.org/index.php/jface_data_binding_scenarios

  可以通过cvs很方便的下载到test包:
  打开cvs repositories view,选new-->repository location
  在窗口里依次填入:

host:  dev.eclipse.org
repository path: /home/eclipse
user:   anonymous
password:空白
connection type: pserver

展开head...
“org.eclipse.jface.databinding”
“org.eclipse.jface.tests.databinding”
就是代码和测试代码了.

  可以先运行检查配置是否正确:

   1. 展开 org.eclipse.jface.tests.databinding
   2. 展开 the org.eclipse.jface.tests.databinding package
   3. 右击 “bindingtestsuite.java” 并选 “run as | swt application”

  如果终端出现一些....然后是测试多少个,具体log等,那就没问题了。

  关于jface data binding framework:

  一般的ui都需要自己保存数据,然后向每个text,combo写监听器,然后返回到主程序中,非常繁琐,但是现在因为ui和data的绑定,简单地让人吃惊....

  以我的财务管理程序举例来说,现在我只需要写完数据结构和图形界面,然后在代码里加上下面这样的代码:

idatabindingcontext dbc = databinding.createcontext(composite);
dbc.bind(departmentcombo, new property(depatments, "department"), null);
dbc.bind(projectcombo, new property(depatments, "project"), null);
dbc.bind(datetext, new property(depatments, "date), null);
dbc.bind(waretext, new property(depatments, "ware"), null);
dbc.bind(pricetext, new property(depatments, "price"), null);

eclipse新特性--jface data binding


  我不需要自己再很多的代码,只需要加上两个方法:
dialog.getdepartments()
dialog.setdepartments(...)
就完全搞定数据在ui和数据结构之间的传输:)

扫描关注微信公众号