架构调整

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

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

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

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

Loading…
Cancel
Save

Powered by TurnKey Linux.