架构升级

Former-commit-id: 317fb3cff92f9ca068a3e3a8f2797cc05df631ae
master
wangbing 4 years ago
parent c746bece96
commit 3fd54a5502

@ -10,8 +10,10 @@ import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.fxml.FXMLLoader;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.CheckBox;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.control.RadioButton;
@ -87,7 +89,7 @@ public class JavaFxApplication extends Application {
private ContextMenu table_right_menu;
private XEventHandler xEventHandler = new XEventHandler();
private boolean dragMD = false;
private Stage primaryStage;
public static Stage primaryStage;
@Override
public void start(Stage primaryStage) throws Exception {
@ -680,7 +682,31 @@ public class JavaFxApplication extends Application {
detailTableController.getAdd().setOnMouseClicked(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent event) {
Dialog.showInput(primaryStage, "新增业务", "请输入:");
Dialog.showInput("新增业务", "请输入:", new Dialog.InputCall() {
@Override
public void call(String input) {
if (input.matches("create|delete|update|find|get|search")){
Dialog.showYesNo("已经存在的基础业务方法!");
return;
}
for (Node node : detailTableController.getMethods().getChildren()) {
if (node instanceof CheckBox) {
CheckBox checkBox = (CheckBox) node;
if (input.equals(checkBox.getText())) {
Dialog.showYesNo("已经存在的业务方法!");
return;
}
}
}
CheckBox checkBox = new CheckBox(input);
checkBox.setSelected(true);
int size = detailTableController.getMethods().getChildren().size();
detailTableController.getMethods().getChildren().add(size - 1, checkBox);
}
});
}
});
}
@ -1487,6 +1513,8 @@ public class JavaFxApplication extends Application {
}
}
public static void main(String[] args) {
launch(args);
}

@ -148,14 +148,15 @@ public class MainController {
@FXML
public void modelDelete(ActionEvent actionEvent) {
Dialog.showConfirmDialog("确认删除当前模型?", new EventHandler() {
Dialog.showYesNo("", "确认删除当前模型?", new Dialog.ConfirmCall() {
@Override
public void handle(Event event) {
dBmanger.delete();
dBmanger.invalidate();
main.loadProjectTree();
main.loadProject();
public void call(boolean result) {
if (result){
dBmanger.delete();
dBmanger.invalidate();
main.loadProjectTree();
main.loadProject();
}
}
});
}

@ -283,21 +283,21 @@ public class ProjectManager {
public boolean doCheck() {
if (project.getName() == null || "".equals(project.getName())) {
Dialog.showConfirmDialog("没有填写项目名!");
Dialog.showYesNo("没有填写项目名!");
return false;
} else if (project.getDomain() == null || "".equals(project.getDomain())) {
Dialog.showConfirmDialog("没有填写基本域名!");
Dialog.showYesNo("没有填写基本域名!");
return false;
} else if (project.getAuthor() == null || "".equals(project.getAuthor())) {
Dialog.showConfirmDialog("没有填写作者!");
Dialog.showYesNo("没有填写作者!");
return false;
}
for (Module md : project.getModules()) {
if (md.getModuleName() == null || "".equals(md.getModuleName())) {
Dialog.showConfirmDialog("项目" + project.getName() + "没有填写模块名!");
Dialog.showYesNo("项目" + project.getName() + "没有填写模块名!");
return false;
} else if (md.getModuleComment() == null || "".equals(md.getModuleComment())) {
Dialog.showConfirmDialog("项目" + project.getName() + "没有模块注释!");
Dialog.showYesNo("项目" + project.getName() + "没有模块注释!");
return false;
}
}

@ -14,6 +14,8 @@ import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ButtonBar;
import javafx.scene.control.ButtonType;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressIndicator;
@ -29,6 +31,7 @@ import javafx.stage.Modality;
import javafx.stage.Stage;
import javafx.stage.WindowEvent;
import xyz.wbsite.dbtool.Application;
import xyz.wbsite.dbtool.javafx.JavaFxApplication;
import xyz.wbsite.dbtool.javafx.ctrl.ConnectInfoController;
import xyz.wbsite.dbtool.javafx.ctrl.OptionAndroidController;
import xyz.wbsite.dbtool.javafx.ctrl.OptionApiController;
@ -104,57 +107,29 @@ public class Dialog {
thread.start();
}
public static void showConfirmDialog(String message) {
popup = new Stage();
popup.setWidth(250);
popup.setHeight(160);
popup.setAlwaysOnTop(true);
popup.initModality(Modality.WINDOW_MODAL);
final Button closeBtn = new Button("确认");
closeBtn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
popup.close();
}
});
public static void showYesNo(String message) {
showYesNo("提示", message, null);
}
VBox root = new VBox();
root.setPadding(new Insets(10));
root.setAlignment(Pos.BASELINE_CENTER);
root.setSpacing(10);
Label label = new Label(message);
root.getChildren().addAll(label, closeBtn);
Scene scene = new Scene(root);
popup.setScene(scene);
popup.setTitle("提示信息");
popup.show();
public static void showYesNo(String title, String message) {
showYesNo(title, message, null);
}
public static void showConfirmDialog(String message, EventHandler handler) {
popup = new Stage();
popup.setAlwaysOnTop(true);
popup.setWidth(250);
popup.setHeight(160);
popup.initModality(Modality.APPLICATION_MODAL);
final Button okBtn = new Button("确认");
okBtn.setOnAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent event) {
popup.close();
handler.handle(event);
public static void showYesNo(String title, String message, ConfirmCall call) {
Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
alert.setHeaderText(null);
alert.setTitle(title);
alert.setContentText(message);
alert.setX(JavaFxApplication.primaryStage.getX() + JavaFxApplication.primaryStage.getWidth() / 2 - 213);
alert.setY(JavaFxApplication.primaryStage.getY() + JavaFxApplication.primaryStage.getHeight() / 2 - 70);
Optional<ButtonType> buttonType = alert.showAndWait();
if (call != null) {
if (buttonType.get().getButtonData().equals(ButtonBar.ButtonData.YES)) {
call.call(true);
} else {
call.call(false);
}
});
VBox root = new VBox();
root.setPadding(new Insets(10));
root.setAlignment(Pos.BASELINE_CENTER);
root.setSpacing(10);
Label label = new Label(message);
root.getChildren().addAll(label, okBtn);
Scene scene = new Scene(root);
popup.setScene(scene);
popup.setTitle("提示信息");
popup.show();
}
}
public static void showError(String message) {
@ -280,9 +255,9 @@ public class Dialog {
map.put("driverClassName", driver);
boolean b = ProjectManager.testConnect(map);
if (b) {
Dialog.showConfirmDialog("连接成功!");
Dialog.showYesNo("连接成功!");
} else {
Dialog.showConfirmDialog("连接失败!");
Dialog.showYesNo("连接失败!");
}
}
});
@ -297,22 +272,22 @@ public class Dialog {
String password = controller.getPassword().getText();
if (driver == null || driver.equals("")) {
Dialog.showConfirmDialog("驱动名称不能为空!");
Dialog.showYesNo("驱动名称不能为空!");
return;
} else if (url == null || url.equals("")) {
Dialog.showConfirmDialog("连接不能为空!");
Dialog.showYesNo("连接不能为空!");
return;
} else if (userName == null || userName.equals("")) {
Dialog.showConfirmDialog("用户名不能为空!");
Dialog.showYesNo("用户名不能为空!");
return;
} else if (password == null || password.equals("")) {
Dialog.showConfirmDialog("密码不能为空!");
Dialog.showYesNo("密码不能为空!");
return;
}
for (Module db : ManagerFactory.getProjectManager().getMds()) {
if (db.getModuleName().equals(userName)) {
Dialog.showConfirmDialog("已经存的模块!");
Dialog.showYesNo("已经存的模块!");
return;
}
}
@ -514,7 +489,7 @@ public class Dialog {
}
});
} else {
Dialog.showConfirmDialog("项目不存在!");
Dialog.showYesNo("项目不存在!");
}
}
});
@ -673,7 +648,7 @@ public class Dialog {
}
});
} else {
Dialog.showConfirmDialog("项目不存在!");
Dialog.showYesNo("项目不存在!");
}
}
});
@ -704,6 +679,8 @@ public class Dialog {
stage.setScene(scene);
stage.setTitle("编辑选项");
stage.setX(JavaFxApplication.primaryStage.getX() + JavaFxApplication.primaryStage.getWidth() / 2 - 150);
stage.setY(JavaFxApplication.primaryStage.getY() + JavaFxApplication.primaryStage.getHeight() / 2 - 100);
OptionSelectController controller = dbdetailloader.getController();
controller.setData(field.getSelectItems());
@ -760,7 +737,6 @@ public class Dialog {
}
}
public static void showAndroid() {
FXMLLoader dbdetailloader = new FXMLLoader(Application.class.getResource("../../../fxml/OptionAndroid.fxml"));
try {
@ -876,24 +852,16 @@ public class Dialog {
popup.show();
}
public static void showInput(Stage stage, String title, String hint) {
TextInputDialog dialog = new TextInputDialog("");
public static void showInput(String title, String hint, InputCall inputCall) {
TextInputDialog dialog = new TextInputDialog();
dialog.setTitle(title);
dialog.setHeaderText(null);
dialog.setContentText(hint);
double x = stage.getX();
double y = stage.getY();
double width = stage.getWidth();
double height = stage.getHeight();
double awidth = dialog.getWidth();
double aheight = dialog.getHeight();
dialog.setX(stage.getX() + stage.getWidth() / 2);
dialog.setY(stage.getY() + stage.getHeight() / 2 );
dialog.setX(JavaFxApplication.primaryStage.getX() + JavaFxApplication.primaryStage.getWidth() / 2 - 140);
dialog.setY(JavaFxApplication.primaryStage.getY() + JavaFxApplication.primaryStage.getHeight() / 2 - 70);
Optional<String> result = dialog.showAndWait();
if (result.isPresent()) {
System.out.println("Your name: " + result.get());
inputCall.call(result.get());
}
}
@ -906,6 +874,13 @@ public class Dialog {
controller.initData();
}
public interface InputCall {
void call(String input);
}
public interface ConfirmCall {
void call(boolean result);
}
private static File findAction(File file) {
if (file == null) {

@ -5,14 +5,9 @@
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.ColumnConstraints?>
<?import javafx.scene.layout.FlowPane?>
<?import javafx.scene.layout.GridPane?>
<?import javafx.scene.layout.HBox?>
<?import javafx.scene.layout.RowConstraints?>
<?import javafx.scene.layout.*?>
<GridPane maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
xmlns="http://javafx.com/javafx/8.0.112" xmlns:fx="http://javafx.com/fxml/1"
xmlns="http://javafx.com/javafx/8.0.101" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="xyz.wbsite.dbtool.javafx.ctrl.DetailTableController">
<columnConstraints>
<ColumnConstraints hgrow="SOMETIMES" prefWidth="10.0"/>
@ -71,7 +66,11 @@
<FlowPane fx:id="methods" alignment="CENTER_LEFT" GridPane.columnIndex="2" GridPane.halignment="CENTER"
GridPane.rowIndex="4" GridPane.valignment="CENTER">
<children>
<Button fx:id="add" mnemonicParsing="false" text="+"/>
<Button fx:id="add" mnemonicParsing="false" text="+">
<FlowPane.margin>
<Insets left="1.0"/>
</FlowPane.margin>
</Button>
</children>
</FlowPane>
</children>

@ -598,7 +598,7 @@
//typeof rfs != "undefined" && rfs
if (rfs) {
rfs.call(el);
rfs.inputCall(el);
} else if (typeof window.ActiveXObject !== "undefined") {
//for IE这里其实就是模拟了按下键盘的F11使浏览器全屏
var wscript = new ActiveXObject("WScript.Shell");
@ -614,7 +614,7 @@
//typeof cfs != "undefined" && cfs
if (cfs) {
cfs.call(el);
cfs.inputCall(el);
} else if (typeof window.ActiveXObject !== "undefined") {
//for IE这里和fullScreen相同模拟按下F11键退出全屏
var wscript = new ActiveXObject("WScript.Shell");

@ -184,13 +184,13 @@
location.href = "${context}/app/index.htm"
}
},
handleFile: function (file, call) {
handleFile: function (file, inputCall) {
//do upload
console.log("正在上传文件" + file.name);
if (true) {
call.finish();
inputCall.finish();
} else {
call.cancel();
inputCall.cancel();
}
}
}

Loading…
Cancel
Save

Powered by TurnKey Linux.