KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > tool > codegen > Main


1
2 /*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  * Paul Mahar
22  *
23  */

24 package org.enhydra.tool.codegen;
25
26 // ToolBox imports
27
import org.enhydra.tool.ToolBoxInfo;
28 import org.enhydra.tool.common.ResUtil;
29 import org.enhydra.tool.common.SwingUtil;
30
31 // Standard imports
32
import java.util.ResourceBundle JavaDoc;
33
34 //
35
public class Main {
36     static ResourceBundle JavaDoc res = ResourceBundle.getBundle("org.enhydra.tool.codegen.Res"); // nores
37
static private final String JavaDoc PARAM_DEBUG = "-debug"; // nores
38
static private final String JavaDoc PARAM_LIST = "-list"; // nores
39
static private final String JavaDoc PARAM_HELP = "-help"; // nores
40
/**
41      *
42      * Invoke CodeGen and process command line parameters.
43      * No arguments will default to opening the Swing based wizard.
44      *
45      * Basic command line options:
46      * <generator name> <generator specific options>
47      * Invoke generator with options
48      * -help <generator name>
49      * Show command line options for specified genertator.
50      * -help
51      * Show basic command line options
52      * -config [<enhydraHome>]
53      * Recreate the codegen.properties file with default
54      * generators and the specified enhydra home setting.
55      * -debug
56      * Turn the debug flag on.
57      * -verbose
58      * Turn the verbose flag on.
59      *
60      * Generator specific help will also display if required
61      * options are missing or invalid values are passed.
62      */

63     public static void main(String JavaDoc[] args) {
64         System.out.println("Kelp Application Wizard " +
65            ToolBoxInfo.getToolBoxVersion());
66         System.out.println(ToolBoxInfo.getCopyright());
67         for (int i = 0; i < args.length; i++) {
68             if (args[i].trim().equalsIgnoreCase(Main.PARAM_DEBUG)) {
69                 CodeGen.debug = true;
70                 if (args.length == 1) {
71                     args = new String JavaDoc[0];
72                 }
73                 break;
74             }
75         }
76         try {
77             if ((args.length != 2) && (args.length >= 1)
78                        && (args[0].length() > 0 && args[0].charAt(0) == '-')
79                        && (!args[0].equalsIgnoreCase(Main.PARAM_LIST))) {
80                 Main.showHelp();
81             } else {
82                 CodeGen codeGen;
83
84                 if (args.length < 1) {
85                     codeGen = new CodeGen(true);
86                     SwingUtil.setLookAndFeelToSystem();
87                     codeGen.invokeWizard(null);
88                 } else if ((args.length >= 2)
89                            && args[0].trim().equalsIgnoreCase(Main.PARAM_HELP)) {
90                     codeGen = new CodeGen();
91                     codeGen.showGeneratorOptionHelp(args[1]);
92                 } else if (args[0].trim().equalsIgnoreCase(Main.PARAM_LIST)) {
93                     codeGen = new CodeGen();
94                     codeGen.list();
95                 } else {
96                     codeGen = new CodeGen();
97                     codeGen.invokeGenerator(args);
98                 }
99             }
100         } catch (GeneratorException e) {
101             if (CodeGen.debug) {
102                 e.printStackTrace();
103             } else {
104                 System.out.println(e.getMessage());
105             }
106         }
107         System.exit(0);
108     }
109
110     /**
111      * Method declaration
112      *
113      */

114     private static void showHelp() {
115         System.out.println(new String JavaDoc());
116         System.out.println(res.getString("Usage01"));
117         System.out.println(res.getString("Usage02"));
118         System.out.println(res.getString("Usage03"));
119         System.out.println(new String JavaDoc());
120         System.out.println(res.getString("Usage04"));
121         System.out.println(new String JavaDoc());
122         System.out.println(res.getString("Usage05"));
123         System.out.println(res.getString("Usage06"));
124         System.out.println(res.getString("Usage07"));
125         System.out.println(res.getString("Usage08"));
126         System.out.println(ResUtil.format(res.getString("Usage09"), ToolBoxInfo.getPropertyFilename()));
127         System.out.println(res.getString("Usage10"));
128         System.out.println(res.getString("Usage11"));
129     }
130
131
132 }
Popular Tags