diff --git a/pom.xml b/pom.xml
index 0a2db26c..dc4186d9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -11,19 +11,9 @@
- org.apache.httpcomponents
- httpclient
- 4.3.2
-
-
- org.apache.httpcomponents
- httpcore
- 4.3.2
-
-
- org.apache.httpcomponents
- httpmime
- 4.3.4
+ org.mybatis.generator
+ mybatis-generator-core
+ 1.3.2
ch.qos.logback
@@ -35,11 +25,6 @@
logback-core
1.1.2
-
- org.springframework.session
- spring-session-data-redis
- 1.2.0.RC2
-
diff --git a/src/main/java/com/zzg/mybatis/generator/MainUI.java b/src/main/java/com/zzg/mybatis/generator/MainUI.java
index 9734ca22..d2b56048 100644
--- a/src/main/java/com/zzg/mybatis/generator/MainUI.java
+++ b/src/main/java/com/zzg/mybatis/generator/MainUI.java
@@ -2,25 +2,30 @@
import java.net.URL;
+import com.zzg.mybatis.generator.controller.MainUIController;
+
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
+import javafx.stage.StageStyle;
public class MainUI extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
- ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
-
- URL skeletonResource = classLoader.getResource("MainUI.fxml");
-
- Parent root = FXMLLoader.load(skeletonResource);
-
+ URL url = Thread.currentThread().getContextClassLoader().getResource("MainUI.fxml");
+ FXMLLoader fxmlLoader = new FXMLLoader(url);
+ Parent root = fxmlLoader.load();
+ //primaryStage.initStyle(StageStyle.TRANSPARENT);
+ primaryStage.setResizable(false);
primaryStage.setScene(new Scene(root));
-
primaryStage.show();
+
+
+ MainUIController controller = fxmlLoader.getController();
+ controller.setPrimaryStage(primaryStage);
}
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 facd590c..715fc7a7 100644
--- a/src/main/java/com/zzg/mybatis/generator/controller/MainUIController.java
+++ b/src/main/java/com/zzg/mybatis/generator/controller/MainUIController.java
@@ -1,151 +1,179 @@
package com.zzg.mybatis.generator.controller;
+import java.io.File;
import java.net.URL;
-import java.util.Collection;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
import java.util.ResourceBundle;
import java.util.Set;
-import java.util.stream.Collectors;
-
-import org.springframework.data.redis.connection.DataType;
-import org.springframework.data.redis.connection.RedisNode;
-import org.springframework.data.redis.connection.RedisSentinelConfiguration;
-import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
-import org.springframework.data.redis.core.StringRedisTemplate;
-import org.springframework.data.redis.core.ZSetOperations.TypedTuple;
-import org.springframework.data.redis.serializer.StringRedisSerializer;
-
-import javafx.collections.FXCollections;
-import javafx.collections.ObservableList;
+
+import org.mybatis.generator.api.MyBatisGenerator;
+import org.mybatis.generator.api.ProgressCallback;
+import org.mybatis.generator.api.ShellCallback;
+import org.mybatis.generator.api.VerboseProgressCallback;
+import org.mybatis.generator.config.Configuration;
+import org.mybatis.generator.config.Context;
+import org.mybatis.generator.config.JDBCConnectionConfiguration;
+import org.mybatis.generator.config.JavaClientGeneratorConfiguration;
+import org.mybatis.generator.config.JavaModelGeneratorConfiguration;
+import org.mybatis.generator.config.ModelType;
+import org.mybatis.generator.config.SqlMapGeneratorConfiguration;
+import org.mybatis.generator.config.TableConfiguration;
+import org.mybatis.generator.internal.DefaultShellCallback;
+
+import com.zzg.mybatis.generator.model.DatabaseDTO;
+
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
-import javafx.scene.control.Button;
-import javafx.scene.control.Label;
-import javafx.scene.control.ListView;
+import javafx.scene.control.ChoiceBox;
import javafx.scene.control.TextField;
-import javafx.scene.control.TreeItem;
-import javafx.scene.control.TreeView;
+import javafx.scene.text.Text;
+import javafx.stage.DirectoryChooser;
+import javafx.stage.FileChooser;
+import javafx.stage.FileChooser.ExtensionFilter;
+import javafx.stage.Stage;
public class MainUIController implements Initializable {
@FXML
- private TextField nodesField;
+ private ChoiceBox dbTypeChoice;
@FXML
- private TextField masterField;
+ private TextField driverClassField;
@FXML
- private TextField databaseField;
-
+ private TextField connectorFileField;
@FXML
- private Label connectStatusLabel;
-
+ private TextField connectionUrlField;
@FXML
- private Label typeLabel;
-
+ private TextField userNameField;
@FXML
- private Button connectBtn;
-
+ private TextField passwordField;
@FXML
- private TreeView treeView;
-
+ private TextField modelFolderField;
+ @FXML
+ private TextField mapperFolderField;
+ @FXML
+ private TextField daoFolderField;
+ @FXML
+ private TextField tableNameField;
+ @FXML
+ private TextField domainObjectNameField;
+ @FXML
+ private TextField packageNameField;
@FXML
- private ListView valueListView;
+ private TextField projectFolderField;
- private StringRedisTemplate redis;
+ private Stage primaryStage;
@Override
public void initialize(URL location, ResourceBundle resources) {
+ dbTypeChoice.setOnKeyPressed(event -> {
+ String driverClass = dbTypeChoice.getSelectionModel().getSelectedItem().getDriverClass();
+ driverClassField.setText(driverClass);
+ });
+ driverClassField.setText("com.mysql.jdbc.Driver");
}
@FXML
- void connectToRedis() {
- String redisNodes = nodesField.getText();
- String master = masterField.getText();
- redis = new StringRedisTemplate();
- redis.setKeySerializer(new StringRedisSerializer());
- RedisSentinelConfiguration config = new RedisSentinelConfiguration();
- config.setMaster(master);
- String[] nodes = redisNodes.split(",");
- for (String node : nodes) {
- String[] hostport = node.split(":");
- String host = hostport[0];
- int port = Integer.parseInt(hostport[1]);
- config.addSentinel(new RedisNode(host, port));
+ public void chooseConnectorFile() {
+ FileChooser fileChooser = new FileChooser();
+ fileChooser.setTitle("Select " + dbTypeChoice.getSelectionModel().getSelectedItem().getName() + " Connector jar file");
+ fileChooser.getExtensionFilters().add(new ExtensionFilter("jar file", "*.jar"));
+ File selectedFile = fileChooser.showOpenDialog(primaryStage);
+ if (selectedFile != null) {
+ connectorFileField.setText(selectedFile.getAbsolutePath());
}
- JedisConnectionFactory factory = new JedisConnectionFactory(config);
- factory.setUsePool(true);
- factory.afterPropertiesSet();
- redis.setConnectionFactory(factory);
- redis.afterPropertiesSet();
-
- connectStatusLabel.setText("θΏζ₯ζε");
- testKeys();
}
@FXML
- void testKeys() {
- TreeItem rootItem = new TreeItem<>("Root");
- treeView.setRoot(rootItem);
- treeView.setShowRoot(false);
- Set keys = redis.keys("Cobra_*");
- if (keys != null && keys.size() > 0) {
- keys.stream().forEach(key -> {
- TreeItem item = new TreeItem<>();
- Label label = new Label(key);
- // label.setBackground(new Background(new BackgroundFill(new Color(1, 0, 0, 1), null, null)));
- label.setOnMouseClicked(event -> {
- ObservableList observableList = FXCollections.observableArrayList();
- DataType type = redis.type(key);
- String code = type.code();
- typeLabel.setText(code);
- System.out.println(code);
- Collection> values = null;
- if ("zset".equals(code)) {
- Set> hashKeys = redis.opsForZSet().rangeWithScores(key, 0, -1);
- if (hashKeys != null && hashKeys.size() > 0) {
- values = hashKeys.stream().map(
- tuple -> "value: " + tuple.getValue() + ", score: " + tuple.getScore().longValue())
- .collect(Collectors.toList());
- }
- System.out.println(values);
- } else if ("set".equals(code)) {
- values = redis.opsForSet().members(key);
- System.out.println(key + ": " + values);
- } else if ("hash".equals(code)) {
- Set