龙盟编程博客 | 无障碍搜索 | 云盘搜索神器
快速搜索
主页 > 软件开发 > JAVA开发 >

eclipse新特性--JFace Data Binding

时间:2009-12-23 15:42来源:未知 作者:admin 点击:
分享到:
现在eclipse M4已经出来了,其中一个最cool的非UI特性就是JFace data binding framework. 在M5发布的时候JFace binding小组会结束data binding API的开发. 到现在为止,大量我们可以用到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和数据结构之间的传输:)
  


  
精彩图集

赞助商链接