Former-commit-id: b691d608a5767d4945af345de028238c50a081c9
master
wangbingit@outlook.com 5 years ago
parent 057f3ddb9f
commit bd70252646

@ -1,15 +1,12 @@
package xyz.wbsite.dbtool;
import xyz.wbsite.dbtool.javafx.JavaFxApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import xyz.wbsite.dbtool.web.frame.utils.ResourceUtil;
import xyz.wbsite.dbtool.javafx.JavaFxApplication;
import java.io.File;
import java.io.FileNotFoundException;
import java.net.URL;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

@ -57,16 +57,16 @@ import java.util.List;
public class JavaFxApplication extends Application {
private ProjectManager dBmanger = ManagerFactory.getProjectManager();
private TreeView mdtree = null;
private Pane detail = null;
private TableView feilds = null;
private ProjectManager dBmanager = ManagerFactory.getProjectManager();
private TreeView mTree = null;
private Pane mDetail = null;
private TableView mFields = null;
private Button add = null;
private Button sub = null;
private FXMLLoader mainloader;
private FXMLLoader projectdetailloader;
private FXMLLoader mddetailloader;
private FXMLLoader tabledetailloader;
private FXMLLoader mMainLoader;
private FXMLLoader mProjectLoader;
private FXMLLoader mModuleLoader;
private FXMLLoader mTableLoader;
private MainController mainController;
private DetailProjectController detailProjectController;
private DetailModuleController mdDetailController;
@ -83,7 +83,7 @@ public class JavaFxApplication extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
BorderPane root = mainloader.getRoot();
BorderPane root = mMainLoader.getRoot();
primaryStage.setTitle("DBtool");
primaryStage.setScene(new Scene(root, 700, 500));
@ -105,15 +105,15 @@ public class JavaFxApplication extends Application {
if (main == null) {
main = getClass().getResource("../../../fxml/main.fxml");
}
mainloader = new FXMLLoader(main);
mainloader.load();
mainController = mainloader.getController();
mMainLoader = new FXMLLoader(main);
mMainLoader.load();
mainController = mMainLoader.getController();
mainController.setMain(this);
mdtree = mainController.getDbtree();
detail = mainController.getDetail();
feilds = mainController.getFeilds();
feilds.setEditable(true);
feilds.setSortPolicy(new Callback<TableView, Boolean>() {
mTree = mainController.getDbtree();
mDetail = mainController.getDetail();
mFields = mainController.getFeilds();
mFields.setEditable(true);
mFields.setSortPolicy(new Callback<TableView, Boolean>() {
@Override
public Boolean call(TableView param) {
//禁止点击列头排序
@ -140,7 +140,7 @@ public class JavaFxApplication extends Application {
@Override
public void handle(ActionEvent event) {
MenuItem target = (MenuItem) event.getTarget();
int index = feilds.getSelectionModel().getSelectedIndex();
int index = mFields.getSelectionModel().getSelectedIndex();
List<Field> fields = currentTable.getFields();
if ("新增".equals(target.getText())) {
@ -170,11 +170,11 @@ public class JavaFxApplication extends Application {
break;
}
loadingTable();
feilds.getSelectionModel().clearSelection();
JavaFxApplication.this.mFields.getSelectionModel().clearSelection();
}
}
});
feilds.setContextMenu(con);
mFields.setContextMenu(con);
project_menu = new ContextMenu(new MenuItem("新增模块"));
md_right_menu = new ContextMenu(new MenuItem("新增对象"), new MenuItem("删除模块"), new MenuItem("向上调整"), new MenuItem("向下调整"));
@ -187,31 +187,31 @@ public class JavaFxApplication extends Application {
if (projectdetail == null) {
projectdetail = getClass().getResource("../../../fxml/projectdetail.fxml");
}
projectdetailloader = new FXMLLoader(projectdetail);
projectdetailloader.load();
detailProjectController = projectdetailloader.getController();
mProjectLoader = new FXMLLoader(projectdetail);
mProjectLoader.load();
detailProjectController = mProjectLoader.getController();
URL mddetail = JavaFxApplication.class.getClassLoader().getResource("fxml/moduledetail.fxml");
if (mddetail == null) {
mddetail = getClass().getResource("../../../fxml/moduledetail.fxml");
}
mddetailloader = new FXMLLoader(mddetail);
mddetailloader.load();
mdDetailController = mddetailloader.getController();
mModuleLoader = new FXMLLoader(mddetail);
mModuleLoader.load();
mdDetailController = mModuleLoader.getController();
URL tabledetail = JavaFxApplication.class.getClassLoader().getResource("fxml/tabledetail.fxml");
if (tabledetail == null) {
tabledetail = getClass().getResource("../../../fxml/tabledetail.fxml");
}
tabledetailloader = new FXMLLoader(tabledetail);
tabledetailloader.load();
detailTableController = tabledetailloader.getController();
mTableLoader = new FXMLLoader(tabledetail);
mTableLoader.load();
detailTableController = mTableLoader.getController();
mdtree.setShowRoot(true);
mdtree.setEditable(true);
mdtree.setDisable(false);
mdtree.setCellFactory(new Callback<TreeView, TreeCell>() {
mTree.setShowRoot(true);
mTree.setEditable(true);
mTree.setDisable(false);
mTree.setCellFactory(new Callback<TreeView, TreeCell>() {
@Override
public TreeCell call(TreeView param) {
TextFieldTreeCell textFieldTreeCell = new TextFieldTreeCell(new DefaultStringConverter());
@ -224,7 +224,7 @@ public class JavaFxApplication extends Application {
public void handle(MouseEvent event) {
TextFieldTreeCell source = (TextFieldTreeCell) event.getSource();
String text = source.getText();
Module dbByDBName = dBmanger.findDBByDBName(text);
Module dbByDBName = dBmanager.findDBByDBName(text);
if (dbByDBName != null) {
dragMD = true;
} else {
@ -248,7 +248,7 @@ public class JavaFxApplication extends Application {
Dragboard md = event.getDragboard();
TextFieldTreeCell source = (TextFieldTreeCell) event.getSource();
Module dbByDBName = dBmanger.findDBByDBName(source.getText());
Module dbByDBName = dBmanager.findDBByDBName(source.getText());
if (dragMD && dbByDBName != null) {
double y = event.getY();
@ -284,7 +284,7 @@ public class JavaFxApplication extends Application {
String m2 = ((TreeCell<String>) event.getGestureTarget()).getItem();
if (dragMD) {
List<Module> mds = dBmanger.getMds();
List<Module> mds = dBmanager.getMds();
int i1 = 0, i2 = 0;
for (int i = 0; i < mds.size(); i++) {
@ -346,19 +346,19 @@ public class JavaFxApplication extends Application {
}
event.setDropCompleted(true);
event.consume();
mdtree.getSelectionModel().clearSelection();
int focusedIndex = mdtree.getFocusModel().getFocusedIndex();
mTree.getSelectionModel().clearSelection();
int focusedIndex = mTree.getFocusModel().getFocusedIndex();
System.out.println(focusedIndex);
}
});
return textFieldTreeCell;
}
});
mdtree.setOnEditCommit(new YEventHandler());
mdtree.setOnMouseClicked(new EventHandler<MouseEvent>() {
mTree.setOnEditCommit(new YEventHandler());
mTree.setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
TreeItem targetItem = (TreeItem) mdtree.getSelectionModel().getSelectedItem();
TreeItem targetItem = (TreeItem) mTree.getSelectionModel().getSelectedItem();
if (targetItem == null)
return;
@ -367,24 +367,24 @@ public class JavaFxApplication extends Application {
switch (level) {
case 0: {//查看模块
mdtree.setContextMenu(project_menu);
mTree.setContextMenu(project_menu);
loadingProject();
}
break;
case 1: {//查看模块
mdtree.setContextMenu(md_right_menu);
currentMD = dBmanger.findDBByDBName((String) targetItem.getValue());
mTree.setContextMenu(md_right_menu);
currentMD = dBmanager.findDBByDBName((String) targetItem.getValue());
currentTable = null;
loadingModule();
}
break;
case 2: {//查看对象
mdtree.setContextMenu(table_right_menu);
mTree.setContextMenu(table_right_menu);
TreeItem parent = targetItem.getParent();
currentMD = dBmanger.findDBByDBName((String) parent.getValue());
currentMD = dBmanager.findDBByDBName((String) parent.getValue());
if (currentMD != null) {
currentTable = dBmanger.findTableByTableName(currentMD, (String) targetItem.getValue());
currentTable = dBmanager.findTableByTableName(currentMD, (String) targetItem.getValue());
}
loadingTable();
break;
@ -533,21 +533,21 @@ public class JavaFxApplication extends Application {
}
private void addField() {
if (currentTable != null && feilds != null) {
if (currentTable != null && mFields != null) {
List<Field> fields = currentTable.getFields();
String fieldName = dBmanger.getNewFieldName(fields);
String fieldName = dBmanager.getNewFieldName(fields);
System.out.println("新增字段-" + fieldName + "成功!");
feilds.getSelectionModel().select(fields.size() - 1);
this.mFields.getSelectionModel().select(fields.size() - 1);
loadingTable();
}
}
private void subField() {
if (currentTable != null) {
int selectedIndex = feilds.getSelectionModel().getSelectedIndex();
int selectedIndex = mFields.getSelectionModel().getSelectedIndex();
if (selectedIndex > -1 && !currentTable.getFields().get(selectedIndex).getIsSystem()) {
currentTable.getFields().remove(selectedIndex);
feilds.getSelectionModel().clearSelection();
mFields.getSelectionModel().clearSelection();
loadingTable();
}
@ -555,11 +555,11 @@ public class JavaFxApplication extends Application {
}
public void loadingProjectTree() {
currentProject = dBmanger.getProject();
currentProject = dBmanager.getProject();
currentProject.setValue(currentProject.getProjectName());
currentProject.setExpanded(true);
mdtree.setRoot(currentProject);
mTree.setRoot(currentProject);
for (int i = 0; i < currentProject.getModules().size(); i++) {
Module module = currentProject.getModules().get(i);
@ -574,7 +574,7 @@ public class JavaFxApplication extends Application {
}
private int getLevel(TreeItem treeItem) {
TreeItem root = mdtree.getRoot();
TreeItem root = mTree.getRoot();
int level = 0;
if (treeItem == root) {
level = 0;
@ -591,22 +591,22 @@ public class JavaFxApplication extends Application {
return;
}
GridPane gridPane = mddetailloader.getRoot();
GridPane gridPane = mModuleLoader.getRoot();
mdDetailController.getModuleComment().setText(currentMD.getModuleComment());
mdDetailController.getModulePrefix().setText(currentMD.getModulePrefix());
mdDetailController.getModuleName().setText(currentMD.getModuleName());
if (gridPane != null) {
detail.getChildren().clear();
detail.getChildren().add(gridPane);
mDetail.getChildren().clear();
mDetail.getChildren().add(gridPane);
}
if (feilds != null && feilds.getItems() != null) {
feilds.getItems().clear();
if (mFields != null && mFields.getItems() != null) {
mFields.getItems().clear();
}
}
public void loadingProject() {
GridPane gridPane = projectdetailloader.getRoot();
GridPane gridPane = mProjectLoader.getRoot();
detailProjectController.getProjectName().setText(currentProject.getProjectName());
detailProjectController.getProjectBasePackage().setText(currentProject.getProjectBasePackage());
detailProjectController.getProjectAuthor().setText(currentProject.getProjectAuthor());
@ -614,11 +614,11 @@ public class JavaFxApplication extends Application {
detailProjectController.getSysMD().setSelected(currentProject.getSysMD());
if (gridPane != null) {
detail.getChildren().clear();
detail.getChildren().add(gridPane);
mDetail.getChildren().clear();
mDetail.getChildren().add(gridPane);
}
if (feilds != null && feilds.getItems() != null) {
feilds.getItems().clear();
if (mFields != null && mFields.getItems() != null) {
mFields.getItems().clear();
}
}
@ -626,7 +626,7 @@ public class JavaFxApplication extends Application {
*
*/
private void loadingTable() {
GridPane gridPane = tabledetailloader.getRoot();
GridPane gridPane = mTableLoader.getRoot();
if (currentTable != null) {
detailTableController.getTablename().setText(currentTable.getTableName());
detailTableController.getTablecomment().setText(currentTable.getTableComment());
@ -641,10 +641,10 @@ public class JavaFxApplication extends Application {
}
if (gridPane != null) {
detail.getChildren().clear();
detail.getChildren().add(gridPane);
mDetail.getChildren().clear();
mDetail.getChildren().add(gridPane);
}
ObservableList<TableColumn> columns = feilds.getColumns();
ObservableList<TableColumn> columns = mFields.getColumns();
columns.get(0).setCellValueFactory(new PropertyValueFactory<Field, String>("fieldName"));
columns.get(0).setCellFactory(new Callback<TableColumn, TableCell>() {
@Override
@ -794,7 +794,7 @@ public class JavaFxApplication extends Application {
FieldType fieldType = field.getFieldType();
if (fieldType.isFix() && fieldType.getDefaultLength() != field.getFieldLength()) {
field.setFieldLength(fieldType.getDefaultLength());
feilds.refresh();
mFields.refresh();
}
if (field.getIsSystem()) {
ignoreField(this);
@ -819,7 +819,7 @@ public class JavaFxApplication extends Application {
FieldType newValue = (FieldType) event.getNewValue();
field.setFieldLength(newValue.getDefaultLength());
field.setFieldType(newValue);
feilds.refresh();
mFields.refresh();
}
});
return choiceBoxTableCell;
@ -841,7 +841,7 @@ public class JavaFxApplication extends Application {
e.printStackTrace();
}
}
feilds.refresh();
mFields.refresh();
}
});
TextFieldTableCell textFieldTableCell = new TextFieldTableCell(new IntegerStringConverter()) {
@ -1079,7 +1079,7 @@ public class JavaFxApplication extends Application {
data.addAll(fields);
}
feilds.setItems(data);
mFields.setItems(data);
}
void ignoreField(TableCell tableCell) {
@ -1105,20 +1105,20 @@ public class JavaFxApplication extends Application {
switch (level) {
case 0: {//编辑项目名称
dBmanger.getProject().setProjectName((String) event.getNewValue());
dBmanager.getProject().setProjectName((String) event.getNewValue());
loadingProject();
}
break;
case 1: {//编辑模块
Module md = dBmanger.findDBByDBName((String) event.getOldValue());
Module md = dBmanager.findDBByDBName((String) event.getOldValue());
md.setModuleName((String) event.getNewValue());
loadingModule();
}
break;
case 2: {//编辑对象
TreeItem parent = treeItem.getParent();
Module md = dBmanger.findDBByDBName((String) parent.getValue());
Table table = dBmanger.findTableByTableName(md, (String) event.getOldValue());
Module md = dBmanager.findDBByDBName((String) parent.getValue());
Table table = dBmanager.findTableByTableName(md, (String) event.getOldValue());
if (table != null) {
table.setTableName((String) event.getNewValue());
loadingTable();
@ -1141,40 +1141,40 @@ public class JavaFxApplication extends Application {
MenuItem target = (MenuItem) event.getTarget();
String text = target.getText();
Project project = (Project) mdtree.getRoot();
Project project = (Project) mTree.getRoot();
TreeItem targetItem = (TreeItem) mdtree.getFocusModel().getFocusedItem();
TreeItem targetItem = (TreeItem) mTree.getFocusModel().getFocusedItem();
int index = -1;
index = mdtree.getFocusModel().getFocusedIndex();
index = mTree.getFocusModel().getFocusedIndex();
if (targetItem == null) {
targetItem = (TreeItem) mdtree.getSelectionModel().getSelectedItem();
targetItem = (TreeItem) mTree.getSelectionModel().getSelectedItem();
}
if (index == -1) {
index = mdtree.getSelectionModel().getSelectedIndex();
index = mTree.getSelectionModel().getSelectedIndex();
}
if (text != null && targetItem != null) {
switch (text) {
case "向上调整":
if (index > 0) {
Tool.exchange(dBmanger.getProject().getModules(), index - 1, index);
Tool.exchange(dBmanger.getProject().getChildren(), index - 1, index);
Tool.exchange(dBmanager.getProject().getModules(), index - 1, index);
Tool.exchange(dBmanager.getProject().getChildren(), index - 1, index);
}
break;
case "向下调整":
List<Module> mds = dBmanger.getMds();
List<Module> mds = dBmanager.getMds();
if (index < mds.size() - 1) {
Tool.exchange(dBmanger.getProject().getModules(), index, index + 1);
Tool.exchange(dBmanger.getProject().getChildren(), index, index + 1);
Tool.exchange(dBmanager.getProject().getModules(), index, index + 1);
Tool.exchange(dBmanager.getProject().getChildren(), index, index + 1);
}
break;
case "新增模块":
dBmanger.getNewModuleName();
dBmanager.getNewModuleName();
break;
case "删除模块":
if (targetItem != null && targetItem.getParent() == project) {
currentProject.getChildren().remove(targetItem);
boolean b = dBmanger.removeDBByDBName((String) targetItem.getValue());
boolean b = dBmanager.removeDBByDBName((String) targetItem.getValue());
if (b) {
System.out.println("删除模块" + targetItem.getValue() + "成功!");
}
@ -1186,9 +1186,9 @@ public class JavaFxApplication extends Application {
switch (level) {
case 1: {//对模块右击
System.out.println("模块:" + targetItem.getValue());
Module md = dBmanger.findDBByDBName((String) targetItem.getValue());
Module md = dBmanager.findDBByDBName((String) targetItem.getValue());
if (md != null) {
Table newTableName = dBmanger.getNewTableName(md);
Table newTableName = dBmanager.getNewTableName(md);
targetItem.getChildren().add(newTableName);
}
}
@ -1196,8 +1196,8 @@ public class JavaFxApplication extends Application {
case 2: {//对对象右击
TreeItem parent = targetItem.getParent();
System.out.println("对象:" + parent.getValue());
Module md = dBmanger.findDBByDBName((String) parent.getValue());
Table newTableName = dBmanger.getNewTableName(md);
Module md = dBmanager.findDBByDBName((String) parent.getValue());
Table newTableName = dBmanager.getNewTableName(md);
parent.getChildren().add(new TreeItem<>(newTableName.getTableName()));
break;
}
@ -1215,15 +1215,15 @@ public class JavaFxApplication extends Application {
switch (level) {
case 0: {//对模块右击
System.out.println("模块:" + targetItem.getValue());
Module md = dBmanger.findDBByDBName((String) targetItem.getValue());
Table newTableName = dBmanger.getNewTableName(md);
Module md = dBmanager.findDBByDBName((String) targetItem.getValue());
Table newTableName = dBmanager.getNewTableName(md);
targetItem.getChildren().add(new TreeItem<>(newTableName.getTableName()));
}
break;
case 1: {//对对象右击
TreeItem parent = targetItem.getParent();
System.out.println("对象:" + parent.getValue());
Module md = dBmanger.findDBByDBName((String) parent.getValue());
Module md = dBmanager.findDBByDBName((String) parent.getValue());
for (Table table : md.getTables()) {
if (table.getTableName().equals(targetItem.getValue())) {
@ -1243,7 +1243,7 @@ public class JavaFxApplication extends Application {
} else if (text != null && targetItem == null) {
switch (text) {
case "新增模块":
dBmanger.getNewModuleName();
dBmanager.getNewModuleName();
break;
default:
break;
@ -1253,7 +1253,7 @@ public class JavaFxApplication extends Application {
}
private void updateDbTree(List<Module> mds) {
TreeItem root = mdtree.getRoot();
TreeItem root = mTree.getRoot();
for (Module md : mds) {
TreeItem<String> treeItem = new TreeItem<>(md.getModuleName());
treeItem.setExpanded(true);

@ -200,6 +200,7 @@ public class MainController {
public void generateAndroid(ActionEvent actionEvent) {
Dialog.showAndroid();
}
@FXML
public void generateSBMDB(ActionEvent actionEvent) {
Dialog.showSBMDB();

@ -2,7 +2,6 @@ package xyz.wbsite.dbtool.javafx.ctrl;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextField;
public class OptionAndroidController {

@ -6,7 +6,12 @@ import javafx.beans.value.ObservableValue;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.fxml.FXML;
import javafx.scene.control.*;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TableCell;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;
import javafx.scene.control.TextField;
import javafx.scene.control.cell.PropertyValueFactory;
import javafx.scene.control.cell.TextFieldTableCell;
import javafx.util.Callback;
@ -18,9 +23,14 @@ import xyz.wbsite.dbtool.javafx.tool.Dialog;
import xyz.wbsite.dbtool.javafx.tool.Tool;
import xyz.wbsite.dbtool.javafx.view.DBCheckBoxTableCell;
import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

@ -1,11 +1,11 @@
package xyz.wbsite.dbtool.javafx.ctrl;
import xyz.wbsite.dbtool.javafx.listener.GenerateOptionListener;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.RadioButton;
import javafx.scene.control.ToggleGroup;
import xyz.wbsite.dbtool.javafx.listener.GenerateOptionListener;
public class OptionMainController {

@ -2,8 +2,6 @@ package xyz.wbsite.dbtool.javafx.ctrl;
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.TextField;
import javafx.scene.control.ToggleGroup;
public class OptionVueController {

@ -3,5 +3,5 @@ package xyz.wbsite.dbtool.javafx.listener;
import xyz.wbsite.dbtool.javafx.enums.DataBase;
public interface GenerateOptionListener {
void onGenerate(String option,DataBase dataBase);
void onGenerate(String option, DataBase dataBase);
}

@ -1,19 +1,20 @@
package xyz.wbsite.dbtool.javafx.manger;
import freemarker.cache.*;
import freemarker.template.*;
import org.springframework.core.io.DefaultResourceLoader;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.lang.Nullable;
import org.springframework.ui.freemarker.SpringTemplateLoader;
import freemarker.cache.ClassTemplateLoader;
import freemarker.cache.MultiTemplateLoader;
import freemarker.cache.TemplateLoader;
import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler;
import org.springframework.util.ClassUtils;
import org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer;
import org.springframework.web.util.UriTemplate;
import java.io.*;
import java.net.URL;
import java.util.Properties;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
public class FreeMarkerManager {
private FreeMarkerConfigurer freeMarkerConfigurer;
@ -47,7 +48,7 @@ public class FreeMarkerManager {
//获取ftl,由于已经在配置文件中配置了路径所以在这里直接写模板名称就可以
Template temp = configuration.getTemplate(template);
//输出文件路径
Writer wr = new OutputStreamWriter(new FileOutputStream(outfile),"UTF-8");
Writer wr = new OutputStreamWriter(new FileOutputStream(outfile), "UTF-8");
//写入
temp.process(model, wr);
//关闭流

@ -4,7 +4,7 @@ import xyz.wbsite.dbtool.javafx.JavaFxApplication;
public class ManagerFactory {
private static XmlManager xmlManager = null;
private static ReflashManager reflashManager =null;
private static ReflashManager reflashManager = null;
private static ProjectManager projectManager;
private static FreeMarkerManager freeMarkerManager;
@ -28,7 +28,7 @@ public class ManagerFactory {
}
public static ReflashManager getReflashManager(JavaFxApplication main) {
if (reflashManager == null){
if (reflashManager == null) {
reflashManager = new ReflashManager(main);
}
return reflashManager;

@ -2,7 +2,7 @@ package xyz.wbsite.dbtool.javafx.manger;
import xyz.wbsite.dbtool.javafx.JavaFxApplication;
public class ReflashManager extends Thread{
public class ReflashManager extends Thread {
private JavaFxApplication main;
public ReflashManager(JavaFxApplication main) {
@ -11,13 +11,13 @@ public class ReflashManager extends Thread{
@Override
public void run() {
while (true){
while (true) {
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
if (ProjectManager.isUpdate){
if (ProjectManager.isUpdate) {
main.loadingProjectTree();
ProjectManager.isUpdate = false;
}

@ -193,7 +193,7 @@ public class ApiCallable implements Callable {
ArrayList<Api> apis = new ArrayList<>();
for (Api api : apiList) {
if (m.equals(api.getModule())){
if (m.equals(api.getModule())) {
apis.add(api);
}
}

@ -6,7 +6,7 @@ import xyz.wbsite.dbtool.javafx.enums.FieldType;
public abstract class AbstractDBmapper {
DataBase mDataBase = null;
private AbstractDBmapper(){
private AbstractDBmapper() {
}
@ -14,11 +14,13 @@ public abstract class AbstractDBmapper {
this.mDataBase = mDataBase;
}
DataBase getDataBase(){
DataBase getDataBase() {
return mDataBase;
}
public abstract String getDataBaseType(FieldType type);
abstract String getFieldSql(Field field);
public abstract FieldType getType(String type, int lenght, int precision, int scale);
}

@ -1,9 +1,7 @@
package xyz.wbsite.dbtool.javafx.po;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class Api {

@ -118,7 +118,7 @@ public class Field extends Table {
value = "(byte)1";
} else if (fieldType.name().matches("Short")) {
value = "(short)1";
}else if (fieldType.name().matches("Integer")) {
} else if (fieldType.name().matches("Integer")) {
value = "1";
} else if (fieldType.name().matches("Bytes")) {
value = "null";

@ -5,7 +5,7 @@ import javafx.scene.control.TreeItem;
import java.util.ArrayList;
import java.util.List;
public class Project extends TreeItem{
public class Project extends TreeItem {
public Project() {
this.projectName = "EXAMPLE-WEB";

@ -1,6 +1,10 @@
package xyz.wbsite.dbtool.javafx.tool;
import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

@ -1,6 +1,10 @@
package xyz.wbsite.dbtool.javafx.tool;
import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

@ -1,6 +1,10 @@
package xyz.wbsite.dbtool.javafx.tool;
import java.io.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
@ -24,7 +28,7 @@ public class ResponseReader {
private String findOrSearchflag = "0";
private String Tclass = null;
public ResponseReader(File javaClass){
public ResponseReader(File javaClass) {
this.javaClass = javaClass;
importList = new ArrayList<>();
notesList = new ArrayList<>();

@ -8,7 +8,13 @@ import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.LocaleResolver;
@ -17,7 +23,11 @@ import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
import xyz.wbsite.dbtool.web.config.ActionConfig;
import xyz.wbsite.dbtool.web.frame.auth.LocalData;
import xyz.wbsite.dbtool.web.frame.base.*;
import xyz.wbsite.dbtool.web.frame.base.BaseRequest;
import xyz.wbsite.dbtool.web.frame.base.BaseResponse;
import xyz.wbsite.dbtool.web.frame.base.ErrorType;
import xyz.wbsite.dbtool.web.frame.base.Screen;
import xyz.wbsite.dbtool.web.frame.base.Token;
import xyz.wbsite.dbtool.web.frame.utils.MapperUtil;
import javax.servlet.http.HttpServletRequest;

@ -1,7 +1,7 @@
package xyz.wbsite.dbtool.web.action.control;
import xyz.wbsite.dbtool.web.frame.base.Control;
import org.springframework.ui.Model;
import xyz.wbsite.dbtool.web.frame.base.Control;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@ -1,10 +1,11 @@
package xyz.wbsite.dbtool.web.action.screen;
import xyz.wbsite.dbtool.web.frame.base.Screen;
import org.springframework.ui.Model;
import java.util.ArrayList;
import xyz.wbsite.dbtool.web.frame.base.Screen;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
public class Index extends Screen {

@ -69,7 +69,7 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
@Override
public String generateBeanName(BeanDefinition beanDefinition, BeanDefinitionRegistry beanDefinitionRegistry) {
String beanClassName = beanDefinition.getBeanClassName();
String beamName = beanClassName.replaceAll(basePackage + ".", SCREEN_PREFIX).replaceAll("\\.","/").toLowerCase();
String beamName = beanClassName.replaceAll(basePackage + ".", SCREEN_PREFIX).replaceAll("\\.", "/").toLowerCase();
LogUtil.i("registry screen " + beamName);
return beamName;
}
@ -92,7 +92,7 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
@Override
public String generateBeanName(BeanDefinition beanDefinition, BeanDefinitionRegistry beanDefinitionRegistry) {
String beanClassName = beanDefinition.getBeanClassName();
String beamName = beanClassName.replaceAll(basePackage + ".", CONTROL_PREFIX).replaceAll("\\.","/").toLowerCase();
String beamName = beanClassName.replaceAll(basePackage + ".", CONTROL_PREFIX).replaceAll("\\.", "/").toLowerCase();
LogUtil.i("registry control " + beamName);
return beamName;
}
@ -115,7 +115,7 @@ public class ActionConfig implements BeanDefinitionRegistryPostProcessor {
if (beanClassName != null && beanClassName.endsWith("Ajax")) {
beanClassName = beanClassName.substring(0, beanClassName.length() - 4);
}
String beamName = beanClassName.replaceAll(basePackage + ".", AJAX_PREFIX).replaceAll("\\.","/").toLowerCase();
String beamName = beanClassName.replaceAll(basePackage + ".", AJAX_PREFIX).replaceAll("\\.", "/").toLowerCase();
LogUtil.i("registry ajax " + beamName);
return beamName;
}

@ -1,8 +1,5 @@
package xyz.wbsite.dbtool.web.config;
import xyz.wbsite.dbtool.web.frame.auth.LocalData;
import xyz.wbsite.dbtool.web.frame.base.Control;
import xyz.wbsite.dbtool.web.frame.utils.UrlUtil;
import freemarker.template.SimpleScalar;
import freemarker.template.TemplateMethodModelEx;
import freemarker.template.TemplateModelException;
@ -17,6 +14,9 @@ import org.springframework.web.servlet.DispatcherServlet;
import org.springframework.web.servlet.LocaleResolver;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
import xyz.wbsite.dbtool.web.frame.auth.LocalData;
import xyz.wbsite.dbtool.web.frame.base.Control;
import xyz.wbsite.dbtool.web.frame.utils.UrlUtil;
import javax.annotation.PostConstruct;
import javax.servlet.http.HttpServletRequest;

@ -10,12 +10,16 @@ import org.springframework.security.config.annotation.web.builders.WebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
import xyz.wbsite.dbtool.web.frame.auth.LocalData;
import xyz.wbsite.dbtool.web.frame.base.Token;
import xyz.wbsite.dbtool.web.frame.utils.CookieUtil;
import xyz.wbsite.dbtool.web.frame.auth.LocalData;
import org.springframework.security.web.access.intercept.FilterSecurityInterceptor;
import javax.servlet.*;
import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.regex.Matcher;

@ -22,8 +22,8 @@ import java.util.concurrent.Executors;
@Profile("prod")
public class TaskConfig implements SchedulingConfigurer {
@Scheduled(cron="0/30 * * * * ? ")
public void task(){
@Scheduled(cron = "0/30 * * * * ? ")
public void task() {
// todo 自定实现的定时任务
SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss");
HashMap<String, String> data = new HashMap<>();

@ -1,10 +1,10 @@
package xyz.wbsite.dbtool.web.frame.auth;
import xyz.wbsite.dbtool.web.frame.base.Token;
import org.springframework.context.ApplicationContext;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.context.support.WebApplicationContextUtils;
import xyz.wbsite.dbtool.web.frame.base.Token;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@ -1,6 +1,7 @@
package xyz.wbsite.dbtool.web.frame.base;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.io.Serializable;
import java.util.Date;

@ -9,7 +9,7 @@ import java.util.List;
* @version 0.0.1
* @since 2017-01-01
*/
public class BaseFindResponse<T> extends BaseResponse{
public class BaseFindResponse<T> extends BaseResponse {
private List<T> result;

@ -7,7 +7,7 @@ package xyz.wbsite.dbtool.web.frame.base;
* @version 0.0.1
* @since 2017-01-01
*/
public class BaseUpdateRequest extends BaseRequest{
public class BaseUpdateRequest extends BaseRequest {
/**
*

@ -13,11 +13,17 @@ import java.util.Set;
*/
public class Token implements Serializable {
private static final Long serialVersionUID = 1L;
/** ID */
/**
* ID
*/
private long id;
/** 用户ID */
/**
* ID
*/
private long userId;
/** 用户名称 */
/**
*
*/
private String userName;
private Set<String> resourceSet = new HashSet<>();
@ -47,16 +53,16 @@ public class Token implements Serializable {
this.userName = userName;
}
public boolean hasResource(String resource){
public boolean hasResource(String resource) {
for (String s : resourceSet) {
if (resource.matches(s)){
if (resource.matches(s)) {
return true;
}
}
return false;
}
public void putResource(String resource){
public void putResource(String resource) {
resourceSet.add(resource);
}
@ -64,11 +70,11 @@ public class Token implements Serializable {
return resourceSet;
}
public void addResourceSet(Set<String> resourceSet){
public void addResourceSet(Set<String> resourceSet) {
this.resourceSet.addAll(resourceSet);
}
public void addResourceSet(Token token){
public void addResourceSet(Token token) {
addResourceSet(token.getResourceSet());
}
}

@ -1,8 +1,9 @@
package xyz.wbsite.dbtool.web.frame.utils;
import xyz.wbsite.dbtool.web.frame.auth.LocalData;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import xyz.wbsite.dbtool.web.frame.auth.LocalData;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
/**
* CookieUtil

@ -68,20 +68,20 @@ public class FileUtil {
}
public static byte[] toByteArray(InputStream input, int size) throws IOException {
if(size < 0) {
if (size < 0) {
throw new IllegalArgumentException("Size must be equal or greater than zero: " + size);
} else if(size == 0) {
} else if (size == 0) {
return new byte[0];
} else {
byte[] data = new byte[size];
int offset;
int read;
for(offset = 0; offset < size && (read = input.read(data, offset, size - offset)) != -1; offset += read) {
for (offset = 0; offset < size && (read = input.read(data, offset, size - offset)) != -1; offset += read) {
;
}
if(offset != size) {
if (offset != size) {
throw new IOException("Unexpected read size. current: " + offset + ", expected: " + size);
} else {
return data;

@ -1,9 +1,5 @@
package xyz.wbsite.dbtool.web.frame.utils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
* IDgenerator - ID
*

@ -17,40 +17,44 @@ public class LogUtil {
/**
* info
*
* @param context
*/
public static void i(String context){
public static void i(String context) {
logger.info(context);
}
/**
* debug
*
* @param context
*/
public static void d(String context){
public static void d(String context) {
logger.debug(context);
}
/**
* warn
*
* @param context
*/
public static void w(String context){
public static void w(String context) {
logger.warn(context);
}
/**
* error
*
* @param context
*/
public static void e(String context){
public static void e(String context) {
logger.error(context);
}
/**
*
*/
public static void dumpException(Throwable e){
public static void dumpException(Throwable e) {
StringBuffer msg = new StringBuffer("null");
if (e != null) {
msg = new StringBuffer("");

@ -1,9 +1,7 @@
package xyz.wbsite.dbtool.web.frame.utils;
import com.fasterxml.jackson.core.TreeNode;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Iterator;
/**
* MD5Util - MD5

@ -4,9 +4,14 @@ import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.TreeNode;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.*;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.dozer.DozerBeanMapper;
import org.dozer.Mapper;
import java.io.IOException;
import java.io.InputStream;
import java.util.List;
@ -32,7 +37,7 @@ public class MapperUtil {
//反序列化是忽略多余字段
om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
//支持空类序列化时出错InvalidDefinitionException
om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS,false);
om.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
mapper = new DozerBeanMapper();
}

@ -1,8 +1,6 @@
package xyz.wbsite.dbtool.web.frame.utils;
import java.awt.*;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
@ -16,6 +14,7 @@ import java.io.InputStreamReader;
public class ProcessUtil {
/**
* windowsexe
*
* @param path exe
*/
public static void execExe(String path) {
@ -30,6 +29,7 @@ public class ProcessUtil {
/**
* windows
*
* @param path
*/
public static void execBat(String path) {
@ -44,6 +44,7 @@ public class ProcessUtil {
/**
* windows cmd
*
* @param command cmd
*/
public static String execCmd(String command) {
@ -53,6 +54,7 @@ public class ProcessUtil {
/**
*
*
* @param command cmd
*/
public static String exec(String command) {

@ -3,7 +3,13 @@ package xyz.wbsite.dbtool.web.frame.utils;
import javax.crypto.Cipher;
import java.io.ByteArrayOutputStream;
import java.io.UnsupportedEncodingException;
import java.security.*;
import java.security.KeyFactory;
import java.security.KeyPair;
import java.security.KeyPairGenerator;
import java.security.NoSuchAlgorithmException;
import java.security.PrivateKey;
import java.security.PublicKey;
import java.security.Signature;
import java.security.interfaces.RSAPrivateKey;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.InvalidKeySpecException;

@ -3,18 +3,12 @@ package xyz.wbsite.dbtool.web.frame.utils;
import xyz.wbsite.dbtool.web.frame.base.BaseRequest;
import xyz.wbsite.dbtool.web.frame.base.BaseResponse;
import xyz.wbsite.dbtool.web.frame.base.ErrorType;
import javax.validation.ConstraintViolation;
import javax.validation.Validation;
import javax.validation.Validator;
import javax.validation.ValidatorFactory;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
*

@ -1,7 +1,16 @@
package xyz.wbsite.dbtool.web.frame.utils;
import javax.net.ssl.*;
import java.io.*;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLDecoder;

@ -1,6 +1,10 @@
package xyz.wbsite.dbtool.web.frame.utils;
import java.io.*;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

@ -2,7 +2,10 @@ package xyz.wbsite.dbtool.web.frame.validation;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD})
@Retention(RetentionPolicy.RUNTIME)

@ -1,4 +1,5 @@
import xyz.wbsite.dbtool.javafx.manger.ProjectManager;
import java.util.HashMap;
public class TestConnect {

Loading…
Cancel
Save

Powered by TurnKey Linux.