Skip to content

Commit

Permalink
简化流程,让用户不用选择connector文件,提供默认值
Browse files Browse the repository at this point in the history
  • Loading branch information
zouzg committed Jan 21, 2017
1 parent 35f5541 commit 2663eff
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 53 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ mybatis-generator-gui是基于[mybatis generator](http://www.mybatis.org/generat

cd target/jfx/app/
java -jar mybatis-generator-gui.jar


* 方法三: IDE中运行

Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.zzg</groupId>
<artifactId>mybatis-generator-gui</artifactId>
<version>0.3</version>
<version>0.6</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down Expand Up @@ -56,7 +56,7 @@
<artifactId>ojdbc14</artifactId>
<version>10.2.0.3.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/lib/ojdbc14.jar</systemPath>
<systemPath>${project.basedir}/src/main/resources/connector/ojdbc14.jar</systemPath>
</dependency>
<dependency>
<groupId>org.postgresql</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,6 @@ public class MainUIController extends BaseFXController {
@FXML
private Label configsLabel;
@FXML
private TextField connectorPathField;
@FXML
private TextField modelTargetPackage;
@FXML
private TextField mapperTargetPackage;
Expand Down Expand Up @@ -207,15 +205,6 @@ void loadLeftDBTree() {
}
}

@FXML
public void chooseConnectorFile() {
FileChooser directoryChooser = new FileChooser();
File selectedFolder = directoryChooser.showOpenDialog(getPrimaryStage());
if (selectedFolder != null) {
connectorPathField.setText(selectedFolder.getAbsolutePath());
}
}

@FXML
public void chooseProjectFolder() {
DirectoryChooser directoryChooser = new DirectoryChooser();
Expand Down Expand Up @@ -272,7 +261,6 @@ public void saveGeneratorConfig() {

public GeneratorConfig getGeneratorConfigFromUI() {
GeneratorConfig generatorConfig = new GeneratorConfig();
generatorConfig.setConnectorJarPath(connectorPathField.getText());
generatorConfig.setProjectFolder(projectFolderField.getText());
generatorConfig.setModelPackage(modelTargetPackage.getText());
generatorConfig.setGenerateKeys(generateKeysField.getText());
Expand All @@ -291,7 +279,6 @@ public GeneratorConfig getGeneratorConfigFromUI() {
}

public void setGeneratorConfigIntoUI(GeneratorConfig generatorConfig) {
connectorPathField.setText(generatorConfig.getConnectorJarPath());
projectFolderField.setText(generatorConfig.getProjectFolder());
modelTargetPackage.setText(generatorConfig.getModelPackage());
generateKeysField.setText(generatorConfig.getGenerateKeys());
Expand Down
62 changes: 24 additions & 38 deletions src/main/resources/fxml/MainUI.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@
<ColumnConstraints hgrow="SOMETIMES" maxWidth="688.0" minWidth="10.0" prefWidth="147.0" />
</columnConstraints>
<rowConstraints>
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="44.0" minHeight="10.0" prefHeight="27.0" vgrow="SOMETIMES" />
<RowConstraints maxHeight="25.0" minHeight="8.0" prefHeight="25.0" vgrow="SOMETIMES" />
Expand All @@ -80,27 +79,14 @@
<RowConstraints maxHeight="92.0" minHeight="62.0" prefHeight="62.0" />
</rowConstraints>
<children>
<Label text="Connector Jar" />
<TextField fx:id="connectorPathField" prefHeight="27.0" prefWidth="243.0" promptText="C:\path\mysql-connector-java-5.1.37.jar" GridPane.columnIndex="1" GridPane.columnSpan="2">
<GridPane.margin>
<Insets left="5.0" />
</GridPane.margin></TextField>
<Button mnemonicParsing="false" onAction="#chooseConnectorFile" text="Choose" GridPane.columnIndex="3">
<GridPane.margin>
<Insets left="5.0" />
</GridPane.margin>
<styleClass>
<String fx:value="btn" />
<String fx:value="btn-default" />
</styleClass></Button>
<Label text="Table Name" GridPane.rowIndex="1" />
<TextField fx:id="tableNameField" prefHeight="27.0" prefWidth="156.0" promptText="person" GridPane.columnIndex="1" GridPane.rowIndex="1">
<Label text="Table Name" />
<TextField fx:id="tableNameField" prefHeight="27.0" prefWidth="156.0" promptText="person" GridPane.columnIndex="1">
<GridPane.margin>
<Insets left="5.0" right="5.0" />
</GridPane.margin>
</TextField>
<Label text="Domain Object Name" GridPane.rowIndex="2" />
<HBox alignment="CENTER_LEFT" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="2" GridPane.valignment="CENTER">
<Label text="Domain Object Name" GridPane.rowIndex="1" />
<HBox alignment="CENTER_LEFT" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="1" GridPane.valignment="CENTER">
<children>
<TextField fx:id="domainObjectNameField" prefHeight="27.0" prefWidth="154.0" promptText="Person" GridPane.columnIndex="1" GridPane.rowIndex="2">
<GridPane.margin>
Expand All @@ -121,8 +107,8 @@
<Insets left="5.0" />
</GridPane.margin>
</HBox>
<Label text="GenerateKeys" GridPane.rowIndex="3" />
<HBox alignment="CENTER_LEFT" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="3" GridPane.valignment="CENTER">
<Label text="GenerateKeys" GridPane.rowIndex="2" />
<HBox alignment="CENTER_LEFT" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="2" GridPane.valignment="CENTER">
<children>
<TextField fx:id="generateKeysField" prefHeight="27.0" prefWidth="154.0" promptText="primary key, such as id" GridPane.columnIndex="1" GridPane.rowIndex="3">
<GridPane.margin>
Expand All @@ -137,8 +123,8 @@
<Insets left="5.0" />
</GridPane.margin>
</HBox>
<Label text="Project Folder" GridPane.rowIndex="4" />
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.columnSpan="4" GridPane.rowIndex="4">
<Label text="Project Folder" GridPane.rowIndex="3" />
<HBox alignment="CENTER_LEFT" prefHeight="100.0" prefWidth="200.0" GridPane.columnIndex="1" GridPane.columnSpan="4" GridPane.rowIndex="3">
<children>
<TextField fx:id="projectFolderField" prefHeight="27.0" prefWidth="348.0" promptText="D:\workspace\example">
<HBox.margin>
Expand All @@ -152,49 +138,49 @@
</styleClass></Button>
</children>
</HBox>
<Label text="Model Package" GridPane.rowIndex="5" />
<TextField fx:id="modelTargetPackage" prefHeight="27.0" prefWidth="152.0" promptText="com.example.model" GridPane.columnIndex="1" GridPane.rowIndex="5">
<Label text="Model Package" GridPane.rowIndex="4" />
<TextField fx:id="modelTargetPackage" prefHeight="27.0" prefWidth="152.0" promptText="com.example.model" GridPane.columnIndex="1" GridPane.rowIndex="4">
<HBox.margin>
<Insets right="5.0" />
</HBox.margin>
<GridPane.margin>
<Insets left="5.0" right="5.0" />
</GridPane.margin>
</TextField>
<Label text="Target Folder" GridPane.columnIndex="2" GridPane.rowIndex="5" />
<TextField fx:id="modelTargetProject" prefHeight="27.0" prefWidth="155.0" promptText="src/main/java" GridPane.columnIndex="3" GridPane.rowIndex="5">
<Label text="Target Folder" GridPane.columnIndex="2" GridPane.rowIndex="4" />
<TextField fx:id="modelTargetProject" prefHeight="27.0" prefWidth="155.0" promptText="src/main/java" GridPane.columnIndex="3" GridPane.rowIndex="4">
<GridPane.margin>
<Insets left="5.0" />
</GridPane.margin></TextField>
<Label text="DAO Package" GridPane.rowIndex="6" />
<TextField fx:id="daoTargetPackage" prefHeight="27.0" prefWidth="248.0" promptText="com.example.mapper" GridPane.columnIndex="1" GridPane.rowIndex="6">
<Label text="DAO Package" GridPane.rowIndex="5" />
<TextField fx:id="daoTargetPackage" prefHeight="27.0" prefWidth="248.0" promptText="com.example.mapper" GridPane.columnIndex="1" GridPane.rowIndex="5">
<HBox.margin>
<Insets right="5.0" />
</HBox.margin>
<GridPane.margin>
<Insets left="5.0" right="5.0" />
</GridPane.margin>
</TextField>
<Label text="Target Folder" GridPane.columnIndex="2" GridPane.rowIndex="6" />
<TextField fx:id="daoTargetProject" prefHeight="27.0" prefWidth="155.0" promptText="src/main/java" GridPane.columnIndex="3" GridPane.rowIndex="6">
<Label text="Target Folder" GridPane.columnIndex="2" GridPane.rowIndex="5" />
<TextField fx:id="daoTargetProject" prefHeight="27.0" prefWidth="155.0" promptText="src/main/java" GridPane.columnIndex="3" GridPane.rowIndex="5">
<GridPane.margin>
<Insets left="5.0" />
</GridPane.margin></TextField>
<Label text="Mapping XML Package" GridPane.rowIndex="7" />
<TextField fx:id="mapperTargetPackage" prefHeight="27.0" prefWidth="248.0" promptText="com.example" GridPane.columnIndex="1" GridPane.rowIndex="7">
<Label text="Mapping XML Package" GridPane.rowIndex="6" />
<TextField fx:id="mapperTargetPackage" prefHeight="27.0" prefWidth="248.0" promptText="com.example" GridPane.columnIndex="1" GridPane.rowIndex="6">
<HBox.margin>
<Insets right="5.0" />
</HBox.margin>
<GridPane.margin>
<Insets left="5.0" right="5.0" />
</GridPane.margin>
</TextField>
<Label text="Target Folder" GridPane.columnIndex="2" GridPane.rowIndex="7" />
<TextField fx:id="mappingTargetProject" prefHeight="27.0" prefWidth="155.0" promptText="src/main/resources" GridPane.columnIndex="3" GridPane.rowIndex="7">
<Label text="Target Folder" GridPane.columnIndex="2" GridPane.rowIndex="6" />
<TextField fx:id="mappingTargetProject" prefHeight="27.0" prefWidth="155.0" promptText="src/main/resources" GridPane.columnIndex="3" GridPane.rowIndex="6">
<GridPane.margin>
<Insets left="5.0" />
</GridPane.margin></TextField>
<VBox spacing="5.0" GridPane.columnIndex="1" GridPane.columnSpan="4" GridPane.rowIndex="8">
<VBox spacing="5.0" GridPane.columnIndex="1" GridPane.columnSpan="4" GridPane.rowIndex="7">
<children>
<HBox alignment="CENTER_LEFT" spacing="10.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="8">
<children>
Expand All @@ -212,7 +198,7 @@
<Insets left="5.0" />
</padding>
</VBox>
<HBox prefHeight="100.0" prefWidth="200.0" spacing="10.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="9">
<HBox prefHeight="100.0" prefWidth="200.0" spacing="10.0" GridPane.columnIndex="1" GridPane.columnSpan="3" GridPane.rowIndex="8">
<children>
<Button mnemonicParsing="false" onAction="#generateCode" text="Generate">
<styleClass>
Expand All @@ -226,12 +212,12 @@
</styleClass></Button>
</children>
</HBox>
<Label text="DAO Name" GridPane.columnIndex="4" GridPane.rowIndex="5">
<Label text="DAO Name" GridPane.columnIndex="4" GridPane.rowIndex="4">
<padding>
<Insets left="5.0" />
</padding>
</Label>
<TextField fx:id="mapperName" prefHeight="27.0" prefWidth="138.0" promptText="PersonDAO" GridPane.columnIndex="5" GridPane.rowIndex="5">
<TextField fx:id="mapperName" prefHeight="27.0" prefWidth="138.0" promptText="PersonDAO" GridPane.columnIndex="5" GridPane.rowIndex="4">
<GridPane.margin>
<Insets left="5.0" />
</GridPane.margin></TextField>
Expand Down
Binary file removed src/main/resources/lib/ojdbc14.jar
Binary file not shown.

0 comments on commit 2663eff

Please sign in to comment.