中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 编程语言 > Java > 用户界面
Develop with DUIL
作者:未知 时间:2005-07-24 21:17 出处:JR 责编:chinaitpower
              摘要:Develop with DUIL
 

1.       What is DUIL?


DUIL (Dynamic User Interface logic) is an innovative java UI solution provided by UILOGIC that can generate the UI from the XML-based UI definition file, it abstract the UI logic from native java code, that avoid the chaos of mixing the GUI and java code together and enable you build your GUI independently with the GUI action process code, it is like the role of struts that divide the Java process code from the JSP& HTML code.

Furthermore, DUIL provide a mechanism for the interactive-support of components, that will enable you build relationship among components easier than the traditional way.

 

2.       Install and configuration


2.1.         Get the package



You can get the latest version of DUIL package from UILOGIC's website: http://www.uilogic.com/modules/mydownloads/singlefile.php?cid=1&lid=4

2.2.       Extract the zip package



 

There are the following files in the package

duil_cfg.xml      the duil configuration file

WHATSNEW     the history of version revises.

duilstart.jar      the starter of DUIL.

 

 

There are following directory in the package.

demo   the source code of DUIL sample.

lib        all of the DUIL jar files are put here.

docs     the DUIL's java doc reference.

 

3.       config DUIL



 

You can set the work parameters of DUIL by modify the duil_cfg.xml, 

The following options can be configured:

 

1.     Add user-defined component's wrapper

2.     Specify the log output level.

3.     Porive the codec for DUIL, the codec (coder and decoder) is used to convert the value between java data type and string type, such as string-color coder can convert #ff0000 to the java.awt.Color type.

 

The log's level attribute is used to control the log information; you can set it to 1(DEBUG) when you are designing your UI.

 

A simple DUIL config file:

 

  1. <DUIL>
  2.     <elements ver="1.0">
  3.         <element name="YourButtonTag" class="your component wrapper class"/>
  4.     </elements>
  5.     <log level="1"/>
  6. </DUIL>


 

4.       How does the DUIL works?


DUIL can generate the JAVA GUI base on the DUIL definition XML and the DUIL Renders, The Renders is used to provide a chance for the developers to control and modify the GUI attributes and actions.



 

There are the following renders can be used

  •          IORender:  it is used to load/save UI component's value from/to external.


  •          ListenerRender: it is used to provide the Listener for specific component.


  •          ResultRender: it is used to provide the method to calculate the result value for specific component.

  •          Resource:   it is used to specify the resource base for i18n support.

  •          ValueRender: it is used to provide the User Interface for specific component.



  • All of the Renders are put in the CompositeRenders (CompositeRenders is a wrapper class for contains the Renders), that will be pass to DUIL after developer finish to set the Renders information, You can assign the Renders information for the specific component with the setXXXRender provided by CompositeRenders, there are three prototype of setXXXRender: 


  •          Prototype1:


    1. public void setXXXRender (String dlgId, String comId, AbstractCom.XXXRender render)


    Set the specific dialog's specific component.

  •          Prototype2:


    1. public void setXXXRender (String dlgId, AbstractCom.XXXRender render)

    Set the specific dialog? renders. 

  •          Prototype3:


    1. public void setXXXRender (AbstractCom.XXXRender render)

    Set the global renders.

    The XXX means the specific Render information; the following is the case of IORender. 
     
    1. public void setIORender (String dlgId, String comId, AbstractCom.IORender render)
    2. public void setIORender (String dlgId, AbstractCom.IORender render)
    3. public void setIORender (AbstractCom.IORender render)



    5.       Develop with DUIL


    Hi, we have get overview of DUIL, now let's develop a sample with DUIL.


    Design targert:

    1.       In this sample we need to design a simple texteditor with character counter

    2.       The outer data can be read to the editor in action be performed. 

     
    the following is the DUIL XML definition and its java code.
    The DUIL xml definition in demoAction.xml:

     
    1. <JPanel id="demoAction" layout="=new BorderLayout()" text="display" preferredSize="300,200">
    2. <JMenuBar name="menubar" layoutContrains="NORTH">
    3. <JMenu text="file" name="file">
    4. <JMenuItem id="open" text="open" name="open" actionListener="readData"/> 
    5. </JMenu>
    6. </JMenuBar>
    7. <JScrollPane layoutContrains="CENTER"><JTextArea name="editor" text="" /></JScrollPane>
    8. <JPanel layoutContrains="SOUTH"
    9. <JLabel text="length:"/>
    10. <JLabel text="=$(root.editor$document.length)"/>
    11. <JButton text="read data" actionListener="readData"/>
    12. <JButton text="exit" actionListener="readFile" action="CLOSE_WINDOW"/>
    13. </JPanel>
    14. </JPanel>


     

     

    Java code in demoAction.java

     
    1. package org.lx.demo;
    2. import java.io.*;
    3. import java.awt.event.*;
    4. import javax.swing.*;
    5. import org.lx.gui.*;
    6. import org.lx.gui.dui.*;
    7. public class demoAction{
    8. public static class readDataAction extends AbstractDUIListener implements
    9. ActionListener{
    10. public void actionPerformed(ActionEvent e) {
    11. AbstractCom root = getComponent().getRoot();
    12. AbstractCom editor = root.findChildRecursively("name""editor");
    13. if (editor != null) {
    14. JTextArea ta = (JTextArea) editor.getComponent();
    15. ta.setText("your info read from data source");
    16. }
    17. }
    18. }
    19. public static void main(String[] argv) {
    20. ComFactory factroy = ComFactory.createInstance();
    21. CompositeRenders renders = new CompositeRenders();
    22. DefaultListenerRender listenerRender = new DefaultListenerRender();
    23. //install your action to swing component.
    24. listenerRender.addListener("readData"new readDataAction());
    25. renders.setListenerRender(listenerRender);
    26. Reader reader = new InputStreamReader(
    27. demoAction.class.getResourceAsStream(
    28. "/org/lx/demo/demoAction.xml"));
    29. factroy.showDialog(reader, "id""demoAction", renders, nulltrue);
    30. System.exit(0);
    31. }
    32. }

     

  •          Set the DUIL compile and running environment


  • Enter the $DUIL_HOME/bin and then execute the following batch file.

    For windows:

    1. duil_env.bat


    For linux/solaris:

    1. duil_env.sh


  •          Compile it:


  • For windows:

    1. javac -classpath %CLASSPATH% orglxdemodemoAction.java


    For linux/solaris:

    1. javac -classpath $CLASSPATH orglxdemodemoAction.java

     
  •          Run the sample

  • For windows:

    1. java -classpath %CLASSPATH% org.lx.demo.demoAction


    For linux/solaris:

    1. java -classpath $CLASSPATH org.lx.demo.demoAction


    the following is the result after run this sample.




    Yeah, It is so easy to develop java GUI with DUIL.

     
    关闭本页
     
    首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
    Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有