Skip to content

Commit 83ca602

Browse files
committed
fix bug: 数据库连接配置页面NPE
1 parent 408dbce commit 83ca602

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/main/java/com/zzg/mybatis/generator/controller/DbConnectionController.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class DbConnectionController extends BaseFXController {
3434
@FXML
3535
protected ChoiceBox<String> dbTypeChoice;
3636
protected MainUIController mainUIController;
37+
protected TabPaneController tabPaneController;
3738
protected boolean isUpdate = false;
3839
protected Integer primayKey;
3940

@@ -48,7 +49,7 @@ final void saveConnection() {
4849
}
4950
try {
5051
ConfigHelper.saveDatabaseConfig(this.isUpdate, primayKey, config);
51-
getDialogStage().close();
52+
this.tabPaneController.getDialogStage().close();
5253
mainUIController.loadLeftDBTree();
5354
} catch (Exception e) {
5455
_LOG.error(e.getMessage(), e);
@@ -61,6 +62,10 @@ void setMainUIController(MainUIController controller) {
6162
super.setDialogStage(mainUIController.getDialogStage());
6263
}
6364

65+
public void setTabPaneController(TabPaneController tabPaneController) {
66+
this.tabPaneController = tabPaneController;
67+
}
68+
6469
public DatabaseConfig extractConfigForUI() {
6570
String name = nameField.getText();
6671
String host = hostField.getText();

src/main/java/com/zzg/mybatis/generator/controller/OverSshController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ public void saveConfig() {
202202
}
203203
try {
204204
ConfigHelper.saveDatabaseConfig(this.isUpdate, primayKey, databaseConfig);
205-
getDialogStage().close();
205+
this.tabPaneController.getDialogStage().close();
206206
mainUIController.loadLeftDBTree();
207207
} catch (Exception e) {
208208
logger.error(e.getMessage(), e);

src/main/java/com/zzg/mybatis/generator/controller/TabPaneController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ public void initialize(URL location, ResourceBundle resources) {
5151
public void setMainUIController(MainUIController mainUIController) {
5252
this.mainUIController = mainUIController;
5353
this.tabControlAController.setMainUIController(mainUIController);
54+
this.tabControlAController.setTabPaneController(this);
5455
this.tabControlBController.setMainUIController(mainUIController);
56+
this.tabControlBController.setTabPaneController(this);
5557
}
5658

5759
public void setConfig(DatabaseConfig selectedConfig) {

0 commit comments

Comments
 (0)