diff --git a/README.md b/README.md index 8c8cfbc0..503cd7d5 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,10 @@ mybatis-generator-gui is a mybatis generator GUI tool, used to easy generate myb ![MainUI](https://cloud.githubusercontent.com/assets/3505708/16178144/35eabdcc-3673-11e6-9ff7-f701754f1550.png) +### Requirements +This tools require JRE 8.0, if you have JDK or JRE installed, you can download no jre version, otherwise +you need download jre bundled version. + ### Downloads ### Building from source diff --git a/home.png b/home.png deleted file mode 100644 index 57d3fce8..00000000 Binary files a/home.png and /dev/null differ diff --git a/src/main/java/com/zzg/mybatis/generator/controller/MainUIController.java b/src/main/java/com/zzg/mybatis/generator/controller/MainUIController.java index 940a4a19..32b7cb87 100644 --- a/src/main/java/com/zzg/mybatis/generator/controller/MainUIController.java +++ b/src/main/java/com/zzg/mybatis/generator/controller/MainUIController.java @@ -10,6 +10,7 @@ import com.zzg.mybatis.generator.util.DbUtil; import com.zzg.mybatis.generator.util.StringUtils; import com.zzg.mybatis.generator.util.XMLConfigHelper; +import com.zzg.mybatis.generator.view.AlertUtil; import com.zzg.mybatis.generator.view.LeftDbTreeCell; import com.zzg.mybatis.generator.view.UIProgressCallback; import javafx.collections.FXCollections; @@ -105,6 +106,7 @@ public void initialize(URL location, ResourceBundle resources) { int level = leftDBTree.getTreeItemLevel(cell.getTreeItem()); TreeCell treeCell = (TreeCell) event.getSource(); TreeItem item = treeCell.getTreeItem(); + item.setExpanded(true); if (level == 1) { DatabaseConfig selectedConfig = (DatabaseConfig) item.getGraphic().getUserData(); // Accept clicks only on node cells, and not on empty spaces of the TreeView @@ -134,12 +136,12 @@ public void initialize(URL location, ResourceBundle resources) { System.out.println("index: " + leftDBTree.getSelectionModel().getSelectedIndex()); DatabaseConfig selectedConfig = (DatabaseConfig) item.getParent().getGraphic().getUserData(); String schema = treeCell.getTreeItem().getValue(); - item.setExpanded(true); try { List tables = DbUtil.getTableNames(selectedConfig, schema); if (tables != null && tables.size() > 0) { + ObservableList> children = cell.getTreeItem().getChildren(); + children.clear(); for (String tableName : tables) { - ObservableList> children = cell.getTreeItem().getChildren(); TreeItem treeItem = new TreeItem<>(); ImageView imageView = new ImageView("icons/table.png"); imageView.setFitHeight(16); @@ -219,6 +221,10 @@ public void generateCode() throws Exception { tableConfig.setTableName(tableNameField.getText()); tableConfig.setDomainObjectName(domainObjectNameField.getText()); // JDBC config + if (selectedDatabaseConfig == null) { + AlertUtil.showInfoAlert("Please select the table from left DB tree"); + return; + } JDBCConnectionConfiguration jdbcConfig = new JDBCConnectionConfiguration(); jdbcConfig.setDriverClass(DbType.valueOf(selectedDatabaseConfig.getDbType()).getDriverClass()); jdbcConfig.setConnectionURL(DbUtil.getConnectionUrlWithSchema(selectedDatabaseConfig)); diff --git a/src/main/java/com/zzg/mybatis/generator/view/AlertUtil.java b/src/main/java/com/zzg/mybatis/generator/view/AlertUtil.java new file mode 100644 index 00000000..835dd178 --- /dev/null +++ b/src/main/java/com/zzg/mybatis/generator/view/AlertUtil.java @@ -0,0 +1,28 @@ +package com.zzg.mybatis.generator.view; + +import javafx.scene.control.Alert; + +/** + * Created by Owen on 6/21/16. + */ +public class AlertUtil { + + public static void showInfoAlert(String message) { + Alert alert = new Alert(Alert.AlertType.INFORMATION); + alert.setContentText(message); + alert.show(); + } + + public static void showWarnAlert(String message) { + Alert alert = new Alert(Alert.AlertType.WARNING); + alert.setContentText(message); + alert.show(); + } + + public static void showErrorAlert(String message) { + Alert alert = new Alert(Alert.AlertType.ERROR); + alert.setContentText(message); + alert.show(); + } + +} diff --git a/src/main/java/com/zzg/mybatis/generator/view/UIProgressCallback.java b/src/main/java/com/zzg/mybatis/generator/view/UIProgressCallback.java index 7ada2b42..2bdeb03e 100644 --- a/src/main/java/com/zzg/mybatis/generator/view/UIProgressCallback.java +++ b/src/main/java/com/zzg/mybatis/generator/view/UIProgressCallback.java @@ -1,5 +1,6 @@ package com.zzg.mybatis.generator.view; +import javafx.scene.control.Alert; import javafx.scene.control.TextArea; import org.mybatis.generator.api.ProgressCallback; @@ -48,6 +49,9 @@ public void startTask(String taskName) { public void done() { sb.append("generation done\n"); consoleTextArea.setText(sb.toString()); + Alert alert = new Alert(Alert.AlertType.INFORMATION); + alert.setContentText("Generation Completed"); + alert.show(); } @Override