Project VN2664QNR : Export to QSL from Questionnaire Editor

From Catglobe Wiki
Revision as of 05:42, 27 April 2009 by Catglobe (talk | contribs) (Making an customize save file dialog)
Jump to: navigation, search

What's purpose of this project ?

The main goal of this project is to allow user to export the structure of a questionnaire template into a QSL script .

Feature design

The feature design could be found here : \\catproc\Share\CatGlobe Teams\Questionnaire\Projects\Version 5.8\VN2644QNR - Export to QSL from Questionnaire Editor

Implement GUI

In this project , we need to write a new collapse-able container and a container that can hold a collection of collapse-able container because the editor only use Swing ( standard Java's API library for providing a graphical user interface ) and this library does not have an explicit collapse-able container .

Class diagram

Container.JPG

How to use an instance of collapse-able container

All sub panels of the container initialized once on constructor . The parameter of constructor contains an Array of sub panel's caption and an Array of sub panel . In order get the collapse-able container itself , use method getComponent() TO add a collapse-able container to another

Making an customize save file dialog

Currently we have an class for customize save file dialog but this one has not been supported our customize file filter yet so i modified it a little bit so that it supports

Making the a file filter

The default "All file(*.*)" filter is in inconvenient when using so it will be overwrite . Another useful of it is that we can have text resource fully supported .

Make QSL file filter

 1 public class QSLFilter extends FileFilter {
 2 
 3     /* (non-Javadoc)
 4      * @see javax.swing.filechooser.FileFilter#accept(java.io.File)
 5      */
 6     @Override
 7     public boolean accept(File arg0) {
 8         // TODO Auto-generated method stub
 9         if(arg0.isDirectory())
10             return true;
11         else 
12             return (getExtension(arg0).equals("qsl"));
13     }
14 
15     /* (non-Javadoc)
16      * @see javax.swing.filechooser.FileFilter#getDescription()
17      */
18     @Override
19     public String getDescription() {
20         
21         // TODO Auto-generated method stub
22         return "QSL file(*.qsl)";
23     }
24     public static String getExtension(File f) {
25         String ext = null;
26         String s = f.getName();
27         int i = s.lastIndexOf('.');
28 
29         if (i > 0 &&  i < s.length() - 1) {
30             ext = s.substring(i+1).toLowerCase();
31         }
32         return ext;
33     }

Export questionnaire template to QSL script

To implement export task , we use Visitor pattern .

Class diagram