|
|
|
@ -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) {
|
|
|
|
|