📄 jsourcecodewizard.java
字号:
/**
* IgaLib -> wizard
* Copyright (C) 2001 Tosiki IGA , IgaLib project member
* (http://homepage2.nifty.com/igat/igapyon/index.html)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
package jp.ne.nifty.iga.tosiki.wizard;
import jp.ne.nifty.iga.tosiki.wizard.wiz.*;
import java.io.*;
import java.util.*;
/**
* JSourceCodeWizard 偺僄儞僩儕億僀儞僩偱偡丅
* 偙偺僋儔僗偼XML掕媊僼傽僀儖(JSourceCodeWizard*.xml)偺忣曬傪尦偵Java僜乕僗僐乕僪傪帺摦惗惉偟傑偡丅<BR>
* 椺偊偽僋儔僗偺僼傿乕儖僪偍傛傃傾僋僙僗儊僜僢僪偺惗惉傪峴偄傑偡丅<BR>
* <BR>
* [Generaton Gap僷僞乕儞] 帺摦惗惉偝傟偨僋儔僗偦傟帺恎偵偼 嬌椡曄峏偼壛偊側偄偱偔偩偝偄丅
* 曄峏傪壛偊傞偲偟偨傜 僋儔僗傪攈惗偝偣偰攈惗愭僋儔僗偵曄峏傪壛偊偰偔偩偝偄丅
* (寢忛峗偝傑偵偦偺巪偺僣僢僐儈傪捀偒傑偟偨)<BR>
* <BR>
* XML掕媊僼傽僀儖偺挊嶌幰偑 帺摦惗惉偝傟偨Java僜乕僗僐乕僪偺挊嶌幰偵側傝傑偡丅<BR>
* <BR>
* <H3>摦嶌曽朄</H3>
* <OL>
* <LI>JSourceCodeWizard*.xml僼傽僀儖偵 帺摦惗惉偟偨偄僋儔僗偺巇條傪婰弎偟偰壓偝偄丅
* <LI>JSourceCodeWizard傪幚峴偟偰壓偝偄丅
* <LI>帺摦惗惉偝傟偨僋儔僗傪 偛棗壓偝偄丅
* </OL>
* <P><STRONG>./sample/JSourceCodeWizardMember.xml</STRONG> 偑擖椡僼傽僀儖偱 <STRONG>./sample/DataMember.java</STRONG> 偑幚峴寢壥惗惉偝傟偨Java僜乕僗僐乕僪偱偡丅</P>
* <H3>DB娭楢偺摦嶌妋擣娐嫬 (婎杮揑僠僃僢僋偺傒幚巤)</H3>
* <UL>
* <LI>Oracle 8.1.7.1
* <LI>MS SQLServer 2000
* <LI>MS Access JET (MDAC 2.5)
* </UL>
* <BR>
*
* @author Tosiki IGA
*/
public class JSourceCodeWizard
extends JSourceCodeWizardAbstract
{
public static final String VERSION="0.1.6";
private static final boolean IS_DEBUG=false;
/**
* 僇儗儞僩僨傿儗僋僩儕埲壓偺 JSourceCodeWizard*.xml僼傽僀儖傪慡偰張棟偟傑偡丅<BR>
* 偙偺僋儔僗偺僄儞僩儕億僀儞僩<BR>
*
* @param String[] args 柍帇偟偰偄傑偡丅
*/
public static final void main(String[] args)
{
prompt();
try{
listDirectory(".");
}catch(IOException ex){
System.out.println(ex.toString());
ex.printStackTrace();
}
}
/**
* prompt product informations.
*/
public static final void prompt()
{
System.out.println("JSourceCodeWizard "+VERSION);
System.out.println("Copyright (C) 2001 Tosiki IGA , IgaLib project member");
System.out.println("This library is free software, and you are welcome to redistribute it under certain conditions.");
System.out.println(" WWW : http://sourceforge.net/projects/jscwiz/");
}
private static void listDirectory(String strDirectory)
throws IOException
{
//if(IS_DEBUG)System.out.println(" processing directory:"+strDirectory);
File fileCheckDirectory=new File(strDirectory);
File[] fileList=fileCheckDirectory.listFiles();
if(fileList==null)
{
return;
}
for(int index=0;index<fileList.length;index++)
{
File fileCheckFile=fileList[index];
if(fileCheckFile.isDirectory()==true)
{
String strNextDirectory=strDirectory+"/";
if(strNextDirectory.equals("./"))
{
strNextDirectory="";
}
strNextDirectory+=fileCheckFile.getName();
listDirectory(strNextDirectory);
}
else
{
if(fileCheckFile.getName().startsWith("JSourceCodeWizard")
&& fileCheckFile.getName().endsWith(".xml"))
{
JSourceCodeWizard accessGenerator=new JSourceCodeWizard();
System.out.println(" processing:"+strDirectory+"/"+fileCheckFile.getName());
accessGenerator.setCurrentDirectory(strDirectory+"/");
accessGenerator.parseXml(new File(strDirectory+"/"+fileCheckFile.getName()));
JSourceCodeWizardProcessor.write(accessGenerator,accessGenerator.getChannel(),accessGenerator.getField(),strDirectory+"/");
}
}
}
}
/**
* (幚尡揑) DB僗僉乕儅掕媊XML僼傽僀儖傪彂偒弌偟傑偡丅
*
* @param String strXmlDefFile 彂偒崬傒偨偄掕媊僼傽僀儖
*/
public static void writeDefFile(String strXmlDefFile)
throws IOException
{
JSourceCodeWizard wrk_wizard=new JSourceCodeWizard();
JSourceCodeWizardChannel wrk_channel=new JSourceCodeWizardChannel();
wrk_channel.setPrefix("Data");
wrk_channel.setName("Sample");
wrk_channel.setTitle("僒儞僾儖掕媊");
wrk_channel.setDescription("僒儞僾儖梡偺僂傿僓乕僪掕媊XML僼傽僀儖偱偡");
wrk_channel.getFunction().setUseSql(true);
wrk_channel.getIndex().add("MojiKoumoku1,MojiKoumoku2");
wrk_wizard.setChannel(wrk_channel);
{
JSourceCodeWizardField dataItem=new JSourceCodeWizardField();
dataItem.setName("MojiKoumoku1");
dataItem.setTitle("1暥帤崁栚1");
dataItem.setType("char");
dataItem.setLength(1);
wrk_wizard.getField().add(dataItem);
dataItem=new JSourceCodeWizardField();
dataItem.setName("MojiKoumoku2");
dataItem.setTitle("暥帤崁栚2");
dataItem.setType("String");
dataItem.setLength(20);
wrk_wizard.getField().add(dataItem);
dataItem=new JSourceCodeWizardField();
dataItem.setName("MojiKoumokuKotekote");
dataItem.setTitle("暥帤崁栚偙偰偙偰巜掕");
dataItem.setType("String");
dataItem.setDefault("\"柍巜掕\"");
dataItem.setLength(20);
dataItem.setPrimary(true);
dataItem.setNotNull(true);
wrk_wizard.getField().add(dataItem);
}
wrk_wizard.serializeXml(new File(strXmlDefFile));
}
/**
* 梌偊傜傟偨Node傪僷乕僗偟偰僼傿乕儖僪偵戙擖偡傞嵺偺屻張棟
*
* @param Node nodeLook 擖椡僲乕僪
*/
public void parse(org.w3c.dom.Node nodeLook)
{
super.parse(nodeLook);
JSourceCodeWizardFunction function=getChannel().getFunction();
if(function.isUseServlet())
{
// Servlet 偲 Swing 偲偼摨帪愝掕偱偒傑偣傫丅
function.setUseSwing(false);
}
for(int index=0;index<getField().size();index++)
{
JSourceCodeWizardField field=(JSourceCodeWizardField)getField().get(index);
field.setChannel(getChannel());
//System.out.println(field.getDisplayString()+"偵"+getChannel().getDisplayString()+"傪僙僢僩");
field.processInitialize(this);
}
}
private ResourceBundle bundle;
public void initResourceBundle(String strLocale)
{
try{
bundle=ResourceBundle.getBundle("jp.ne.nifty.iga.tosiki.wizard.jscwiz",new java.util.Locale(strLocale,"",""));
}catch(MissingResourceException ex){
throw new Error("Error: missing resource bundle: initResourceBundle: "+ex.getClassName());
}
}
public final String getString(String key)
{
return getString(key, null);
}
public final String getString(String key,Object[] args)
{
if(bundle==null)
{
//initResourceBundle("en");
initResourceBundle(getChannel().getLanguage());
}
try{
String msg=bundle.getString(key);
if(args==null)
{
return msg;
}
java.text.MessageFormat format=new java.text.MessageFormat(msg);
return format.format(args);
}catch(MissingResourceException ex){
throw new Error("Error: missing resource for ("+key+"): "+ex.getClassName());
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -