|
|
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:
- <DUIL>
-
- <elements ver="1.0">
-
- <element name="YourButtonTag" class="your component wrapper class"/>
-
- </elements>
-
-
-
- <log level="1"/>
-
- </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:
- public void setXXXRender (String dlgId, String comId, AbstractCom.XXXRender render)
Set the specific dialog's specific component.
Prototype2:
- public void setXXXRender (String dlgId, AbstractCom.XXXRender render)
Set the specific dialog? renders.
Prototype3:
- public void setXXXRender (AbstractCom.XXXRender render)
Set the global renders.
The XXX means the specific Render information; the following is the case of IORender.
- public void setIORender (String dlgId, String comId, AbstractCom.IORender render)
- public void setIORender (String dlgId, AbstractCom.IORender render)
- 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:
-
- <JPanel id="demoAction" layout="=new BorderLayout()" text="display" preferredSize="300,200">
-
- <JMenuBar name="menubar" layoutContrains="NORTH">
-
- <JMenu text="file" name="file">
-
- <JMenuItem id="open" text="open" name="open" actionListener="readData"/>
-
- </JMenu>
-
- </JMenuBar>
-
- <JScrollPane layoutContrains="CENTER"><JTextArea name="editor" text="" /></JScrollPane>
-
- <JPanel layoutContrains="SOUTH">
-
- <JLabel text="length:"/>
-
- <JLabel text="=$(root.editor$document.length)"/>
-
- <JButton text="read data" actionListener="readData"/>
-
- <JButton text="exit" actionListener="readFile" action="CLOSE_WINDOW"/>
-
- </JPanel>
-
- </JPanel>
Java code in demoAction.java
-
- package org.lx.demo;
-
-
-
- import java.io.*;
-
- import java.awt.event.*;
-
- import javax.swing.*;
-
-
-
- import org.lx.gui.*;
-
- import org.lx.gui.dui.*;
-
-
-
- public class demoAction{
-
- public static class readDataAction extends AbstractDUIListener implements
-
- ActionListener{
-
- public void actionPerformed(ActionEvent e) {
-
- AbstractCom root = getComponent().getRoot();
-
- AbstractCom editor = root.findChildRecursively("name", "editor");
-
- if (editor != null) {
-
- JTextArea ta = (JTextArea) editor.getComponent();
-
- ta.setText("your info read from data source");
-
- }
-
- }
-
- }
-
-
-
- public static void main(String[] argv) {
-
- ComFactory factroy = ComFactory.createInstance();
-
- CompositeRenders renders = new CompositeRenders();
-
- DefaultListenerRender listenerRender = new DefaultListenerRender();
-
- //install your action to swing component.
-
- listenerRender.addListener("readData", new readDataAction());
-
- renders.setListenerRender(listenerRender);
-
- Reader reader = new InputStreamReader(
-
- demoAction.class.getResourceAsStream(
-
- "/org/lx/demo/demoAction.xml"));
-
- factroy.showDialog(reader, "id", "demoAction", renders, null, true);
-
- System.exit(0);
-
- }
-
- }
Set the DUIL compile and running environment
Enter the $DUIL_HOME/bin and then execute the following batch file.
For windows:
For linux/solaris:
Compile it:
For windows:
- javac -classpath %CLASSPATH% orglxdemodemoAction.java
For linux/solaris:
- javac -classpath $CLASSPATH orglxdemodemoAction.java
Run the sample For windows:
- java -classpath %CLASSPATH% org.lx.demo.demoAction
For linux/solaris:
- 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.
|
|