架构调整

Former-commit-id: 214182c5c077112b4c6b99fce293cfa751e784c3
master
王兵 4 years ago
parent 7b6e0a56bc
commit 3ba50c0534

@ -114,29 +114,24 @@ public class MainController {
@FXML
public void modelSave(ActionEvent actionEvent) {
if (dBmanger.getPath() == null || "".equals(dBmanger.getPath())) {
DirectoryChooser directoryChooser = new DirectoryChooser();
Stage stage = new Stage();
File file = directoryChooser.showDialog(stage);
if (file == null) {
System.err.println("请选择目录!");
} else {
dBmanger.setPath(file);
System.out.println(file.getAbsolutePath());
}
Dialog.showDirectoryChooser(null, new Dialog.DirectoryCall() {
@Override
public void call(File result) {
dBmanger.setPath(result.getAbsoluteFile());
}
});
}
dBmanger.save();
}
@FXML
public void modelSaveAs(ActionEvent actionEvent) {
DirectoryChooser directoryChooser = new DirectoryChooser();
Stage stage = new Stage();
File file = directoryChooser.showDialog(stage);
if (file != null) {
dBmanger.save(file);
}
Dialog.showDirectoryChooser(null, new Dialog.DirectoryCall() {
@Override
public void call(File result) {
dBmanger.save(result);
}
});
}
@FXML
@ -170,15 +165,13 @@ public class MainController {
public void modelGenerate(ActionEvent actionEvent) {
this.modelSave(null);
if (dBmanger.doCheck()) {
DirectoryChooser directoryChooser = new DirectoryChooser();
directoryChooser.setInitialDirectory(dBmanger.getPath());
Stage stage = new Stage();
File file = directoryChooser.showDialog(stage);
if (file != null) {
System.out.println("生成目录:" + file.getAbsolutePath());
dBmanger.generate(ManagerFactory.getProjectManager().getProject(), file);
}
Dialog.showDirectoryChooser(dBmanger.getPath(), new Dialog.DirectoryCall() {
@Override
public void call(File result) {
System.out.println("生成目录:" + result.getAbsolutePath());
dBmanger.generate(ManagerFactory.getProjectManager().getProject(), result);
}
});
}
}

@ -331,9 +331,10 @@ public class ProjectManager {
*/
public void generate(Project project, final File root) {
if (!root.exists()) {
Dialog.showTimedDialog(1000, "目录不存在!");
Dialog.showYesNo("目录不存在!");
return;
}
Dialog.showProgress("生成中...");
Dialog.showWait("生成中...");
service.execute(new Runnable() {
@Override
@ -348,7 +349,7 @@ public class ProjectManager {
} catch (ExecutionException e) {
e.printStackTrace();
}
Dialog.stopPopup();
Dialog.stopWait();
Dialog.showSuccess("生成完毕.");
}
});
@ -356,7 +357,7 @@ public class ProjectManager {
public void generateApi(File module, File api, List<String> domainList, List<Api> apis) {
if (module.exists()) {
Dialog.showProgress("生成中...");
Dialog.showWait("生成中...");
service.execute(new Runnable() {
@Override
@ -375,7 +376,7 @@ public class ProjectManager {
e.printStackTrace();
}
Dialog.stopPopup();
Dialog.stopWait();
Dialog.showSuccess("Api生成完毕.");
}
});
@ -384,7 +385,7 @@ public class ProjectManager {
public void generateDoc(File module, File api, List<Doc> apis) {
if (module.exists()) {
Dialog.showProgress("生成中...");
Dialog.showWait("生成中...");
service.execute(new Runnable() {
@Override
@ -403,7 +404,7 @@ public class ProjectManager {
e.printStackTrace();
}
Dialog.stopPopup();
Dialog.stopWait();
Dialog.showSuccess("Doc生成完毕.");
}
});
@ -412,7 +413,7 @@ public class ProjectManager {
public void generate(final String path, AndroidOption option) {
Dialog.showProgress("生成中...");
Dialog.showWait("生成中...");
new Thread() {
@Override
public void run() {
@ -430,14 +431,14 @@ public class ProjectManager {
e.printStackTrace();
}
Dialog.stopPopup();
Dialog.stopWait();
Dialog.showSuccess("Android生成完毕.");
}
}.start();
}
public void generate(final String path, VueOption option) {
Dialog.showProgress("生成中...");
Dialog.showWait("生成中...");
new Thread() {
@Override
public void run() {
@ -455,7 +456,7 @@ public class ProjectManager {
e.printStackTrace();
}
Dialog.stopPopup();
Dialog.stopWait();
Dialog.showSuccess("Vue生成完毕.");
}
}.start();

@ -31,7 +31,6 @@ import javafx.stage.DirectoryChooser;
import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import javafx.util.Callback;
import xyz.wbsite.dbtool.Application;
import xyz.wbsite.dbtool.javafx.JavaFxApplication;
import xyz.wbsite.dbtool.javafx.ctrl.ConnectInfoController;
@ -49,6 +48,7 @@ import xyz.wbsite.dbtool.javafx.po.Field;
import xyz.wbsite.dbtool.javafx.po.Module;
import xyz.wbsite.dbtool.javafx.po.SelectItem;
import xyz.wbsite.dbtool.javafx.po.VueOption;
import xyz.wbsite.dbtool.web.frame.utils.StringUtil;
import java.io.File;
import java.io.IOException;
@ -139,9 +139,11 @@ public class Dialog {
public void run() {
Alert alert = new Alert(Alert.AlertType.ERROR);
alert.setTitle("错误");
alert.setX(JavaFxApplication.primaryStage.getX() + JavaFxApplication.primaryStage.getWidth() / 2 - 213);
alert.setY(JavaFxApplication.primaryStage.getY() + JavaFxApplication.primaryStage.getHeight() / 2 - 70);
alert.setHeaderText("");
alert.setContentText(message);
alert.showAndWait();
alert.show();
}
});
}
@ -151,55 +153,66 @@ public class Dialog {
public void run() {
Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("消息");
alert.setX(JavaFxApplication.primaryStage.getX() + JavaFxApplication.primaryStage.getWidth() / 2 - 213);
alert.setY(JavaFxApplication.primaryStage.getY() + JavaFxApplication.primaryStage.getHeight() / 2 - 70);
alert.setHeaderText("");
alert.setContentText(message);
alert.showAndWait();
alert.show();
}
});
}
public static void showProgress(String message) {
if (popup != null) {
popup.close();
private static javafx.scene.control.Dialog dialog = null;
public static void showWait(String message) {
if (dialog == null) {
dialog = new javafx.scene.control.Dialog();
dialog.setTitle("提示");
dialog.setResult("1");
dialog.setX(JavaFxApplication.primaryStage.getX() + JavaFxApplication.primaryStage.getWidth() / 2 - 68);
dialog.setY(JavaFxApplication.primaryStage.getY() + JavaFxApplication.primaryStage.getHeight() / 2 - 70);
GridPane gridPane = new GridPane();
gridPane.setPrefWidth(200);
gridPane.setHgap(10);
gridPane.setVgap(10);
gridPane.setAlignment(Pos.CENTER);
gridPane.setPadding(new Insets(10, 10, 10, 10));
dialog.getDialogPane().setContent(gridPane);
ProgressIndicator indicator = new ProgressIndicator();
indicator.setPrefSize(30, 30);
gridPane.add(indicator, 0, 0);
gridPane.add(new Label(message), 0, 1);
dialog.show();
}
popup = new Stage();
popup.setAlwaysOnTop(true);
popup.initModality(Modality.APPLICATION_MODAL);
ProgressIndicator indicator = new ProgressIndicator();
indicator.setPrefSize(30, 30);
VBox root = new VBox();
root.setPadding(new Insets(50, 80, 50, 80));
root.setAlignment(Pos.BASELINE_CENTER);
root.setSpacing(10);
Label label = new Label(message);
root.getChildren().addAll(indicator, label);
Scene scene = new Scene(root);
popup.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
event.consume();
}
});
popup.setScene(scene);
popup.setTitle("提示");
popup.show();
}
public static void stopPopup() {
if (popup != null) {
public static void stopWait() {
if (dialog != null) {
Platform.runLater(new Runnable() {
@Override
public void run() {
popup.close();
dialog.close();
dialog = null;
}
});
}
}
public static void showDirectoryChooser(File file, DirectoryCall call) {
DirectoryChooser directoryChooser = new DirectoryChooser();
directoryChooser.setInitialDirectory(file);
Stage stage = new Stage();
stage.setX(JavaFxApplication.primaryStage.getX());
stage.setY(JavaFxApplication.primaryStage.getY());
File file_ = directoryChooser.showDialog(stage);
if (file_ != null && call != null) {
call.call(file_);
}
}
public static void showDBConnectInput() {
Stage stage = new Stage();
stage.setAlwaysOnTop(true);
@ -301,7 +314,7 @@ public class Dialog {
map.put("password", password);
map.put("driverClassName", driver);
Dialog.showProgress("加载中,请稍等...");
Dialog.showWait("加载中,请稍等...");
new Thread() {
@Override
public void run() {
@ -309,7 +322,7 @@ public class Dialog {
Platform.runLater(new Runnable() {
@Override
public void run() {
Dialog.stopPopup();
Dialog.stopWait();
stage.close();
}
});
@ -353,45 +366,40 @@ public class Dialog {
controller.getSelectModulePath().setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
DirectoryChooser directoryChooser = new DirectoryChooser();
Stage stage = new Stage();
stage.setAlwaysOnTop(true);
File file = directoryChooser.showDialog(stage);
if (file == null) {
return;
}
modulePath.setText(file.getAbsolutePath());
String projectName = "";
// 尝试查找Windows下的项目名称
String path = file.getAbsolutePath();
String pathReplace = Tool.replaceSeparator(path, "#");
Pattern compile = Pattern.compile("#([^#]*)#src#main#java#");
Matcher matcher = compile.matcher(pathReplace);
if (matcher.find()) {
projectName = matcher.group(1);
}
Dialog.showDirectoryChooser(null, new Dialog.DirectoryCall() {
@Override
public void call(File result) {
modulePath.setText(result.getAbsolutePath());
String projectName = "";
// 尝试查找Windows下的项目名称
String path = result.getAbsolutePath();
String pathReplace = Tool.replaceSeparator(path, "#");
Pattern compile = Pattern.compile("#([^#]*)#src#main#java#");
Matcher matcher = compile.matcher(pathReplace);
if (matcher.find()) {
projectName = matcher.group(1);
}
apiPath.setText(new File(ProjectManager.getPath(), projectName + "-api").getAbsolutePath());
apiPath.setText(new File(ProjectManager.getPath(), projectName + "-api").getAbsolutePath());
}
});
}
});
controller.getSelectSdkPath().setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
DirectoryChooser directoryChooser = new DirectoryChooser();
Stage stage = new Stage();
File file = directoryChooser.showDialog(stage);
if (file == null) {
return;
}
String text = modulePath.getText();
File moduleFile = new File(text);
Dialog.showDirectoryChooser(null, new Dialog.DirectoryCall() {
@Override
public void call(File result) {
String text = modulePath.getText();
File moduleFile = new File(text);
apiPath.setText(new File(file.getAbsolutePath(), moduleFile.getName() + "-api").getAbsolutePath());
System.out.println(file.getAbsolutePath());
apiPath.setText(new File(result.getAbsolutePath(), moduleFile.getName() + "-api").getAbsolutePath());
System.out.println(result.getAbsolutePath());
}
});
}
});
@ -442,12 +450,12 @@ public class Dialog {
modulePath.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
Dialog.showProgress("初始化面板");
Dialog.showWait("初始化面板");
Callable<Object> callable = Executors.callable(new Runnable() {
@Override
public void run() {
controller.load();
Dialog.stopPopup();
Dialog.stopWait();
}
});
Executors.newSingleThreadExecutor().submit(callable);
@ -481,9 +489,9 @@ public class Dialog {
String api = controller.getApiPath().getText();
if (new File(module).exists()) {
Dialog.showProgress("生成中...");
Dialog.showWait("生成中...");
dBmanger.generateApi(new File(module), new File(api), controller.getDomainList(), controller.getData());
Dialog.stopPopup();
Dialog.stopWait();
Platform.runLater(new Runnable() {
@Override
public void run() {
@ -531,45 +539,40 @@ public class Dialog {
controller.getSelectModulePath().setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
DirectoryChooser directoryChooser = new DirectoryChooser();
Stage stage = new Stage();
stage.setAlwaysOnTop(true);
File file = directoryChooser.showDialog(stage);
if (file == null) {
return;
}
modulePath.setText(file.getAbsolutePath());
String projectName = "";
// 尝试查找Windows下的项目名称
String path = file.getAbsolutePath();
String pathReplace = Tool.replaceSeparator(path, "#");
Pattern compile = Pattern.compile("#([^#]*)#src#main#java#");
Matcher matcher = compile.matcher(pathReplace);
if (matcher.find()) {
projectName = matcher.group(1);
}
Dialog.showDirectoryChooser(null, new Dialog.DirectoryCall() {
@Override
public void call(File result) {
modulePath.setText(result.getAbsolutePath());
String projectName = "";
// 尝试查找Windows下的项目名称
String path = result.getAbsolutePath();
String pathReplace = Tool.replaceSeparator(path, "#");
Pattern compile = Pattern.compile("#([^#]*)#src#main#java#");
Matcher matcher = compile.matcher(pathReplace);
if (matcher.find()) {
projectName = matcher.group(1);
}
docPath.setText(new File(ProjectManager.getPath(), projectName + "-doc").getAbsolutePath());
docPath.setText(new File(ProjectManager.getPath(), projectName + "-doc").getAbsolutePath());
}
});
}
});
controller.getSelectDocPath().setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
DirectoryChooser directoryChooser = new DirectoryChooser();
Stage stage = new Stage();
File file = directoryChooser.showDialog(stage);
if (file == null) {
return;
}
String text = modulePath.getText();
File moduleFile = new File(text);
Dialog.showDirectoryChooser(null, new Dialog.DirectoryCall() {
@Override
public void call(File result) {
String text = modulePath.getText();
File moduleFile = new File(text);
docPath.setText(new File(file.getAbsolutePath(), moduleFile.getName() + "-doc").getAbsolutePath());
System.out.println(file.getAbsolutePath());
docPath.setText(new File(result.getAbsolutePath(), moduleFile.getName() + "-doc").getAbsolutePath());
System.out.println(result.getAbsolutePath());
}
});
}
});
@ -601,12 +604,12 @@ public class Dialog {
modulePath.textProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
Dialog.showProgress("初始化面板");
Dialog.showWait("初始化面板");
Callable<Object> callable = Executors.callable(new Runnable() {
@Override
public void run() {
controller.load();
Dialog.stopPopup();
Dialog.stopWait();
}
});
Executors.newSingleThreadExecutor().submit(callable);
@ -640,9 +643,9 @@ public class Dialog {
String api = controller.getDocPath().getText();
if (new File(module).exists()) {
Dialog.showProgress("生成中...");
Dialog.showWait("生成中...");
dBmanger.generateDoc(new File(module), new File(api), controller.getData());
Dialog.stopPopup();
Dialog.stopWait();
Platform.runLater(new Runnable() {
@Override
public void run() {
@ -714,7 +717,7 @@ public class Dialog {
start.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
Dialog.stopPopup();
Dialog.stopWait();
Platform.runLater(new Runnable() {
@Override
public void run() {
@ -752,32 +755,24 @@ public class Dialog {
controller.getCancel().setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
stopPopup();
stopWait();
}
});
controller.getOk().setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
ProjectManager dBmanger = ManagerFactory.getProjectManager();
DirectoryChooser directoryChooser = new DirectoryChooser();
directoryChooser.setInitialDirectory(dBmanger.getPath());
Stage stage = new Stage();
File file = directoryChooser.showDialog(stage);
if (file != null) {
System.out.println("生成目录:" + file.getAbsolutePath());
AndroidOption androidOption = new AndroidOption();
androidOption.projectName = controller.getName().getText();
androidOption.packages = controller.getPackages().getText();
androidOption.domain = controller.getDomain().getText();
dBmanger.generate(file.getAbsolutePath(), androidOption);
Platform.runLater(new Runnable() {
@Override
public void run() {
stage.close();
}
});
}
Dialog.showDirectoryChooser(dBmanger.getPath(), new Dialog.DirectoryCall() {
@Override
public void call(File result) {
System.out.println("生成目录:" + result.getAbsolutePath());
AndroidOption androidOption = new AndroidOption();
androidOption.projectName = controller.getName().getText();
androidOption.packages = controller.getPackages().getText();
androidOption.domain = controller.getDomain().getText();
dBmanger.generate(result.getAbsolutePath(), androidOption);
}
});
}
});
@ -789,7 +784,7 @@ public class Dialog {
popup.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
stopPopup();
stopWait();
}
});
popup.setScene(scene);
@ -810,31 +805,24 @@ public class Dialog {
controller.getCancel().setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
stopPopup();
stopWait();
}
});
controller.getOk().setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
ProjectManager dBmanger = ManagerFactory.getProjectManager();
DirectoryChooser directoryChooser = new DirectoryChooser();
directoryChooser.setInitialDirectory(dBmanger.getPath());
Stage stage = new Stage();
File file = directoryChooser.showDialog(stage);
if (file != null) {
System.out.println("生成目录:" + file.getAbsolutePath());
VueOption vueOption = new VueOption();
ToggleGroup type = controller.getType();
RadioButton value = (RadioButton) type.selectedToggleProperty().getValue();
vueOption.type = value.textProperty().getValue();
dBmanger.generate(file.getAbsolutePath(), vueOption);
Platform.runLater(new Runnable() {
@Override
public void run() {
stage.close();
}
});
}
Dialog.showDirectoryChooser(null, new Dialog.DirectoryCall() {
@Override
public void call(File result) {
System.out.println("生成目录:" + result.getAbsolutePath());
VueOption vueOption = new VueOption();
ToggleGroup type = controller.getType();
RadioButton value = (RadioButton) type.selectedToggleProperty().getValue();
vueOption.type = value.textProperty().getValue();
dBmanger.generate(result.getAbsolutePath(), vueOption);
}
});
}
});
@ -846,7 +834,7 @@ public class Dialog {
popup.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
stopPopup();
stopWait();
}
});
popup.setScene(scene);
@ -872,7 +860,8 @@ public class Dialog {
dialog.setTitle(title);
dialog.getDialogPane().getButtonTypes().addAll(ButtonType.OK, ButtonType.CANCEL);
dialog.setX(JavaFxApplication.primaryStage.getX() + JavaFxApplication.primaryStage.getWidth() / 2 - 115);
dialog.setY(JavaFxApplication.primaryStage.getY() + JavaFxApplication.primaryStage.getHeight() / 2 - 70);
GridPane gridPane = new GridPane();
gridPane.setHgap(10);
gridPane.setVgap(10);
@ -889,22 +878,15 @@ public class Dialog {
gridPane.add(new Label("业务注释:"), 0, 1);
gridPane.add(noteField, 1, 1);
dialog.setResultConverter(new Callback() {
@Override
public Object call(Object param) {
Map<String, String> hashMap = new HashMap<>();
if (param == ButtonType.OK) {
hashMap.put("name", nameField.getText());
hashMap.put("note", noteField.getText());
}
return hashMap;
Optional<ButtonType> optional = dialog.showAndWait();
if (optional.isPresent() && optional.get() == ButtonType.OK) {
String name = nameField.getText();
String note = noteField.getText();
if (StringUtil.isEmpty(name)) {
Dialog.showYesNo("业务方法不能为空");
} else if (inputCall != null) {
inputCall.call(name, note);
}
});
Optional optional = dialog.showAndWait();
if (optional.isPresent()) {
Map<String, String> map = (Map<String, String>) optional.get();
inputCall.call(map.get("name"),map.get("note"));
}
}
@ -922,13 +904,17 @@ public class Dialog {
}
public interface InputMethodCall {
void call(String name,String note);
void call(String name, String note);
}
public interface ConfirmCall {
void call(boolean result);
}
public interface DirectoryCall {
void call(File result);
}
private static File findAction(File file) {
if (file == null) {
return null;

Loading…
Cancel
Save

Powered by TurnKey Linux.