Skip to content

Commit

Permalink
v0.1.6同步更新
Browse files Browse the repository at this point in the history
  • Loading branch information
Zhuoyuan1 committed Feb 27, 2023
1 parent 3684215 commit 5bbbbdb
Show file tree
Hide file tree
Showing 64 changed files with 2,299 additions and 955 deletions.
Binary file added lib/xugu-jdbc-12.0.0.jar
Binary file not shown.
45 changes: 24 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<poi.version>5.2.2</poi.version>
<lombok.version>1.18.6</lombok.version>
<mysql.version>8.0.29</mysql.version>
<oracle.version>19.7.0.0</oracle.version>
Expand All @@ -30,42 +29,36 @@
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>

<!-- oracle驱动包 -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>${oracle.version}</version>
</dependency>

<!-- SqlServer驱动 -->
<dependency>
<groupId>com.microsoft.sqlserver</groupId>
<artifactId>mssql-jdbc</artifactId>
<version>${sqlserver.version}</version>
</dependency>

<!-- postgresql驱动 -->
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>${postgresql.version}</version>
</dependency>

<!-- DB2驱动 -->
<dependency>
<groupId>com.ibm.db2</groupId>
<artifactId>jcc</artifactId>
<version>${db2.version}</version>
</dependency>

<!-- sqlite驱动 -->
<!--<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>${sqlite.version}</version>
</dependency>-->

<!-- 达梦驱动 -->
<dependency>
<groupId>com</groupId>
Expand All @@ -74,7 +67,6 @@
<scope>system</scope>
<systemPath>${basedir}/lib/DmJdbcDriver18.jar</systemPath>
</dependency>

<!-- kingbase8驱动 -->
<dependency>
<groupId>com</groupId>
Expand All @@ -83,7 +75,6 @@
<scope>system</scope>
<systemPath>${basedir}/lib/kingbase8-8.6.0.jar</systemPath>
</dependency>

<!--虚谷驱动-->
<dependency>
<groupId>com.xugu</groupId>
Expand All @@ -92,42 +83,53 @@
<scope>system</scope>
<systemPath>${basedir}/lib/xugu-jdbc-12.0.0.jar</systemPath>
</dependency>

<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>

<!--fastjson-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<!-- poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>${poi.version}</version>
</dependency>
<!--theme-->
<dependency>
<groupId>com.github.insubstantial</groupId>
<artifactId>substance</artifactId>
<version>${substance.version}</version>
</dependency>
<!--ini-->
<dependency>
<groupId>org.ini4j</groupId>
<artifactId>ini4j</artifactId>
<version>${ini4j.version}</version>
</dependency>

<!-- itextpdf -->
<!--poi-tl-->
<dependency>
<groupId>com.deepoove</groupId>
<artifactId>poi-tl</artifactId>
<version>1.12.0</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<!-- itext-pdf -->
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>kernel</artifactId>
<version>${itext7.version}</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
Expand All @@ -140,11 +142,11 @@
<version>${itext7.version}</version>
</dependency>
<!-- 中文字体支持 -->
<dependency>
<!--<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>font-asian</artifactId>
<version>${itext7.version}</version>
</dependency>
</dependency>-->
</dependencies>

<repositories>
Expand Down Expand Up @@ -209,6 +211,7 @@
<include>**/*.ini</include>
<include>**/*.gif</include>
<include>**/*.properties</include>
<include>**/*.ttc</include>
</includes>
<filtering>false</filtering>
</resource>
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/com/easydatabaseexport/EasyDataBaseExportMain.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.easydatabaseexport;

import com.easydatabaseexport.common.CommonConstant;
import com.easydatabaseexport.common.PatternConstant;
import com.easydatabaseexport.exception.ExceptionHandler;
import com.easydatabaseexport.log.LogManager;
import com.easydatabaseexport.ui.IndexJavaFrame;
import com.easydatabaseexport.util.AESCoder;
import com.easydatabaseexport.util.FileIniRead;
import lombok.SneakyThrows;
import lombok.extern.java.Log;

import javax.swing.JDialog;
Expand All @@ -25,10 +27,14 @@ public class EasyDataBaseExportMain {
static {
try {
AESCoder.initKeyAndEndurance();
//检查ini配置
CommonConstant.checkConfigIniFile();
//初始化ini文件
CommonConstant.copySystemIniFile();
//生成模板文件
CommonConstant.copyTemplateFile();
//检查ini配置
CommonConstant.checkConfigIniFile();
//改变参数
PatternConstant.reCheckConfig();
} catch (Exception e) {
LogManager.writeLogFile(e, log);
}
Expand All @@ -37,10 +43,13 @@ public class EasyDataBaseExportMain {
/**
* 程序入口
**/
@SneakyThrows
public static void main(String[] args) {
//允许修改JFrame的标题栏
JFrame.setDefaultLookAndFeelDecorated(true);
JDialog.setDefaultLookAndFeelDecorated(true);
//启用跨平台的外观
UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
//读取配置文件哦
CommonConstant.index = Integer.parseInt(FileIniRead.getIniThemeIndex());
SwingUtilities.invokeLater(() -> {
Expand Down
103 changes: 65 additions & 38 deletions src/main/java/com/easydatabaseexport/common/CommonConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,24 @@
import com.easydatabaseexport.enums.DataBaseType;
import com.easydatabaseexport.enums.UpdateEnum;
import com.easydatabaseexport.log.LogManager;
import com.easydatabaseexport.ui.ConnectJavaFrame;
import com.easydatabaseexport.ui.component.JCheckBoxTree;
import com.easydatabaseexport.util.FileIniRead;
import com.easydatabaseexport.util.FileOperateUtil;
import com.easydatabaseexport.util.StringUtil;
import lombok.SneakyThrows;
import lombok.extern.java.Log;

import javax.swing.*;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.UIManager;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
Expand All @@ -33,7 +35,7 @@
* @date 2021/11/1 14:51
**/
@Log
public class CommonConstant {
public final class CommonConstant {

public static final String IP_PORT = "^(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])" +
"\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.(\\d|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5]):([0-9]|[1-9]" +
Expand Down Expand Up @@ -68,9 +70,16 @@ public class CommonConstant {
/**
* 表head
**/
public static final String[] INDEX_HEAD_NAMES =
public static String[] INDEX_HEAD_NAMES =
{"名称", "字段", "索引类型", "索引方法", "注释"};
public static final String[] COLUMN_HEAD_NAMES =
public static String[] COLUMN_HEAD_NAMES =
{"序号", "字段名", "类型", "长度", "是否为空", "默认值", "小数位", "注释"};
/**
* 不变的表头用于展示 和 配置选择
**/
public static final String[] INDEX_FINAL_HEAD_NAMES =
{"名称", "字段", "索引类型", "索引方法", "注释"};
public static final String[] COLUMN_FINAL_HEAD_NAMES =
{"序号", "字段名", "类型", "长度", "是否为空", "默认值", "小数位", "注释"};
/**
* 表名
Expand All @@ -92,11 +101,11 @@ public class CommonConstant {
/**
* frame的宽
*/
public static int FRAME_WIDTH = 1500;
public static final int FRAME_WIDTH = 1500;
/**
* frame的高
*/
public static int FRAME_HEIGHT = 800;
public static final int FRAME_HEIGHT = 800;

public static Connection connection = null;
public static JCheckBoxTree root;
Expand All @@ -116,7 +125,7 @@ public class CommonConstant {
/**
* 导出配置
*/
public static Map<String, String> configMap = new ConcurrentHashMap<>(0);
public static Map<String, String> configMap = new ConcurrentHashMap<>(16);
public static final String INI_NODE_KEY = "config";
public static final String EXPORT = "export";
public static final String UPDATE = "update";
Expand Down Expand Up @@ -145,14 +154,17 @@ public static void initCheckAllKey(String key) {
if (UPDATE.equals(key)) {
for (UpdateEnum updateEnum : UpdateEnum.values()) {
if (!configMap.containsKey(updateEnum.getKey())) {
writeNewKey(updateEnum.getKey(), "1");
if (updateEnum.getKey().equals(UpdateEnum.UPDATE_VERSION.getKey())) {
writeNewKey(updateEnum.getKey(), "1");
}
}
}
} else if (EXPORT.equals(key)) {
for (ConfigEnum configEnum : ConfigEnum.values()) {
if (!configMap.containsKey(configEnum.getKey())) {
if (configEnum.getKey().equals(ConfigEnum.TABLE_HEAD.getKey()) ||
configEnum.getKey().equals(ConfigEnum.INDEX_TABLE_HEAD.getKey())) {
configEnum.getKey().equals(ConfigEnum.INDEX_TABLE_HEAD.getKey()) ||
configEnum.getKey().equals(ConfigEnum.DEFAULT_EXPORT_PATH.getKey())) {
writeNewKey(configEnum.getKey(), configEnum.getValue());
} else {
writeNewKey(configEnum.getKey(), null);
Expand All @@ -177,6 +189,7 @@ public static void initByClose() {
CommonDataBaseType.CON_DATABASE_TABLE_MAP.clear();
CommonDataBaseType.CON_MODE_TABLE_MAP.clear();
CommonDataBaseType.CON_DATABASE_MODE_TABLE_MAP.clear();
ConnectJavaFrame.cacheRootNode = null;
TABLE_NAME = "";
DATABASE_NAME = "";
TREE_DATABASE = "";
Expand Down Expand Up @@ -206,35 +219,49 @@ public static void copyTemplateFile() {
file.mkdir();
}
for (int i = 0; i < EnvironmentConstant.TEMPLATE_FILE.size(); i++) {
FileOutputStream outputStream = null;
InputStream inputStream = null;
try {
outputStream = new FileOutputStream(template + File.separator + EnvironmentConstant.TEMPLATE_FILE.get(i));
// 模板文件输入输出地址 读取resources下文件
//返回读取指定资源的输入流
inputStream = CommonConstant.class.getClassLoader().getResourceAsStream(EnvironmentConstant.TEMPLATE_FILE.get(i));
byte[] buffer = new byte[4096];
int n = 0;
while (-1 != (n = inputStream.read(buffer))) {
outputStream.write(buffer, 0, n);
}
outputStream.flush();
} catch (Exception ex) {
LogManager.writeLogFile(ex, log);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException ex) {
LogManager.writeLogFile(ex, log);
}
saveFile(template, EnvironmentConstant.TEMPLATE_FILE.get(i), true);
}
}

public static void copySystemIniFile() {
saveFile(FileOperateUtil.getSavePath(), "database.ini", false);
}

public static void saveFile(String dir, String path, boolean isOverride) {
FileOutputStream outputStream = null;
InputStream inputStream = null;
if (!isOverride) {
File file = new File(dir + File.separator + path);
if (file.exists()) {
return;
}
}
try {
outputStream = new FileOutputStream(dir + File.separator + path);
// 模板文件输入输出地址 读取resources下文件
//返回读取指定资源的输入流
inputStream = CommonConstant.class.getClassLoader().getResourceAsStream(path);
byte[] buffer = new byte[4096];
int n = 0;
while (-1 != (n = inputStream.read(buffer))) {
outputStream.write(buffer, 0, n);
}
outputStream.flush();
} catch (Exception ex) {
LogManager.writeLogFile(ex, log);
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException ex) {
LogManager.writeLogFile(ex, log);
}
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException ex) {
LogManager.writeLogFile(ex, log);
}
}
if (outputStream != null) {
try {
outputStream.close();
} catch (IOException ex) {
LogManager.writeLogFile(ex, log);
}
}
}
Expand Down
Loading

0 comments on commit 5bbbbdb

Please sign in to comment.