Skip to content

Commit

Permalink
improved some UI and imporve README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
zouzg committed Jun 21, 2016
1 parent 6f00e53 commit 62c93da
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file removed home.png
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -105,6 +106,7 @@ public void initialize(URL location, ResourceBundle resources) {
int level = leftDBTree.getTreeItemLevel(cell.getTreeItem());
TreeCell<String> treeCell = (TreeCell<String>) event.getSource();
TreeItem<String> 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
Expand Down Expand Up @@ -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<String> tables = DbUtil.getTableNames(selectedConfig, schema);
if (tables != null && tables.size() > 0) {
ObservableList<TreeItem<String>> children = cell.getTreeItem().getChildren();
children.clear();
for (String tableName : tables) {
ObservableList<TreeItem<String>> children = cell.getTreeItem().getChildren();
TreeItem<String> treeItem = new TreeItem<>();
ImageView imageView = new ImageView("icons/table.png");
imageView.setFitHeight(16);
Expand Down Expand Up @@ -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));
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/com/zzg/mybatis/generator/view/AlertUtil.java
Original file line number Diff line number Diff line change
@@ -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();
}

}
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 62c93da

Please sign in to comment.