/*
* Enhydra Java Application Server Project
*
* The contents of this file are subject to the Enhydra Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License on
* the Enhydra web site ( http://www.enhydra.org/ ).
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific terms governing rights and limitations
* under the License.
*
* The Initial Developer of the Enhydra Application Server is Lutris
* Technologies, Inc. The Enhydra Application Server and portions created
* by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
* All Rights Reserved.
*
* Contributor(s):
* Paul Mahar
*
*/
package org.enhydra.tool.codegen;
// ToolBox imports
import org.enhydra.tool.ToolBoxInfo;
// Standard imports
import java.io.File;
import java.util.StringTokenizer;
import java.util.ResourceBundle;
/**
* This class instantiates a set of default GeneratorOptions during
* initialization. The default options include: project, d, package
* copywrite, copywritefile, make, script, j2ee and overwrite.
*/
abstract public class ProjectOptionSet extends OptionSet implements Constants {
/**
* Property name for the project name option.
*/
public static final String PROJECT = "project"; // nores
/**
* Property name for the destintation option
*/
public static final String ROOT = "root"; // nores
/**
* Property name for the package option.
*/
public static final String PACKAGE = "package"; // nores
/**
* Property name for the copyright option.
*/
public static final String COPYRIGHT = "copyright"; // nores
/**
* Property name for the copyright file option.
*/
public static final String COPYRIGHTFILE = "copyrightfile"; // nores
/**
* Property name for the script option.
*/
public static final String NOCLI = "nocli"; // nores
/**
* Property name for the overwrite option.
*/
public static final String OVERWRITE = "overwrite"; // nores
//
private final String DEF_PROJECT = "untitled1"; // nores
private final String DEF_PACKAGE = "untitled"; // nores
/**
* Create a default set of options. This is a convenience class that
* can be used as the basis for building custom option set within
* a generator.
*/
public ProjectOptionSet() {
try {
add (new GeneratorOption (PROJECT, DEF_PROJECT,
res.getString ("PROJECT"),
res.getString ("PROJECT_Instruct"),
true, true));
add (new GeneratorOption (PACKAGE, DEF_PACKAGE,
res.getString ("PACKAGE"),
res.getString ("PACKAGE_Instruct"),
true, true));
add (new GeneratorOption (ROOT, getDefaultRoot (),
res.getString ("ROOT"),
res.getString ("ROOT_Instruct"),
true, true));
add (new GeneratorOption (COPYRIGHT, new String (),
res.getString ("STRING"),
res.getString ("STRING instruct"),
false, true));
add (new GeneratorOption (COPYRIGHTFILE, new String (),
res.getString ("FILE"),
res.getString ("FILE_instruct"),
false, true));
add (new GeneratorOption (NOCLI, false,
res.getString ("Suppress_CLI"),
true));
add (new GeneratorOption (OVERWRITE, false,
res.getString ("OK_to_overwrite"),
false));
} catch (GeneratorException e) {
e.printStackTrace ();
}
}
/**
* Method declaration
*
*
* @return
*/
private String getDefaultRoot () {
final String DIR_ENHYDRA_APPS = "myProjects"; // nores
StringBuffer buf = new StringBuffer ();
String userHome = new String ();
File file = null;
userHome = System.getProperties ().getProperty (SYS_USER_HOME);
buf.append (userHome);
buf.append (File.separator);
buf.append (DIR_ENHYDRA_APPS);
file = new File (buf.toString ());
if (!file.exists ()) {
file.mkdirs ();
}
if (!file.isDirectory ()) {
buf.setLength (0);
buf.append (userHome);
}
return buf.toString ();
}
}
|