📄 octopusgeneratorthread.java
字号:
/*
LoaderGenerator - tool for generated xml, sql and doml file needed for Octopus.
Copyright (C) 2003 Together
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 org.webdocwf.util.loader.wizard;
import javax.swing.JTextArea;
import org.webdocwf.util.loader.BufferOctopusClass;
import org.webdocwf.util.loader.LoaderException;
import org.webdocwf.util.loader.generator.LoaderGenerator;
/**
*
* ExecThread class execute thread which control LoaderGenerator application
* @author Radoslav Dutina
* @version 1.0
*/
public class OctopusGeneratorThread extends Thread {
private OctopusGeneratorData initData;
// TraceDialog td = null; //trace dialog of this Thread
private JTextArea td;
private String errorMsg = null;
private OctopusGenerator generator;
/**
* Construct object ExecThread with associated parameters.
* @param traceArea
* @param initData is object which contain input parameters of wizard application
* @param errorMsg is error message
*/
public OctopusGeneratorThread(OctopusGeneratorData initData, String errorMsg, JTextArea traceArea) {
this.initData = initData;
this.errorMsg = errorMsg;
td = traceArea;
// desktop.add(td);
}
/**
* This method append line in to trace area
* @param s is value which to be set
*/
public void appendLine(String s) {
td.append(s);
td.getCaret().setDot(td.getText().length() - 1);
}
/**
* Run the thread
*/
public void run() {
td.setVisible(true);
// td.setDefaultFocus();
if (errorMsg != null) {
appendLine(errorMsg + "\n");
// td.setButtonEnabled();
// td.setButtonName("Open");
} else {
try {
OctopusGenerator generator = new OctopusGenerator(initData);
String[] process = generator.generateAll();
GeneratorThread generatorThread = null;
if (process.length != 0) {
BufferOctopusClass.getInstance();
BufferOctopusClass.getInstance().setUsed();
generatorThread = new GeneratorThread(process);
generatorThread.start();
while (generatorThread.isAlive()) {
String value = BufferOctopusClass.getInstance().readFromBuffer();
if (value.indexOf("***TogetherGroop***") == -1)
appendLine(value + "\n");
else
break;
}
// td.setButtonEnabled();
} else {
appendLine("Some error is occur!" + "\n");
}
// td.setButtonName("Open");
// setTitle("Building OctopusGenerator Application (Done)");
generator = null;
} catch (Exception e) {
appendLine(e.getMessage());
try {
Thread.sleep(100);
} catch (Exception ex) {
appendLine(ex.getMessage());
}
// td.setButtonEnabled();
// td.setTitle("Building OctopusGenerator Application (ERROR)");
// td.setButtonName("Open");
BufferOctopusClass.getInstance().writeToBuffer("***TogetherGroop***");
BufferOctopusClass.getInstance().empty();
System.out.println(e.getMessage());
}
BufferOctopusClass.getInstance().empty();
}
}
/**
* This class creates new thread
*/
class GeneratorThread extends Thread {
private String[] args;
/**
* Initialise the thread
* @param args represents the arguments
*/
public GeneratorThread(String[] args) {
this.args = args;
}
/**
* Run the thread
*/
public void run() {
String generatorOutput = null;
String valueMode = null;
String domlUrl = null;
String packageName = null;
String sourceType = null;
String sourceDataBase = null;
String sourceDriverName = null;
String sourceUser = null;
String sourcePassword = null;
String targetType = null;
String targetDataBase = null;
String targetDriverName = null;
String targetUser = null;
String targetPassword = null;
//logging
String logDirName = null;
String logFileName = null;
String logMode = null;
//Output mode
//main
String generateXml = null;
String generateDoml = null;
//for generate sql
String generateDropTableStmt = null;
String generateDropIntegrityStmt = null;
String generateCreateTableStmt = null;
String generateCreatePKStmt = null;
String generateCreateFKStmt = null;
String generateCreateIndexStmt = null;
//for genrate sql for all vendors
String generateSqlForAllVendors = null;
//optimized modes
String fullMode = null;
String includeTableList = null;
String confJarStructure = null;
if (args.length > 8 && args.length < 53) {
for (int i = 0; i < args.length - 1; i = i + 1) {
if (args[i].equalsIgnoreCase("-st"))
sourceType = args[++i];
else if (args[i].equalsIgnoreCase("-sdb"))
sourceDataBase = args[++i];
else if (args[i].equalsIgnoreCase("-m"))
valueMode = args[++i];
else if (args[i].equalsIgnoreCase("-o"))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -