1、UI重新优化

master
wangbing 6 years ago
parent 5d411169b3
commit 68ac6c917f

@ -10,13 +10,13 @@ import javafx.scene.control.TableView;
import javafx.scene.control.TreeView; import javafx.scene.control.TreeView;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import javafx.stage.DirectoryChooser; import javafx.stage.DirectoryChooser;
import javafx.stage.FileChooser;
import javafx.stage.Stage; import javafx.stage.Stage;
import xyz.wbsite.dbtool.javafx.JavaFxApplication; import xyz.wbsite.dbtool.javafx.JavaFxApplication;
import xyz.wbsite.dbtool.javafx.enumeration.DataBase; import xyz.wbsite.dbtool.javafx.enumeration.DataBase;
import xyz.wbsite.dbtool.javafx.listener.GenerateOptionListener; import xyz.wbsite.dbtool.javafx.listener.GenerateOptionListener;
import xyz.wbsite.dbtool.javafx.manger.ManagerFactory; import xyz.wbsite.dbtool.javafx.manger.ManagerFactory;
import xyz.wbsite.dbtool.javafx.manger.ProjectManager; import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
import xyz.wbsite.dbtool.javafx.po.Project;
import xyz.wbsite.dbtool.javafx.tool.Dialog; import xyz.wbsite.dbtool.javafx.tool.Dialog;
import java.io.File; import java.io.File;
@ -104,62 +104,66 @@ public class MainController {
} }
@FXML @FXML
public void showFileChooser(ActionEvent actionEvent) { public void modelOpen(ActionEvent actionEvent) {
DirectoryChooser directoryChooser = new DirectoryChooser(); FileChooser fileChooser = new FileChooser();
fileChooser.setTitle("选择模型文件");
fileChooser.setInitialDirectory(dBmanger.getPath());
fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("模型文件", "*.xml", "*.XML"));
Stage stage = new Stage(); Stage stage = new Stage();
File file = directoryChooser.showDialog(stage); File file = fileChooser.showOpenDialog(stage);
if (file != null && file.exists()) { if (file != null && file.exists()) {
dBmanger.setPath(file.getAbsolutePath()); dBmanger.invalidate(file);//初始化模型树 - 到内容
dBmanger.invalidate(); main.loadingProjectTree();//加载模型树 - 到组件
main.loadingProjectTree(); main.loadingProject();
System.out.println(file.getAbsolutePath());
} }
} }
public boolean doSave(ActionEvent actionEvent) { @FXML
public void modelSave(ActionEvent actionEvent) {
if (dBmanger.getPath() == null || "".equals(dBmanger.getPath())) { if (dBmanger.getPath() == null || "".equals(dBmanger.getPath())) {
DirectoryChooser directoryChooser = new DirectoryChooser(); DirectoryChooser directoryChooser = new DirectoryChooser();
Stage stage = new Stage(); Stage stage = new Stage();
File file = directoryChooser.showDialog(stage); File file = directoryChooser.showDialog(stage);
if (file == null) { if (file == null) {
System.err.println("请选择目录!");
return false; } else {
dBmanger.setPath(file);
System.out.println(file.getAbsolutePath());
} }
dBmanger.setPath(file.getAbsolutePath());
System.out.println(file.getAbsolutePath());
} }
dBmanger.save(); dBmanger.save();
System.out.println("自动保存成功");
return true;
} }
@FXML @FXML
public void save(ActionEvent actionEvent) { public void modelSaveAs(ActionEvent actionEvent) {
doSave(actionEvent);
}
@FXML
public void saveAs(ActionEvent actionEvent) {
DirectoryChooser directoryChooser = new DirectoryChooser(); DirectoryChooser directoryChooser = new DirectoryChooser();
Stage stage = new Stage(); Stage stage = new Stage();
File file = directoryChooser.showDialog(stage); File file = directoryChooser.showDialog(stage);
if (file != null) { if (file != null) {
dBmanger.setPath(file.getAbsolutePath()); dBmanger.save(file);
dBmanger.save();
} }
} }
@FXML @FXML
public void clear(ActionEvent actionEvent) { public void modelCreate(ActionEvent actionEvent) {
Dialog.showConfirmDialog("确认清空所有信息?", new EventHandler() { dBmanger.modelCreate();
main.loadingProjectTree();
main.loadingProject();
}
@FXML
public void modelDelete(ActionEvent actionEvent) {
Dialog.showConfirmDialog("确认删除当前模型?", new EventHandler() {
@Override @Override
public void handle(Event event) { public void handle(Event event) {
dBmanger.clear(); dBmanger.delete();
dBmanger.invalidate();
main.loadingProjectTree(); main.loadingProjectTree();
main.loadingProject(); main.loadingProject();
} }
@ -167,18 +171,16 @@ public class MainController {
} }
@FXML @FXML
public void showConnectInfo(ActionEvent actionEvent) { public void modelImport(ActionEvent actionEvent) {
Dialog.showDBConnectInput(); Dialog.showDBConnectInput();
} }
@FXML @FXML
public void generate(ActionEvent actionEvent) { public void modelGenerate(ActionEvent actionEvent) {
if (!this.doSave(null)) { this.modelSave(null);
return;
}
if (dBmanger.doCheck()) { if (dBmanger.doCheck()) {
DirectoryChooser directoryChooser = new DirectoryChooser(); DirectoryChooser directoryChooser = new DirectoryChooser();
directoryChooser.setInitialDirectory(new File(dBmanger.getPath())); directoryChooser.setInitialDirectory(dBmanger.getPath());
Stage stage = new Stage(); Stage stage = new Stage();
File file = directoryChooser.showDialog(stage); File file = directoryChooser.showDialog(stage);
@ -204,6 +206,7 @@ public class MainController {
public void generateApi(ActionEvent actionEvent) { public void generateApi(ActionEvent actionEvent) {
Dialog.showApi(); Dialog.showApi();
} }
@FXML @FXML
public void generateAndroid(ActionEvent actionEvent) { public void generateAndroid(ActionEvent actionEvent) {
Dialog.showAndroid(); Dialog.showAndroid();

@ -201,7 +201,7 @@ public class SdkInfoController {
if (moduleFile.exists()) { if (moduleFile.exists()) {
data.clear(); data.clear();
File reqs = new File(moduleFile.getAbsolutePath() + File.separator + "req"); File reqs = new File(moduleFile,"req");
if (!reqs.exists()) { if (!reqs.exists()) {
return; return;

@ -8,6 +8,7 @@ import xyz.wbsite.dbtool.javafx.po.*;
import xyz.wbsite.dbtool.javafx.tool.Dialog; import xyz.wbsite.dbtool.javafx.tool.Dialog;
import java.io.File; import java.io.File;
import java.io.FilenameFilter;
import java.sql.*; import java.sql.*;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -18,7 +19,7 @@ public class ProjectManager {
public static boolean isUpdate = false; public static boolean isUpdate = false;
private XmlManager xmlService; private XmlManager xmlService;
public static AbstractDBmapper dBmapper; public static AbstractDBmapper dBmapper;
public static String path; public static File path;
private Project project = new Project(); private Project project = new Project();
public ProjectManager() { public ProjectManager() {
@ -26,15 +27,23 @@ public class ProjectManager {
try { try {
ApplicationHome home = new ApplicationHome(getClass()); ApplicationHome home = new ApplicationHome(getClass());
File jarFile = home.getSource(); File jarFile = home.getSource();
this.path = jarFile.getParent() + File.separator + "project"; this.path = new File(jarFile.getParent(), "project");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
this.path = System.getProperty("user.home") + File.separator + "project"; this.path = new File(System.getProperty("user.home"), "project");
} }
invalidate(); invalidate();
} }
public void clear() { public static File getPath() {
return path;
}
public static void setPath(File path) {
ProjectManager.path = path;
}
public void modelCreate() {
project = new Project(); project = new Project();
} }
@ -163,17 +172,6 @@ public class ProjectManager {
return project; return project;
} }
public String getPath() {
return path;
}
public void setPath(String path) {
if (path != null && !path.equals(this.path)) {
this.path = path;
invalidate();
}
}
public boolean doCheck() { public boolean doCheck() {
if (project.getProjectName() == null || "".equals(project.getProjectName())) { if (project.getProjectName() == null || "".equals(project.getProjectName())) {
Dialog.showConfirmDialog("没有填写项目名!"); Dialog.showConfirmDialog("没有填写项目名!");
@ -200,31 +198,18 @@ public class ProjectManager {
/** /**
* *
*/ */
public void save() { public void save(File file) {
if (path != null) { xmlService.saveAs(file, project);
File file = new File(path);
if (!file.exists()) {
file.mkdirs();
}
xmlService.save(path, project);
}
} }
private void clear(File f) { public void save() {
if (f.isDirectory()) { xmlService.saveAs(path, project);
File[] files = f.listFiles(); }
for (File file : files) {
if (file.isDirectory()) {
clear(file);
boolean delete = file.delete();
System.out.println("删除" + file.getName() + (delete ? "成功" : "失败"));
} else {
boolean delete = file.delete();
System.out.println("删除" + file.getName() + (delete ? "成功" : "失败")); public void delete() {
} File file = new File(path, project.getProjectName() + ".xml");
} if (file.exists()) {
file.delete();
} }
} }
@ -290,10 +275,10 @@ public class ProjectManager {
@Override @Override
public void run() { public void run() {
boolean mkdirs = sdk.mkdirs(); boolean mkdirs = sdk.mkdirs();
File reqList = new File(module.getAbsolutePath() + File.separator + "req"); File reqList = new File(module,"req");
File rspList = new File(module.getAbsolutePath() + File.separator + "rsp"); File rspList = new File(module,"rsp");
File entList = new File(module.getAbsolutePath() + File.separator + "ent"); File entList = new File(module, "ent");
File enumsList = new File(module.getAbsolutePath() + File.separator + "enums"); File enumsList = new File(module, "enums");
SDKCallable sdkCallable = new SDKCallable(sdk, reqList, rspList, entList, enumsList, apis); SDKCallable sdkCallable = new SDKCallable(sdk, reqList, rspList, entList, enumsList, apis);
Future submit = service.submit(sdkCallable); Future submit = service.submit(sdkCallable);
try { try {
@ -362,8 +347,28 @@ public class ProjectManager {
}.start(); }.start();
} }
/**
*
*/
public void invalidate() { public void invalidate() {
project = xmlService.inflate(path); File[] files = path.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.endsWith(".xml") || name.endsWith(".XML");
}
});
if (files.length == 0) {
project = xmlService.inflate(null);
} else {
project = xmlService.inflate(files[0]);
}
}
/**
*
*/
public void invalidate(File xmlFile) {
project = xmlService.inflate(xmlFile);
} }
public static boolean testConnect(Map<String, String> properties) { public static boolean testConnect(Map<String, String> properties) {

@ -17,141 +17,128 @@ import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory; import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource; import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult; import javax.xml.transform.stream.StreamResult;
import java.io.*; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
public class XmlManager { public class XmlManager {
public Project inflate(String path) { public Project inflate(File xmlFile) {
Project project = new Project(); Project project = new Project();
if (path == null || "".equals(path)) { if (xmlFile == null) {
return project; return project;
} } else if (!xmlFile.exists()) {
File file = new File(path); System.err.println("文件不存在!");
if (!file.exists()) {
System.err.println("目录不存在!");
} else { } else {
File dbFile = new File(path); //开始解析
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
if (!dbFile.exists()) { FileInputStream inputStream = null;
dbFile.mkdir(); try {
} else { inputStream = new FileInputStream(xmlFile);
File[] files = dbFile.listFiles(new FilenameFilter() { Document document = documentBuilderFactory.newDocumentBuilder().parse(inputStream);
public boolean accept(File dir, String name) {
return name.endsWith(".xml") || name.endsWith(".XML");
}
});
//开始解析
DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
for (File xml : files) {
FileInputStream inputStream = null;
try {
inputStream = new FileInputStream(xml);
Document document = documentBuilderFactory.newDocumentBuilder().parse(inputStream);
Element dbElement = document.getDocumentElement(); Element dbElement = document.getDocumentElement();
if ("project".endsWith(dbElement.getNodeName())) { if ("project".endsWith(dbElement.getNodeName())) {
System.out.println("发现项目:" + xml.getName()); System.out.println("加载模型[" + xmlFile.getName() + "]");
NodeList projectName = dbElement.getElementsByTagName("projectName"); NodeList projectName = dbElement.getElementsByTagName("projectName");
if (projectName.getLength() == 1) { if (projectName.getLength() == 1) {
project.setProjectName(projectName.item(0).getTextContent()); project.setProjectName(projectName.item(0).getTextContent());
} }
NodeList projectBasePackage = dbElement.getElementsByTagName("projectBasePackage"); NodeList projectBasePackage = dbElement.getElementsByTagName("projectBasePackage");
if (projectBasePackage.getLength() == 1) { if (projectBasePackage.getLength() == 1) {
project.setProjectBasePackage(projectBasePackage.item(0).getTextContent()); project.setProjectBasePackage(projectBasePackage.item(0).getTextContent());
} }
NodeList projectAuthor = dbElement.getElementsByTagName("projectAuthor"); NodeList projectAuthor = dbElement.getElementsByTagName("projectAuthor");
if (projectAuthor.getLength() == 1) { if (projectAuthor.getLength() == 1) {
project.setProjectAuthor(projectAuthor.item(0).getTextContent()); project.setProjectAuthor(projectAuthor.item(0).getTextContent());
} }
NodeList modules = dbElement.getElementsByTagName("module"); NodeList modules = dbElement.getElementsByTagName("module");
if (modules.getLength() > 0) { if (modules.getLength() > 0) {
for (int i = 0; i < modules.getLength(); i++) { for (int i = 0; i < modules.getLength(); i++) {
Module module = new Module(); Module module = new Module();
Element moduleElement = (Element) modules.item(i); Element moduleElement = (Element) modules.item(i);
NodeList moduleName = moduleElement.getElementsByTagName("moduleName"); NodeList moduleName = moduleElement.getElementsByTagName("moduleName");
if (moduleName.getLength() == 1) { if (moduleName.getLength() == 1) {
module.setModuleName(moduleName.item(0).getTextContent()); module.setModuleName(moduleName.item(0).getTextContent());
} }
NodeList moduleComment = moduleElement.getElementsByTagName("moduleComment"); NodeList moduleComment = moduleElement.getElementsByTagName("moduleComment");
if (moduleComment.getLength() == 1) { if (moduleComment.getLength() == 1) {
module.setModuleComment(moduleComment.item(0).getTextContent()); module.setModuleComment(moduleComment.item(0).getTextContent());
} }
NodeList modulePrefix = moduleElement.getElementsByTagName("modulePrefix"); NodeList modulePrefix = moduleElement.getElementsByTagName("modulePrefix");
if (modulePrefix.getLength() == 1) { if (modulePrefix.getLength() == 1) {
module.setModulePrefix(modulePrefix.item(0).getTextContent()); module.setModulePrefix(modulePrefix.item(0).getTextContent());
} }
NodeList hasSysFields = moduleElement.getElementsByTagName("hasSysFields"); NodeList hasSysFields = moduleElement.getElementsByTagName("hasSysFields");
if (hasSysFields.getLength() == 1) { if (hasSysFields.getLength() == 1) {
module.setHasSysFields(Boolean.parseBoolean(hasSysFields.item(0).getTextContent())); module.setHasSysFields(Boolean.parseBoolean(hasSysFields.item(0).getTextContent()));
} }
NodeList tables = moduleElement.getElementsByTagName("table"); NodeList tables = moduleElement.getElementsByTagName("table");
if (tables.getLength() > 0) { if (tables.getLength() > 0) {
for (int j = 0; j < tables.getLength(); j++) { for (int j = 0; j < tables.getLength(); j++) {
Element tableElement = (Element) tables.item(j); Element tableElement = (Element) tables.item(j);
Table table = new Table(); Table table = new Table();
table.setdBhandle(module); table.setdBhandle(module);
table.setTableName(tableElement.getAttribute("tableName")); table.setTableName(tableElement.getAttribute("tableName"));
table.setTableComment(tableElement.getAttribute("tableComment")); table.setTableComment(tableElement.getAttribute("tableComment"));
table.setCreate(Boolean.parseBoolean(tableElement.getAttribute("create"))); table.setCreate(Boolean.parseBoolean(tableElement.getAttribute("create")));
table.setDelete(Boolean.parseBoolean(tableElement.getAttribute("delete"))); table.setDelete(Boolean.parseBoolean(tableElement.getAttribute("delete")));
table.setUpdate(Boolean.parseBoolean(tableElement.getAttribute("update"))); table.setUpdate(Boolean.parseBoolean(tableElement.getAttribute("update")));
table.setFind(Boolean.parseBoolean(tableElement.getAttribute("find"))); table.setFind(Boolean.parseBoolean(tableElement.getAttribute("find")));
table.setGet(Boolean.parseBoolean(tableElement.getAttribute("get"))); table.setGet(Boolean.parseBoolean(tableElement.getAttribute("get")));
table.setSearch(Boolean.parseBoolean(tableElement.getAttribute("search"))); table.setSearch(Boolean.parseBoolean(tableElement.getAttribute("search")));
table.setGetAll(Boolean.parseBoolean(tableElement.getAttribute("getAll"))); table.setGetAll(Boolean.parseBoolean(tableElement.getAttribute("getAll")));
NodeList fields = tableElement.getElementsByTagName("field"); NodeList fields = tableElement.getElementsByTagName("field");
if (fields.getLength() > 0) { if (fields.getLength() > 0) {
for (int k = 0; k < fields.getLength(); k++) { for (int k = 0; k < fields.getLength(); k++) {
Element fieldElement = (Element) fields.item(k); Element fieldElement = (Element) fields.item(k);
Field field = new Field(); Field field = new Field();
field.setFieldName(fieldElement.getAttribute("fieldName")); field.setFieldName(fieldElement.getAttribute("fieldName"));
field.setFieldType(FieldType.parse(fieldElement.getAttribute("fieldType"))); field.setFieldType(FieldType.parse(fieldElement.getAttribute("fieldType")));
field.setFieldLength(Integer.parseInt(fieldElement.getAttribute("fieldLength"))); field.setFieldLength(Integer.parseInt(fieldElement.getAttribute("fieldLength")));
field.setFieldComment(fieldElement.getAttribute("fieldComment")); field.setFieldComment(fieldElement.getAttribute("fieldComment"));
field.setDefaultValue(fieldElement.getAttribute("defaultValue")); field.setDefaultValue(fieldElement.getAttribute("defaultValue"));
field.setIsSystem(Boolean.parseBoolean(fieldElement.getAttribute("IsSystem"))); field.setIsSystem(Boolean.parseBoolean(fieldElement.getAttribute("IsSystem")));
field.setIsMust(Boolean.parseBoolean(fieldElement.getAttribute("isMust"))); field.setIsMust(Boolean.parseBoolean(fieldElement.getAttribute("isMust")));
field.setIsPrimaryKey(Boolean.parseBoolean(fieldElement.getAttribute("isPrimaryKey"))); field.setIsPrimaryKey(Boolean.parseBoolean(fieldElement.getAttribute("isPrimaryKey")));
field.setIsQuery(Boolean.parseBoolean(fieldElement.getAttribute("isQuery"))); field.setIsQuery(Boolean.parseBoolean(fieldElement.getAttribute("isQuery")));
field.setIsSearch(Boolean.parseBoolean(fieldElement.getAttribute("isSearch"))); field.setIsSearch(Boolean.parseBoolean(fieldElement.getAttribute("isSearch")));
table.putField(field); table.putField(field);
}
}
module.putTable(table);
} }
} }
project.putModule(module); module.putTable(table);
} }
} }
System.out.println("数据初始化成功..."); project.putModule(module);
return project;
} }
} catch (Exception e) { }
System.out.println("文件:'" + xml.getName() + "'解析失败!请检查语法是否正确!"); System.out.println("模型初始化成功...");
return project;
}
} catch (Exception e) {
System.out.println("文件:'" + xmlFile.getName() + "'解析失败!请检查语法是否正确!");
e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} }
} }
} }
@ -159,7 +146,7 @@ public class XmlManager {
return project; return project;
} }
public boolean saveAs(String path, Project project) { public boolean saveAs(File path, Project project) {
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder; DocumentBuilder builder;
//生成DOM模型 //生成DOM模型
@ -257,16 +244,16 @@ public class XmlManager {
t.setOutputProperty(OutputKeys.INDENT, "yes"); t.setOutputProperty(OutputKeys.INDENT, "yes");
t.setOutputProperty(OutputKeys.METHOD, "xml"); t.setOutputProperty(OutputKeys.METHOD, "xml");
File dbFile = new File(path); if (!path.exists()) {
if (!dbFile.exists()) { path.mkdirs();
dbFile.mkdirs();
} }
File file = new File(dbFile.getAbsolutePath() + File.separator + project.getProjectName() + ".xml"); File file = new File(path, project.getProjectName() + ".xml");
if (!file.exists()) { if (!file.exists()) {
file.createNewFile(); file.createNewFile();
} }
stream = new FileOutputStream(file); stream = new FileOutputStream(file);
t.transform(new DOMSource(doc), new StreamResult(stream)); t.transform(new DOMSource(doc), new StreamResult(stream));
System.out.println("[" + file.getName() + "]保存成功!");
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return false; return false;
@ -286,10 +273,4 @@ public class XmlManager {
} }
return true; return true;
} }
public boolean save(String path, Project project) {
File projectFile = new File(path);
saveAs(projectFile.getAbsolutePath(), project);
return true;
}
} }

@ -53,7 +53,7 @@ public class SDKCallable implements Callable {
System.out.println("生成模块:Pom"); System.out.println("生成模块:Pom");
HashMap<String, Object> ctx = new HashMap<String, Object>(); HashMap<String, Object> ctx = new HashMap<String, Object>();
ctx.put("sdk", sdk.getName().toLowerCase()); ctx.put("sdk", sdk.getName().toLowerCase());
File file = new File(sdk.getAbsolutePath() + File.separator + "pom.xml"); File file = new File(sdk, "pom.xml");
freeMarkerManager.outputTemp(file, "Java_api/pom.ftl", ctx); freeMarkerManager.outputTemp(file, "Java_api/pom.ftl", ctx);
} }
@ -103,7 +103,7 @@ public class SDKCallable implements Callable {
stringBuffer.append(javaClassReader.getModuleName()); stringBuffer.append(javaClassReader.getModuleName());
File request = new File(stringBuffer.toString() + File.separator + "request"); File request = new File(stringBuffer.toString(), "request");
request.mkdirs(); request.mkdirs();
{ {
@ -118,7 +118,7 @@ public class SDKCallable implements Callable {
ctx.put("tool", tool); ctx.put("tool", tool);
ctx.put("hasList", javaClassReader.isHasList()); ctx.put("hasList", javaClassReader.isHasList());
ctx.put("findOrSearchflag", javaClassReader.getFindOrSearchflag()); ctx.put("findOrSearchflag", javaClassReader.getFindOrSearchflag());
File file = new File(request.getAbsolutePath() + File.separator + api.getReq().getName()); File file = new File(request.getAbsolutePath(), api.getReq().getName());
freeMarkerManager.outputTemp(file, "Java_api/module/request/request.ftl", ctx); freeMarkerManager.outputTemp(file, "Java_api/module/request/request.ftl", ctx);
System.out.println("生成文件" + file.getName() + "成功"); System.out.println("生成文件" + file.getName() + "成功");
@ -148,7 +148,7 @@ public class SDKCallable implements Callable {
stringBuffer.append(javaClassReader.getModuleName()); stringBuffer.append(javaClassReader.getModuleName());
File response = new File(stringBuffer.toString() + File.separator + "response"); File response = new File(stringBuffer.toString(), "response");
response.mkdirs(); response.mkdirs();
{ {
@ -163,7 +163,7 @@ public class SDKCallable implements Callable {
ctx.put("tool", tool); ctx.put("tool", tool);
ctx.put("hasList", javaClassReader.isHasList()); ctx.put("hasList", javaClassReader.isHasList());
ctx.put("Tclass", javaClassReader.getTclass()); ctx.put("Tclass", javaClassReader.getTclass());
File file = new File(response.getAbsolutePath() + File.separator + api.getRsp().getName().replaceAll("Request", "Response")); File file = new File(response.getAbsolutePath(), api.getRsp().getName().replaceAll("Request", "Response"));
freeMarkerManager.outputTemp(file, "Java_api/module/response/response.ftl", ctx); freeMarkerManager.outputTemp(file, "Java_api/module/response/response.ftl", ctx);
System.out.println("生成文件" + api.getRsp().getName() + "成功"); System.out.println("生成文件" + api.getRsp().getName() + "成功");
@ -175,7 +175,7 @@ public class SDKCallable implements Callable {
for (String s : api.getDepReq()) { for (String s : api.getDepReq()) {
try { try {
File f = new File(req.getAbsolutePath() + File.separator + s + ".java"); File f = new File(req.getAbsolutePath(), s + ".java");
if (!f.exists()) { if (!f.exists()) {
System.err.println("文件" + f.getAbsolutePath() + "不存在"); System.err.println("文件" + f.getAbsolutePath() + "不存在");
continue; continue;
@ -213,7 +213,7 @@ public class SDKCallable implements Callable {
stringBuffer.append(javaClassReader.getModuleName()); stringBuffer.append(javaClassReader.getModuleName());
File request = new File(stringBuffer.toString() + File.separator + "request"); File request = new File(stringBuffer.toString(), "request");
request.mkdirs(); request.mkdirs();
{ {
@ -228,7 +228,7 @@ public class SDKCallable implements Callable {
ctx.put("tool", tool); ctx.put("tool", tool);
ctx.put("hasList", javaClassReader.isHasList()); ctx.put("hasList", javaClassReader.isHasList());
ctx.put("findOrSearchflag", javaClassReader.getFindOrSearchflag()); ctx.put("findOrSearchflag", javaClassReader.getFindOrSearchflag());
File file = new File(request.getAbsolutePath() + File.separator + f.getName()); File file = new File(request.getAbsolutePath(), f.getName());
freeMarkerManager.outputTemp(file, "Java_api/module/request/request.ftl", ctx); freeMarkerManager.outputTemp(file, "Java_api/module/request/request.ftl", ctx);
System.out.println("生成文件" + file.getName() + "成功"); System.out.println("生成文件" + file.getName() + "成功");
@ -239,8 +239,8 @@ public class SDKCallable implements Callable {
} }
try { try {
File f = new File(rsp.getAbsolutePath() + File.separator + s.replaceAll("Request", "Response.java")); File f = new File(rsp.getAbsolutePath(), s.replaceAll("Request", "Response.java"));
if (!f.exists()){ if (!f.exists()) {
System.err.println("文件" + f.getAbsolutePath() + "不存在"); System.err.println("文件" + f.getAbsolutePath() + "不存在");
} }
JavaClassReader javaClassReader = new JavaClassReader(f); JavaClassReader javaClassReader = new JavaClassReader(f);
@ -260,7 +260,7 @@ public class SDKCallable implements Callable {
stringBuffer.append(javaClassReader.getModuleName()); stringBuffer.append(javaClassReader.getModuleName());
File response = new File(stringBuffer.toString() + File.separator + "response"); File response = new File(stringBuffer.toString(), "response");
response.mkdirs(); response.mkdirs();
{ {
@ -275,7 +275,7 @@ public class SDKCallable implements Callable {
ctx.put("tool", tool); ctx.put("tool", tool);
ctx.put("hasList", javaClassReader.isHasList()); ctx.put("hasList", javaClassReader.isHasList());
ctx.put("Tclass", javaClassReader.getTclass()); ctx.put("Tclass", javaClassReader.getTclass());
File file = new File(response.getAbsolutePath() + File.separator + f.getName()); File file = new File(response.getAbsolutePath(), f.getName());
freeMarkerManager.outputTemp(file, "Java_api/module/response/response.ftl", ctx); freeMarkerManager.outputTemp(file, "Java_api/module/response/response.ftl", ctx);
System.out.println("生成文件" + api.getRsp().getName() + "成功"); System.out.println("生成文件" + api.getRsp().getName() + "成功");
@ -289,7 +289,7 @@ public class SDKCallable implements Callable {
for (String s : api.getDepEnt()) { for (String s : api.getDepEnt()) {
try { try {
File f = new File(ent.getAbsolutePath() + File.separator + s + ".java"); File f = new File(ent.getAbsolutePath(), s + ".java");
if (!f.exists()) { if (!f.exists()) {
System.out.println("文件" + f.getAbsolutePath() + "不存在"); System.out.println("文件" + f.getAbsolutePath() + "不存在");
continue; continue;
@ -311,7 +311,7 @@ public class SDKCallable implements Callable {
stringBuffer.append(javaClassReader.getModuleName()); stringBuffer.append(javaClassReader.getModuleName());
File entity = new File(stringBuffer.toString() + File.separator + "entity"); File entity = new File(stringBuffer.toString(), "entity");
entity.mkdirs(); entity.mkdirs();
{ {
@ -324,7 +324,7 @@ public class SDKCallable implements Callable {
ctx.put("className", javaClassReader.getClassName().replaceAll("Entity", "")); ctx.put("className", javaClassReader.getClassName().replaceAll("Entity", ""));
ctx.put("body", javaClassReader.getBody()); ctx.put("body", javaClassReader.getBody());
ctx.put("tool", tool); ctx.put("tool", tool);
File file = new File(entity.getAbsolutePath() + File.separator + f.getName()); File file = new File(entity.getAbsolutePath(), f.getName());
freeMarkerManager.outputTemp(file, "Java_api/module/entity/entity.ftl", ctx); freeMarkerManager.outputTemp(file, "Java_api/module/entity/entity.ftl", ctx);
System.out.println("生成文件" + file.getName() + "成功"); System.out.println("生成文件" + file.getName() + "成功");
} }
@ -336,7 +336,7 @@ public class SDKCallable implements Callable {
for (String s : api.getDepEnum()) { for (String s : api.getDepEnum()) {
try { try {
File f = new File(enums.getAbsolutePath() + File.separator + s + ".java"); File f = new File(enums, s + ".java");
if (!f.exists()) { if (!f.exists()) {
System.err.println("文件" + f.getAbsolutePath() + "不存在"); System.err.println("文件" + f.getAbsolutePath() + "不存在");
continue; continue;
@ -358,7 +358,7 @@ public class SDKCallable implements Callable {
stringBuffer.append(javaEnumReader.getModuleName()); stringBuffer.append(javaEnumReader.getModuleName());
File enums_ = new File(stringBuffer.toString() + File.separator + "enums"); File enums_ = new File(stringBuffer.toString(), "enums");
enums_.mkdirs(); enums_.mkdirs();
{ {
@ -371,7 +371,7 @@ public class SDKCallable implements Callable {
ctx.put("body", javaEnumReader.getBody()); ctx.put("body", javaEnumReader.getBody());
ctx.put("tool", tool); ctx.put("tool", tool);
File file = new File(enums_.getAbsolutePath() + File.separator + f.getName()); File file = new File(enums_, f.getName());
freeMarkerManager.outputTemp(file, "Java_api/module/enums/type.ftl", ctx); freeMarkerManager.outputTemp(file, "Java_api/module/enums/type.ftl", ctx);
System.out.println("生成文件" + file.getName() + "成功"); System.out.println("生成文件" + file.getName() + "成功");
} }
@ -607,90 +607,90 @@ public class SDKCallable implements Callable {
ctx.put("domain", domain); ctx.put("domain", domain);
ctx.put("module", module); ctx.put("module", module);
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "ApiEntity.java"); File file = new File(frameWork, "ApiEntity.java");
freeMarkerManager.outputTemp(file, "/Java_api/ApiEntity.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/ApiEntity.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "AESUtil.java"); File file = new File(frameWork, "AESUtil.java");
freeMarkerManager.outputTemp(file, "/Java_api/AESUtil.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/AESUtil.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "ApiClient.java"); File file = new File(frameWork, "ApiClient.java");
freeMarkerManager.outputTemp(file, "/Java_api/ApiClient.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/ApiClient.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "ApiRequest.java"); File file = new File(frameWork, "ApiRequest.java");
freeMarkerManager.outputTemp(file, "/Java_api/ApiRequest.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/ApiRequest.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "ApiFindRequest.java"); File file = new File(frameWork, "ApiFindRequest.java");
freeMarkerManager.outputTemp(file, "/Java_api/ApiFindRequest.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/ApiFindRequest.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "ApiSearchRequest.java"); File file = new File(frameWork, "ApiSearchRequest.java");
freeMarkerManager.outputTemp(file, "/Java_api/ApiSearchRequest.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/ApiSearchRequest.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "ApiResponse.java"); File file = new File(frameWork, "ApiResponse.java");
freeMarkerManager.outputTemp(file, "/Java_api/ApiResponse.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/ApiResponse.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "ApiFindResponse.java"); File file = new File(frameWork, "ApiFindResponse.java");
freeMarkerManager.outputTemp(file, "/Java_api/ApiFindResponse.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/ApiFindResponse.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "Base64Util.java"); File file = new File(frameWork, "Base64Util.java");
freeMarkerManager.outputTemp(file, "/Java_api/Base64Util.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/Base64Util.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "DownloadUtil.java"); File file = new File(frameWork, "DownloadUtil.java");
freeMarkerManager.outputTemp(file, "/Java_api/DownloadUtil.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/DownloadUtil.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "Error.java"); File file = new File(frameWork, "Error.java");
freeMarkerManager.outputTemp(file, "/Java_api/Error.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/Error.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "ErrorType.java"); File file = new File(frameWork, "ErrorType.java");
freeMarkerManager.outputTemp(file, "/Java_api/ErrorType.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/ErrorType.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "FileUploadRequest.java"); File file = new File(frameWork, "FileUploadRequest.java");
freeMarkerManager.outputTemp(file, "/Java_api/FileUploadRequest.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/FileUploadRequest.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "FileUploadResponse.java"); File file = new File(frameWork, "FileUploadResponse.java");
freeMarkerManager.outputTemp(file, "/Java_api/FileUploadResponse.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/FileUploadResponse.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "MapperUtil.java"); File file = new File(frameWork, "MapperUtil.java");
freeMarkerManager.outputTemp(file, "/Java_api/MapperUtil.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/MapperUtil.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "MD5Util.java"); File file = new File(frameWork, "MD5Util.java");
freeMarkerManager.outputTemp(file, "/Java_api/MD5Util.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/MD5Util.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "RSAUtil.java"); File file = new File(frameWork, "RSAUtil.java");
freeMarkerManager.outputTemp(file, "/Java_api/RSAUtil.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/RSAUtil.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "ProgressRequestBody.java"); File file = new File(frameWork, "ProgressRequestBody.java");
freeMarkerManager.outputTemp(file, "/Java_api/ProgressRequestBody.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/ProgressRequestBody.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "SortType.java"); File file = new File(frameWork, "SortType.java");
freeMarkerManager.outputTemp(file, "/Java_api/SortType.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/SortType.ftl", ctx);
} }
{ {
File file = new File(frameWork.getAbsolutePath() + File.separator + "StringUtils.java"); File file = new File(frameWork, "StringUtils.java");
freeMarkerManager.outputTemp(file, "/Java_api/StringUtils.ftl", ctx); freeMarkerManager.outputTemp(file, "/Java_api/StringUtils.ftl", ctx);
} }
//4.0.1 去掉验证 减少体积 //4.0.1 去掉验证 减少体积
// { // {
// File file = new File(frameWork.getAbsolutePath() + File.separator + "ValidationUtil.java"); // File file = new File(frameWork , "ValidationUtil.java");
// freeMarkerManager.outputTemp(file, "/Java_api/ValidationUtil.ftl", ctx); // freeMarkerManager.outputTemp(file, "/Java_api/ValidationUtil.ftl", ctx);
// } // }
System.out.println("finish"); System.out.println("finish");

@ -40,7 +40,7 @@ public class SpringBootCallable implements Callable {
dBmapper = ProjectManager.dBmapper; dBmapper = ProjectManager.dBmapper;
// 创建项目文件夹 // 创建项目文件夹
File projectDir = new File(root + File.separator + project.getProjectName()); File projectDir = new File(root , project.getProjectName());
if (!projectDir.exists()) { if (!projectDir.exists()) {
projectDir.mkdir(); projectDir.mkdir();
} else { } else {
@ -588,7 +588,7 @@ public class SpringBootCallable implements Callable {
dbtool.mkdirs(); dbtool.mkdirs();
{ {
XmlManager xmlManager = ManagerFactory.getXmlManager(); XmlManager xmlManager = ManagerFactory.getXmlManager();
xmlManager.saveAs(dbtool.getAbsolutePath(), project); xmlManager.saveAs(dbtool, project);
} }
for (Module module : project.getModules()) { for (Module module : project.getModules()) {

@ -524,7 +524,7 @@ public class SpringMVCMybatisCallable implements Callable {
dbtool.mkdirs(); dbtool.mkdirs();
{ {
XmlManager xmlManager = ManagerFactory.getXmlManager(); XmlManager xmlManager = ManagerFactory.getXmlManager();
xmlManager.saveAs(dbtool.getAbsolutePath(), project); xmlManager.saveAs(dbtool, project);
} }
try { try {

@ -497,9 +497,8 @@ public class Dialog {
}); });
ProjectManager dBmanger = ManagerFactory.getdBManager(); ProjectManager dBmanger = ManagerFactory.getdBManager();
String path = dBmanger.getPath();
File file = new File(path); File file = dBmanger.getPath();
File[] files = file.listFiles(); File[] files = file.listFiles();
s: s:
for (File f : files) { for (File f : files) {
@ -575,7 +574,7 @@ public class Dialog {
public void handle(ActionEvent event) { public void handle(ActionEvent event) {
ProjectManager dBmanger = ManagerFactory.getdBManager(); ProjectManager dBmanger = ManagerFactory.getdBManager();
DirectoryChooser directoryChooser = new DirectoryChooser(); DirectoryChooser directoryChooser = new DirectoryChooser();
directoryChooser.setInitialDirectory(new File(dBmanger.getPath())); directoryChooser.setInitialDirectory(dBmanger.getPath());
Stage stage = new Stage(); Stage stage = new Stage();
File file = directoryChooser.showDialog(stage); File file = directoryChooser.showDialog(stage);
if (file != null) { if (file != null) {
@ -636,7 +635,7 @@ public class Dialog {
public void handle(ActionEvent event) { public void handle(ActionEvent event) {
ProjectManager dBmanger = ManagerFactory.getdBManager(); ProjectManager dBmanger = ManagerFactory.getdBManager();
DirectoryChooser directoryChooser = new DirectoryChooser(); DirectoryChooser directoryChooser = new DirectoryChooser();
directoryChooser.setInitialDirectory(new File(dBmanger.getPath())); directoryChooser.setInitialDirectory(dBmanger.getPath());
Stage stage = new Stage(); Stage stage = new Stage();
File file = directoryChooser.showDialog(stage); File file = directoryChooser.showDialog(stage);
if (file != null) { if (file != null) {

@ -1,22 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.*?> <?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?> <?import javafx.scene.layout.*?>
<?import javafx.geometry.Insets?>
<BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0" <BorderPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" prefHeight="400.0"
prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" prefWidth="600.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="xyz.wbsite.dbtool.javafx.ctrl.MainController"> fx:controller="xyz.wbsite.dbtool.javafx.ctrl.MainController">
<top> <top>
<MenuBar BorderPane.alignment="CENTER"> <MenuBar BorderPane.alignment="CENTER">
<menus> <menus>
<Menu mnemonicParsing="false" text="File"> <Menu mnemonicParsing="false" text="数据模型">
<items>
<MenuItem mnemonicParsing="false" onAction="#modelCreate" text="新建模型"/>
<MenuItem mnemonicParsing="false" onAction="#modelSave" text="保存模型"/>
<MenuItem mnemonicParsing="false" onAction="#modelSaveAs" text="另存模型"/>
<MenuItem mnemonicParsing="false" onAction="#modelDelete" text="删除模型"/>
<MenuItem mnemonicParsing="false" onAction="#modelOpen" text="打开模型"/>
<MenuItem mnemonicParsing="false" onAction="#modelImport" text="模型导入"/>
<MenuItem mnemonicParsing="false" onAction="#modelGenerate" text="生成模型"/>
</items>
</Menu>
<Menu mnemonicParsing="false" text="其他模型">
<items> <items>
<MenuItem mnemonicParsing="false" onAction="#save" text="保存"/>
<MenuItem mnemonicParsing="false" onAction="#saveAs" text="另存"/>
<MenuItem mnemonicParsing="false" onAction="#clear" text="清除"/>
<MenuItem mnemonicParsing="false" onAction="#showFileChooser" text="打开"/>
<MenuItem mnemonicParsing="false" onAction="#showConnectInfo" text="数据库导入"/>
<MenuItem mnemonicParsing="false" onAction="#generate" text="生成模型"/>
<MenuItem mnemonicParsing="false" onAction="#generateVue" text="生成Vue"/> <MenuItem mnemonicParsing="false" onAction="#generateVue" text="生成Vue"/>
<MenuItem mnemonicParsing="false" onAction="#generateApi" text="生成Api"/> <MenuItem mnemonicParsing="false" onAction="#generateApi" text="生成Api"/>
<MenuItem mnemonicParsing="false" onAction="#generateAndroid" text="生成Android"/> <MenuItem mnemonicParsing="false" onAction="#generateAndroid" text="生成Android"/>
@ -58,9 +63,10 @@
<items> <items>
<Button mnemonicParsing="false" text=" + " fx:id="add"/> <Button mnemonicParsing="false" text=" + " fx:id="add"/>
<Button mnemonicParsing="false" text=" - " fx:id="sub"/> <Button mnemonicParsing="false" text=" - " fx:id="sub"/>
<CheckBox mnemonicParsing="false" fx:id="addSysFields" text="添加系统字段" selected="false"> <CheckBox mnemonicParsing="false" fx:id="addSysFields" text="添加系统字段"
selected="false">
<HBox.margin> <HBox.margin>
<Insets left="30.0" /> <Insets left="30.0"/>
</HBox.margin> </HBox.margin>
</CheckBox> </CheckBox>
</items> </items>

Loading…
Cancel
Save

Powered by TurnKey Linux.