├── .travis.yml ├── DB_Backup ├── Target │ └── demo_back.sql ├── mysql_backup.bat └── mysql_table_backup.sql ├── LICENSE.txt ├── TableField ├── init │ ├── my_role.DELETE.sql │ ├── my_role.INSERT.sql │ ├── my_role.UPDATE.sql │ ├── my_user.DELETE.sql │ ├── my_user.INSERT.sql │ └── my_user.UPDATE.sql ├── my_role.DELETE.sql ├── my_role.INSERT.sql ├── my_role.UPDATE.sql ├── my_user.DELETE.sql ├── my_user.INSERT.sql ├── my_user.UPDATE.sql └── 公式说明.txt ├── Trigger └── Trigger.txt ├── _config.yml ├── config ├── Re-initialization.sql ├── config.xml ├── databaseBakOriginal.csv ├── databaseBakTarget.csv └── zh-cn.properties ├── dist ├── DB_Backup │ ├── Target │ │ └── demo_back.sql │ ├── mysql_backup.bat │ └── mysql_table_backup.sql ├── TableField │ ├── init │ │ ├── my_role.DELETE.sql │ │ ├── my_role.INSERT.sql │ │ ├── my_role.UPDATE.sql │ │ ├── my_user.DELETE.sql │ │ ├── my_user.INSERT.sql │ │ └── my_user.UPDATE.sql │ ├── my_role.DELETE.sql │ ├── my_role.INSERT.sql │ ├── my_role.UPDATE.sql │ ├── my_user.DELETE.sql │ ├── my_user.INSERT.sql │ ├── my_user.UPDATE.sql │ └── 公式说明.txt ├── Trigger │ └── Trigger.txt ├── WeSync-1.0.jar ├── WeSync.bat ├── config │ ├── Re-initialization.sql │ ├── config.xml │ ├── databaseBakOriginal.csv │ ├── databaseBakTarget.csv │ └── zh-cn.properties ├── lib │ ├── aopalliance-1.0.jar │ ├── commons-beanutils-1.9.3.jar │ ├── commons-collections-3.2.2.jar │ ├── commons-lang3-3.5.jar │ ├── commons-logging-1.2.jar │ ├── dom4j-2.0.1.jar │ ├── emoji-java-3.1.3.jar │ ├── jaxen-1.1.6.jar │ ├── json-20140107.jar │ ├── logback-classic-1.2.1.jar │ ├── logback-core-1.2.1.jar │ ├── mysql-connector-java-6.0.6.jar │ ├── opencsv-3.9.jar │ ├── pinyin4j-2.5.1.jar │ ├── saxpath-1.0-FCS.jar │ ├── slf4j-api-1.7.22.jar │ ├── spring-aop-4.3.9.RELEASE.jar │ ├── spring-beans-4.3.9.RELEASE.jar │ ├── spring-context-4.3.9.RELEASE.jar │ ├── spring-core-4.3.9.RELEASE.jar │ ├── spring-expression-4.3.9.RELEASE.jar │ └── spring-security-core-4.2.3.RELEASE.jar ├── snaps │ ├── role.csv │ ├── role_before.csv │ ├── user.csv │ └── user_before.csv └── snaps_bak │ ├── role.csv │ ├── role_before.csv │ ├── user.csv │ └── user_before.csv ├── log_SQL └── log_sql.csv ├── memo.txt ├── pom.xml ├── readme.md ├── screen_shot ├── WeSync.png ├── 图像 030.png ├── 图像 031.png ├── 图像 032.png ├── 图像 033.png ├── 图像 034.png └── 图像 035.png ├── snaps ├── role.csv ├── role_before.csv ├── user.csv └── user_before.csv ├── snaps_bak ├── role.csv ├── role_before.csv ├── user.csv └── user_before.csv └── src └── main ├── java └── com │ └── luoboduner │ └── wesync │ ├── App.java │ ├── logic │ ├── BackupManage.java │ ├── ConstantsLogic.java │ ├── ExecuteThread.java │ ├── ExecuteThreadInterface.java │ ├── ScheduleExecuteThread.java │ ├── SnapManage.java │ ├── TriggerManage.java │ ├── bean │ │ └── Table.java │ └── init │ │ └── Init4pxp2p.java │ ├── tools │ ├── ConfigManager.java │ ├── ConstantsTools.java │ ├── DESPlus.java │ ├── DbUtilMySQL.java │ ├── DbUtilSQLServer.java │ ├── FileUtils.java │ ├── LogLevel.java │ ├── PropertyUtil.java │ ├── StatusLog.java │ ├── Utils.java │ └── package-info.java │ └── ui │ ├── UiConsts.java │ ├── component │ └── MyIconButton.java │ ├── dialog │ └── DbBackUpCreateDialog.java │ └── panel │ ├── BackupPanel.java │ ├── DatabasePanel.java │ ├── DatabasePanelFrom.java │ ├── DatabasePanelTo.java │ ├── SchedulePanel.java │ ├── SettingPanel.java │ ├── SettingPanelAbout.java │ ├── SettingPanelOption.java │ ├── StatusPanel.java │ └── ToolBarPanel.java └── resources ├── icon ├── WeSync.ico ├── WeSync.png ├── WeSync.psd ├── WeSyncInstaller.ico ├── about.png ├── backup.png ├── backupEnable.png ├── clearAllBaks.png ├── clearAllBaksDisable.png ├── clearAllBaksEnable.png ├── clearLog.png ├── clearLogDisable.png ├── clearLogEnable.png ├── database.png ├── databaseEnable.png ├── deleteBak.png ├── deleteBakDisable.png ├── deleteBakEnable.png ├── newBak.png ├── newBakDisable.png ├── newBakEnable.png ├── recoverBak.png ├── recoverBakDisable.png ├── recoverBakEnable.png ├── saveButton.png ├── saveButtonDisable.png ├── saveButtonEnable.png ├── schedule.png ├── scheduleEnable.png ├── setting.png ├── settingEnable.png ├── start.png ├── startDisable.png ├── startEnable.png ├── startSchedule.png ├── startScheduleDisable.png ├── startScheduleEnable.png ├── status.png ├── statusEnable.png ├── stop.png ├── stopDisable.png ├── stopEnable.png ├── syncNow.png ├── syncNowDisable.png ├── syncNowEnable.png ├── tableFiled.png ├── tableFiledDisable.png ├── tableFiledEnable.png ├── testLinkButton.png ├── testLinkButtonDisable.png ├── testLinkButtonEnable.png ├── textButton.psd ├── textButton206_30.psd └── textButton82_30.psd └── logback.xml /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | 3 | jdk: 4 | - openjdk8 5 | script: "mvn clean package -Dmaven.test.skip=true" 6 | 7 | notifications: 8 | email: 9 | - rememberber@163.com -------------------------------------------------------------------------------- /DB_Backup/Target/demo_back.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/DB_Backup/Target/demo_back.sql -------------------------------------------------------------------------------- /DB_Backup/mysql_backup.bat: -------------------------------------------------------------------------------- 1 | @echo off & setlocal ENABLEEXTENSIONS 2 | set BACKUP_PATH=D:\workspaceWeSync\weSync\DB_Backup\Target 3 | set DATABASES=TEST_2017_M 4 | set HOST=localhost 5 | set USERNAME=root 6 | set PASSWORD=123456S 7 | set MYSQL=D:\MySQL 8 | set path_bin_mysql=%MYSQL%\bin\ 9 | set YEAR=%date:~0,4% 10 | set MONTH=%date:~5,2% 11 | set DAY=%date:~8,2% 12 | set HOUR=%time:~0,2% 13 | set MINUTE=%time:~3,2% 14 | set SECOND=%time:~6,2% 15 | set DIR=%BACKUP_PATH% 16 | set ADDON="%YEAR%%MONTH%%DAY%_%HOUR%%MINUTE%%SECOND%" 17 | if not exist %DIR% ( 18 | mkdir %DIR% 19 | ) 20 | if not exist %DIR% ( 21 | echo Backup path: %DIR% not exists, create dir failed. 22 | goto exit 23 | ) 24 | cd /d %DIR% 25 | echo Start dump databases... 26 | for %%D in (%DATABASES%) do ( 27 | echo Dumping database %%D ... 28 | %path_bin_mysql%mysqldump -h%HOST% -u%USERNAME% -p%PASSWORD% --skip-lock-tables %%D > %%D_%ADDON%.sql 29 | ) 30 | echo Done 31 | :exit -------------------------------------------------------------------------------- /DB_Backup/mysql_table_backup.sql: -------------------------------------------------------------------------------- 1 | drop table if exists table_demo_a_bak; 2 | create table table_demo_a_bak like table_demo_a; 3 | insert into table_demo_a_bak select * from table_demo_a; 4 | 5 | drop table if exists table_demo_b_bak; 6 | create table table_demo_b_bak like table_demo_b; 7 | insert into table_demo_b_bak select * from table_demo_b; 8 | 9 | drop table if exists table_demo_c_bak; 10 | create table table_demo_c_bak like table_demo_c; 11 | insert into table_demo_c_bak select * from table_demo_c; 12 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2017] [WeSync] 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /TableField/init/my_role.DELETE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_role 2 | SET UPDATE_DATE = '$SYS_DATE_TIME$', 3 | UPDATE_USER = 2, 4 | STATUS = '1' 5 | WHERE 6 | (ROLE_NAME = 'before.Name'); -------------------------------------------------------------------------------- /TableField/init/my_role.INSERT.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO my_role ( 2 | ROLE_NAME, 3 | CREATE_DATE, 4 | CREATE_USER, 5 | UPDATE_DATE, 6 | UPDATE_USER, 7 | STATUS, 8 | REMARK 9 | ) 10 | VALUES 11 | ( 12 | 'this.Name', 13 | '$SYS_DATE_TIME$', 14 | 2, 15 | '', 16 | 2, 17 | '2', 18 | '' 19 | ); 20 | -------------------------------------------------------------------------------- /TableField/init/my_role.UPDATE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_role 2 | SET ROLE_NAME = 'this.Name', 3 | UPDATE_DATE = '$SYS_DATE_TIME$', 4 | UPDATE_USER = 2 5 | WHERE 6 | (ROLE_NAME = 'before.Name'); -------------------------------------------------------------------------------- /TableField/init/my_user.DELETE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_user 2 | SET STATUS = '1', 3 | UPDATE_DATE = '$SYS_DATE_TIME$', 4 | UPDATE_USER = 2 5 | WHERE ID_CARD = 'before.IDCardID' ; -------------------------------------------------------------------------------- /TableField/init/my_user.INSERT.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO my_user ( 2 | LOGIN_NAME, 3 | PASSWORD, 4 | REAL_NAME, 5 | STATUS, 6 | ADDRESS, 7 | RMK, 8 | CREATE_DATE, 9 | CREATE_USER, 10 | UPDATE_DATE, 11 | UPDATE_USER, 12 | LOGIN_IP, 13 | MOBILE, 14 | SYS_EMAIL, 15 | TELPHONE, 16 | LOGO_IMG, 17 | PROVINCE, 18 | CITY, 19 | sbc_id, 20 | EMP_CODE, 21 | ID_CARD, 22 | DEPT_CODE, 23 | POSITION_CODE, 24 | BANK_NUMBER 25 | ) 26 | VALUES 27 | ( 28 | '$PINYIN{this.Name}$@SUB(7,END){this.Telphone}@', 29 | '#MD5PE{@SUB(12,END){this.IDCardID}@}#', 30 | 'this.Name', 31 | '#CASE(1=2,2=1){this.Status}#', 32 | 'this.Address', 33 | '', 34 | '$SYS_DATE_TIME$', 35 | 2, 36 | '', 37 | null, 38 | '', 39 | 'this.Telphone', 40 | 'this.EMail', 41 | '', 42 | '', 43 | '', 44 | '', 45 | null, 46 | '', 47 | 'this.IDCardID', 48 | left('#REPLACE(".",""){@SUB(".",END){this.UnitCode}@}#',16), 49 | (SELECT SP_POSITION_CODE FROM my_position WHERE SP_POSITION_NAME = '$SQL{SELECT PositionName FROM Info WHERE id = 'this.id'}$'), 50 | 'this.BankAccountNum' 51 | ); 52 | 53 | INSERT INTO my_user_role ( 54 | USER_ID, 55 | ROLE_ID, 56 | STATUS, 57 | CREATE_DATE, 58 | CREATE_USER, 59 | UPDATE_DATE, 60 | UPDATE_USER, 61 | REMARK 62 | ) 63 | VALUES 64 | ( 65 | (SELECT MAX(ID) FROM my_user), 66 | (SELECT ID FROM my_role WHERE ROLE_NAME = 'test'), 67 | '2', 68 | '$SYS_DATE_TIME$', 69 | 2, 70 | '', 71 | null, 72 | null 73 | ); 74 | 75 | -------------------------------------------------------------------------------- /TableField/init/my_user.UPDATE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_user 2 | SET REAL_NAME = 'this.Name', 3 | ADDRESS = 'this.Address', 4 | UPDATE_DATE = '$SYS_DATE_TIME$', 5 | UPDATE_USER = 2, 6 | MOBILE = 'this.Telphone', 7 | SYS_EMAIL = 'this.EMail', 8 | ID_CARD = 'this.IDCardID', 9 | DEPT_CODE = left('#REPLACE(".",""){@SUB(".",END){this.UnitCode}@}#',16), 10 | POSITION_CODE = (SELECT SP_POSITION_CODE FROM my_position WHERE SP_POSITION_NAME = '$SQL{SELECT PositionName FROM Info WHERE id = 'this.id'}$'), 11 | BANK_NUMBER = 'this.BankAccountNum' 12 | WHERE ID_CARD = 'before.IDCardID' ; -------------------------------------------------------------------------------- /TableField/my_role.DELETE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_role 2 | SET UPDATE_DATE = '$SYS_DATE_TIME$', 3 | UPDATE_USER = 2, 4 | STATUS = '1' 5 | WHERE 6 | (ROLE_NAME = 'before.Name'); -------------------------------------------------------------------------------- /TableField/my_role.INSERT.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO my_role ( 2 | ROLE_NAME, 3 | CREATE_DATE, 4 | CREATE_USER, 5 | UPDATE_DATE, 6 | UPDATE_USER, 7 | STATUS, 8 | REMARK 9 | ) 10 | VALUES 11 | ( 12 | 'this.Name', 13 | '$SYS_DATE_TIME$', 14 | 2, 15 | '', 16 | 2, 17 | '2', 18 | '' 19 | ); 20 | -------------------------------------------------------------------------------- /TableField/my_role.UPDATE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_role 2 | SET ROLE_NAME = 'this.Name', 3 | UPDATE_DATE = '$SYS_DATE_TIME$', 4 | UPDATE_USER = 2 5 | WHERE 6 | (ROLE_NAME = 'before.Name'); -------------------------------------------------------------------------------- /TableField/my_user.DELETE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_user 2 | SET STATUS = '1', 3 | UPDATE_DATE = '$SYS_DATE_TIME$', 4 | UPDATE_USER = 2 5 | WHERE ID_CARD = 'before.IDCardID' ; -------------------------------------------------------------------------------- /TableField/my_user.INSERT.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO my_user ( 2 | LOGIN_NAME, 3 | PASSWORD, 4 | REAL_NAME, 5 | STATUS, 6 | ADDRESS, 7 | RMK, 8 | CREATE_DATE, 9 | CREATE_USER, 10 | UPDATE_DATE, 11 | UPDATE_USER, 12 | LOGIN_IP, 13 | MOBILE, 14 | SYS_EMAIL, 15 | TELPHONE, 16 | LOGO_IMG, 17 | PROVINCE, 18 | CITY, 19 | sbc_id, 20 | EMP_CODE, 21 | ID_CARD, 22 | DEPT_CODE, 23 | POSITION_CODE, 24 | BANK_NUMBER 25 | ) 26 | VALUES 27 | ( 28 | '$PINYIN{this.Name}$@SUB(7,END){this.Telphone}@', 29 | '#MD5PE{@SUB(12,END){this.IDCardID}@}#', 30 | 'this.Name', 31 | '#CASE(1=2,2=1){this.Status}#', 32 | 'this.Address', 33 | '', 34 | '$SYS_DATE_TIME$', 35 | 2, 36 | '', 37 | null, 38 | '', 39 | 'this.Telphone', 40 | 'this.EMail', 41 | '', 42 | '', 43 | '', 44 | '', 45 | null, 46 | '', 47 | 'this.IDCardID', 48 | left('#REPLACE(".",""){@SUB(".",END){this.UnitCode}@}#',16), 49 | (SELECT SP_POSITION_CODE FROM my_position WHERE SP_POSITION_NAME = '$SQL{SELECT PositionName FROM Info WHERE id = 'this.id'}$'), 50 | 'this.BankAccountNum' 51 | ); 52 | 53 | INSERT INTO my_user_role ( 54 | USER_ID, 55 | ROLE_ID, 56 | STATUS, 57 | CREATE_DATE, 58 | CREATE_USER, 59 | UPDATE_DATE, 60 | UPDATE_USER, 61 | REMARK 62 | ) 63 | VALUES 64 | ( 65 | (SELECT MAX(ID) FROM my_user), 66 | (SELECT ID FROM my_role WHERE ROLE_NAME = 'test'), 67 | '2', 68 | '$SYS_DATE_TIME$', 69 | 2, 70 | '', 71 | null, 72 | null 73 | ); 74 | 75 | -------------------------------------------------------------------------------- /TableField/my_user.UPDATE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_user 2 | SET REAL_NAME = 'this.Name', 3 | ADDRESS = 'this.Address', 4 | UPDATE_DATE = '$SYS_DATE_TIME$', 5 | UPDATE_USER = 2, 6 | MOBILE = 'this.Telphone', 7 | SYS_EMAIL = 'this.EMail', 8 | ID_CARD = 'this.IDCardID', 9 | DEPT_CODE = left('#REPLACE(".",""){@SUB(".",END){this.UnitCode}@}#',16), 10 | POSITION_CODE = (SELECT SP_POSITION_CODE FROM my_position WHERE SP_POSITION_NAME = '$SQL{SELECT PositionName FROM Info WHERE id = 'this.id'}$'), 11 | BANK_NUMBER = 'this.BankAccountNum' 12 | WHERE ID_CARD = 'before.IDCardID' ; -------------------------------------------------------------------------------- /TableField/公式说明.txt: -------------------------------------------------------------------------------- 1 | 注意:同级别公式暂不支持嵌套! 2 | 3 | 第一级别公式: 4 | this.***:取当前快照该条记录的某字段值 5 | before.***:取原快照该条记录的某字段值(仅UPDATE和DELETE时会用到) 6 | 7 | 第二级别公式: 8 | $INCREASE{POSITION_CODE}$:将大括号内的持久化变量递增(*在config文件中设置持久化变量) 9 | $PINYIN{}$:将大括号内的汉字转为拼音 10 | $SYS_DATE_TIME$:系统日期+时间(2016-01-19 17:57:49) 11 | $SQL{}$:执行大括号内的子查询sql,返回对应的查询结果(仅限一个) 12 | 13 | 第三级别公式: 14 | @SUB(5,8){}@:将大括号内的字符串从第5个字符截取到第8个字符(同java的substring方法,含左不含右) 15 | @SUB(5,END){}@:将大括号内的字符串从第5个字符截取到最后(同java的substring方法,含左不含右) 16 | @SUB(0,LAST"."){}@:将大括号内的字符串从第0个字符截取到最后一个"."(同java的substring方法,含左不含右) 17 | @SUB("a",LAST"a"){}@:将大括号内的字符串从第1个"a"截取到最后一个"a"(不含左不含右) 18 | 19 | 第四级别公式: 20 | #REPLACE("a","b"){}#:将大括号内容中所有的"a"替换为"b" 21 | #CASE(a=b,c=d,e=f){}#:如果大括号里边的内容是a,则替换为b;如果为c,则替换为d... 22 | #MD5PE{}#:将大括号内的密码字符串进行Md5PasswordEncoder的encodePassword处理 -------------------------------------------------------------------------------- /Trigger/Trigger.txt: -------------------------------------------------------------------------------- 1 | 2 | // 规则:快照名:<来源表>(主键){字段}[其他条件]=<目标表1>(主键){字段}[保留]=<目标表2>(主键){字段}[保留]... 3 | // 多个以英文逗号隔开 4 | // 注意:]=<等符号旁边不要有空格 5 | 6 | // 示例:Snap_tableA:(id){id,name,other}[WHERE status = '1' ORDER BY id]=(id){id,real_name,password} 7 | 8 | role:(Name){Name}[WHERE IsDelete = 0 GROUP BY Name ORDER BY Name]=(ID){ID,ROLE_NAME,CREATE_DATE,CREATE_USER,UPDATE_DATE,UPDATE_USER,STATUS,REMARK}[] 9 | 10 | user:(id){u.id,u.Name,u.IDCardID,u.Telphone,u.Address,u.EMail,u.Status}[WHERE u.Status = 1 and u.IDCardID is not null and u.IDCardID != '' ORDER BY u.id]=(ID){ID,LOGIN_NAME,PASSWORD,REAL_NAME,STATUS,ADDRESS,RMK,CREATE_DATE,CREATE_USER,UPDATE_DATE,UPDATE_USER,LOGIN_IP,MOBILE,SYS_EMAIL,TELPHONE,LOGO_IMG,PROVINCE,CITY,sbc_id,EMP_CODE,ID_CARD,DEPT_CODE,POSITION_CODE,BANK_NUMBER}[] -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /config/Re-initialization.sql: -------------------------------------------------------------------------------- 1 | -- 还原普相关表到初始化状态 2 | -- 这里相当于一个备忘录,记录和保存你日常经常执行的一些还原操作的sql -------------------------------------------------------------------------------- /config/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 2016-05-27 09:53:00 6 | 10.125 7 | 35 8 | 9 9 | 10 | 11 | 12 | SQL Server 13 | 127.0.0.1 14 | TEST_2017 15 | 16 | 17 | 18 | 19 | MySQL 20 | localhost 21 | TEST_2017_M 22 | 23 | 24 | 25 | 26 | 27 | false,false,false,false,false,false,true 28 | 23:45:00 29 | 30 | 31 | 32 | true 33 | false 34 | false 35 | D:\MySQL 36 | 产品A,产品B 37 | 38 | 39 | 0 40 | 41 | 42 | -------------------------------------------------------------------------------- /config/databaseBakOriginal.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/config/databaseBakOriginal.csv -------------------------------------------------------------------------------- /config/databaseBakTarget.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/config/databaseBakTarget.csv -------------------------------------------------------------------------------- /config/zh-cn.properties: -------------------------------------------------------------------------------- 1 | ds.ui.sure=\u786E\u5B9A 2 | ds.ui.cancel=\u53D6\u6D88 3 | ds.ui.save.success=\u4FDD\u5B58\u6210\u529F\uFF01 4 | ds.ui.save.fail=\u4FDD\u5B58\u5931\u8D25\uFF01\n 5 | ds.ui.tips=\u63D0\u793A 6 | ds.ui.font.family=\u5FAE\u8F6F\u96C5\u9ED1 7 | ds.ui.mainwindow.exitconfirm=\u4E3A\u907F\u514D\u4E0D\u5FC5\u8981\u7684\u4EFB\u52A1\u5931\u8D25\n\u5DF2\u963B\u6B62\u60A8\u5173\u95ED\u8BE5\u7A0B\u5E8F\uFF01\n\u5982\u9700\u9000\u51FA\uFF0C\u8BF7\u5148\u505C\u6B62\u4EFB\u52A1\uFF01 8 | ds.ui.mainwindow.dialog.newBackUp=\u65B0\u5EFA\u5907\u4EFD 9 | ds.ui.mainwindow.dialog.type=\u7C7B\u578B\uFF1A 10 | ds.ui.mainwindow.dialog.remarks=\u5907\u6CE8\uFF1A 11 | ds.ui.mainwindow.dialog.progress=\u8FDB\u5EA6\uFF1A 12 | ds.ui.mainwindow.dialog.comboxType0=\u6765\u6E90\u6570\u636E\u5E93\u6574\u5E93\u5907\u4EFD 13 | ds.ui.mainwindow.dialog.comboxType1=\u6765\u6E90\u8868\u5907\u4EFD 14 | ds.ui.mainwindow.dialog.comboxType2=\u76EE\u6807\u6570\u636E\u5E93\u6574\u5E93\u5907\u4EFD 15 | ds.ui.mainwindow.dialog.comboxType3=\u76EE\u6807\u8868\u5907\u4EFD 16 | ds.ui.app.advice=\u53CD\u9988\u5EFA\u8BAE 17 | ds.ui.app.help=\u5E2E\u52A9 18 | ds.ui.app.info=Copyright 2016 | All Rights Reserved.\u5468\u6CE2\u4E2D\u56FD | www.zhoubochina.com 19 | ds.ui.status.title=\u72B6\u6001 20 | ds.ui.database.title=\u6570\u636E\u5E93\u8BBE\u7F6E 21 | ds.ui.schedule.title=\u4EFB\u52A1\u8BA1\u5212 22 | ds.ui.backup.title=\u5907\u4EFD\u7BA1\u7406 23 | ds.ui.setting.title=\u8BBE\u7F6E 24 | ds.ui.backup.table.head0=\u5E8F\u53F7 25 | ds.ui.backup.table.head1=\u540D\u79F0 26 | ds.ui.backup.table.head2=\u5927\u5C0F 27 | ds.ui.database.label.from=\u6765\u6E90\u6570\u636E\u5E93 28 | ds.ui.database.label.to=\u76EE\u6807\u6570\u636E\u5E93 29 | ds.ui.database.type=\u6570\u636E\u5E93\u7C7B\u578B\uFF1A 30 | ds.ui.database.host=\u6570\u636E\u5E93\u5730\u5740\uFF1A 31 | ds.ui.database.name=\u6570\u636E\u5E93\u540D\u79F0\uFF1A 32 | ds.ui.database.user=\u7528\u6237\u540D\uFF1A 33 | ds.ui.database.password=\u5BC6\u7801\uFF1A 34 | ds.ui.database.from.err.decode=\u6765\u6E90\u6570\u636E\u5E93\u7528\u6237\u540D\u6216\u5BC6\u7801\u89E3\u5BC6\u9519\u8BEF\uFF1A 35 | ds.ui.database.from.err.encode=\u6765\u6E90\u6570\u636E\u5E93\u7528\u6237\u540D\u6216\u5BC6\u7801\u52A0\u5BC6\u9519\u8BEF\uFF1A 36 | ds.ui.database.err.link.fail=\u8FDE\u63A5\u5931\u8D25\uFF01 37 | ds.ui.database.err.link.success=\u8FDE\u63A5\u6210\u529F\uFF01 38 | ds.ui.database.to.err.decode=\u76EE\u6807\u6570\u636E\u5E93\u7528\u6237\u540D\u6216\u5BC6\u7801\u89E3\u5BC6\u9519\u8BEF\uFF1A 39 | ds.ui.database.to.err.encode=\u76EE\u6807\u6570\u636E\u5E93\u7528\u6237\u540D\u6216\u5BC6\u7801\u52A0\u5BC6\u9519\u8BEF\uFF1A 40 | ds.ui.schedule.radio1=5\u5206\u949F\u4E00\u6B21 41 | ds.ui.schedule.radio2=15\u5206\u949F\u4E00\u6B21 42 | ds.ui.schedule.radio3=30\u5206\u949F\u4E00\u6B21 43 | ds.ui.schedule.radio4=\u6BCF\u5C0F\u65F6\u4E00\u6B21 44 | ds.ui.schedule.radio5=\u6BCF\u5929\u4E00\u6B21 45 | ds.ui.schedule.radio6=\u6BCF\u5468\u4E00\u6B21 46 | ds.ui.schedule.radio7=\u6BCF\u5929\u6309\u56FA\u5B9A\u65F6\u95F4\u6267\u884C(hh:mm:ss)\uFF1A 47 | ds.ui.schedule.saveTips=\u4FDD\u5B58\u6210\u529F\uFF01\n\n\u5C06\u5728\u4E0B\u6B21\u4EFB\u52A1\u65F6\u751F\u6548\n\u5982\u6B63\u5728\u6267\u884C\u8BA1\u5212\u4EFB\u52A1\uFF0C\u8BF7\u624B\u52A8\u505C\u6B62\u5E76\u91CD\u65B0\u542F\u52A8\u8BA1\u5212\u4EFB\u52A1\n 48 | ds.ui.schedule.nextTime=\u4E0B\u4E00\u6B21\u540C\u6B65\u65F6\u95F4\uFF1A 49 | ds.ui.setting.option=\u9AD8\u7EA7\u9009\u9879 50 | ds.ui.setting.about=\u5173\u4E8E 51 | ds.ui.setting.autoBackUp=\u81EA\u52A8\u5907\u4EFD 52 | ds.ui.setting.mysqlPath=MySQL\u5B89\u88C5\u8DEF\u5F84: 53 | ds.ui.setting.strict=\u4E25\u683C\u6A21\u5F0F 54 | ds.ui.setting.debugMode=\u5F00\u53D1\u8005\u8C03\u8BD5\u6A21\u5F0F 55 | ds.ui.setting.clean.makeSure=\u786E\u5B9A\u6E05\u7A7A\u5417\uFF1F 56 | ds.ui.setting.clean.success=\u6E05\u7A7A\u6210\u529F\uFF01 57 | ds.ui.setting.clean.fail=\u6E05\u7A7A\u5931\u8D25\uFF01\n 58 | ds.ui.status.ready=\u5C31\u7EEA 59 | ds.ui.status.detail=\u8BE6\u60C5\uFF1A\u5C31\u7EEA 60 | ds.ui.status.logDetail=\u67E5\u770B\u8BE6\u7EC6\u65E5\u5FD7 61 | ds.ui.status.progress.current=\u5F53\u524D\u8FDB\u5EA6\uFF1A 62 | ds.ui.status.progress.total=\u672C\u6B21\u603B\u8FDB\u5EA6\uFF1A 63 | ds.ui.status.from=\u6765\u6E90\uFF1ASQL Server/ 64 | ds.ui.status.to=\u76EE\u6807\uFF1AMySQL/ 65 | ds.ui.status.lastSync=\u4E0A\u4E00\u6B21\u540C\u6B65\u65F6\u95F4\uFF1A 66 | ds.ui.status.keepTime=\u6301\u7EED\u65F6\u95F4\uFF1A 67 | ds.ui.status.second=\u79D2 68 | ds.ui.status.successTimes=\u6210\u529F\u603B\u6B21\u6570 69 | ds.ui.status.failTimes=\u5931\u8D25\u603B\u6B21\u6570\uFF1A 70 | ds.ui.status.manu=\u624B\u52A8\u540C\u6B65\u6267\u884C\u4E2D\u2026\u2026 71 | ds.ui.status.scheduledRunning=\u6309\u8BA1\u5212\u6267\u884C\u4E2D\u2026\u2026 72 | ds.tool.detail=\u8BE6\u60C5\uFF1A 73 | ds.com.luoboduner.wesync.logic.backuping=\u6B63\u5728\u5907\u4EFDMySQL\u6570\u636E\u5E93\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85\u2026\u2026 74 | ds.com.luoboduner.wesync.logic.backupTable=\u6B63\u5728\u5907\u4EFDMySQL\u6570\u636E\u5E93\u76F8\u5173\u8868\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85: 75 | ds.com.luoboduner.wesync.logic.testLinking=\u5F00\u59CB\u6D4B\u8BD5\u8FDE\u63A5 76 | ds.com.luoboduner.wesync.logic.testLinkFail=\u8FDE\u63A5\u6D4B\u8BD5\u5931\u8D25 77 | ds.com.luoboduner.wesync.logic.testLinkFinish=\u8FDE\u63A5\u6D4B\u8BD5\u7ED3\u675F 78 | ds.com.luoboduner.wesync.logic.startAnalyse=\u5F00\u59CB\u89E3\u6790\u914D\u7F6E\u6587\u4EF6 79 | ds.com.luoboduner.wesync.logic.AnalyseFail=\u89E3\u6790\u8868-\u5B57\u6BB5\u914D\u7F6Esql\u6587\u4EF6\u5931\u8D25 80 | ds.com.luoboduner.wesync.logic.AnalyseTriggerFail=\u89E3\u6790Trigger\u6587\u4EF6\u5931\u8D25 81 | ds.com.luoboduner.wesync.logic.finishAnalyse=\u914D\u7F6E\u6587\u4EF6\u89E3\u6790\u5B8C\u6210 82 | ds.com.luoboduner.wesync.logic.startBackUp=\u5F00\u59CB\u5907\u4EFD 83 | ds.com.luoboduner.wesync.logic.finishBackUp=\u5907\u4EFD\u5B8C\u6210 84 | ds.com.luoboduner.wesync.logic.startNewSnap=\u5F00\u59CB\u65B0\u5EFA\u5FEB\u7167 85 | ds.com.luoboduner.wesync.logic.finishNewSnap=\u65B0\u5FEB\u7167\u5EFA\u7ACB\u5B8C\u6210 86 | ds.com.luoboduner.wesync.logic.startDiffSnap=\u5F00\u59CB\u5BF9\u6BD4\u5FEB\u7167 87 | ds.com.luoboduner.wesync.logic.finishDiffSnap=\u5BF9\u6BD4\u5FEB\u7167\u5B8C\u6210 88 | ds.com.luoboduner.wesync.logic.diffSnapFail=\u5BF9\u6BD4\u5FEB\u7167\u5931\u8D25 89 | ds.com.luoboduner.wesync.logic.startRunSql=\u5F00\u59CB\u6267\u884CSQL 90 | ds.com.luoboduner.wesync.logic.runSqlFail=SQL\u6267\u884C\u5931\u8D25\uFF0C\u7531\u4E8E\u5176\u4E2D\u67D0\u4E9BSQL\u5F71\u54CD\u591A\u884C\uFF0C\u5DF2\u7ECF\u56DE\u6EDA\u4E8B\u52A1 91 | ds.com.luoboduner.wesync.logic.runSqlFinish=SQL\u6267\u884C\u5B8C\u6210 92 | ds.com.luoboduner.wesync.logic.syncFinish=\u540C\u6B65\u5B8C\u6210\uFF01 93 | ds.com.luoboduner.wesync.logic.currentSqlFail=->\u6267\u884CSQL\u5931\u8D25: 94 | ds.com.luoboduner.wesync.logic.runScheduleing=\u6309\u8BA1\u5212\u6267\u884C\u4E2D\u2026\u2026 95 | ds.com.luoboduner.wesync.logic.manuSyncFinish=\u624B\u52A8\u540C\u6B65\u5B8C\u6210\uFF01 96 | ds.com.luoboduner.wesync.logic.currentManuSyncFinish=\u672C\u6B21\u624B\u52A8\u540C\u6B65\u5B8C\u6210\uFF01 97 | ds.com.luoboduner.wesync.logic.currentSyncFinish=\u672C\u6B21\u540C\u6B65\u5B8C\u6210\uFF01 98 | ds.com.luoboduner.wesync.logic.currentSnapDirBackFail=\u5907\u4EFD\u5F53\u524D\u5FEB\u7167\u6587\u4EF6\u5939\u5931\u8D25 99 | ds.com.luoboduner.wesync.logic.ifLastSnapExistFail=\u5224\u65AD\u4E0A\u4E00\u6B21\u7684\u5FEB\u7167\u662F\u5426\u5B58\u5728\u5931\u8D25 100 | ds.com.luoboduner.wesync.logic.newSnapFileFail=\u65B0\u5FEB\u7167\u6587\u4EF6\u5931\u8D25 101 | ds.com.luoboduner.wesync.logic.beforeSnapMd5Fail=\u83B7\u53D6\u539F\u5FEB\u7167MD5\u5931\u8D25 102 | ds.com.luoboduner.wesync.logic.nowSnapMd5Fail=\u83B7\u53D6\u65B0\u5FEB\u7167MD5\u5931\u8D25 103 | ds.com.luoboduner.wesync.logic.lineByLineDiffFail=\u9010\u884C\u5BF9\u6BD4\u5FEB\u7167csv\u5931\u8D25 104 | ds.com.luoboduner.wesync.logic.restoreSnapBackFail=\u6062\u590D\u5FEB\u7167\u5907\u4EFD\u5931\u8D25\uFF1A 105 | ds.com.luoboduner.wesync.logic.tableChanged=:\u65B0\u5FEB\u7167\u4E0E\u539F\u5FEB\u7167\u8868\u5934\u4E0D\u4E00\u81F4\uFF0C\u8003\u8651\u8868\u7ED3\u6784\u662F\u5426\u5DF2\u7ECF\u53D8\u66F4\uFF1F -------------------------------------------------------------------------------- /dist/DB_Backup/Target/demo_back.sql: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/DB_Backup/Target/demo_back.sql -------------------------------------------------------------------------------- /dist/DB_Backup/mysql_backup.bat: -------------------------------------------------------------------------------- 1 | @echo off & setlocal ENABLEEXTENSIONS 2 | set BACKUP_PATH=D:\workspaceWeSync\weSync\DB_Backup\Target 3 | set DATABASES=TEST_2017_M 4 | set HOST=localhost 5 | set USERNAME=root 6 | set PASSWORD=123456S 7 | set MYSQL=D:\MySQL 8 | set path_bin_mysql=%MYSQL%\bin\ 9 | set YEAR=%date:~0,4% 10 | set MONTH=%date:~5,2% 11 | set DAY=%date:~8,2% 12 | set HOUR=%time:~0,2% 13 | set MINUTE=%time:~3,2% 14 | set SECOND=%time:~6,2% 15 | set DIR=%BACKUP_PATH% 16 | set ADDON="%YEAR%%MONTH%%DAY%_%HOUR%%MINUTE%%SECOND%" 17 | if not exist %DIR% ( 18 | mkdir %DIR% 19 | ) 20 | if not exist %DIR% ( 21 | echo Backup path: %DIR% not exists, create dir failed. 22 | goto exit 23 | ) 24 | cd /d %DIR% 25 | echo Start dump databases... 26 | for %%D in (%DATABASES%) do ( 27 | echo Dumping database %%D ... 28 | %path_bin_mysql%mysqldump -h%HOST% -u%USERNAME% -p%PASSWORD% --skip-lock-tables %%D > %%D_%ADDON%.sql 29 | ) 30 | echo Done 31 | :exit -------------------------------------------------------------------------------- /dist/DB_Backup/mysql_table_backup.sql: -------------------------------------------------------------------------------- 1 | drop table if exists table_demo_a_bak; 2 | create table table_demo_a_bak like table_demo_a; 3 | insert into table_demo_a_bak select * from table_demo_a; 4 | 5 | drop table if exists table_demo_b_bak; 6 | create table table_demo_b_bak like table_demo_b; 7 | insert into table_demo_b_bak select * from table_demo_b; 8 | 9 | drop table if exists table_demo_c_bak; 10 | create table table_demo_c_bak like table_demo_c; 11 | insert into table_demo_c_bak select * from table_demo_c; 12 | -------------------------------------------------------------------------------- /dist/TableField/init/my_role.DELETE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_role 2 | SET UPDATE_DATE = '$SYS_DATE_TIME$', 3 | UPDATE_USER = 2, 4 | STATUS = '1' 5 | WHERE 6 | (ROLE_NAME = 'before.Name'); -------------------------------------------------------------------------------- /dist/TableField/init/my_role.INSERT.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO my_role ( 2 | ROLE_NAME, 3 | CREATE_DATE, 4 | CREATE_USER, 5 | UPDATE_DATE, 6 | UPDATE_USER, 7 | STATUS, 8 | REMARK 9 | ) 10 | VALUES 11 | ( 12 | 'this.Name', 13 | '$SYS_DATE_TIME$', 14 | 2, 15 | '', 16 | 2, 17 | '2', 18 | '' 19 | ); 20 | -------------------------------------------------------------------------------- /dist/TableField/init/my_role.UPDATE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_role 2 | SET ROLE_NAME = 'this.Name', 3 | UPDATE_DATE = '$SYS_DATE_TIME$', 4 | UPDATE_USER = 2 5 | WHERE 6 | (ROLE_NAME = 'before.Name'); -------------------------------------------------------------------------------- /dist/TableField/init/my_user.DELETE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_user 2 | SET STATUS = '1', 3 | UPDATE_DATE = '$SYS_DATE_TIME$', 4 | UPDATE_USER = 2 5 | WHERE ID_CARD = 'before.IDCardID' ; -------------------------------------------------------------------------------- /dist/TableField/init/my_user.INSERT.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO my_user ( 2 | LOGIN_NAME, 3 | PASSWORD, 4 | REAL_NAME, 5 | STATUS, 6 | ADDRESS, 7 | RMK, 8 | CREATE_DATE, 9 | CREATE_USER, 10 | UPDATE_DATE, 11 | UPDATE_USER, 12 | LOGIN_IP, 13 | MOBILE, 14 | SYS_EMAIL, 15 | TELPHONE, 16 | LOGO_IMG, 17 | PROVINCE, 18 | CITY, 19 | sbc_id, 20 | EMP_CODE, 21 | ID_CARD, 22 | DEPT_CODE, 23 | POSITION_CODE, 24 | BANK_NUMBER 25 | ) 26 | VALUES 27 | ( 28 | '$PINYIN{this.Name}$@SUB(7,END){this.Telphone}@', 29 | '#MD5PE{@SUB(12,END){this.IDCardID}@}#', 30 | 'this.Name', 31 | '#CASE(1=2,2=1){this.Status}#', 32 | 'this.Address', 33 | '', 34 | '$SYS_DATE_TIME$', 35 | 2, 36 | '', 37 | null, 38 | '', 39 | 'this.Telphone', 40 | 'this.EMail', 41 | '', 42 | '', 43 | '', 44 | '', 45 | null, 46 | '', 47 | 'this.IDCardID', 48 | left('#REPLACE(".",""){@SUB(".",END){this.UnitCode}@}#',16), 49 | (SELECT SP_POSITION_CODE FROM my_position WHERE SP_POSITION_NAME = '$SQL{SELECT PositionName FROM Info WHERE id = 'this.id'}$'), 50 | 'this.BankAccountNum' 51 | ); 52 | 53 | INSERT INTO my_user_role ( 54 | USER_ID, 55 | ROLE_ID, 56 | STATUS, 57 | CREATE_DATE, 58 | CREATE_USER, 59 | UPDATE_DATE, 60 | UPDATE_USER, 61 | REMARK 62 | ) 63 | VALUES 64 | ( 65 | (SELECT MAX(ID) FROM my_user), 66 | (SELECT ID FROM my_role WHERE ROLE_NAME = 'test'), 67 | '2', 68 | '$SYS_DATE_TIME$', 69 | 2, 70 | '', 71 | null, 72 | null 73 | ); 74 | 75 | -------------------------------------------------------------------------------- /dist/TableField/init/my_user.UPDATE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_user 2 | SET REAL_NAME = 'this.Name', 3 | ADDRESS = 'this.Address', 4 | UPDATE_DATE = '$SYS_DATE_TIME$', 5 | UPDATE_USER = 2, 6 | MOBILE = 'this.Telphone', 7 | SYS_EMAIL = 'this.EMail', 8 | ID_CARD = 'this.IDCardID', 9 | DEPT_CODE = left('#REPLACE(".",""){@SUB(".",END){this.UnitCode}@}#',16), 10 | POSITION_CODE = (SELECT SP_POSITION_CODE FROM my_position WHERE SP_POSITION_NAME = '$SQL{SELECT PositionName FROM Info WHERE id = 'this.id'}$'), 11 | BANK_NUMBER = 'this.BankAccountNum' 12 | WHERE ID_CARD = 'before.IDCardID' ; -------------------------------------------------------------------------------- /dist/TableField/my_role.DELETE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_role 2 | SET UPDATE_DATE = '$SYS_DATE_TIME$', 3 | UPDATE_USER = 2, 4 | STATUS = '1' 5 | WHERE 6 | (ROLE_NAME = 'before.Name'); -------------------------------------------------------------------------------- /dist/TableField/my_role.INSERT.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO my_role ( 2 | ROLE_NAME, 3 | CREATE_DATE, 4 | CREATE_USER, 5 | UPDATE_DATE, 6 | UPDATE_USER, 7 | STATUS, 8 | REMARK 9 | ) 10 | VALUES 11 | ( 12 | 'this.Name', 13 | '$SYS_DATE_TIME$', 14 | 2, 15 | '', 16 | 2, 17 | '2', 18 | '' 19 | ); 20 | -------------------------------------------------------------------------------- /dist/TableField/my_role.UPDATE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_role 2 | SET ROLE_NAME = 'this.Name', 3 | UPDATE_DATE = '$SYS_DATE_TIME$', 4 | UPDATE_USER = 2 5 | WHERE 6 | (ROLE_NAME = 'before.Name'); -------------------------------------------------------------------------------- /dist/TableField/my_user.DELETE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_user 2 | SET STATUS = '1', 3 | UPDATE_DATE = '$SYS_DATE_TIME$', 4 | UPDATE_USER = 2 5 | WHERE ID_CARD = 'before.IDCardID' ; -------------------------------------------------------------------------------- /dist/TableField/my_user.INSERT.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO my_user ( 2 | LOGIN_NAME, 3 | PASSWORD, 4 | REAL_NAME, 5 | STATUS, 6 | ADDRESS, 7 | RMK, 8 | CREATE_DATE, 9 | CREATE_USER, 10 | UPDATE_DATE, 11 | UPDATE_USER, 12 | LOGIN_IP, 13 | MOBILE, 14 | SYS_EMAIL, 15 | TELPHONE, 16 | LOGO_IMG, 17 | PROVINCE, 18 | CITY, 19 | sbc_id, 20 | EMP_CODE, 21 | ID_CARD, 22 | DEPT_CODE, 23 | POSITION_CODE, 24 | BANK_NUMBER 25 | ) 26 | VALUES 27 | ( 28 | '$PINYIN{this.Name}$@SUB(7,END){this.Telphone}@', 29 | '#MD5PE{@SUB(12,END){this.IDCardID}@}#', 30 | 'this.Name', 31 | '#CASE(1=2,2=1){this.Status}#', 32 | 'this.Address', 33 | '', 34 | '$SYS_DATE_TIME$', 35 | 2, 36 | '', 37 | null, 38 | '', 39 | 'this.Telphone', 40 | 'this.EMail', 41 | '', 42 | '', 43 | '', 44 | '', 45 | null, 46 | '', 47 | 'this.IDCardID', 48 | left('#REPLACE(".",""){@SUB(".",END){this.UnitCode}@}#',16), 49 | (SELECT SP_POSITION_CODE FROM my_position WHERE SP_POSITION_NAME = '$SQL{SELECT PositionName FROM Info WHERE id = 'this.id'}$'), 50 | 'this.BankAccountNum' 51 | ); 52 | 53 | INSERT INTO my_user_role ( 54 | USER_ID, 55 | ROLE_ID, 56 | STATUS, 57 | CREATE_DATE, 58 | CREATE_USER, 59 | UPDATE_DATE, 60 | UPDATE_USER, 61 | REMARK 62 | ) 63 | VALUES 64 | ( 65 | (SELECT MAX(ID) FROM my_user), 66 | (SELECT ID FROM my_role WHERE ROLE_NAME = 'test'), 67 | '2', 68 | '$SYS_DATE_TIME$', 69 | 2, 70 | '', 71 | null, 72 | null 73 | ); 74 | 75 | -------------------------------------------------------------------------------- /dist/TableField/my_user.UPDATE.sql: -------------------------------------------------------------------------------- 1 | UPDATE my_user 2 | SET REAL_NAME = 'this.Name', 3 | ADDRESS = 'this.Address', 4 | UPDATE_DATE = '$SYS_DATE_TIME$', 5 | UPDATE_USER = 2, 6 | MOBILE = 'this.Telphone', 7 | SYS_EMAIL = 'this.EMail', 8 | ID_CARD = 'this.IDCardID', 9 | DEPT_CODE = left('#REPLACE(".",""){@SUB(".",END){this.UnitCode}@}#',16), 10 | POSITION_CODE = (SELECT SP_POSITION_CODE FROM my_position WHERE SP_POSITION_NAME = '$SQL{SELECT PositionName FROM Info WHERE id = 'this.id'}$'), 11 | BANK_NUMBER = 'this.BankAccountNum' 12 | WHERE ID_CARD = 'before.IDCardID' ; -------------------------------------------------------------------------------- /dist/TableField/公式说明.txt: -------------------------------------------------------------------------------- 1 | 注意:同级别公式暂不支持嵌套! 2 | 3 | 第一级别公式: 4 | this.***:取当前快照该条记录的某字段值 5 | before.***:取原快照该条记录的某字段值(仅UPDATE和DELETE时会用到) 6 | 7 | 第二级别公式: 8 | $INCREASE{POSITION_CODE}$:将大括号内的持久化变量递增(*在config文件中设置持久化变量) 9 | $PINYIN{}$:将大括号内的汉字转为拼音 10 | $SYS_DATE_TIME$:系统日期+时间(2016-01-19 17:57:49) 11 | $SQL{}$:执行大括号内的子查询sql,返回对应的查询结果(仅限一个) 12 | 13 | 第三级别公式: 14 | @SUB(5,8){}@:将大括号内的字符串从第5个字符截取到第8个字符(同java的substring方法,含左不含右) 15 | @SUB(5,END){}@:将大括号内的字符串从第5个字符截取到最后(同java的substring方法,含左不含右) 16 | @SUB(0,LAST"."){}@:将大括号内的字符串从第0个字符截取到最后一个"."(同java的substring方法,含左不含右) 17 | @SUB("a",LAST"a"){}@:将大括号内的字符串从第1个"a"截取到最后一个"a"(不含左不含右) 18 | 19 | 第四级别公式: 20 | #REPLACE("a","b"){}#:将大括号内容中所有的"a"替换为"b" 21 | #CASE(a=b,c=d,e=f){}#:如果大括号里边的内容是a,则替换为b;如果为c,则替换为d... 22 | #MD5PE{}#:将大括号内的密码字符串进行Md5PasswordEncoder的encodePassword处理 -------------------------------------------------------------------------------- /dist/Trigger/Trigger.txt: -------------------------------------------------------------------------------- 1 | 2 | // 规则:快照名:<来源表>(主键){字段}[其他条件]=<目标表1>(主键){字段}[保留]=<目标表2>(主键){字段}[保留]... 3 | // 多个以英文逗号隔开 4 | // 注意:]=<等符号旁边不要有空格 5 | 6 | // 示例:Snap_tableA:(id){id,name,other}[WHERE status = '1' ORDER BY id]=(id){id,real_name,password} 7 | 8 | role:(Name){Name}[WHERE IsDelete = 0 GROUP BY Name ORDER BY Name]=(ID){ID,ROLE_NAME,CREATE_DATE,CREATE_USER,UPDATE_DATE,UPDATE_USER,STATUS,REMARK}[] 9 | 10 | user:(id){u.id,u.Name,u.IDCardID,u.Telphone,u.Address,u.EMail,u.Status}[WHERE u.Status = 1 and u.IDCardID is not null and u.IDCardID != '' ORDER BY u.id]=(ID){ID,LOGIN_NAME,PASSWORD,REAL_NAME,STATUS,ADDRESS,RMK,CREATE_DATE,CREATE_USER,UPDATE_DATE,UPDATE_USER,LOGIN_IP,MOBILE,SYS_EMAIL,TELPHONE,LOGO_IMG,PROVINCE,CITY,sbc_id,EMP_CODE,ID_CARD,DEPT_CODE,POSITION_CODE,BANK_NUMBER}[] -------------------------------------------------------------------------------- /dist/WeSync-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/WeSync-1.0.jar -------------------------------------------------------------------------------- /dist/WeSync.bat: -------------------------------------------------------------------------------- 1 | start javaw -jar WeSync-1.0.jar -------------------------------------------------------------------------------- /dist/config/Re-initialization.sql: -------------------------------------------------------------------------------- 1 | -- 还原普相关表到初始化状态 2 | -- 这里相当于一个备忘录,记录和保存你日常经常执行的一些还原操作的sql -------------------------------------------------------------------------------- /dist/config/config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 2016-05-27 09:53:00 6 | 10.125 7 | 35 8 | 9 9 | 10 | 11 | 12 | SQL Server 13 | 127.0.0.1 14 | TEST_2017 15 | 97da459ae523ae80 16 | 1ca6dbffc8f125b4 17 | 18 | 19 | MySQL 20 | localhost 21 | TEST_2017_M 22 | 9bc42c9884cdbe3e 23 | 1ca6dbffc8f125b4 24 | 25 | 26 | 27 | false,false,false,false,false,false,true 28 | 23:45:00 29 | 30 | 31 | 32 | true 33 | false 34 | false 35 | D:\MySQL 36 | 产品A,产品B 37 | 38 | 39 | 0 40 | 41 | 42 | -------------------------------------------------------------------------------- /dist/config/databaseBakOriginal.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/config/databaseBakOriginal.csv -------------------------------------------------------------------------------- /dist/config/databaseBakTarget.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/config/databaseBakTarget.csv -------------------------------------------------------------------------------- /dist/config/zh-cn.properties: -------------------------------------------------------------------------------- 1 | ds.ui.sure=\u786E\u5B9A 2 | ds.ui.cancel=\u53D6\u6D88 3 | ds.ui.save.success=\u4FDD\u5B58\u6210\u529F\uFF01 4 | ds.ui.save.fail=\u4FDD\u5B58\u5931\u8D25\uFF01\n 5 | ds.ui.tips=\u63D0\u793A 6 | ds.ui.font.family=\u5FAE\u8F6F\u96C5\u9ED1 7 | ds.ui.mainwindow.exitconfirm=\u4E3A\u907F\u514D\u4E0D\u5FC5\u8981\u7684\u4EFB\u52A1\u5931\u8D25\n\u5DF2\u963B\u6B62\u60A8\u5173\u95ED\u8BE5\u7A0B\u5E8F\uFF01\n\u5982\u9700\u9000\u51FA\uFF0C\u8BF7\u5148\u505C\u6B62\u4EFB\u52A1\uFF01 8 | ds.ui.mainwindow.dialog.newBackUp=\u65B0\u5EFA\u5907\u4EFD 9 | ds.ui.mainwindow.dialog.type=\u7C7B\u578B\uFF1A 10 | ds.ui.mainwindow.dialog.remarks=\u5907\u6CE8\uFF1A 11 | ds.ui.mainwindow.dialog.progress=\u8FDB\u5EA6\uFF1A 12 | ds.ui.mainwindow.dialog.comboxType0=\u6765\u6E90\u6570\u636E\u5E93\u6574\u5E93\u5907\u4EFD 13 | ds.ui.mainwindow.dialog.comboxType1=\u6765\u6E90\u8868\u5907\u4EFD 14 | ds.ui.mainwindow.dialog.comboxType2=\u76EE\u6807\u6570\u636E\u5E93\u6574\u5E93\u5907\u4EFD 15 | ds.ui.mainwindow.dialog.comboxType3=\u76EE\u6807\u8868\u5907\u4EFD 16 | ds.ui.app.advice=\u53CD\u9988\u5EFA\u8BAE 17 | ds.ui.app.help=\u5E2E\u52A9 18 | ds.ui.app.info=Copyright 2016 | All Rights Reserved.\u5468\u6CE2\u4E2D\u56FD | www.zhoubochina.com 19 | ds.ui.status.title=\u72B6\u6001 20 | ds.ui.database.title=\u6570\u636E\u5E93\u8BBE\u7F6E 21 | ds.ui.schedule.title=\u4EFB\u52A1\u8BA1\u5212 22 | ds.ui.backup.title=\u5907\u4EFD\u7BA1\u7406 23 | ds.ui.setting.title=\u8BBE\u7F6E 24 | ds.ui.backup.table.head0=\u5E8F\u53F7 25 | ds.ui.backup.table.head1=\u540D\u79F0 26 | ds.ui.backup.table.head2=\u5927\u5C0F 27 | ds.ui.database.label.from=\u6765\u6E90\u6570\u636E\u5E93 28 | ds.ui.database.label.to=\u76EE\u6807\u6570\u636E\u5E93 29 | ds.ui.database.type=\u6570\u636E\u5E93\u7C7B\u578B\uFF1A 30 | ds.ui.database.host=\u6570\u636E\u5E93\u5730\u5740\uFF1A 31 | ds.ui.database.name=\u6570\u636E\u5E93\u540D\u79F0\uFF1A 32 | ds.ui.database.user=\u7528\u6237\u540D\uFF1A 33 | ds.ui.database.password=\u5BC6\u7801\uFF1A 34 | ds.ui.database.from.err.decode=\u6765\u6E90\u6570\u636E\u5E93\u7528\u6237\u540D\u6216\u5BC6\u7801\u89E3\u5BC6\u9519\u8BEF\uFF1A 35 | ds.ui.database.from.err.encode=\u6765\u6E90\u6570\u636E\u5E93\u7528\u6237\u540D\u6216\u5BC6\u7801\u52A0\u5BC6\u9519\u8BEF\uFF1A 36 | ds.ui.database.err.link.fail=\u8FDE\u63A5\u5931\u8D25\uFF01 37 | ds.ui.database.err.link.success=\u8FDE\u63A5\u6210\u529F\uFF01 38 | ds.ui.database.to.err.decode=\u76EE\u6807\u6570\u636E\u5E93\u7528\u6237\u540D\u6216\u5BC6\u7801\u89E3\u5BC6\u9519\u8BEF\uFF1A 39 | ds.ui.database.to.err.encode=\u76EE\u6807\u6570\u636E\u5E93\u7528\u6237\u540D\u6216\u5BC6\u7801\u52A0\u5BC6\u9519\u8BEF\uFF1A 40 | ds.ui.schedule.radio1=5\u5206\u949F\u4E00\u6B21 41 | ds.ui.schedule.radio2=15\u5206\u949F\u4E00\u6B21 42 | ds.ui.schedule.radio3=30\u5206\u949F\u4E00\u6B21 43 | ds.ui.schedule.radio4=\u6BCF\u5C0F\u65F6\u4E00\u6B21 44 | ds.ui.schedule.radio5=\u6BCF\u5929\u4E00\u6B21 45 | ds.ui.schedule.radio6=\u6BCF\u5468\u4E00\u6B21 46 | ds.ui.schedule.radio7=\u6BCF\u5929\u6309\u56FA\u5B9A\u65F6\u95F4\u6267\u884C(hh:mm:ss)\uFF1A 47 | ds.ui.schedule.saveTips=\u4FDD\u5B58\u6210\u529F\uFF01\n\n\u5C06\u5728\u4E0B\u6B21\u4EFB\u52A1\u65F6\u751F\u6548\n\u5982\u6B63\u5728\u6267\u884C\u8BA1\u5212\u4EFB\u52A1\uFF0C\u8BF7\u624B\u52A8\u505C\u6B62\u5E76\u91CD\u65B0\u542F\u52A8\u8BA1\u5212\u4EFB\u52A1\n 48 | ds.ui.schedule.nextTime=\u4E0B\u4E00\u6B21\u540C\u6B65\u65F6\u95F4\uFF1A 49 | ds.ui.setting.option=\u9AD8\u7EA7\u9009\u9879 50 | ds.ui.setting.about=\u5173\u4E8E 51 | ds.ui.setting.autoBackUp=\u81EA\u52A8\u5907\u4EFD 52 | ds.ui.setting.mysqlPath=MySQL\u5B89\u88C5\u8DEF\u5F84: 53 | ds.ui.setting.strict=\u4E25\u683C\u6A21\u5F0F 54 | ds.ui.setting.debugMode=\u5F00\u53D1\u8005\u8C03\u8BD5\u6A21\u5F0F 55 | ds.ui.setting.clean.makeSure=\u786E\u5B9A\u6E05\u7A7A\u5417\uFF1F 56 | ds.ui.setting.clean.success=\u6E05\u7A7A\u6210\u529F\uFF01 57 | ds.ui.setting.clean.fail=\u6E05\u7A7A\u5931\u8D25\uFF01\n 58 | ds.ui.status.ready=\u5C31\u7EEA 59 | ds.ui.status.detail=\u8BE6\u60C5\uFF1A\u5C31\u7EEA 60 | ds.ui.status.logDetail=\u67E5\u770B\u8BE6\u7EC6\u65E5\u5FD7 61 | ds.ui.status.progress.current=\u5F53\u524D\u8FDB\u5EA6\uFF1A 62 | ds.ui.status.progress.total=\u672C\u6B21\u603B\u8FDB\u5EA6\uFF1A 63 | ds.ui.status.from=\u6765\u6E90\uFF1ASQL Server/ 64 | ds.ui.status.to=\u76EE\u6807\uFF1AMySQL/ 65 | ds.ui.status.lastSync=\u4E0A\u4E00\u6B21\u540C\u6B65\u65F6\u95F4\uFF1A 66 | ds.ui.status.keepTime=\u6301\u7EED\u65F6\u95F4\uFF1A 67 | ds.ui.status.second=\u79D2 68 | ds.ui.status.successTimes=\u6210\u529F\u603B\u6B21\u6570 69 | ds.ui.status.failTimes=\u5931\u8D25\u603B\u6B21\u6570\uFF1A 70 | ds.ui.status.manu=\u624B\u52A8\u540C\u6B65\u6267\u884C\u4E2D\u2026\u2026 71 | ds.ui.status.scheduledRunning=\u6309\u8BA1\u5212\u6267\u884C\u4E2D\u2026\u2026 72 | ds.tool.detail=\u8BE6\u60C5\uFF1A 73 | ds.com.luoboduner.wesync.logic.backuping=\u6B63\u5728\u5907\u4EFDMySQL\u6570\u636E\u5E93\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85\u2026\u2026 74 | ds.com.luoboduner.wesync.logic.backupTable=\u6B63\u5728\u5907\u4EFDMySQL\u6570\u636E\u5E93\u76F8\u5173\u8868\uFF0C\u8BF7\u8010\u5FC3\u7B49\u5F85: 75 | ds.com.luoboduner.wesync.logic.testLinking=\u5F00\u59CB\u6D4B\u8BD5\u8FDE\u63A5 76 | ds.com.luoboduner.wesync.logic.testLinkFail=\u8FDE\u63A5\u6D4B\u8BD5\u5931\u8D25 77 | ds.com.luoboduner.wesync.logic.testLinkFinish=\u8FDE\u63A5\u6D4B\u8BD5\u7ED3\u675F 78 | ds.com.luoboduner.wesync.logic.startAnalyse=\u5F00\u59CB\u89E3\u6790\u914D\u7F6E\u6587\u4EF6 79 | ds.com.luoboduner.wesync.logic.AnalyseFail=\u89E3\u6790\u8868-\u5B57\u6BB5\u914D\u7F6Esql\u6587\u4EF6\u5931\u8D25 80 | ds.com.luoboduner.wesync.logic.AnalyseTriggerFail=\u89E3\u6790Trigger\u6587\u4EF6\u5931\u8D25 81 | ds.com.luoboduner.wesync.logic.finishAnalyse=\u914D\u7F6E\u6587\u4EF6\u89E3\u6790\u5B8C\u6210 82 | ds.com.luoboduner.wesync.logic.startBackUp=\u5F00\u59CB\u5907\u4EFD 83 | ds.com.luoboduner.wesync.logic.finishBackUp=\u5907\u4EFD\u5B8C\u6210 84 | ds.com.luoboduner.wesync.logic.startNewSnap=\u5F00\u59CB\u65B0\u5EFA\u5FEB\u7167 85 | ds.com.luoboduner.wesync.logic.finishNewSnap=\u65B0\u5FEB\u7167\u5EFA\u7ACB\u5B8C\u6210 86 | ds.com.luoboduner.wesync.logic.startDiffSnap=\u5F00\u59CB\u5BF9\u6BD4\u5FEB\u7167 87 | ds.com.luoboduner.wesync.logic.finishDiffSnap=\u5BF9\u6BD4\u5FEB\u7167\u5B8C\u6210 88 | ds.com.luoboduner.wesync.logic.diffSnapFail=\u5BF9\u6BD4\u5FEB\u7167\u5931\u8D25 89 | ds.com.luoboduner.wesync.logic.startRunSql=\u5F00\u59CB\u6267\u884CSQL 90 | ds.com.luoboduner.wesync.logic.runSqlFail=SQL\u6267\u884C\u5931\u8D25\uFF0C\u7531\u4E8E\u5176\u4E2D\u67D0\u4E9BSQL\u5F71\u54CD\u591A\u884C\uFF0C\u5DF2\u7ECF\u56DE\u6EDA\u4E8B\u52A1 91 | ds.com.luoboduner.wesync.logic.runSqlFinish=SQL\u6267\u884C\u5B8C\u6210 92 | ds.com.luoboduner.wesync.logic.syncFinish=\u540C\u6B65\u5B8C\u6210\uFF01 93 | ds.com.luoboduner.wesync.logic.currentSqlFail=->\u6267\u884CSQL\u5931\u8D25: 94 | ds.com.luoboduner.wesync.logic.runScheduleing=\u6309\u8BA1\u5212\u6267\u884C\u4E2D\u2026\u2026 95 | ds.com.luoboduner.wesync.logic.manuSyncFinish=\u624B\u52A8\u540C\u6B65\u5B8C\u6210\uFF01 96 | ds.com.luoboduner.wesync.logic.currentManuSyncFinish=\u672C\u6B21\u624B\u52A8\u540C\u6B65\u5B8C\u6210\uFF01 97 | ds.com.luoboduner.wesync.logic.currentSyncFinish=\u672C\u6B21\u540C\u6B65\u5B8C\u6210\uFF01 98 | ds.com.luoboduner.wesync.logic.currentSnapDirBackFail=\u5907\u4EFD\u5F53\u524D\u5FEB\u7167\u6587\u4EF6\u5939\u5931\u8D25 99 | ds.com.luoboduner.wesync.logic.ifLastSnapExistFail=\u5224\u65AD\u4E0A\u4E00\u6B21\u7684\u5FEB\u7167\u662F\u5426\u5B58\u5728\u5931\u8D25 100 | ds.com.luoboduner.wesync.logic.newSnapFileFail=\u65B0\u5FEB\u7167\u6587\u4EF6\u5931\u8D25 101 | ds.com.luoboduner.wesync.logic.beforeSnapMd5Fail=\u83B7\u53D6\u539F\u5FEB\u7167MD5\u5931\u8D25 102 | ds.com.luoboduner.wesync.logic.nowSnapMd5Fail=\u83B7\u53D6\u65B0\u5FEB\u7167MD5\u5931\u8D25 103 | ds.com.luoboduner.wesync.logic.lineByLineDiffFail=\u9010\u884C\u5BF9\u6BD4\u5FEB\u7167csv\u5931\u8D25 104 | ds.com.luoboduner.wesync.logic.restoreSnapBackFail=\u6062\u590D\u5FEB\u7167\u5907\u4EFD\u5931\u8D25\uFF1A 105 | ds.com.luoboduner.wesync.logic.tableChanged=:\u65B0\u5FEB\u7167\u4E0E\u539F\u5FEB\u7167\u8868\u5934\u4E0D\u4E00\u81F4\uFF0C\u8003\u8651\u8868\u7ED3\u6784\u662F\u5426\u5DF2\u7ECF\u53D8\u66F4\uFF1F -------------------------------------------------------------------------------- /dist/lib/aopalliance-1.0.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/aopalliance-1.0.jar -------------------------------------------------------------------------------- /dist/lib/commons-beanutils-1.9.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/commons-beanutils-1.9.3.jar -------------------------------------------------------------------------------- /dist/lib/commons-collections-3.2.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/commons-collections-3.2.2.jar -------------------------------------------------------------------------------- /dist/lib/commons-lang3-3.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/commons-lang3-3.5.jar -------------------------------------------------------------------------------- /dist/lib/commons-logging-1.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/commons-logging-1.2.jar -------------------------------------------------------------------------------- /dist/lib/dom4j-2.0.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/dom4j-2.0.1.jar -------------------------------------------------------------------------------- /dist/lib/emoji-java-3.1.3.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/emoji-java-3.1.3.jar -------------------------------------------------------------------------------- /dist/lib/jaxen-1.1.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/jaxen-1.1.6.jar -------------------------------------------------------------------------------- /dist/lib/json-20140107.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/json-20140107.jar -------------------------------------------------------------------------------- /dist/lib/logback-classic-1.2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/logback-classic-1.2.1.jar -------------------------------------------------------------------------------- /dist/lib/logback-core-1.2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/logback-core-1.2.1.jar -------------------------------------------------------------------------------- /dist/lib/mysql-connector-java-6.0.6.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/mysql-connector-java-6.0.6.jar -------------------------------------------------------------------------------- /dist/lib/opencsv-3.9.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/opencsv-3.9.jar -------------------------------------------------------------------------------- /dist/lib/pinyin4j-2.5.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/pinyin4j-2.5.1.jar -------------------------------------------------------------------------------- /dist/lib/saxpath-1.0-FCS.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/saxpath-1.0-FCS.jar -------------------------------------------------------------------------------- /dist/lib/slf4j-api-1.7.22.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/slf4j-api-1.7.22.jar -------------------------------------------------------------------------------- /dist/lib/spring-aop-4.3.9.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/spring-aop-4.3.9.RELEASE.jar -------------------------------------------------------------------------------- /dist/lib/spring-beans-4.3.9.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/spring-beans-4.3.9.RELEASE.jar -------------------------------------------------------------------------------- /dist/lib/spring-context-4.3.9.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/spring-context-4.3.9.RELEASE.jar -------------------------------------------------------------------------------- /dist/lib/spring-core-4.3.9.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/spring-core-4.3.9.RELEASE.jar -------------------------------------------------------------------------------- /dist/lib/spring-expression-4.3.9.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/spring-expression-4.3.9.RELEASE.jar -------------------------------------------------------------------------------- /dist/lib/spring-security-core-4.2.3.RELEASE.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/dist/lib/spring-security-core-4.2.3.RELEASE.jar -------------------------------------------------------------------------------- /dist/snaps/role.csv: -------------------------------------------------------------------------------- 1 | "Name" 2 | "3D设计师" 3 | "IT专员" 4 | "SEM" 5 | "SEO" 6 | "UI前端工程师" 7 | "部门经理" 8 | -------------------------------------------------------------------------------- /dist/snaps/role_before.csv: -------------------------------------------------------------------------------- 1 | "Name" 2 | "3D设计师" 3 | "IT专员" 4 | "UI前端工程师" 5 | "部门经理" 6 | -------------------------------------------------------------------------------- /dist/snaps/user.csv: -------------------------------------------------------------------------------- 1 | "id","Name","IDCardID","Telphone","Address","EMail","Status" 2 | "A1","张某","211918181765325431","15512345678","辽宁省葫芦岛",,"1" 3 | "D8","王某","211918181765325432","13912345678",,,"辽宁省葫芦岛" 4 | "32","李某","211918181765325433","15112345678","辽宁省葫芦岛",,"1" 5 | "7B","赵某","211918181765325434","13512345678",,,"1" 6 | "97","刘某","211918181765325435","15612345678","辽宁省葫芦岛",,"1" -------------------------------------------------------------------------------- /dist/snaps/user_before.csv: -------------------------------------------------------------------------------- 1 | "id","Name","IDCardID","Telphone","Address","EMail","Status" 2 | "A1","张某","211918181765325431","15512345678","辽宁省葫芦岛",,"1" 3 | "D8","王某","211918181765325432","13912345678",,,"辽宁省葫芦岛" 4 | "32","李某","211918181765325433","15112345678","辽宁省葫芦岛",,"1" 5 | "7B","赵某","211918181765325434","13512345678",,,"1" 6 | "97","刘某","211918181765325435","15612345678","辽宁省葫芦岛",,"1" 7 | -------------------------------------------------------------------------------- /dist/snaps_bak/role.csv: -------------------------------------------------------------------------------- 1 | "Name" 2 | "3D设计师" 3 | "IT专员" 4 | "SEM" 5 | "SEO" 6 | "UI前端工程师" 7 | "部门经理" 8 | -------------------------------------------------------------------------------- /dist/snaps_bak/role_before.csv: -------------------------------------------------------------------------------- 1 | "Name" 2 | "3D设计师" 3 | "IT专员" 4 | "UI前端工程师" 5 | "部门经理" 6 | -------------------------------------------------------------------------------- /dist/snaps_bak/user.csv: -------------------------------------------------------------------------------- 1 | "id","Name","IDCardID","Telphone","Address","EMail","Status" 2 | "A1","张某","211918181765325431","15512345678","辽宁省葫芦岛",,"1" 3 | "D8","王某","211918181765325432","13912345678",,,"辽宁省葫芦岛" 4 | "32","李某","211918181765325433","15112345678","辽宁省葫芦岛",,"1" 5 | "7B","赵某","211918181765325434","13512345678",,,"1" 6 | "97","刘某","211918181765325435","15612345678","辽宁省葫芦岛",,"1" -------------------------------------------------------------------------------- /dist/snaps_bak/user_before.csv: -------------------------------------------------------------------------------- 1 | "id","Name","IDCardID","Telphone","Address","EMail","Status" 2 | "A1","张某","211918181765325431","15512345678","辽宁省葫芦岛",,"1" 3 | "D8","王某","211918181765325432","13912345678",,,"辽宁省葫芦岛" 4 | "32","李某","211918181765325433","15112345678","辽宁省葫芦岛",,"1" 5 | "7B","赵某","211918181765325434","13512345678",,,"1" 6 | "97","刘某","211918181765325435","15612345678","辽宁省葫芦岛",,"1" 7 | -------------------------------------------------------------------------------- /log_SQL/log_sql.csv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/log_SQL/log_sql.csv -------------------------------------------------------------------------------- /memo.txt: -------------------------------------------------------------------------------- 1 | JPanel(boolean isDoubleBuffered) 2 | 创建具有 FlowLayout 和指定缓冲策略的新 JPanel。 3 | 4 | public JPanel(boolean isDoubleBuffered)创建具有 FlowLayout 和指定缓冲策略的新 JPanel。如果 isDoubleBuffered 为 true,则 JPanel 将使用双缓冲。 5 | 6 | 参数: 7 | isDoubleBuffered - 一个 boolean 值,为 true 表示双缓冲,使用更多内存空间实现快速、无闪烁的更新 -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | com.zhoubochina.tool.wesync 8 | WeSync 9 | 1.0 10 | jar 11 | 12 | 13 | UTF-8 14 | UTF-8 15 | 1.8 16 | 1.2.1 17 | 3.1.3 18 | 3.9 19 | 6.0.6 20 | 8.4.1.jre8 21 | 2.1.3 22 | 5.1.11.RELEASE 23 | 1.1.6 24 | 1.0-FCS 25 | 2.5.1 26 | 27 | 28 | 29 | 30 | ch.qos.logback 31 | logback-classic 32 | ${logback.version} 33 | 34 | 35 | 36 | com.vdurmont 37 | emoji-java 38 | ${emoji-java.version} 39 | 40 | 41 | 42 | com.opencsv 43 | opencsv 44 | ${opencsv.version} 45 | 46 | 47 | 48 | mysql 49 | mysql-connector-java 50 | ${mysql-connector-java.version} 51 | 52 | 53 | 54 | com.microsoft.sqlserver 55 | mssql-jdbc 56 | ${mssql-jdbc.version} 57 | 58 | 59 | 60 | org.dom4j 61 | dom4j 62 | ${dom4j.version} 63 | 64 | 65 | 66 | org.springframework.security 67 | spring-security-core 68 | ${spring-security-core.version} 69 | 70 | 71 | 72 | jaxen 73 | jaxen 74 | ${jaxen.version} 75 | 76 | 77 | 78 | saxpath 79 | saxpath 80 | ${saxpath.version} 81 | 82 | 83 | 84 | com.belerweb 85 | pinyin4j 86 | ${pinyin4j.version} 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | org.apache.maven.plugins 95 | maven-compiler-plugin 96 | 3.6.1 97 | 98 | 1.8 99 | 1.8 100 | UTF-8 101 | 102 | 103 | 104 | 105 | org.apache.maven.plugins 106 | maven-jar-plugin 107 | 2.6 108 | 109 | 110 | 111 | true 112 | lib/ 113 | com.luoboduner.wesync.App 114 | 115 | 116 | 117 | 118 | 119 | org.apache.maven.plugins 120 | maven-dependency-plugin 121 | 2.10 122 | 123 | 124 | copy-dependencies 125 | package 126 | 127 | copy-dependencies 128 | 129 | 130 | ${project.build.directory}/lib 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 |

2 | 3 | WeSync-Logo 4 | 5 |

6 | 7 | WeSync [![Build Status](https://travis-ci.org/rememberber/WeSync.svg?branch=master)](https://travis-ci.org/rememberber/WeSync) 8 | ============ 9 | 10 | com.luoboduner.wesync.ui 11 | ------- 12 | >Java Swing 13 | >some icons 14 | 15 | 功能特性 16 | --------- 17 | >数据库同步,数据库间数据传输 18 | >支持不同数据库间,不同表和不同表结构间数据同步 19 | >支持同步过程中数据加工(可扩展) 20 | >支持失败事务回滚 21 | >支持失败快照回滚 22 | >目前支持SqlServer->MySQL 23 | >可扩展任意不同数据库间数据传输 24 | 25 | 速览 26 | ----- 27 |

28 | 29 | WeSync 30 | 31 |

32 |

33 | 34 | WeSync 35 | 36 |

37 |

38 | 39 | WeSync 40 | 41 |

42 |

43 | 44 | WeSync 45 | 46 |

47 |

48 | 49 | WeSync 50 | 51 |

52 |

53 | 54 | WeSync 55 | 56 |

57 | 58 | 59 | 环境依赖 60 | --------- 61 | >Java 8 62 | 63 | 目录结构描述 64 | ------------- 65 | >config:配置 66 | >>config.xml:UI设置参数的持久化 67 | >>Re-initialization.sql:还原相关表到初始化状态的memo 68 | >>zh-cn.properties:语言,国际化 69 | 70 | >DB_Backup:备份相关 71 | >>mysql_backup.bat:备份脚本 72 | >>mysql_table_backup.sql:备份时执行的sql 73 | 74 | >log_SQL:记录每次执行的sql流水 75 | 76 | >snaps:csv快照 77 | >snaps_bak:csv快照备份 78 | 79 | >TableField:表-字段 对应关系配置 80 | 81 | >Trigger:同步出发机制配置 82 | 83 | 版本内容更新 84 | ------------- 85 | 86 | 声明 87 | ------- 88 | >图标来源:http://designmodo.com/linecons-free/ -------------------------------------------------------------------------------- /screen_shot/WeSync.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/screen_shot/WeSync.png -------------------------------------------------------------------------------- /screen_shot/图像 030.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/screen_shot/图像 030.png -------------------------------------------------------------------------------- /screen_shot/图像 031.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/screen_shot/图像 031.png -------------------------------------------------------------------------------- /screen_shot/图像 032.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/screen_shot/图像 032.png -------------------------------------------------------------------------------- /screen_shot/图像 033.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/screen_shot/图像 033.png -------------------------------------------------------------------------------- /screen_shot/图像 034.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/screen_shot/图像 034.png -------------------------------------------------------------------------------- /screen_shot/图像 035.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/screen_shot/图像 035.png -------------------------------------------------------------------------------- /snaps/role.csv: -------------------------------------------------------------------------------- 1 | "Name" 2 | "3D设计师" 3 | "IT专员" 4 | "SEM" 5 | "SEO" 6 | "UI前端工程师" 7 | "部门经理" 8 | -------------------------------------------------------------------------------- /snaps/role_before.csv: -------------------------------------------------------------------------------- 1 | "Name" 2 | "3D设计师" 3 | "IT专员" 4 | "UI前端工程师" 5 | "部门经理" 6 | -------------------------------------------------------------------------------- /snaps/user.csv: -------------------------------------------------------------------------------- 1 | "id","Name","IDCardID","Telphone","Address","EMail","Status" 2 | "A1","张某","211918181765325431","15512345678","辽宁省葫芦岛",,"1" 3 | "D8","王某","211918181765325432","13912345678",,,"辽宁省葫芦岛" 4 | "32","李某","211918181765325433","15112345678","辽宁省葫芦岛",,"1" 5 | "7B","赵某","211918181765325434","13512345678",,,"1" 6 | "97","刘某","211918181765325435","15612345678","辽宁省葫芦岛",,"1" -------------------------------------------------------------------------------- /snaps/user_before.csv: -------------------------------------------------------------------------------- 1 | "id","Name","IDCardID","Telphone","Address","EMail","Status" 2 | "A1","张某","211918181765325431","15512345678","辽宁省葫芦岛",,"1" 3 | "D8","王某","211918181765325432","13912345678",,,"辽宁省葫芦岛" 4 | "32","李某","211918181765325433","15112345678","辽宁省葫芦岛",,"1" 5 | "7B","赵某","211918181765325434","13512345678",,,"1" 6 | "97","刘某","211918181765325435","15612345678","辽宁省葫芦岛",,"1" 7 | -------------------------------------------------------------------------------- /snaps_bak/role.csv: -------------------------------------------------------------------------------- 1 | "Name" 2 | "3D设计师" 3 | "IT专员" 4 | "SEM" 5 | "SEO" 6 | "UI前端工程师" 7 | "部门经理" 8 | -------------------------------------------------------------------------------- /snaps_bak/role_before.csv: -------------------------------------------------------------------------------- 1 | "Name" 2 | "3D设计师" 3 | "IT专员" 4 | "UI前端工程师" 5 | "部门经理" 6 | -------------------------------------------------------------------------------- /snaps_bak/user.csv: -------------------------------------------------------------------------------- 1 | "id","Name","IDCardID","Telphone","Address","EMail","Status" 2 | "A1","张某","211918181765325431","15512345678","辽宁省葫芦岛",,"1" 3 | "D8","王某","211918181765325432","13912345678",,,"辽宁省葫芦岛" 4 | "32","李某","211918181765325433","15112345678","辽宁省葫芦岛",,"1" 5 | "7B","赵某","211918181765325434","13512345678",,,"1" 6 | "97","刘某","211918181765325435","15612345678","辽宁省葫芦岛",,"1" -------------------------------------------------------------------------------- /snaps_bak/user_before.csv: -------------------------------------------------------------------------------- 1 | "id","Name","IDCardID","Telphone","Address","EMail","Status" 2 | "A1","张某","211918181765325431","15512345678","辽宁省葫芦岛",,"1" 3 | "D8","王某","211918181765325432","13912345678",,,"辽宁省葫芦岛" 4 | "32","李某","211918181765325433","15112345678","辽宁省葫芦岛",,"1" 5 | "7B","赵某","211918181765325434","13512345678",,,"1" 6 | "97","刘某","211918181765325435","15612345678","辽宁省葫芦岛",,"1" 7 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/App.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync; 2 | 3 | import com.luoboduner.wesync.ui.UiConsts; 4 | import com.luoboduner.wesync.ui.dialog.DbBackUpCreateDialog; 5 | import com.luoboduner.wesync.ui.panel.*; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import com.luoboduner.wesync.tools.PropertyUtil; 9 | 10 | import javax.swing.*; 11 | import java.awt.*; 12 | import java.awt.event.WindowEvent; 13 | import java.awt.event.WindowListener; 14 | 15 | /** 16 | * 程序入口,主窗口Frame 17 | * 18 | * @author Bob 19 | */ 20 | public class App { 21 | private static final Logger logger = LoggerFactory.getLogger(App.class); 22 | 23 | private JFrame frame; 24 | 25 | public static JPanel mainPanelCenter; 26 | 27 | public static StatusPanel statusPanel; 28 | public static DatabasePanel databasePanel; 29 | public static SchedulePanel schedulePanel; 30 | public static BackupPanel backupPanel; 31 | public static SettingPanel settingPanel; 32 | /** 33 | * 新建备份dialog 34 | */ 35 | public static DbBackUpCreateDialog dbBackUpCreateDialog; 36 | 37 | /** 38 | * 程序入口main 39 | */ 40 | public static void main(String[] args) { 41 | EventQueue.invokeLater(() -> { 42 | try { 43 | App window = new App(); 44 | window.frame.setVisible(true); 45 | } catch (Exception e) { 46 | e.printStackTrace(); 47 | } 48 | }); 49 | } 50 | 51 | /** 52 | * 构造,创建APP 53 | */ 54 | public App() { 55 | initialize(); 56 | StatusPanel.buttonStartSchedule.doClick(); 57 | } 58 | 59 | /** 60 | * 初始化frame内容 61 | */ 62 | private void initialize() { 63 | logger.info("==================AppInitStart"); 64 | // 设置系统默认样式 65 | try { 66 | UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); 67 | } catch (ClassNotFoundException | InstantiationException | IllegalAccessException 68 | | UnsupportedLookAndFeelException e) { 69 | // TODO Auto-generated catch block 70 | e.printStackTrace(); 71 | } 72 | 73 | // 初始化主窗口 74 | frame = new JFrame(); 75 | frame.setBounds(UiConsts.MAIN_WINDOW_X, UiConsts.MAIN_WINDOW_Y, UiConsts.MAIN_WINDOW_WIDTH, 76 | UiConsts.MAIN_WINDOW_HEIGHT); 77 | frame.setTitle(UiConsts.APP_NAME); 78 | frame.setIconImage(UiConsts.IMAGE_ICON); 79 | frame.setBackground(UiConsts.MAIN_BACK_COLOR); 80 | JPanel mainPanel = new JPanel(true); 81 | mainPanel.setBackground(Color.white); 82 | mainPanel.setLayout(new BorderLayout()); 83 | 84 | ToolBarPanel toolbar = new ToolBarPanel(); 85 | statusPanel = new StatusPanel(); 86 | databasePanel = new DatabasePanel(); 87 | schedulePanel = new SchedulePanel(); 88 | backupPanel = new BackupPanel(); 89 | settingPanel = new SettingPanel(); 90 | 91 | mainPanel.add(toolbar, BorderLayout.WEST); 92 | 93 | mainPanelCenter = new JPanel(true); 94 | mainPanelCenter.setLayout(new BorderLayout()); 95 | mainPanelCenter.add(statusPanel, BorderLayout.CENTER); 96 | 97 | mainPanel.add(mainPanelCenter, BorderLayout.CENTER); 98 | 99 | // 添加数据库备份对话框 100 | addDialog(); 101 | 102 | frame.add(mainPanel); 103 | 104 | frame.addWindowListener(new WindowListener() { 105 | 106 | @Override 107 | public void windowOpened(WindowEvent e) { 108 | // TODO Auto-generated method stub 109 | 110 | } 111 | 112 | @Override 113 | public void windowIconified(WindowEvent e) { 114 | // TODO Auto-generated method stub 115 | 116 | } 117 | 118 | @Override 119 | public void windowDeiconified(WindowEvent e) { 120 | // TODO Auto-generated method stub 121 | 122 | } 123 | 124 | @Override 125 | public void windowDeactivated(WindowEvent e) { 126 | // TODO Auto-generated method stub 127 | 128 | } 129 | 130 | @Override 131 | public void windowClosing(WindowEvent e) { 132 | if (!StatusPanel.buttonStartSchedule.isEnabled()) { 133 | JOptionPane.showMessageDialog(App.statusPanel, 134 | PropertyUtil.getProperty("ds.ui.mainwindow.exitconfirm"), "Sorry~", JOptionPane.WARNING_MESSAGE); 135 | } else { 136 | frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 137 | } 138 | 139 | } 140 | 141 | @Override 142 | public void windowClosed(WindowEvent e) { 143 | 144 | } 145 | 146 | @Override 147 | public void windowActivated(WindowEvent e) { 148 | 149 | } 150 | }); 151 | frame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE); 152 | logger.info("==================AppInitEnd"); 153 | } 154 | 155 | /** 156 | * 数据库备份对话框 157 | */ 158 | private void addDialog() { 159 | // 数据库备份对话框 160 | dbBackUpCreateDialog = new DbBackUpCreateDialog(frame, PropertyUtil.getProperty("ds.ui.mainwindow.dialog.newBackUp"), true); 161 | dbBackUpCreateDialog.init(); 162 | } 163 | 164 | } -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/logic/BackupManage.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.logic; 2 | 3 | import com.luoboduner.wesync.tools.*; 4 | 5 | import java.io.BufferedWriter; 6 | import java.io.File; 7 | import java.io.FileWriter; 8 | import java.io.IOException; 9 | import java.sql.SQLException; 10 | import java.util.ArrayList; 11 | 12 | /** 13 | * 备份管理类 14 | * 15 | * @author Bob 16 | */ 17 | public class BackupManage { 18 | 19 | /** 20 | * 创建生成mysql备份bat 21 | * 22 | * @param hostIP 23 | * @param userName 24 | * @param password 25 | * @param databaseName 26 | * @return 27 | */ 28 | public static boolean createMysqlBackBat(String hostIP, String userName, String password, String databaseName) { 29 | boolean isSuccess = true; 30 | 31 | // 写bat文件 32 | File bat = new File(ConstantsLogic.BAT_DIR_MYSQL); 33 | BufferedWriter bw = null; 34 | try { 35 | bw = new BufferedWriter(new FileWriter(bat)); 36 | 37 | bw.write("@echo off & setlocal ENABLEEXTENSIONS"); 38 | bw.newLine(); 39 | bw.write("set BACKUP_PATH=" + ConstantsLogic.PATH_MYSQL_BAK); 40 | bw.newLine(); 41 | bw.write("set DATABASES=" + databaseName); 42 | bw.newLine(); 43 | bw.write("set HOST=" + hostIP); 44 | bw.newLine(); 45 | bw.write("set USERNAME=" + userName); 46 | bw.newLine(); 47 | bw.write("set PASSWORD=" + password); 48 | bw.newLine(); 49 | bw.write("set MYSQL=" + ConstantsTools.CONFIGER.getMysqlPath()); 50 | bw.newLine(); 51 | bw.write("set path_bin_mysql=%MYSQL%\\bin\\"); 52 | bw.newLine(); 53 | 54 | StringBuffer batContentPart2 = new StringBuffer(); 55 | batContentPart2.append("set YEAR=%date:~0,4%").append("\r\n"); 56 | batContentPart2.append("set MONTH=%date:~5,2%").append("\r\n"); 57 | batContentPart2.append("set DAY=%date:~8,2%").append("\r\n"); 58 | batContentPart2.append("set HOUR=%time:~0,2%").append("\r\n"); 59 | batContentPart2.append("set MINUTE=%time:~3,2%").append("\r\n"); 60 | batContentPart2.append("set SECOND=%time:~6,2%").append("\r\n"); 61 | batContentPart2.append("set DIR=%BACKUP_PATH%").append("\r\n"); 62 | batContentPart2.append("set ADDON=\"%YEAR%%MONTH%%DAY%_%HOUR%%MINUTE%%SECOND%\"").append("\r\n"); 63 | 64 | batContentPart2.append("if not exist %DIR% (").append("\r\n"); 65 | batContentPart2.append("mkdir %DIR%").append("\r\n"); 66 | batContentPart2.append(")").append("\r\n"); 67 | batContentPart2.append("if not exist %DIR% (").append("\r\n"); 68 | batContentPart2.append("echo Backup path: %DIR% not exists, create dir failed.").append("\r\n"); 69 | batContentPart2.append("goto exit").append("\r\n"); 70 | batContentPart2.append(")").append("\r\n"); 71 | batContentPart2.append("cd /d %DIR%").append("\r\n"); 72 | 73 | batContentPart2.append("echo Start dump databases...").append("\r\n"); 74 | batContentPart2.append("for %%D in (%DATABASES%) do (").append("\r\n"); 75 | batContentPart2.append("echo Dumping database %%D ...").append("\r\n"); 76 | batContentPart2 77 | .append("%path_bin_mysql%mysqldump -h%HOST% -u%USERNAME% -p%PASSWORD% --skip-lock-tables %%D > %%D_%ADDON%.sql") 78 | .append("\r\n"); 79 | batContentPart2.append(")").append("\r\n"); 80 | batContentPart2.append("echo Done").append("\r\n"); 81 | batContentPart2.append(":exit"); 82 | bw.write(batContentPart2.toString()); 83 | bw.flush(); 84 | } catch (IOException e) { 85 | isSuccess = false; 86 | e.printStackTrace(); 87 | return false; 88 | } finally { 89 | if (bw != null) { 90 | try { 91 | bw.close(); 92 | } catch (IOException e) { 93 | // TODO Auto-generated catch block 94 | e.printStackTrace(); 95 | } 96 | } 97 | } 98 | 99 | return isSuccess; 100 | } 101 | 102 | /** 103 | * MySQL数据库导出 104 | * 105 | * @param hostIP 106 | * @param userName 107 | * @param password 108 | * @param databaseName 109 | * @return 110 | */ 111 | public static boolean exportDatabase(String hostIP, String userName, String password, String databaseName) { 112 | StatusLog.setStatusDetail(PropertyUtil.getProperty("ds.logic.backuping"), LogLevel.INFO); 113 | boolean isSuccess = true; 114 | 115 | // 创建整库备份bat 116 | // isSuccess = createMysqlBackBat(hostIP, userName, password, 117 | // databaseName); 118 | // 119 | // Process ps = null; 120 | // try { 121 | // ps = Runtime.getRuntime().exec(ConstantsLogic.BAT_DIR_MYSQL); 122 | // // 取得命令结果的输出流 123 | // InputStream fis = ps.getInputStream(); 124 | // // 用一个读输出流类去读 125 | // InputStreamReader isr = new InputStreamReader(fis); 126 | // // 用缓冲器读行 127 | // BufferedReader br = new BufferedReader(isr); 128 | // String line = null; 129 | // // 直到读完为止 130 | // while ((line = br.readLine()) != null) { 131 | // StatusLog.setStatusDetail("正在备份MySQL数据库,请耐心等待:" + line, 132 | // LogLevel.INFO); 133 | // } 134 | // ps.waitFor(); 135 | // } catch (IOException | InterruptedException e) { 136 | // // TODO Auto-generated catch block 137 | // e.printStackTrace(); 138 | // } 139 | 140 | // 进行表备份 141 | try { 142 | DbUtilMySQL mySql = DbUtilMySQL.getInstance(); 143 | ArrayList list = new ArrayList(); 144 | // 读取解析表备份sql文件 145 | File file = new File(ConstantsLogic.MYSQL_TABLE_BACKUP_SQL_FILE); 146 | list = FileUtils.getSqlFileContentList(file); 147 | for (String string : list) { 148 | StatusLog.setStatusDetail(PropertyUtil.getProperty("ds.logic.backupTable") + string, LogLevel.INFO); 149 | mySql.executeUpdate(string); 150 | } 151 | mySql.getConnection().commit(); 152 | isSuccess = true; 153 | } catch (IOException | SQLException e1) { 154 | isSuccess = false; 155 | e1.printStackTrace(); 156 | StatusLog.setStatusDetail(e1.toString(), LogLevel.ERROR); 157 | } 158 | 159 | return isSuccess; 160 | } 161 | 162 | } 163 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/logic/ConstantsLogic.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.logic; 2 | 3 | import java.io.File; 4 | 5 | import com.luoboduner.wesync.ui.UiConsts; 6 | 7 | /** 8 | * Logic层的常量类 9 | * 10 | * @author Bob 11 | */ 12 | public class ConstantsLogic { 13 | 14 | // 各配置文件路径 15 | /** 16 | * 表-字段配置文件 路径 17 | */ 18 | public final static String TABLE_FIELD_DIR = UiConsts.CURRENT_DIR + File.separator + "TableField"; 19 | /** 20 | * 表-字段配置文件 路径 21 | */ 22 | public final static String TABLE_FIELD_INIT_DIR = UiConsts.CURRENT_DIR + File.separator + "TableField" 23 | + File.separator + "init"; 24 | /** 25 | * Trigger配置文件 26 | */ 27 | public final static String TRIGGER_FILE = UiConsts.CURRENT_DIR + File.separator + "Trigger" + File.separator 28 | + "Trigger.txt"; 29 | /** 30 | * 表快照文件 路径 31 | */ 32 | public final static String SNAPS_DIR = UiConsts.CURRENT_DIR + File.separator + "snaps"; 33 | /** 34 | * 表快照文件备份 路径 35 | */ 36 | public final static String SNAPS_BAK_DIR = UiConsts.CURRENT_DIR + File.separator + "snaps_bak"; 37 | /** 38 | * sql日志文件路径 39 | */ 40 | public final static String LOG_SQL_DIR = UiConsts.CURRENT_DIR + File.separator + "log_SQL"; 41 | /** 42 | * sql日志文件 43 | */ 44 | public final static String LOG_SQL = UiConsts.CURRENT_DIR + File.separator + "log_SQL" + File.separator 45 | + "log_sql.csv"; 46 | 47 | /** 48 | * mysql整库备份bat文件路径 49 | */ 50 | public final static String BAT_DIR_MYSQL = UiConsts.CURRENT_DIR + File.separator + "DB_Backup" + File.separator 51 | + "mysql_backup.bat"; 52 | 53 | /** 54 | * mysql表备份sql文件路径 55 | */ 56 | public final static String MYSQL_TABLE_BACKUP_SQL_FILE = UiConsts.CURRENT_DIR + File.separator + "DB_Backup" 57 | + File.separator + "mysql_table_backup.sql"; 58 | 59 | /** 60 | * mysql备份sql文件路径 61 | */ 62 | public final static String PATH_MYSQL_BAK = UiConsts.CURRENT_DIR + File.separator + "DB_Backup" + File.separator 63 | + "Target"; 64 | 65 | // 正则表达式 66 | /** 67 | * trigger配置文件,解析表名的正则 68 | */ 69 | public final static String REGEX_TRIGGER_TABLE = "<([^<>]+)>"; 70 | /** 71 | * trigger配置文件,解析表主键的正则 72 | */ 73 | public final static String REGEX_TRIGGER_PRIM_KEY = "\\(([^()]+)\\)"; 74 | /** 75 | * trigger配置文件,解析表字段的正则 76 | */ 77 | public final static String REGEX_TRIGGER_FIELDS = "\\{([^{}]+)\\}"; 78 | /** 79 | * trigger配置文件,解析“其他条件或保留”的正则 80 | */ 81 | public final static String REGEX_TRIGGER_OTHER = "\\[([^\\[\\]]+)\\]"; 82 | 83 | } -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/logic/ExecuteThreadInterface.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.logic; 2 | 3 | /** 4 | * 执行器的接口 5 | * 6 | * @author Bob 7 | */ 8 | public interface ExecuteThreadInterface { 9 | /** 10 | * 初始化变量 11 | */ 12 | void init(); 13 | 14 | /** 15 | * 测试连接 16 | * 17 | * @return 18 | */ 19 | boolean testLink(); 20 | 21 | /** 22 | * 解析配置文件 23 | * 24 | * @return 25 | */ 26 | boolean analyseConfigFile(); 27 | 28 | /** 29 | * 备份 30 | */ 31 | void backUp(); 32 | 33 | /** 34 | * 建立快照 35 | * 36 | * @return 37 | */ 38 | boolean newSnap(); 39 | 40 | /** 41 | * 对比快照,生成SQL 42 | * 43 | * @return 44 | */ 45 | boolean diffSnap(); 46 | 47 | /** 48 | * 执行SQL 49 | * 50 | * @return 51 | */ 52 | boolean executeSQL(); 53 | 54 | } -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/logic/ScheduleExecuteThread.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.logic; 2 | 3 | import com.luoboduner.wesync.ui.panel.StatusPanel; 4 | import com.luoboduner.wesync.tools.*; 5 | 6 | /** 7 | * 定时任务执行器,继承于执行器线程类 8 | * 9 | * @author Bob 10 | */ 11 | public class ScheduleExecuteThread extends ExecuteThread { 12 | 13 | @Override 14 | public void run() { 15 | if (!StatusPanel.isRunning) { 16 | StatusPanel.isRunning = true; 17 | this.setName("ScheduleExecuteThread"); 18 | StatusPanel.buttonStartNow.setEnabled(false); 19 | long enterTime = System.currentTimeMillis(); 20 | StatusPanel.progressTotal.setMaximum(6); 21 | // 初始化变量 22 | init(); 23 | // 测试连接 24 | boolean isLinked = testLink(); 25 | 26 | if (isLinked) { 27 | StatusPanel.progressTotal.setValue(1); 28 | // 分析配置文件 29 | boolean isAnalyseSuccess = analyseConfigFile(); 30 | if (isAnalyseSuccess) { 31 | StatusPanel.progressTotal.setValue(2); 32 | // 备份 33 | if ("true".equals(ConstantsTools.CONFIGER.getAutoBak())) { 34 | backUp(); 35 | } 36 | StatusPanel.progressTotal.setValue(3); 37 | // 建立新快照 38 | boolean isSnapSuccess = newSnap(); 39 | if (isSnapSuccess) { 40 | StatusPanel.progressTotal.setValue(4); 41 | // 对比快照,并根据对比结果生成SQL 42 | boolean isDiffSuccess = diffSnap(); 43 | if (isDiffSuccess) { 44 | StatusPanel.progressTotal.setValue(5); 45 | // 执行SQL 46 | boolean isExecuteSuccess = executeSQL(); 47 | if (isExecuteSuccess) { 48 | StatusPanel.progressTotal.setValue(6); 49 | 50 | // 设置持续时间 51 | long leaveTime = System.currentTimeMillis(); 52 | float minutes = (float) (leaveTime - enterTime) / 1000; 53 | StatusLog.setKeepTime(String.valueOf(minutes)); 54 | // 设置成功次数+1 55 | String success = String 56 | .valueOf((Long.parseLong(ConstantsTools.CONFIGER.getSuccessTime()) + 1)); 57 | StatusLog.setSuccess(success); 58 | StatusLog.setStatusDetail(PropertyUtil.getProperty("ds.logic.currentSyncFinish"), LogLevel.INFO); 59 | } else { 60 | // 恢复快照备份 61 | SnapManage.recoverSnapBak(); 62 | 63 | String fail = String 64 | .valueOf((Long.parseLong(ConstantsTools.CONFIGER.getFailTime()) + 1)); 65 | StatusLog.setFail(fail); 66 | } 67 | 68 | } else { 69 | // 恢复快照备份 70 | SnapManage.recoverSnapBak(); 71 | 72 | String fail = String.valueOf((Long.parseLong(ConstantsTools.CONFIGER.getFailTime()) + 1)); 73 | StatusLog.setFail(fail); 74 | } 75 | 76 | } else { 77 | // 恢复快照备份 78 | SnapManage.recoverSnapBak(); 79 | 80 | String fail = String.valueOf((Long.parseLong(ConstantsTools.CONFIGER.getFailTime()) + 1)); 81 | StatusLog.setFail(fail); 82 | } 83 | 84 | } else { 85 | String fail = String.valueOf((Long.parseLong(ConstantsTools.CONFIGER.getFailTime()) + 1)); 86 | StatusLog.setFail(fail); 87 | } 88 | 89 | } else { 90 | String fail = String.valueOf((Long.parseLong(ConstantsTools.CONFIGER.getFailTime()) + 1)); 91 | StatusLog.setFail(fail); 92 | } 93 | // 设置显示下一次执行时间 94 | StatusPanel.labelNextTime.setText(PropertyUtil.getProperty("ds.ui.schedule.nextTime") + Utils.getNextSyncTime()); 95 | StatusPanel.isRunning = false; 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/logic/bean/Table.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.logic.bean; 2 | 3 | /** 4 | * 表object类 5 | * 6 | * @author Bob 7 | */ 8 | public class Table { 9 | /** 10 | * 表名 11 | */ 12 | private String tableName; 13 | /** 14 | * 主键 15 | */ 16 | private String primKey; 17 | /** 18 | * 字段 19 | */ 20 | private String fields; 21 | 22 | /** 23 | * 其他条件/保留 24 | */ 25 | private String other; 26 | 27 | public String getTableName() { 28 | return tableName; 29 | } 30 | 31 | public void setTableName(String tableName) { 32 | this.tableName = tableName; 33 | } 34 | 35 | public String getPrimKey() { 36 | return primKey; 37 | } 38 | 39 | public void setPrimKey(String primKey) { 40 | this.primKey = primKey; 41 | } 42 | 43 | public String getFields() { 44 | return fields; 45 | } 46 | 47 | public void setFields(String fields) { 48 | this.fields = fields; 49 | } 50 | 51 | public String getOther() { 52 | return other; 53 | } 54 | 55 | public void setOther(String other) { 56 | this.other = other; 57 | } 58 | 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/logic/init/Init4pxp2p.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.logic.init; 2 | 3 | import com.luoboduner.wesync.ui.panel.StatusPanel; 4 | import com.opencsv.CSVWriter; 5 | import com.luoboduner.wesync.tools.DbUtilMySQL; 6 | import com.luoboduner.wesync.tools.DbUtilSQLServer; 7 | import com.luoboduner.wesync.tools.LogLevel; 8 | import com.luoboduner.wesync.tools.StatusLog; 9 | 10 | import java.io.File; 11 | 12 | public class Init4pxp2p { 13 | 14 | public static boolean init() { 15 | StatusLog.setStatusDetail("开始初始化第一次快照,请耐心等待……", LogLevel.INFO); 16 | 17 | boolean isSuccess = true; 18 | DbUtilMySQL mySql = DbUtilMySQL.getInstance(); 19 | DbUtilSQLServer sqlserver = DbUtilSQLServer.getInstance(); 20 | CSVWriter csvWriterRole = null; 21 | CSVWriter csvWriterUser = null; 22 | File snapsDir = null; 23 | StatusPanel.progressCurrent.setMaximum(7); 24 | int progressValue = 0; 25 | StatusPanel.progressCurrent.setValue(progressValue); 26 | 27 | /*Do Sth you need to init*/ 28 | return isSuccess; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/tools/ConfigManager.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.tools; 2 | 3 | import java.io.File; 4 | import java.io.FileOutputStream; 5 | import java.io.OutputStreamWriter; 6 | import java.nio.charset.StandardCharsets; 7 | 8 | import org.dom4j.Document; 9 | import org.dom4j.DocumentException; 10 | import org.dom4j.io.OutputFormat; 11 | import org.dom4j.io.SAXReader; 12 | import org.dom4j.io.XMLWriter; 13 | import org.slf4j.Logger; 14 | import org.slf4j.LoggerFactory; 15 | 16 | /** 17 | * 配置文件管理 单例 18 | * 19 | * @author Bob 20 | */ 21 | public class ConfigManager { 22 | private volatile static ConfigManager confManager; 23 | private static final Logger logger = LoggerFactory.getLogger(ConfigManager.class); 24 | public Document document; 25 | 26 | /** 27 | * 私有的构造 28 | */ 29 | private ConfigManager() { 30 | reloadDom(); 31 | } 32 | 33 | /** 34 | * 读取xml,加载到dom 35 | */ 36 | public void reloadDom() { 37 | SAXReader reader = new SAXReader(); 38 | try { 39 | document = reader.read(new File(ConstantsTools.PATH_CONFIG)); 40 | } catch (DocumentException e) { 41 | e.printStackTrace(); 42 | logger.error("Read config xml error:" + e.toString()); 43 | } 44 | } 45 | 46 | /** 47 | * 获取实例,线程安全 48 | * 49 | * @return 50 | */ 51 | public static ConfigManager getConfigManager() { 52 | if (confManager == null) { 53 | synchronized (ConfigManager.class) { 54 | if (confManager == null) { 55 | confManager = new ConfigManager(); 56 | } 57 | } 58 | } 59 | return confManager; 60 | } 61 | 62 | /** 63 | * 把document对象写入新的文件 64 | * 65 | * @throws Exception 66 | */ 67 | public void writeToXml() throws Exception { 68 | // 排版缩进的格式 69 | OutputFormat format = OutputFormat.createPrettyPrint(); 70 | // 设置编码 71 | format.setEncoding("UTF-8"); 72 | // 创建XMLWriter对象,指定了写出文件及编码格式 73 | XMLWriter writer = null; 74 | writer = new XMLWriter( 75 | new OutputStreamWriter(new FileOutputStream(new File(ConstantsTools.PATH_CONFIG)), StandardCharsets.UTF_8), format); 76 | 77 | // 写入 78 | writer.write(document); 79 | writer.flush(); 80 | writer.close(); 81 | 82 | } 83 | 84 | public String getLastSyncTime() { 85 | return this.document.selectSingleNode(ConstantsTools.XPATH_LAST_SYNC_TIME).getText(); 86 | } 87 | 88 | public void setLastSyncTime(String lastSyncTime) throws Exception { 89 | this.document.selectSingleNode(ConstantsTools.XPATH_LAST_SYNC_TIME).setText(lastSyncTime); 90 | writeToXml(); 91 | } 92 | 93 | public String getLastKeepTime() { 94 | return this.document.selectSingleNode(ConstantsTools.XPATH_LAST_KEEP_TIME).getText(); 95 | } 96 | 97 | public void setLastKeepTime(String lastKeepTime) throws Exception { 98 | this.document.selectSingleNode(ConstantsTools.XPATH_LAST_KEEP_TIME).setText(lastKeepTime); 99 | writeToXml(); 100 | } 101 | 102 | public String getSuccessTime() { 103 | return this.document.selectSingleNode(ConstantsTools.XPATH_SUCCESS_TIME).getText(); 104 | } 105 | 106 | public void setSuccessTime(String successTime) throws Exception { 107 | this.document.selectSingleNode(ConstantsTools.XPATH_SUCCESS_TIME).setText(successTime); 108 | writeToXml(); 109 | } 110 | 111 | public String getFailTime() { 112 | return this.document.selectSingleNode(ConstantsTools.XPATH_FAIL_TIME).getText(); 113 | } 114 | 115 | public void setFailTime(String failTime) throws Exception { 116 | this.document.selectSingleNode(ConstantsTools.XPATH_FAIL_TIME).setText(failTime); 117 | writeToXml(); 118 | } 119 | 120 | public String getTypeFrom() { 121 | return this.document.selectSingleNode(ConstantsTools.XPATH_TYPE_FROM).getText(); 122 | } 123 | 124 | public void setTypeFrom(String typeFrom) throws Exception { 125 | this.document.selectSingleNode(ConstantsTools.XPATH_TYPE_FROM).setText(typeFrom); 126 | writeToXml(); 127 | } 128 | 129 | public String getHostFrom() { 130 | return this.document.selectSingleNode(ConstantsTools.XPATH_HOST_FROM).getText(); 131 | } 132 | 133 | public void setHostFrom(String hostFrom) throws Exception { 134 | this.document.selectSingleNode(ConstantsTools.XPATH_HOST_FROM).setText(hostFrom); 135 | writeToXml(); 136 | } 137 | 138 | public String getNameFrom() { 139 | return this.document.selectSingleNode(ConstantsTools.XPATH_NAME_FROM).getText(); 140 | } 141 | 142 | public void setNameFrom(String nameFrom) throws Exception { 143 | this.document.selectSingleNode(ConstantsTools.XPATH_NAME_FROM).setText(nameFrom); 144 | writeToXml(); 145 | } 146 | 147 | public String getUserFrom() { 148 | return this.document.selectSingleNode(ConstantsTools.XPATH_USER_FROM).getText(); 149 | } 150 | 151 | public void setUserFrom(String userFrom) throws Exception { 152 | this.document.selectSingleNode(ConstantsTools.XPATH_USER_FROM).setText(userFrom); 153 | writeToXml(); 154 | } 155 | 156 | public String getPasswordFrom() { 157 | return this.document.selectSingleNode(ConstantsTools.XPATH_PASSWORD_FROM).getText(); 158 | } 159 | 160 | public void setPasswordFrom(String passwordFrom) throws Exception { 161 | this.document.selectSingleNode(ConstantsTools.XPATH_PASSWORD_FROM).setText(passwordFrom); 162 | writeToXml(); 163 | } 164 | 165 | public String getTypeTo() { 166 | return this.document.selectSingleNode(ConstantsTools.XPATH_TYPE_TO).getText(); 167 | } 168 | 169 | public void setTypeTo(String typeTo) throws Exception { 170 | this.document.selectSingleNode(ConstantsTools.XPATH_TYPE_TO).setText(typeTo); 171 | writeToXml(); 172 | } 173 | 174 | public String getHostTo() { 175 | return this.document.selectSingleNode(ConstantsTools.XPATH_HOST_TO).getText(); 176 | } 177 | 178 | public void setHostTo(String hostTo) throws Exception { 179 | this.document.selectSingleNode(ConstantsTools.XPATH_HOST_TO).setText(hostTo); 180 | writeToXml(); 181 | } 182 | 183 | public String getNameTo() { 184 | return this.document.selectSingleNode(ConstantsTools.XPATH_NAME_TO).getText(); 185 | } 186 | 187 | public void setNameTo(String nameTo) throws Exception { 188 | this.document.selectSingleNode(ConstantsTools.XPATH_NAME_TO).setText(nameTo); 189 | writeToXml(); 190 | } 191 | 192 | public String getUserTo() { 193 | return this.document.selectSingleNode(ConstantsTools.XPATH_USER_TO).getText(); 194 | } 195 | 196 | public void setUserTo(String userTo) throws Exception { 197 | this.document.selectSingleNode(ConstantsTools.XPATH_USER_TO).setText(userTo); 198 | writeToXml(); 199 | } 200 | 201 | public String getPasswordTo() { 202 | return this.document.selectSingleNode(ConstantsTools.XPATH_PASSWORD_TO).getText(); 203 | } 204 | 205 | public void setPasswordTo(String passwordTo) throws Exception { 206 | this.document.selectSingleNode(ConstantsTools.XPATH_PASSWORD_TO).setText(passwordTo); 207 | writeToXml(); 208 | } 209 | 210 | public String getSchedule() { 211 | return this.document.selectSingleNode(ConstantsTools.XPATH_SCHEDULE).getText(); 212 | } 213 | 214 | public void setSchedule(String schedule) throws Exception { 215 | this.document.selectSingleNode(ConstantsTools.XPATH_SCHEDULE).setText(schedule); 216 | writeToXml(); 217 | } 218 | 219 | public String getScheduleFixTime() { 220 | return this.document.selectSingleNode(ConstantsTools.XPATH_SCHEDULE_FIX_TIME).getText(); 221 | } 222 | 223 | public void setScheduleFixTime(String fixTime) throws Exception { 224 | this.document.selectSingleNode(ConstantsTools.XPATH_SCHEDULE_FIX_TIME).setText(fixTime); 225 | writeToXml(); 226 | } 227 | 228 | public String getAutoBak() { 229 | return this.document.selectSingleNode(ConstantsTools.XPATH_AUTO_BAK).getText(); 230 | } 231 | 232 | public void setAutoBak(String autoBak) throws Exception { 233 | this.document.selectSingleNode(ConstantsTools.XPATH_AUTO_BAK).setText(autoBak); 234 | writeToXml(); 235 | } 236 | 237 | public String getDebugMode() { 238 | return this.document.selectSingleNode(ConstantsTools.XPATH_DEBUG_MODE).getText(); 239 | } 240 | 241 | public void setDebugMode(String debugMode) throws Exception { 242 | this.document.selectSingleNode(ConstantsTools.XPATH_DEBUG_MODE).setText(debugMode); 243 | writeToXml(); 244 | } 245 | 246 | public String getStrictMode() { 247 | return this.document.selectSingleNode(ConstantsTools.XPATH_STRICT_MODE).getText(); 248 | } 249 | 250 | public void setStrictMode(String strictMode) throws Exception { 251 | this.document.selectSingleNode(ConstantsTools.XPATH_STRICT_MODE).setText(strictMode); 252 | writeToXml(); 253 | } 254 | 255 | public String getMysqlPath() { 256 | return this.document.selectSingleNode(ConstantsTools.XPATH_MYSQL_PATH).getText(); 257 | } 258 | 259 | public void setMysqlPath(String mysqlPath) throws Exception { 260 | this.document.selectSingleNode(ConstantsTools.XPATH_MYSQL_PATH).setText(mysqlPath); 261 | writeToXml(); 262 | } 263 | 264 | public String getProductName() { 265 | return this.document.selectSingleNode(ConstantsTools.XPATH_PRODUCT_NAME).getText(); 266 | } 267 | 268 | public void setProductName(String productName) throws Exception { 269 | this.document.selectSingleNode(ConstantsTools.XPATH_PRODUCT_NAME).setText(productName); 270 | writeToXml(); 271 | } 272 | 273 | public String getPositionCode() { 274 | return this.document.selectSingleNode(ConstantsTools.XPATH_POSITION_CODE).getText(); 275 | } 276 | 277 | public void setPositionCode(String positionCode) throws Exception { 278 | this.document.selectSingleNode(ConstantsTools.XPATH_POSITION_CODE).setText(positionCode); 279 | writeToXml(); 280 | } 281 | } 282 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/tools/ConstantsTools.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.tools; 2 | 3 | import com.luoboduner.wesync.ui.UiConsts; 4 | 5 | import java.io.File; 6 | 7 | /** 8 | * 工具层相关的常量 9 | * 10 | * @author Bob 11 | */ 12 | public class ConstantsTools { 13 | 14 | // 配置文件 15 | /** 16 | * 配置文件 路径 17 | */ 18 | public final static String PATH_CONFIG = UiConsts.CURRENT_DIR + File.separator + "config" + File.separator 19 | + "config.xml"; 20 | 21 | /** 22 | * properties路径 23 | */ 24 | public final static String PATH_PROPERTY = UiConsts.CURRENT_DIR + File.separator + "config" + File.separator 25 | + "zh-cn.properties"; 26 | /** 27 | * 配置文件dom实例 28 | */ 29 | public final static ConfigManager CONFIGER = ConfigManager.getConfigManager(); 30 | /** 31 | * xpath 32 | */ 33 | public final static String XPATH_LAST_SYNC_TIME = "//weSync/status/lastSyncTime"; 34 | public final static String XPATH_LAST_KEEP_TIME = "//weSync/status/lastKeepTime"; 35 | public final static String XPATH_SUCCESS_TIME = "//weSync/status/successTime"; 36 | public final static String XPATH_FAIL_TIME = "//weSync/status/failTime"; 37 | 38 | public final static String XPATH_TYPE_FROM = "//weSync/database/from/type"; 39 | public final static String XPATH_HOST_FROM = "//weSync/database/from/host"; 40 | public final static String XPATH_NAME_FROM = "//weSync/database/from/name"; 41 | public final static String XPATH_USER_FROM = "//weSync/database/from/user"; 42 | public final static String XPATH_PASSWORD_FROM = "//weSync/database/from/password"; 43 | 44 | public final static String XPATH_TYPE_TO = "//weSync/database/to/type"; 45 | public final static String XPATH_HOST_TO = "//weSync/database/to/host"; 46 | public final static String XPATH_NAME_TO = "//weSync/database/to/name"; 47 | public final static String XPATH_USER_TO = "//weSync/database/to/user"; 48 | public final static String XPATH_PASSWORD_TO = "//weSync/database/to/password"; 49 | 50 | public final static String XPATH_SCHEDULE = "//weSync/schedule/radio"; 51 | public final static String XPATH_SCHEDULE_FIX_TIME = "//weSync/schedule/fixtime"; 52 | 53 | public final static String XPATH_AUTO_BAK = "//weSync/setting/autoBak"; 54 | public final static String XPATH_DEBUG_MODE = "//weSync/setting/debugMode"; 55 | public final static String XPATH_STRICT_MODE = "//weSync/setting/strictMode"; 56 | public final static String XPATH_MYSQL_PATH = "//weSync/setting/mysqlPath"; 57 | public final static String XPATH_PRODUCT_NAME = "//weSync/setting/productname"; 58 | 59 | public final static String XPATH_POSITION_CODE = "//weSync/increase/POSITION_CODE"; 60 | 61 | /** 62 | * 日志文件 路径 63 | */ 64 | public final static String PATH_LOG = UiConsts.CURRENT_DIR + File.separator + "log" + File.separator + "log.log"; 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/tools/DESPlus.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.tools; 2 | 3 | import com.sun.crypto.provider.SunJCE; 4 | import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; 5 | import org.springframework.security.crypto.password.MessageDigestPasswordEncoder; 6 | import org.springframework.security.crypto.password.PasswordEncoder; 7 | 8 | import javax.crypto.Cipher; 9 | import javax.crypto.spec.SecretKeySpec; 10 | import java.security.Key; 11 | import java.security.Security; 12 | 13 | public class DESPlus { 14 | private static String strDefaultKey = "HELP"; 15 | 16 | private Cipher encryptCipher; 17 | 18 | private Cipher decryptCipher; 19 | 20 | public static String byteArr2HexStr(byte[] arrB) { 21 | int iLen = arrB.length; 22 | 23 | StringBuffer sb = new StringBuffer(iLen * 2); 24 | for (int i = 0; i < iLen; i++) { 25 | int intTmp = arrB[i]; 26 | 27 | while (intTmp < 0) { 28 | intTmp += 256; 29 | } 30 | 31 | if (intTmp < 16) { 32 | sb.append("0"); 33 | } 34 | sb.append(Integer.toString(intTmp, 16)); 35 | } 36 | return sb.toString(); 37 | } 38 | 39 | public static byte[] hexStr2ByteArr(String strIn) { 40 | byte[] arrB = strIn.getBytes(); 41 | int iLen = arrB.length; 42 | 43 | byte[] arrOut = new byte[iLen / 2]; 44 | for (int i = 0; i < iLen; i += 2) { 45 | String strTmp = new String(arrB, i, 2); 46 | arrOut[(i / 2)] = (byte) Integer.parseInt(strTmp, 16); 47 | } 48 | return arrOut; 49 | } 50 | 51 | public DESPlus() throws Exception { 52 | this(strDefaultKey); 53 | } 54 | 55 | public DESPlus(String strKey) throws Exception { 56 | Security.addProvider(new SunJCE()); 57 | Key key = getKey(strKey.getBytes()); 58 | 59 | this.encryptCipher = Cipher.getInstance("DES"); 60 | this.encryptCipher.init(1, key); 61 | 62 | this.decryptCipher = Cipher.getInstance("DES"); 63 | this.decryptCipher.init(2, key); 64 | } 65 | 66 | public byte[] encrypt(byte[] arrB) throws Exception { 67 | return this.encryptCipher.doFinal(arrB); 68 | } 69 | 70 | public String encrypt(String strIn) throws Exception { 71 | return byteArr2HexStr(encrypt(strIn.getBytes())); 72 | } 73 | 74 | public byte[] decrypt(byte[] arrB) throws Exception { 75 | return this.decryptCipher.doFinal(arrB); 76 | } 77 | 78 | public String decrypt(String strIn) throws Exception { 79 | return new String(decrypt(hexStr2ByteArr(strIn))); 80 | } 81 | 82 | private Key getKey(byte[] arrBTmp) { 83 | byte[] arrB = new byte[8]; 84 | 85 | for (int i = 0; (i < arrBTmp.length) && (i < arrB.length); i++) { 86 | arrB[i] = arrBTmp[i]; 87 | } 88 | 89 | Key key = new SecretKeySpec(arrB, "DES"); 90 | 91 | return key; 92 | } 93 | 94 | public static void main(String[] args) { 95 | String test = "asdf"; 96 | String password = "asdfasdf"; 97 | try { 98 | DESPlus des = new DESPlus(); 99 | String miwen = des.encrypt(test); 100 | System.out.println("加密后的字符:" + miwen); 101 | 102 | DESPlus des1 = new DESPlus(); 103 | System.out.println("解密后的字符:" + des1.decrypt(miwen)); 104 | 105 | String passwordMiwen = des.encrypt(password); 106 | System.out.println("密码加密后的字符:" + passwordMiwen); 107 | 108 | DESPlus passwordDes1 = new DESPlus(); 109 | System.out.println("密码解密后的字符:" + passwordDes1.decrypt("asdfasdfasdf")); 110 | } catch (Exception e) { 111 | e.printStackTrace(); 112 | } 113 | 114 | BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder(); 115 | bCryptPasswordEncoder.encode("000000"); 116 | System.out.println(bCryptPasswordEncoder.encode("111111")); 117 | 118 | } 119 | } -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/tools/DbUtilMySQL.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.tools; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.sql.*; 8 | 9 | /** 10 | * MySQL数据库工具,单例,持久连接 11 | * 12 | * @author Bob 13 | */ 14 | public class DbUtilMySQL { 15 | private Connection connection = null; 16 | private Statement statement = null; 17 | private ResultSet resultSet = null; 18 | private static String DBUrl = null; 19 | private static String DBName = null; 20 | private static String DBUser = null; 21 | private static String DBPassword = null; 22 | 23 | private static DbUtilMySQL instance = null; 24 | 25 | private static final Logger logger = LoggerFactory.getLogger(DbUtilMySQL.class); 26 | 27 | /** 28 | * 私有的构造 29 | */ 30 | private DbUtilMySQL() { 31 | loadConfig(); 32 | } 33 | 34 | /** 35 | * 获取实例,线程安全 36 | * 37 | * @return 38 | */ 39 | public static synchronized DbUtilMySQL getInstance() { 40 | 41 | if (instance == null) { 42 | instance = new DbUtilMySQL(); 43 | } 44 | return instance; 45 | } 46 | 47 | /** 48 | * 从配置文件加载设置数据库信息 49 | */ 50 | private void loadConfig() { 51 | try { 52 | String dbclassname = "com.mysql.jdbc.Driver"; 53 | DBUrl = ConstantsTools.CONFIGER.getHostTo(); 54 | DBName = ConstantsTools.CONFIGER.getNameTo(); 55 | DBUser = ConstantsTools.CONFIGER.getUserTo(); 56 | DBPassword = ConstantsTools.CONFIGER.getPasswordTo(); 57 | 58 | Class.forName(dbclassname); 59 | } catch (Exception e) { 60 | 61 | logger.error(e.toString()); 62 | e.printStackTrace(); 63 | } 64 | } 65 | 66 | /** 67 | * 获取连接,线程安全 68 | * 69 | * @return 70 | * @throws SQLException 71 | */ 72 | public synchronized Connection getConnection() throws SQLException { 73 | String user = ""; 74 | String password = ""; 75 | try { 76 | DESPlus des = new DESPlus(); 77 | user = des.decrypt(DBUser); 78 | password = des.decrypt(DBPassword); 79 | } catch (Exception e) { 80 | logger.error(PropertyUtil.getProperty("ds.ui.database.to.err.decode") + e.toString()); 81 | e.printStackTrace(); 82 | } 83 | // 当DB配置变更时重新获取 84 | if (!ConstantsTools.CONFIGER.getHostTo().equals(DBUrl) || !ConstantsTools.CONFIGER.getNameTo().equals(DBName) 85 | || !ConstantsTools.CONFIGER.getUserTo().equals(DBUser) 86 | || !ConstantsTools.CONFIGER.getPasswordTo().equals(DBPassword)) { 87 | loadConfig(); 88 | // "jdbc:mysql://localhost/pxp2p_branch" 89 | connection = DriverManager.getConnection( 90 | "jdbc:mysql://" + DBUrl + "/" + DBName + "?useUnicode=true&characterEncoding=utf8", user, password); 91 | // 把事务提交方式改为手工提交 92 | connection.setAutoCommit(false); 93 | } 94 | 95 | // 当connection失效时重新获取 96 | if (connection == null || !connection.isValid(10)) { 97 | // "jdbc:mysql://localhost/pxp2p_branch" 98 | connection = DriverManager.getConnection( 99 | "jdbc:mysql://" + DBUrl + "/" + DBName + "?useUnicode=true&characterEncoding=utf8", user, password); 100 | // 把事务提交方式改为手工提交 101 | connection.setAutoCommit(false); 102 | } 103 | 104 | if (connection == null) { 105 | logger.error("Can not load MySQL jdbc and get connection."); 106 | } 107 | return connection; 108 | } 109 | 110 | /** 111 | * 测试连接,线程安全 参数从配置文件获取 112 | * 113 | * @return 114 | * @throws SQLException 115 | */ 116 | public synchronized Connection testConnection() throws SQLException { 117 | loadConfig(); 118 | // "jdbc:mysql://localhost/pxp2p_branch" 119 | String user = ""; 120 | String password = ""; 121 | try { 122 | DESPlus des = new DESPlus(); 123 | user = des.decrypt(DBUser); 124 | password = des.decrypt(DBPassword); 125 | } catch (Exception e) { 126 | logger.error(PropertyUtil.getProperty("ds.ui.database.to.err.decode") + e.toString()); 127 | e.printStackTrace(); 128 | } 129 | connection = DriverManager.getConnection("jdbc:mysql://" + DBUrl + "/" + DBName, user, password); 130 | // 把事务提交方式改为手工提交 131 | connection.setAutoCommit(false); 132 | 133 | if (connection == null) { 134 | logger.error("Can not load MySQL jdbc and get connection."); 135 | } 136 | return connection; 137 | } 138 | 139 | /** 140 | * 测试连接,线程安全 参数从入参获取 141 | * 142 | * @return 143 | * @throws SQLException 144 | */ 145 | public synchronized Connection testConnection(String dburl, String dbname, String dbuser, String dbpassword) 146 | throws SQLException { 147 | loadConfig(); 148 | // "jdbc:mysql://localhost/pxp2p_branch" 149 | connection = DriverManager.getConnection("jdbc:mysql://" + dburl + "/" + dbname, dbuser, dbpassword); 150 | // 把事务提交方式改为手工提交 151 | connection.setAutoCommit(false); 152 | 153 | if (connection == null) { 154 | logger.error("Can not load MySQL jdbc and get connection."); 155 | } 156 | return connection; 157 | } 158 | 159 | /** 160 | * 获取数据库声明,私有,线程安全 161 | * 162 | * @throws SQLException 163 | */ 164 | private synchronized void getStatement() throws SQLException { 165 | getConnection(); 166 | // 仅当statement失效时才重新创建 167 | if (statement == null || statement.isClosed()) { 168 | statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); 169 | } 170 | } 171 | 172 | /** 173 | * 关闭(结果集、声明、连接),线程安全 174 | * 175 | * @throws SQLException 176 | */ 177 | public synchronized void close() throws SQLException { 178 | if (resultSet != null) { 179 | resultSet.close(); 180 | resultSet = null; 181 | } 182 | if (statement != null) { 183 | statement.close(); 184 | statement = null; 185 | } 186 | if (connection != null) { 187 | connection.close(); 188 | connection = null; 189 | } 190 | } 191 | 192 | /** 193 | * 执行查询,线程安全 194 | * 195 | * @param sql 196 | * @return 197 | * @throws SQLException 198 | */ 199 | public synchronized ResultSet executeQuery(String sql) throws SQLException { 200 | getStatement(); 201 | if (resultSet != null && !resultSet.isClosed()) { 202 | resultSet.close(); 203 | } 204 | resultSet = null; 205 | resultSet = statement.executeQuery(sql); 206 | return resultSet; 207 | } 208 | 209 | /** 210 | * 执行更新,线程安全 211 | * 212 | * @param sql 213 | * @return 214 | * @throws SQLException 215 | */ 216 | public synchronized int executeUpdate(String sql) throws SQLException { 217 | int result = 0; 218 | getStatement(); 219 | result = statement.executeUpdate(sql); 220 | return result; 221 | } 222 | 223 | } 224 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/tools/DbUtilSQLServer.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.tools; 2 | 3 | 4 | import org.slf4j.Logger; 5 | import org.slf4j.LoggerFactory; 6 | 7 | import java.sql.*; 8 | 9 | /** 10 | * SQLServer数据库工具,单例,持久连接 11 | * 12 | * @author Bob 13 | */ 14 | public class DbUtilSQLServer { 15 | private Connection connection = null; 16 | private Statement statement = null; 17 | private ResultSet resultSet = null; 18 | private static String DBUrl = null; 19 | private static String DBName = null; 20 | private static String DBUser = null; 21 | private static String DBPassword = null; 22 | 23 | private static DbUtilSQLServer instance = null; 24 | 25 | private static final Logger logger = LoggerFactory.getLogger(DbUtilSQLServer.class); 26 | 27 | /** 28 | * 私有的构造 29 | */ 30 | private DbUtilSQLServer() { 31 | loadConfig(); 32 | } 33 | 34 | /** 35 | * 获取实例,线程安全 36 | * 37 | * @return 38 | */ 39 | public static synchronized DbUtilSQLServer getInstance() { 40 | if (instance == null) { 41 | instance = new DbUtilSQLServer(); 42 | } 43 | return instance; 44 | } 45 | 46 | /** 47 | * 从配置文件加载设置数据库信息 48 | */ 49 | private void loadConfig() { 50 | try { 51 | String dbclassname = "com.microsoft.sqlserver.jdbc.SQLServerDriver"; 52 | DBUrl = ConstantsTools.CONFIGER.getHostFrom(); 53 | DBName = ConstantsTools.CONFIGER.getNameFrom(); 54 | DBUser = ConstantsTools.CONFIGER.getUserFrom(); 55 | DBPassword = ConstantsTools.CONFIGER.getPasswordFrom(); 56 | 57 | Class.forName(dbclassname); 58 | } catch (Exception e) { 59 | 60 | logger.error(e.toString()); 61 | e.printStackTrace(); 62 | } 63 | } 64 | 65 | /** 66 | * 获取连接,线程安全 67 | * 68 | * @return 69 | * @throws SQLException 70 | */ 71 | public synchronized Connection getConnection() throws SQLException { 72 | String user = ""; 73 | String password = ""; 74 | try { 75 | DESPlus des = new DESPlus(); 76 | user = des.decrypt(DBUser); 77 | password = des.decrypt(DBPassword); 78 | } catch (Exception e) { 79 | logger.error(PropertyUtil.getProperty("ds.ui.database.from.err.decode") + e.toString()); 80 | e.printStackTrace(); 81 | } 82 | // 当DB配置变更时重新获取 83 | if (!ConstantsTools.CONFIGER.getHostFrom().equals(DBUrl) 84 | || !ConstantsTools.CONFIGER.getNameFrom().equals(DBName) 85 | || !ConstantsTools.CONFIGER.getUserFrom().equals(DBUser) 86 | || !ConstantsTools.CONFIGER.getPasswordFrom().equals(DBPassword)) { 87 | loadConfig(); 88 | // "jdbc:sqlserver://20.1.1.194:1433;DatabaseName=AIS20151221115438;" 89 | connection = DriverManager.getConnection("jdbc:sqlserver://" + DBUrl + ";DatabaseName=" + DBName, user, 90 | password); 91 | // 把事务提交方式改为手工提交 92 | connection.setAutoCommit(false); 93 | } 94 | 95 | // 当connection失效时重新获取 96 | if (connection == null || connection.isValid(10) == false) { 97 | 98 | // "jdbc:sqlserver://20.1.1.194:1433;DatabaseName=AIS20151221115438;" 99 | connection = DriverManager.getConnection("jdbc:sqlserver://" + DBUrl + ";DatabaseName=" + DBName, user, 100 | password); 101 | // 把事务提交方式改为手工提交 102 | connection.setAutoCommit(false); 103 | } 104 | 105 | if (connection == null) { 106 | logger.error("Can not load SQL Server jdbc and get connection."); 107 | } 108 | return connection; 109 | } 110 | 111 | /** 112 | * 测试连接,线程安全 参数从配置文件获取 113 | * 114 | * @return 115 | * @throws SQLException 116 | */ 117 | public synchronized Connection testConnection() throws SQLException { 118 | loadConfig(); 119 | // "jdbc:sqlserver://20.1.1.194:1433;DatabaseName=AIS20151221115438;" 120 | String user = ""; 121 | String password = ""; 122 | try { 123 | DESPlus des = new DESPlus(); 124 | user = des.decrypt(DBUser); 125 | password = des.decrypt(DBPassword); 126 | } catch (Exception e) { 127 | logger.error(PropertyUtil.getProperty("ds.ui.database.from.err.decode") + e.toString()); 128 | e.printStackTrace(); 129 | } 130 | connection = DriverManager.getConnection("jdbc:sqlserver://" + DBUrl + ";DatabaseName=" + DBName, user, 131 | password); 132 | // 把事务提交方式改为手工提交 133 | connection.setAutoCommit(false); 134 | 135 | if (connection == null) { 136 | logger.error("Can not load SQL Server jdbc and get connection."); 137 | } 138 | return connection; 139 | } 140 | 141 | /** 142 | * 测试连接,线程安全 参数从入参传入 143 | * 144 | * @return 145 | * @throws SQLException 146 | */ 147 | public synchronized Connection testConnection(String dburl, String dbname, String dbuser, String dbpassword) 148 | throws SQLException { 149 | loadConfig(); 150 | // "jdbc:sqlserver://20.1.1.194:1433;DatabaseName=AIS20151221115438;" 151 | connection = DriverManager.getConnection("jdbc:sqlserver://" + dburl + ";DatabaseName=" + dbname, dbuser, 152 | dbpassword); 153 | // 把事务提交方式改为手工提交 154 | connection.setAutoCommit(false); 155 | 156 | if (connection == null) { 157 | logger.error("Can not load SQL Server jdbc and get connection."); 158 | } 159 | return connection; 160 | } 161 | 162 | /** 163 | * 获取数据库声明,私有,线程安全 164 | * 165 | * @throws SQLException 166 | */ 167 | private synchronized void getStatement() throws SQLException { 168 | getConnection(); 169 | // 仅当statement失效时才重新创建 170 | if (statement == null || statement.isClosed()) { 171 | statement = connection.createStatement(ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_READ_ONLY); 172 | } 173 | } 174 | 175 | /** 176 | * 关闭(结果集、声明、连接),线程安全 177 | * 178 | * @throws SQLException 179 | */ 180 | public synchronized void close() throws SQLException { 181 | if (resultSet != null) { 182 | resultSet.close(); 183 | resultSet = null; 184 | } 185 | if (statement != null) { 186 | statement.close(); 187 | statement = null; 188 | } 189 | if (connection != null) { 190 | connection.close(); 191 | connection = null; 192 | } 193 | } 194 | 195 | /** 196 | * 执行查询,线程安全 197 | * 198 | * @param sql 199 | * @return 200 | * @throws SQLException 201 | */ 202 | public synchronized ResultSet executeQuery(String sql) throws SQLException { 203 | getStatement(); 204 | if (resultSet != null && !resultSet.isClosed()) { 205 | resultSet.close(); 206 | } 207 | resultSet = null; 208 | resultSet = statement.executeQuery(sql); 209 | return resultSet; 210 | } 211 | 212 | /** 213 | * 执行更新,线程安全 214 | * 215 | * @param sql 216 | * @return 217 | * @throws SQLException 218 | */ 219 | public synchronized int executeUpdate(String sql) throws SQLException { 220 | int result = 0; 221 | getStatement(); 222 | result = statement.executeUpdate(sql); 223 | return result; 224 | } 225 | 226 | /** 227 | * 执行任意,线程安全 228 | * 229 | * @param sql 230 | * @return 231 | * @throws SQLException 232 | */ 233 | public synchronized boolean execute(String sql) throws SQLException { 234 | boolean result; 235 | getStatement(); 236 | result = statement.execute(sql); 237 | return result; 238 | } 239 | 240 | } 241 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/tools/FileUtils.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.tools; 2 | 3 | import java.io.BufferedInputStream; 4 | import java.io.BufferedOutputStream; 5 | import java.io.BufferedReader; 6 | import java.io.File; 7 | import java.io.FileInputStream; 8 | import java.io.FileOutputStream; 9 | import java.io.FileReader; 10 | import java.io.IOException; 11 | import java.io.InputStreamReader; 12 | import java.math.BigInteger; 13 | import java.nio.charset.StandardCharsets; 14 | import java.security.MessageDigest; 15 | import java.text.DecimalFormat; 16 | import java.util.ArrayList; 17 | import java.util.Objects; 18 | 19 | import com.opencsv.CSVReader; 20 | 21 | /** 22 | * 文件工具类 23 | * 24 | * @author Bob 25 | */ 26 | public class FileUtils { 27 | /** 28 | * 复制文件 29 | * 30 | * @param sourceFile 31 | * @param targetFile 32 | * @throws IOException 33 | */ 34 | public static void copyFile(File sourceFile, File targetFile) throws IOException { 35 | // 新建文件输入流并对它进行缓冲 36 | FileInputStream input = new FileInputStream(sourceFile); 37 | BufferedInputStream inBuff = new BufferedInputStream(input); 38 | 39 | // 新建文件输出流并对它进行缓冲 40 | FileOutputStream output = new FileOutputStream(targetFile); 41 | BufferedOutputStream outBuff = new BufferedOutputStream(output); 42 | 43 | // 缓冲数组 44 | byte[] b = new byte[1024 * 5]; 45 | int len; 46 | while ((len = inBuff.read(b)) != -1) { 47 | outBuff.write(b, 0, len); 48 | } 49 | // 刷新此缓冲的输出流 50 | outBuff.flush(); 51 | 52 | // 关闭流 53 | inBuff.close(); 54 | outBuff.close(); 55 | output.close(); 56 | input.close(); 57 | } 58 | 59 | /** 60 | * 复制文件夹 61 | * 62 | * @param sourceDir 63 | * @param targetDir 64 | * @throws IOException 65 | */ 66 | public static void copyDirectiory(String sourceDir, String targetDir) throws IOException { 67 | // 新建目标目录 68 | (new File(targetDir)).mkdirs(); 69 | // 获取源文件夹当前下的文件或目录 70 | File[] file = (new File(sourceDir)).listFiles(); 71 | for (int i = 0; i < file.length; i++) { 72 | if (file[i].isFile()) { 73 | // 源文件 74 | File sourceFile = file[i]; 75 | // 目标文件 76 | File targetFile = new File(new File(targetDir).getAbsolutePath() + File.separator + file[i].getName()); 77 | copyFile(sourceFile, targetFile); 78 | } 79 | if (file[i].isDirectory()) { 80 | // 准备复制的源文件夹 81 | String dir1 = sourceDir + "/" + file[i].getName(); 82 | // 准备复制的目标文件夹 83 | String dir2 = targetDir + "/" + file[i].getName(); 84 | copyDirectiory(dir1, dir2); 85 | } 86 | } 87 | } 88 | 89 | /** 90 | * 计算文件的 MD5 值 91 | * 92 | * @param file 93 | * @return 94 | */ 95 | public static String getFileMD5(File file) { 96 | if (!file.isFile()) { 97 | return null; 98 | } 99 | MessageDigest digest = null; 100 | FileInputStream in = null; 101 | byte[] buffer = new byte[8192]; 102 | int len; 103 | try { 104 | digest = MessageDigest.getInstance("MD5"); 105 | in = new FileInputStream(file); 106 | while ((len = in.read(buffer)) != -1) { 107 | digest.update(buffer, 0, len); 108 | } 109 | BigInteger bigInt = new BigInteger(1, digest.digest()); 110 | return bigInt.toString(16); 111 | } catch (Exception e) { 112 | e.printStackTrace(); 113 | return null; 114 | } finally { 115 | try { 116 | if (in != null) { 117 | in.close(); 118 | } 119 | } catch (Exception e) { 120 | e.printStackTrace(); 121 | } 122 | } 123 | 124 | } 125 | 126 | /** 127 | * 计算文件的SHA-1值 128 | * 129 | * @param file 130 | * @return 131 | */ 132 | public static String getFileSha1(File file) { 133 | if (!file.isFile()) { 134 | return null; 135 | } 136 | MessageDigest digest = null; 137 | FileInputStream in = null; 138 | byte[] buffer = new byte[8192]; 139 | int len; 140 | try { 141 | digest = MessageDigest.getInstance("SHA-1"); 142 | in = new FileInputStream(file); 143 | while ((len = in.read(buffer)) != -1) { 144 | digest.update(buffer, 0, len); 145 | } 146 | BigInteger bigInt = new BigInteger(1, digest.digest()); 147 | return bigInt.toString(16); 148 | } catch (Exception e) { 149 | e.printStackTrace(); 150 | return null; 151 | } finally { 152 | try { 153 | if (in != null) { 154 | in.close(); 155 | } 156 | } catch (Exception e) { 157 | e.printStackTrace(); 158 | } 159 | } 160 | } 161 | 162 | /*** 163 | * 清空文件夹 164 | * 165 | * @param dir 166 | */ 167 | public static void clearDirectiory(String dir) { 168 | File dirFile = new File(dir); 169 | for (File file : Objects.requireNonNull(dirFile.listFiles())) { 170 | file.delete(); 171 | } 172 | 173 | } 174 | 175 | /** 176 | * 读取csv文件到List 177 | * 178 | * @param csvFile 179 | * @return 内容List(每行的字符串数组) 180 | * @throws IOException 181 | */ 182 | public static ArrayList getCsvFileContentList(File csvFile) throws IOException { 183 | FileReader fReader = null; 184 | CSVReader csvReader = null; 185 | ArrayList list; 186 | 187 | try { 188 | // 初始化reader 189 | fReader = new FileReader(csvFile); 190 | csvReader = new CSVReader(fReader); 191 | // 读取解析csv文件 192 | list = (ArrayList) csvReader.readAll(); 193 | return list; 194 | 195 | } catch (IOException e) { 196 | throw e; 197 | } finally { 198 | if (fReader != null) { 199 | try { 200 | fReader.close(); 201 | } catch (IOException e) { 202 | e.printStackTrace(); 203 | } 204 | } 205 | if (csvReader != null) { 206 | try { 207 | csvReader.close(); 208 | } catch (IOException e) { 209 | e.printStackTrace(); 210 | } 211 | } 212 | } 213 | } 214 | 215 | /** 216 | * 读取sql文件到List 217 | * 218 | * @param sqlFile 219 | * @return 内容List(每行的字符串) 220 | * @throws IOException 221 | */ 222 | public static ArrayList getSqlFileContentList(File sqlFile) throws IOException { 223 | ArrayList list = new ArrayList(); 224 | 225 | BufferedReader br = null; 226 | try { 227 | // 初始化reader 228 | br = new BufferedReader(new InputStreamReader(new FileInputStream(sqlFile), StandardCharsets.UTF_8)); 229 | String lineTxt = null; 230 | while ((lineTxt = br.readLine()) != null) { 231 | lineTxt = lineTxt.trim(); 232 | if ("".equals(lineTxt) || lineTxt.startsWith("//")) { 233 | // 跳过注释和空行 234 | } else { 235 | if (lineTxt.contains("//")) { 236 | // 去掉注释 237 | lineTxt = lineTxt.substring(0, lineTxt.indexOf("//")).trim(); 238 | } 239 | list.add(lineTxt); 240 | } 241 | } 242 | return list; 243 | 244 | } catch (IOException e) { 245 | throw e; 246 | } finally { 247 | if (br != null) { 248 | try { 249 | br.close(); 250 | } catch (IOException e) { 251 | e.printStackTrace(); 252 | } 253 | } 254 | } 255 | } 256 | 257 | /** 258 | * 转换文件大小 259 | * 260 | * @param fileS 261 | * @return 262 | */ 263 | public static String formetfilesize(long fileS) { 264 | DecimalFormat df = new DecimalFormat("#.00"); 265 | String fileSizeString = ""; 266 | if (fileS < 1024) { 267 | fileSizeString = df.format((double) fileS) + "B"; 268 | } else if (fileS < 1048576) { 269 | fileSizeString = df.format((double) fileS / 1024) + "K"; 270 | } else if (fileS < 1073741824) { 271 | fileSizeString = df.format((double) fileS / 1048576) + "M"; 272 | } else { 273 | fileSizeString = df.format((double) fileS / 1073741824) + "G"; 274 | } 275 | return fileSizeString; 276 | } 277 | } 278 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/tools/LogLevel.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.tools; 2 | 3 | /** 4 | * 日志级别枚举 5 | * 6 | * @author Bob 7 | */ 8 | public enum LogLevel { 9 | 10 | INFO, DEBUG, WARN, ERROR, FATAL 11 | } 12 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/tools/PropertyUtil.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.tools; 2 | 3 | import java.io.BufferedInputStream; 4 | import java.io.FileInputStream; 5 | import java.io.IOException; 6 | import java.io.InputStream; 7 | import java.util.Properties; 8 | 9 | /** 10 | * Created by zhouy on 2017/2/27. 11 | */ 12 | public class PropertyUtil { 13 | 14 | /** 15 | * 获取property 16 | * 17 | * @param key 18 | * @return 19 | */ 20 | public static String getProperty(String key) { 21 | Properties pps = new Properties(); 22 | try { 23 | InputStream in = new BufferedInputStream(new FileInputStream(ConstantsTools.PATH_PROPERTY)); 24 | pps.load(in); 25 | String value = pps.getProperty(key); 26 | return value; 27 | 28 | } catch (IOException e) { 29 | e.printStackTrace(); 30 | return null; 31 | } 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/tools/StatusLog.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.tools; 2 | 3 | 4 | import com.luoboduner.wesync.ui.panel.StatusPanel; 5 | import org.slf4j.Logger; 6 | import org.slf4j.LoggerFactory; 7 | 8 | /** 9 | * 日志封装类,控制系统信息(界面和log文件)的记录 10 | * 11 | * @author Bob 12 | */ 13 | public class StatusLog { 14 | private static final Logger logger = LoggerFactory.getLogger(StatusLog.class); 15 | 16 | /** 17 | * 设置状态面板状态信息 18 | * 19 | * @param status 20 | */ 21 | public static void setStatus(String status) { 22 | StatusPanel.labelStatus.setText(status); 23 | } 24 | 25 | /** 26 | * 设置状态面板状态的详细信息+写入日志文件(Debug模式下) 27 | * 28 | * @param statusDetail 29 | * @param level 30 | */ 31 | public static void setStatusDetail(String statusDetail, Enum level) { 32 | StatusPanel.labelStatusDetail.setText(PropertyUtil.getProperty("ds.tool.detail") + statusDetail); 33 | if ("true".equals(ConstantsTools.CONFIGER.getDebugMode())) { 34 | 35 | if ("INFO".equals(level.toString())) { 36 | logger.info(statusDetail); 37 | } else if ("DEBUG".equals(level.toString())) { 38 | logger.debug(statusDetail); 39 | } 40 | 41 | } 42 | if ("WARN".equals(level.toString())) { 43 | logger.warn(statusDetail); 44 | } else if ("ERROR".equals(level.toString())) { 45 | logger.error(statusDetail); 46 | } else if ("FATAL".equals(level.toString())) { 47 | logger.error(statusDetail); 48 | } 49 | } 50 | 51 | /** 52 | * 设置状态面板中上一次同步时间,并写入conf 53 | * 54 | * @param lastTime 55 | */ 56 | public static void setLastTime(String lastTime) { 57 | StatusPanel.labelLastTime.setText(PropertyUtil.getProperty("ds.ui.status.lastSync") + lastTime); 58 | try { 59 | ConstantsTools.CONFIGER.setLastSyncTime(lastTime); 60 | } catch (Exception e) { 61 | logger.error(e.toString()); 62 | e.printStackTrace(); 63 | } 64 | } 65 | 66 | /** 67 | * 设置状态面板中的持续时间,并写入conf 68 | * 69 | * @param keepTime 70 | */ 71 | public static void setKeepTime(String keepTime) { 72 | StatusPanel.labelKeepTime.setText(PropertyUtil.getProperty("ds.ui.status.keepTime") + keepTime 73 | + PropertyUtil.getProperty("ds.ui.status.second")); 74 | try { 75 | ConstantsTools.CONFIGER.setLastKeepTime(keepTime); 76 | } catch (Exception e) { 77 | logger.error(e.toString()); 78 | e.printStackTrace(); 79 | } 80 | } 81 | 82 | /** 83 | * 设置状态面板中下一次同步时间 84 | * 85 | * @param nextTime 86 | */ 87 | public static void setNextTime(String nextTime) { 88 | StatusPanel.labelNextTime.setText(PropertyUtil.getProperty("ds.ui.schedule.nextTime") + nextTime); 89 | } 90 | 91 | /** 92 | * 设置状态面板中的成功总次数,并写入conf 93 | * 94 | * @param success 95 | */ 96 | public static void setSuccess(String success) { 97 | StatusPanel.labelSuccess.setText(PropertyUtil.getProperty("ds.ui.status.successTimes") + success); 98 | try { 99 | ConstantsTools.CONFIGER.setSuccessTime(success); 100 | } catch (Exception e) { 101 | logger.error(e.toString()); 102 | e.printStackTrace(); 103 | } 104 | } 105 | 106 | /** 107 | * 设置状态面板中的失败总次数,并写入conf 108 | * 109 | * @param fail 110 | */ 111 | public static void setFail(String fail) { 112 | StatusPanel.labelFail.setText(PropertyUtil.getProperty("ds.ui.status.failTimes") + fail); 113 | try { 114 | ConstantsTools.CONFIGER.setFailTime(fail); 115 | } catch (Exception e) { 116 | logger.error(e.toString()); 117 | e.printStackTrace(); 118 | } 119 | } 120 | } -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/tools/Utils.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.tools; 2 | 3 | import net.sourceforge.pinyin4j.PinyinHelper; 4 | import net.sourceforge.pinyin4j.format.HanyuPinyinCaseType; 5 | import net.sourceforge.pinyin4j.format.HanyuPinyinOutputFormat; 6 | import net.sourceforge.pinyin4j.format.HanyuPinyinToneType; 7 | import net.sourceforge.pinyin4j.format.HanyuPinyinVCharType; 8 | import net.sourceforge.pinyin4j.format.exception.BadHanyuPinyinOutputFormatCombination; 9 | 10 | import java.text.SimpleDateFormat; 11 | import java.util.Date; 12 | import java.util.Iterator; 13 | import java.util.LinkedHashSet; 14 | import java.util.Map; 15 | 16 | /** 17 | * 小工具类 18 | * 19 | * @author Bob 20 | */ 21 | public class Utils { 22 | 23 | /** 24 | * 获取系统当前时间yyyy-MM-dd HH:mm:ss 25 | * 26 | * @return 27 | */ 28 | public static String getCurrentTime() { 29 | // 设置日期格式 30 | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 31 | return df.format(new Date()); 32 | } 33 | 34 | /** 35 | * 获取备份文件名(系统当前时间yyyy-MM-dd HHmmss) 36 | * 37 | * @return 38 | */ 39 | public static String getCurrentTimeForBakName() { 40 | // 设置日期格式 41 | SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HHmmss"); 42 | return df.format(new Date()); 43 | } 44 | 45 | /** 46 | * 计算下一次同步时间 47 | * 48 | * @return 49 | */ 50 | public static String getNextSyncTime() { 51 | 52 | // 1、获取当前时间,获取到的时间类型是long类型的,单位是毫秒 53 | long currentTime = System.currentTimeMillis(); 54 | // 2、在这个基础上加上定时执行时间: 55 | String schedule = ConstantsTools.CONFIGER.getSchedule(); 56 | if ("true,false,false,false,false,false,false".equals(schedule)) { 57 | currentTime += 5 * 60 * 1000; 58 | } else if ("false,true,false,false,false,false,false".equals(schedule)) { 59 | currentTime += 15 * 60 * 1000; 60 | } else if ("false,false,true,false,false,false,false".equals(schedule)) { 61 | currentTime += 30 * 60 * 1000; 62 | } else if ("false,false,false,true,false,false,false".equals(schedule)) { 63 | currentTime += 60 * 60 * 1000; 64 | } else if ("false,false,false,false,true,false,false".equals(schedule)) { 65 | currentTime += 24 * 60 * 60 * 1000; 66 | } else if ("false,false,false,false,false,true,false".equals(schedule)) { 67 | currentTime += 7 * 24 * 60 * 60 * 1000; 68 | } else if ("false,false,false,false,false,false,true".equals(schedule)) { 69 | return "明天 " + ConstantsTools.CONFIGER.getScheduleFixTime(); 70 | } 71 | 72 | // 3、格式化时间,获取到的就是当前时间加上定时执行之后的时间 73 | Date date = new Date(currentTime); 74 | // 4、建立时间格式化对象: 75 | SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); 76 | return dateFormat.format(date); 77 | } 78 | 79 | /** 80 | * 获取某字符串在字符串数组中的index 81 | * 82 | * @param arr 83 | * @param key 84 | * @return 返回某字符串在字符串数组中的index,若找不到返回-1 85 | */ 86 | public static int getStrArrIndex(String[] arr, String key) { 87 | 88 | for (int i = 0; i < arr.length; i++) { 89 | if (key.equals(arr[i])) { 90 | return i; 91 | } 92 | } 93 | return -1; 94 | } 95 | 96 | /** 97 | * 比较两个key完全相同的map内容是否完全一致 98 | * 99 | * @param map1 100 | * @param map2 101 | * @return 102 | */ 103 | public static boolean mapCompare4PrimKey(Map map1, Map map2) { 104 | boolean ifEquals = true; 105 | for (String key : map1.keySet()) { 106 | if (!map1.get(key).equals(map2.get(key))) { 107 | ifEquals = false; 108 | } 109 | } 110 | 111 | return ifEquals; 112 | } 113 | 114 | /** 115 | * 将汉字转换为全拼 116 | * 117 | * @param src 118 | * @return 119 | */ 120 | public static String getPingYin(String src) { 121 | 122 | char[] t1; 123 | t1 = src.toCharArray(); 124 | String[] t2; 125 | HanyuPinyinOutputFormat t3 = new HanyuPinyinOutputFormat(); 126 | 127 | t3.setCaseType(HanyuPinyinCaseType.LOWERCASE); 128 | t3.setToneType(HanyuPinyinToneType.WITHOUT_TONE); 129 | t3.setVCharType(HanyuPinyinVCharType.WITH_V); 130 | String t4 = ""; 131 | int t0 = t1.length; 132 | try { 133 | for (int i = 0; i < t0; i++) { 134 | // 判断是否为汉字字符 135 | if (Character.toString(t1[i]).matches("[\\u4E00-\\u9FA5]+")) { 136 | t2 = PinyinHelper.toHanyuPinyinStringArray(t1[i], t3); 137 | t4 += t2[0]; 138 | } else { 139 | t4 += Character.toString(t1[i]); 140 | } 141 | } 142 | return t4; 143 | } catch (BadHanyuPinyinOutputFormatCombination e1) { 144 | e1.printStackTrace(); 145 | } 146 | return t4; 147 | } 148 | 149 | /** 150 | * 获取linkedHashSet中元素的索引位置 151 | * 152 | * @param linkedHashSet 153 | * @param string 154 | * @return 155 | */ 156 | public static int getIndexInLinkedHashSet(LinkedHashSet linkedHashSet, String string) { 157 | int index = -1; 158 | Iterator linkedSetStringIt = linkedHashSet.iterator(); 159 | while (linkedSetStringIt.hasNext()) { 160 | index++; 161 | String temp = linkedSetStringIt.next(); 162 | if (temp.equals(string)) { 163 | return index; 164 | } 165 | 166 | } 167 | 168 | return -1; 169 | } 170 | } -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/tools/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 本包为工具包,包含各工具类 3 | * 4 | * @author zhouy 5 | */ 6 | /** 7 | * @author zhouy 8 | * 9 | */ 10 | package com.luoboduner.wesync.tools; -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/ui/UiConsts.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.ui; 2 | 3 | import com.luoboduner.wesync.App; 4 | import com.luoboduner.wesync.tools.PropertyUtil; 5 | 6 | import javax.swing.*; 7 | import java.awt.*; 8 | 9 | /** 10 | * UI相关的常量 11 | * 12 | * @author Bob 13 | */ 14 | public class UiConsts { 15 | 16 | /** 17 | * 软件名称,版本 18 | */ 19 | public final static String APP_NAME = "WeSync"; 20 | public final static String APP_VERSION = "v_1.60_160511"; 21 | 22 | /** 23 | * 主窗口大小 24 | */ 25 | public final static int MAIN_WINDOW_X = 240; 26 | public final static int MAIN_WINDOW_Y = 100; 27 | public final static int MAIN_WINDOW_WIDTH = 885; 28 | public final static int MAIN_WINDOW_HEIGHT = 636; 29 | 30 | /** 31 | * 系统当前路径 32 | */ 33 | public final static String CURRENT_DIR = System.getProperty("user.dir"); 34 | 35 | /** 36 | * 主窗口图标 37 | */ 38 | public final static Image IMAGE_ICON = Toolkit.getDefaultToolkit() 39 | .getImage(App.class.getResource("/icon/WeSync.png")); 40 | 41 | /** 42 | * 主窗口背景色 43 | */ 44 | public final static Color MAIN_BACK_COLOR = Color.WHITE; 45 | 46 | /** 47 | * 工具栏背景色 48 | */ 49 | public final static Color TOOL_BAR_BACK_COLOR = new Color(37, 174, 96); 50 | /** 51 | * 表格线条背景色 52 | */ 53 | public final static Color TABLE_LINE_COLOR = new Color(229, 229, 229); 54 | 55 | // 字体 56 | /** 57 | * 标题字体 58 | */ 59 | public final static Font FONT_TITLE = new Font(PropertyUtil.getProperty("ds.ui.font.family"), 0, 27); 60 | /** 61 | * 普通字体 62 | */ 63 | public final static Font FONT_NORMAL = new Font(PropertyUtil.getProperty("ds.ui.font.family"), 0, 13); 64 | /** 65 | * radio字体 66 | */ 67 | public final static Font FONT_RADIO = new Font(PropertyUtil.getProperty("ds.ui.font.family"), 0, 15); 68 | 69 | /** 70 | * 主图标 71 | */ 72 | public final static ImageIcon ICON_DATA_SYNC = new ImageIcon( 73 | App.class.getResource("/icon/WeSync.png")); 74 | // 工具栏图标 75 | /** 76 | * 状态 默认 77 | */ 78 | public final static ImageIcon ICON_STATUS = new ImageIcon( 79 | App.class.getResource("/icon/status.png")); 80 | /** 81 | * 状态 激活 82 | */ 83 | public final static ImageIcon ICON_STATUS_ENABLE = new ImageIcon( 84 | App.class.getResource("/icon/statusEnable.png")); 85 | /** 86 | * 数据库 默认 87 | */ 88 | public final static ImageIcon ICON_DATABASE = new ImageIcon( 89 | App.class.getResource("/icon/database.png")); 90 | /** 91 | * 数据库 激活 92 | */ 93 | public final static ImageIcon ICON_DATABASE_ENABLE = new ImageIcon( 94 | App.class.getResource("/icon/databaseEnable.png")); 95 | /** 96 | * 执行计划 默认 97 | */ 98 | public final static ImageIcon ICON_SCHEDULE = new ImageIcon( 99 | App.class.getResource("/icon/schedule.png")); 100 | /** 101 | * 执行计划 激活 102 | */ 103 | public final static ImageIcon ICON_SCHEDULE_ENABLE = new ImageIcon( 104 | App.class.getResource("/icon/scheduleEnable.png")); 105 | /** 106 | * 设置 默认 107 | */ 108 | public final static ImageIcon ICON_SETTING = new ImageIcon( 109 | App.class.getResource("/icon/setting.png")); 110 | /** 111 | * 设置 激活 112 | */ 113 | public final static ImageIcon ICON_SETTING_ENABLE = new ImageIcon( 114 | App.class.getResource("/icon/settingEnable.png")); 115 | /** 116 | * 备份 默认 117 | */ 118 | public final static ImageIcon ICON_BACKUP = new ImageIcon( 119 | App.class.getResource("/icon/backup.png")); 120 | /** 121 | * 备份 激活 122 | */ 123 | public final static ImageIcon ICON_BACKUP_ENABLE = new ImageIcon( 124 | App.class.getResource("/icon/backupEnable.png")); 125 | 126 | // 按钮 图标 127 | /** 128 | * 按计划执行 默认 129 | */ 130 | public final static ImageIcon ICON_START_SCHEDULE = new ImageIcon( 131 | App.class.getResource("/icon/startSchedule.png")); 132 | /** 133 | * 按计划执行 激活 134 | */ 135 | public final static ImageIcon ICON_START_SCHEDULE_ENABLE = new ImageIcon( 136 | App.class.getResource("/icon/startScheduleEnable.png")); 137 | /** 138 | * 按计划执行 失效 139 | */ 140 | public final static ImageIcon ICON_START_SCHEDULE_DISABLE = new ImageIcon( 141 | App.class.getResource("/icon/startScheduleDisable.png")); 142 | /** 143 | * 停止 默认 144 | */ 145 | public final static ImageIcon ICON_STOP = new ImageIcon( 146 | App.class.getResource("/icon/stop.png")); 147 | /** 148 | * 停止 激活 149 | */ 150 | public final static ImageIcon ICON_STOP_ENABLE = new ImageIcon( 151 | App.class.getResource("/icon/stopEnable.png")); 152 | /** 153 | * 停止 失效 154 | */ 155 | public final static ImageIcon ICON_STOP_DISABLE = new ImageIcon( 156 | App.class.getResource("/icon/stopDisable.png")); 157 | /** 158 | * 立即同步 默认 159 | */ 160 | public final static ImageIcon ICON_SYNC_NOW = new ImageIcon( 161 | App.class.getResource("/icon/syncNow.png")); 162 | /** 163 | * 立即同步 激活 164 | */ 165 | public final static ImageIcon ICON_SYNC_NOW_ENABLE = new ImageIcon( 166 | App.class.getResource("/icon/syncNowEnable.png")); 167 | /** 168 | * 立即同步 失效 169 | */ 170 | public final static ImageIcon ICON_SYNC_NOW_DISABLE = new ImageIcon( 171 | App.class.getResource("/icon/syncNowDisable.png")); 172 | /** 173 | * 测试连接 默认 174 | */ 175 | public final static ImageIcon ICON_TEST_LINK = new ImageIcon( 176 | App.class.getResource("/icon/testLinkButton.png")); 177 | /** 178 | * 测试连接 激活 179 | */ 180 | public final static ImageIcon ICON_TEST_LINK_ENABLE = new ImageIcon( 181 | App.class.getResource("/icon/testLinkButtonEnable.png")); 182 | /** 183 | * 测试连接 失效 184 | */ 185 | public final static ImageIcon ICON_TEST_LINK_DISABLE = new ImageIcon( 186 | App.class.getResource("/icon/testLinkButtonDisable.png")); 187 | /** 188 | * 保存 默认 189 | */ 190 | public final static ImageIcon ICON_SAVE = new ImageIcon( 191 | App.class.getResource("/icon/saveButton.png")); 192 | /** 193 | * 保存 激活 194 | */ 195 | public final static ImageIcon ICON_SAVE_ENABLE = new ImageIcon( 196 | App.class.getResource("/icon/saveButtonEnable.png")); 197 | /** 198 | * 保存 失效 199 | */ 200 | public final static ImageIcon ICON_SAVE_DISABLE = new ImageIcon( 201 | App.class.getResource("/icon/saveButtonDisable.png")); 202 | /** 203 | * 新建备份 默认 204 | */ 205 | public final static ImageIcon ICON_NEW_BAK = new ImageIcon( 206 | App.class.getResource("/icon/newBak.png")); 207 | /** 208 | * 新建备份 激活 209 | */ 210 | public final static ImageIcon ICON_NEW_BAK_ENABLE = new ImageIcon( 211 | App.class.getResource("/icon/newBakEnable.png")); 212 | /** 213 | * 新建备份 失效 214 | */ 215 | public final static ImageIcon ICON_NEW_BAK_DISABLE = new ImageIcon( 216 | App.class.getResource("/icon/newBakDisable.png")); 217 | /** 218 | * 删除备份 默认 219 | */ 220 | public final static ImageIcon ICON_DEL_BAK = new ImageIcon( 221 | App.class.getResource("/icon/deleteBak.png")); 222 | /** 223 | * 删除备份 激活 224 | */ 225 | public final static ImageIcon ICON_DEL_BAK_ENABLE = new ImageIcon( 226 | App.class.getResource("/icon/deleteBakEnable.png")); 227 | /** 228 | * 删除备份 失效 229 | */ 230 | public final static ImageIcon ICON_DEL_BAK_DISABLE = new ImageIcon( 231 | App.class.getResource("/icon/deleteBakDisable.png")); 232 | /** 233 | * 还原备份 默认 234 | */ 235 | public final static ImageIcon ICON_RECOVER_BAK = new ImageIcon( 236 | App.class.getResource("/icon/recoverBak.png")); 237 | /** 238 | * 还原备份 激活 239 | */ 240 | public final static ImageIcon ICON_RECOVER_BAK_ENABLE = new ImageIcon( 241 | App.class.getResource("/icon/recoverBakEnable.png")); 242 | /** 243 | * 还原备份 失效 244 | */ 245 | public final static ImageIcon ICON_RECOVER_BAK_DISABLE = new ImageIcon( 246 | App.class.getResource("/icon/recoverBakDisable.png")); 247 | 248 | /** 249 | * 清空所有备份 默认 250 | */ 251 | public final static ImageIcon ICON_CLEAR_ALL_BAKS = new ImageIcon( 252 | App.class.getResource("/icon/clearAllBaks.png")); 253 | /** 254 | * 清空所有备份 激活 255 | */ 256 | public final static ImageIcon ICON_CLEAR_ALL_BAKS_ENABLE = new ImageIcon( 257 | App.class.getResource("/icon/clearAllBaksEnable.png")); 258 | /** 259 | * 清空所有备份 失效 260 | */ 261 | public final static ImageIcon ICON_CLEAR_ALL_BAKS_DISABLE = new ImageIcon( 262 | App.class.getResource("/icon/clearAllBaksDisable.png")); 263 | 264 | /** 265 | * 表字段对应关系 默认 266 | */ 267 | public final static ImageIcon ICON_TABLE_FIELD = new ImageIcon( 268 | App.class.getResource("/icon/tableFiled.png")); 269 | /** 270 | * 表字段对应关系 激活 271 | */ 272 | public final static ImageIcon ICON_TABLE_FIELD_ENABLE = new ImageIcon( 273 | App.class.getResource("/icon/tableFiledEnable.png")); 274 | /** 275 | * 表字段对应关系 失效 276 | */ 277 | public final static ImageIcon ICON_TABLE_FIELD_DISABLE = new ImageIcon( 278 | App.class.getResource("/icon/tableFiledDisable.png")); 279 | /** 280 | * 清空Log 默认 281 | */ 282 | public final static ImageIcon ICON_CLEAR_LOG = new ImageIcon( 283 | App.class.getResource("/icon/clearLog.png")); 284 | /** 285 | * 清空Log 激活 286 | */ 287 | public final static ImageIcon ICON_CLEAR_LOG_ENABLE = new ImageIcon( 288 | App.class.getResource("/icon/clearLogEnable.png")); 289 | /** 290 | * 清空Log 失效 291 | */ 292 | public final static ImageIcon ICON_CLEAR_LOG_DISABLE = new ImageIcon( 293 | App.class.getResource("/icon/clearLogDisable.png")); 294 | 295 | // 样式布局相关 296 | /** 297 | * 主面板水平间隔 298 | */ 299 | public final static int MAIN_H_GAP = 25; 300 | /** 301 | * 主面板Label 大小 302 | */ 303 | public final static Dimension LABLE_SIZE = new Dimension(1300, 30); 304 | /** 305 | * Item Label 大小 306 | */ 307 | public final static Dimension LABLE_SIZE_ITEM = new Dimension(78, 30); 308 | /** 309 | * Item text field 大小 310 | */ 311 | public final static Dimension TEXT_FIELD_SIZE_ITEM = new Dimension(400, 24); 312 | /** 313 | * radio 大小 314 | */ 315 | public final static Dimension RADIO_SIZE = new Dimension(1300, 60); 316 | /** 317 | * 高级选项面板Item 大小 318 | */ 319 | public final static Dimension PANEL_ITEM_SIZE = new Dimension(1300, 40); 320 | 321 | } -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/ui/component/MyIconButton.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.ui.component; 2 | 3 | import java.awt.Insets; 4 | 5 | import javax.swing.ImageIcon; 6 | import javax.swing.JButton; 7 | 8 | /** 9 | * 自定义按钮类,支持自定义默认图标、激活图标、失效图标和tip提示 10 | * 11 | * @author Bob 12 | */ 13 | public class MyIconButton extends JButton { 14 | 15 | private static final long serialVersionUID = 1L; 16 | private ImageIcon iconEnable, iconDisable; 17 | private String tip; 18 | 19 | /** 20 | * 构造 21 | * 22 | * @param iconNormal 默认图标 23 | * @param iconEnable 激活图标 24 | * @param iconDisable 失效图标 25 | * @param tip 提示 26 | */ 27 | public MyIconButton(ImageIcon iconNormal, ImageIcon iconEnable, ImageIcon iconDisable, String tip) { 28 | super(iconNormal); 29 | 30 | this.iconEnable = iconEnable; 31 | this.iconDisable = iconDisable; 32 | this.tip = tip; 33 | 34 | initialize(); 35 | setUp(); 36 | } 37 | 38 | /** 39 | * 初始化,设置按钮属性:无边,无焦点渲染,无内容区,各边距0 40 | */ 41 | private void initialize() { 42 | this.setBorderPainted(false); 43 | this.setFocusPainted(false); 44 | this.setContentAreaFilled(false); 45 | this.setFocusable(true); 46 | this.setMargin(new Insets(0, 0, 0, 0)); 47 | } 48 | 49 | /** 50 | * 设置按钮图标:鼠标移过、按压、失效的图标 和设置按钮提示 51 | */ 52 | private void setUp() { 53 | this.setRolloverIcon(iconEnable); 54 | // this.setSelectedIcon(iconEnable); 55 | this.setPressedIcon(iconEnable); 56 | this.setDisabledIcon(iconDisable); 57 | 58 | if (!tip.equals("")) { 59 | this.setToolTipText(tip); 60 | } 61 | 62 | } 63 | } -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/ui/dialog/DbBackUpCreateDialog.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.ui.dialog; 2 | 3 | import com.luoboduner.wesync.tools.PropertyUtil; 4 | import com.luoboduner.wesync.ui.UiConsts; 5 | 6 | import javax.swing.*; 7 | import java.awt.*; 8 | 9 | /** 10 | *
11 |  * 新建备份dialog
12 |  * 
13 | * 14 | * @author Zhou Bo 15 | * @since 2019/2/27. 16 | */ 17 | public class DbBackUpCreateDialog extends JDialog { 18 | public DbBackUpCreateDialog(JFrame frame, String property, boolean b) { 19 | super(frame, property, b); 20 | } 21 | 22 | public void init() { 23 | this.setBounds(460, 220, 400, 250); 24 | JPanel panelDialog = new JPanel(new BorderLayout()); 25 | panelDialog.setBackground(UiConsts.MAIN_BACK_COLOR); 26 | JPanel panelDialogCenter = new JPanel(new FlowLayout(FlowLayout.LEFT, UiConsts.MAIN_H_GAP, 10)); 27 | JPanel panelDialogDown = new JPanel(new GridLayout(1, 2)); 28 | JPanel grid1 = new JPanel(new FlowLayout(FlowLayout.RIGHT, 20, 20)); 29 | JPanel grid2 = new JPanel(new FlowLayout(FlowLayout.LEFT, 20, 20)); 30 | 31 | JLabel labelType = new JLabel(PropertyUtil.getProperty("ds.ui.mainwindow.dialog.type")); 32 | JLabel labelComment = new JLabel(PropertyUtil.getProperty("ds.ui.mainwindow.dialog.remarks")); 33 | JLabel labelProgress = new JLabel(PropertyUtil.getProperty("ds.ui.mainwindow.dialog.progress")); 34 | JComboBox comboxType = new JComboBox<>(new String[]{PropertyUtil.getProperty("ds.ui.mainwindow.dialog.comboxType0"), 35 | PropertyUtil.getProperty("ds.ui.mainwindow.dialog.comboxType1"), PropertyUtil.getProperty("ds.ui.mainwindow.dialog.comboxType2"), 36 | PropertyUtil.getProperty("ds.ui.mainwindow.dialog.comboxType3")}); 37 | JTextField textFieldComment = new JTextField(); 38 | JProgressBar progressbar = new JProgressBar(); 39 | 40 | labelType.setFont(UiConsts.FONT_NORMAL); 41 | labelComment.setFont(UiConsts.FONT_NORMAL); 42 | labelProgress.setFont(UiConsts.FONT_NORMAL); 43 | comboxType.setFont(UiConsts.FONT_NORMAL); 44 | textFieldComment.setFont(UiConsts.FONT_NORMAL); 45 | 46 | Dimension preferredSize = new Dimension(250, 30); 47 | comboxType.setPreferredSize(preferredSize); 48 | textFieldComment.setPreferredSize(preferredSize); 49 | progressbar.setPreferredSize(preferredSize); 50 | 51 | panelDialogCenter.add(labelType); 52 | panelDialogCenter.add(comboxType); 53 | panelDialogCenter.add(labelComment); 54 | panelDialogCenter.add(textFieldComment); 55 | panelDialogCenter.add(labelProgress); 56 | panelDialogCenter.add(progressbar); 57 | 58 | JButton buttonSure = new JButton(PropertyUtil.getProperty("ds.ui.sure")); 59 | JButton buttonCancel = new JButton(PropertyUtil.getProperty("ds.ui.cancel")); 60 | buttonSure.setFont(UiConsts.FONT_NORMAL); 61 | buttonCancel.setFont(UiConsts.FONT_NORMAL); 62 | 63 | grid1.add(buttonSure); 64 | grid2.add(buttonCancel); 65 | panelDialogDown.add(grid1); 66 | panelDialogDown.add(grid2); 67 | 68 | panelDialog.add(panelDialogCenter, BorderLayout.CENTER); 69 | panelDialog.add(panelDialogDown, BorderLayout.SOUTH); 70 | 71 | this.add(panelDialog); 72 | 73 | buttonCancel.addActionListener(e -> this.setVisible(false)); 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/ui/panel/BackupPanel.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.ui.panel; 2 | 3 | import com.luoboduner.wesync.App; 4 | import com.luoboduner.wesync.ui.UiConsts; 5 | import com.luoboduner.wesync.ui.component.MyIconButton; 6 | import com.luoboduner.wesync.logic.ConstantsLogic; 7 | import com.luoboduner.wesync.tools.FileUtils; 8 | import com.luoboduner.wesync.tools.PropertyUtil; 9 | 10 | import javax.swing.*; 11 | import java.awt.*; 12 | import java.io.File; 13 | 14 | /** 15 | * 备份面板 16 | * 17 | * @author Bob 18 | */ 19 | public class BackupPanel extends JPanel { 20 | 21 | private static final long serialVersionUID = 1L; 22 | 23 | public static JTable tableFrom; 24 | 25 | private static MyIconButton buttonNewBakFrom; 26 | 27 | private static Object[][] tableDatas; 28 | 29 | /** 30 | * 构造 31 | */ 32 | public BackupPanel() { 33 | initialize(); 34 | initTableData(); 35 | addComponent(); 36 | addListener(); 37 | } 38 | 39 | /** 40 | * 初始化面板 41 | */ 42 | private void initialize() { 43 | this.setBackground(UiConsts.MAIN_BACK_COLOR); 44 | this.setLayout(new BorderLayout()); 45 | } 46 | 47 | /** 48 | * 为面板添加组件 49 | */ 50 | private void addComponent() { 51 | 52 | this.add(getUpPanel(), BorderLayout.NORTH); 53 | this.add(getCenterPanel(), BorderLayout.CENTER); 54 | } 55 | 56 | /** 57 | * 面板上部 58 | * 59 | * @return 60 | */ 61 | private JPanel getUpPanel() { 62 | JPanel panelUp = new JPanel(); 63 | panelUp.setBackground(UiConsts.MAIN_BACK_COLOR); 64 | panelUp.setLayout(new FlowLayout(FlowLayout.LEFT, UiConsts.MAIN_H_GAP, 5)); 65 | 66 | JLabel labelTitle = new JLabel(PropertyUtil.getProperty("ds.ui.backup.title")); 67 | labelTitle.setFont(UiConsts.FONT_TITLE); 68 | labelTitle.setForeground(UiConsts.TOOL_BAR_BACK_COLOR); 69 | panelUp.add(labelTitle); 70 | 71 | return panelUp; 72 | } 73 | 74 | /** 75 | * 面板中部 76 | * 77 | * @return 78 | */ 79 | private JPanel getCenterPanel() { 80 | // 中间面板 81 | JPanel panelCenter = new JPanel(); 82 | panelCenter.setBackground(UiConsts.MAIN_BACK_COLOR); 83 | panelCenter.setLayout(new GridLayout(1, 1)); 84 | 85 | panelCenter.add(getPanelGridBakFrom()); 86 | 87 | return panelCenter; 88 | } 89 | 90 | /** 91 | * 数据库来源Grid面板 92 | * 93 | * @return 94 | */ 95 | private JPanel getPanelGridBakFrom() { 96 | // 来源备份Grid 97 | JPanel panelGridBakFrom = new JPanel(); 98 | panelGridBakFrom.setBackground(UiConsts.MAIN_BACK_COLOR); 99 | panelGridBakFrom.setLayout(new BorderLayout()); 100 | 101 | JPanel panelFromControl = new JPanel(); 102 | panelFromControl.setLayout(new GridLayout(1, 2)); 103 | JPanel panelFromTable = new JPanel(); 104 | panelFromTable.setLayout(new BorderLayout()); 105 | 106 | // 初始化控制组件 107 | JPanel panelFromControlLeft = new JPanel(); 108 | panelFromControlLeft.setLayout(new FlowLayout(FlowLayout.LEFT, UiConsts.MAIN_H_GAP, 5)); 109 | panelFromControlLeft.setBackground(UiConsts.MAIN_BACK_COLOR); 110 | JPanel panelFromControlRight = new JPanel(); 111 | panelFromControlRight.setLayout(new FlowLayout(FlowLayout.RIGHT, UiConsts.MAIN_H_GAP, 5)); 112 | panelFromControlRight.setBackground(UiConsts.MAIN_BACK_COLOR); 113 | 114 | JLabel labelFrom = new JLabel(PropertyUtil.getProperty("ds.ui.database.label.to")); 115 | labelFrom.setFont(new Font(PropertyUtil.getProperty("ds.ui.font.family"), 0, 18)); 116 | labelFrom.setForeground(Color.gray); 117 | panelFromControlLeft.add(labelFrom); 118 | 119 | buttonNewBakFrom = new MyIconButton(UiConsts.ICON_NEW_BAK, UiConsts.ICON_NEW_BAK_ENABLE, 120 | UiConsts.ICON_NEW_BAK_DISABLE, ""); 121 | MyIconButton buttonRecvBakFrom = new MyIconButton(UiConsts.ICON_RECOVER_BAK, 122 | UiConsts.ICON_RECOVER_BAK_ENABLE, UiConsts.ICON_RECOVER_BAK_DISABLE, ""); 123 | MyIconButton buttonDelBakFrom = new MyIconButton(UiConsts.ICON_DEL_BAK, UiConsts.ICON_DEL_BAK_ENABLE, 124 | UiConsts.ICON_DEL_BAK_DISABLE, ""); 125 | panelFromControlRight.add(buttonNewBakFrom); 126 | panelFromControlRight.add(buttonRecvBakFrom); 127 | panelFromControlRight.add(buttonDelBakFrom); 128 | 129 | panelFromControl.add(panelFromControlLeft); 130 | panelFromControl.add(panelFromControlRight); 131 | 132 | panelGridBakFrom.add(panelFromControl, BorderLayout.NORTH); 133 | 134 | // 初始化表格组件 135 | 136 | tableFrom = new JTable(tableDatas, new String[]{PropertyUtil.getProperty("ds.ui.backup.table.head0"), PropertyUtil.getProperty("ds.ui.backup.table.head1"), PropertyUtil.getProperty("ds.ui.backup.table.head2")}); 137 | tableFrom.setFont(UiConsts.FONT_NORMAL); 138 | tableFrom.getTableHeader().setFont(UiConsts.FONT_NORMAL); 139 | tableFrom.getTableHeader().setBackground(UiConsts.TOOL_BAR_BACK_COLOR); 140 | tableFrom.setRowHeight(31); 141 | tableFrom.setGridColor(UiConsts.TABLE_LINE_COLOR); 142 | tableFrom.setSelectionBackground(UiConsts.TOOL_BAR_BACK_COLOR); 143 | // 设置列宽 144 | tableFrom.getColumnModel().getColumn(0).setPreferredWidth(50); 145 | tableFrom.getColumnModel().getColumn(0).setMaxWidth(50); 146 | tableFrom.getColumnModel().getColumn(2).setPreferredWidth(150); 147 | tableFrom.getColumnModel().getColumn(2).setMaxWidth(150); 148 | 149 | JScrollPane panelScroll = new JScrollPane(tableFrom); 150 | panelScroll.setBackground(UiConsts.MAIN_BACK_COLOR); 151 | panelGridBakFrom.add(panelScroll, BorderLayout.CENTER); 152 | 153 | return panelGridBakFrom; 154 | } 155 | 156 | public static void initTableData() { 157 | File bakupFilesDir = new File(ConstantsLogic.PATH_MYSQL_BAK); 158 | if (!bakupFilesDir.exists()) { 159 | bakupFilesDir.mkdirs(); 160 | } 161 | File[] bakupFiles = bakupFilesDir.listFiles(); 162 | tableDatas = new Object[bakupFiles.length][3]; 163 | for (int i = 0; i < bakupFiles.length; i++) { 164 | tableDatas[i] = new Object[]{i + 1, bakupFiles[i].getName(), 165 | FileUtils.formetfilesize(bakupFiles[i].length())}; 166 | } 167 | } 168 | 169 | private void addListener() { 170 | buttonNewBakFrom.addActionListener(e -> App.dbBackUpCreateDialog.setVisible(true)); 171 | } 172 | 173 | } -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/ui/panel/DatabasePanel.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.ui.panel; 2 | 3 | import com.luoboduner.wesync.App; 4 | import com.luoboduner.wesync.ui.UiConsts; 5 | import com.luoboduner.wesync.tools.PropertyUtil; 6 | 7 | import javax.swing.*; 8 | import java.awt.*; 9 | import java.awt.event.MouseEvent; 10 | import java.awt.event.MouseListener; 11 | 12 | /** 13 | * 数据库设置面板 14 | * 15 | * @author Bob 16 | */ 17 | public class DatabasePanel extends JPanel { 18 | 19 | private static final long serialVersionUID = 1L; 20 | 21 | public static JPanel panelFrom; 22 | public static JPanel panelTo; 23 | public static JPanel databaseSettingPanel; 24 | private static JPanel databaseSettingPanelFrom; 25 | private static JPanel databaseSettingPanelTo; 26 | 27 | /** 28 | * 构造 29 | */ 30 | public DatabasePanel() { 31 | initialize(); 32 | addComponent(); 33 | addListener(); 34 | } 35 | 36 | /** 37 | * 初始化面板 38 | */ 39 | private void initialize() { 40 | this.setBackground(UiConsts.MAIN_BACK_COLOR); 41 | this.setLayout(new BorderLayout()); 42 | databaseSettingPanelFrom = new DatabasePanelFrom(); 43 | databaseSettingPanelTo = new DatabasePanelTo(); 44 | } 45 | 46 | /** 47 | * 为面板添加组件 48 | */ 49 | private void addComponent() { 50 | 51 | this.add(getUpPanel(), BorderLayout.NORTH); 52 | this.add(getCenterPanel(), BorderLayout.CENTER); 53 | 54 | } 55 | 56 | /** 57 | * 面板上部 58 | * 59 | * @return 60 | */ 61 | private JPanel getUpPanel() { 62 | JPanel panelUp = new JPanel(); 63 | panelUp.setBackground(UiConsts.MAIN_BACK_COLOR); 64 | panelUp.setLayout(new FlowLayout(FlowLayout.LEFT, UiConsts.MAIN_H_GAP, 5)); 65 | 66 | JLabel labelTitle = new JLabel(PropertyUtil.getProperty("ds.ui.database.title")); 67 | labelTitle.setFont(UiConsts.FONT_TITLE); 68 | labelTitle.setForeground(UiConsts.TOOL_BAR_BACK_COLOR); 69 | panelUp.add(labelTitle); 70 | 71 | return panelUp; 72 | } 73 | 74 | /** 75 | * 面板中部 76 | * 77 | * @return 78 | */ 79 | private JPanel getCenterPanel() { 80 | // 中间面板 81 | JPanel panelCenter = new JPanel(); 82 | panelCenter.setBackground(UiConsts.MAIN_BACK_COLOR); 83 | panelCenter.setLayout(new BorderLayout()); 84 | 85 | // 数据库列表Panel 86 | JPanel panelList = new JPanel(); 87 | Dimension preferredSize = new Dimension(245, UiConsts.MAIN_WINDOW_HEIGHT); 88 | panelList.setPreferredSize(preferredSize); 89 | panelList.setBackground(new Color(62, 62, 62)); 90 | panelList.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); 91 | 92 | panelFrom = new JPanel(); 93 | panelFrom.setBackground(new Color(69, 186, 121)); 94 | panelFrom.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 13)); 95 | Dimension preferredSizeListItem = new Dimension(245, 48); 96 | panelFrom.setPreferredSize(preferredSizeListItem); 97 | panelTo = new JPanel(); 98 | panelTo.setBackground(UiConsts.TOOL_BAR_BACK_COLOR); 99 | panelTo.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 13)); 100 | panelTo.setPreferredSize(preferredSizeListItem); 101 | 102 | JLabel labelFrom = new JLabel(PropertyUtil.getProperty("ds.ui.database.label.from")); 103 | JLabel labelTo = new JLabel(PropertyUtil.getProperty("ds.ui.database.label.to")); 104 | Font fontListItem = new Font(PropertyUtil.getProperty("ds.ui.font.family"), 0, 15); 105 | labelFrom.setFont(fontListItem); 106 | labelTo.setFont(fontListItem); 107 | labelFrom.setForeground(Color.white); 108 | labelTo.setForeground(Color.white); 109 | panelFrom.add(labelFrom); 110 | panelTo.add(labelTo); 111 | 112 | panelList.add(panelFrom); 113 | panelList.add(panelTo); 114 | 115 | // 数据库设置Panel 116 | 117 | databaseSettingPanel = new JPanel(); 118 | databaseSettingPanel.setBackground(UiConsts.MAIN_BACK_COLOR); 119 | databaseSettingPanel.setLayout(new BorderLayout()); 120 | databaseSettingPanel.add(databaseSettingPanelFrom); 121 | 122 | panelCenter.add(panelList, BorderLayout.WEST); 123 | panelCenter.add(databaseSettingPanel, BorderLayout.CENTER); 124 | 125 | return panelCenter; 126 | } 127 | 128 | /** 129 | * 添加相关组件的事件监听 130 | */ 131 | private void addListener() { 132 | panelFrom.addMouseListener(new MouseListener() { 133 | 134 | @Override 135 | public void mouseReleased(MouseEvent e) { 136 | // TODO Auto-generated method stub 137 | 138 | } 139 | 140 | @Override 141 | public void mousePressed(MouseEvent e) { 142 | // TODO Auto-generated method stub 143 | 144 | } 145 | 146 | @Override 147 | public void mouseExited(MouseEvent e) { 148 | // TODO Auto-generated method stub 149 | 150 | } 151 | 152 | @Override 153 | public void mouseEntered(MouseEvent e) { 154 | 155 | } 156 | 157 | @Override 158 | public void mouseClicked(MouseEvent e) { 159 | panelFrom.setBackground(new Color(69, 186, 121)); 160 | panelTo.setBackground(UiConsts.TOOL_BAR_BACK_COLOR); 161 | 162 | DatabasePanel.databaseSettingPanel.removeAll(); 163 | DatabasePanelFrom.setContent(); 164 | DatabasePanel.databaseSettingPanel.add(databaseSettingPanelFrom); 165 | App.databasePanel.updateUI(); 166 | 167 | } 168 | }); 169 | 170 | panelTo.addMouseListener(new MouseListener() { 171 | 172 | @Override 173 | public void mouseReleased(MouseEvent e) { 174 | // TODO Auto-generated method stub 175 | 176 | } 177 | 178 | @Override 179 | public void mousePressed(MouseEvent e) { 180 | // TODO Auto-generated method stub 181 | 182 | } 183 | 184 | @Override 185 | public void mouseExited(MouseEvent e) { 186 | // TODO Auto-generated method stub 187 | 188 | } 189 | 190 | @Override 191 | public void mouseEntered(MouseEvent e) { 192 | 193 | } 194 | 195 | @Override 196 | public void mouseClicked(MouseEvent e) { 197 | panelTo.setBackground(new Color(69, 186, 121)); 198 | panelFrom.setBackground(UiConsts.TOOL_BAR_BACK_COLOR); 199 | 200 | DatabasePanel.databaseSettingPanel.removeAll(); 201 | DatabasePanelTo.setContent(); 202 | DatabasePanel.databaseSettingPanel.add(databaseSettingPanelTo); 203 | App.databasePanel.updateUI(); 204 | 205 | } 206 | }); 207 | 208 | } 209 | } 210 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/ui/panel/DatabasePanelFrom.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.ui.panel; 2 | 3 | import com.luoboduner.wesync.App; 4 | import com.luoboduner.wesync.ui.UiConsts; 5 | import com.luoboduner.wesync.ui.component.MyIconButton; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import com.luoboduner.wesync.tools.ConstantsTools; 9 | import com.luoboduner.wesync.tools.DESPlus; 10 | import com.luoboduner.wesync.tools.DbUtilSQLServer; 11 | import com.luoboduner.wesync.tools.PropertyUtil; 12 | 13 | import javax.swing.*; 14 | import java.awt.*; 15 | import java.sql.Connection; 16 | 17 | /** 18 | * 来源数据库面板 19 | * 20 | * @author Bob 21 | */ 22 | public class DatabasePanelFrom extends JPanel { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | private static MyIconButton buttonTestLink; 27 | private static MyIconButton buttonSave; 28 | private static JTextField textFieldDatabaseHost; 29 | private static JTextField textFieldDatabaseName; 30 | private static JTextField textFieldDatabaseUser; 31 | private static JPasswordField passwordFieldDatabasePassword; 32 | 33 | private static final Logger logger = LoggerFactory.getLogger(DatabasePanelFrom.class); 34 | 35 | /** 36 | * 构造 37 | */ 38 | public DatabasePanelFrom() { 39 | initialize(); 40 | addComponent(); 41 | setContent(); 42 | addListener(); 43 | } 44 | 45 | /** 46 | * 初始化 47 | */ 48 | private void initialize() { 49 | this.setBackground(UiConsts.MAIN_BACK_COLOR); 50 | this.setLayout(new BorderLayout()); 51 | } 52 | 53 | /** 54 | * 添加组件 55 | */ 56 | private void addComponent() { 57 | 58 | this.add(getCenterPanel(), BorderLayout.CENTER); 59 | this.add(getDownPanel(), BorderLayout.SOUTH); 60 | 61 | } 62 | 63 | /** 64 | * 中部面板 65 | * 66 | * @return 67 | */ 68 | private JPanel getCenterPanel() { 69 | // 中间面板 70 | JPanel panelCenter = new JPanel(); 71 | panelCenter.setBackground(UiConsts.MAIN_BACK_COLOR); 72 | panelCenter.setLayout(new GridLayout(2, 1)); 73 | 74 | // 设置Grid 75 | JPanel panelGridSetting = new JPanel(); 76 | panelGridSetting.setBackground(UiConsts.MAIN_BACK_COLOR); 77 | panelGridSetting.setLayout(new FlowLayout(FlowLayout.LEFT, UiConsts.MAIN_H_GAP, 0)); 78 | 79 | // 初始化组件 80 | JLabel labelDatabaseType = new JLabel(PropertyUtil.getProperty("ds.ui.database.type")); 81 | JLabel labelDatabaseHost = new JLabel(PropertyUtil.getProperty("ds.ui.database.host")); 82 | JLabel labelDatabaseName = new JLabel(PropertyUtil.getProperty("ds.ui.database.name")); 83 | JLabel labelDatabaseUser = new JLabel(PropertyUtil.getProperty("ds.ui.database.user")); 84 | JLabel labelDatabasePassword = new JLabel(PropertyUtil.getProperty("ds.ui.database.password")); 85 | JComboBox comboxDatabaseType = new JComboBox(); 86 | comboxDatabaseType.addItem("SQL Server"); 87 | comboxDatabaseType.setEditable(false); 88 | textFieldDatabaseHost = new JTextField(); 89 | textFieldDatabaseName = new JTextField(); 90 | textFieldDatabaseUser = new JTextField(); 91 | passwordFieldDatabasePassword = new JPasswordField(); 92 | 93 | // 字体 94 | labelDatabaseType.setFont(UiConsts.FONT_NORMAL); 95 | labelDatabaseHost.setFont(UiConsts.FONT_NORMAL); 96 | labelDatabaseName.setFont(UiConsts.FONT_NORMAL); 97 | labelDatabaseUser.setFont(UiConsts.FONT_NORMAL); 98 | labelDatabasePassword.setFont(UiConsts.FONT_NORMAL); 99 | comboxDatabaseType.setFont(UiConsts.FONT_NORMAL); 100 | textFieldDatabaseHost.setFont(UiConsts.FONT_NORMAL); 101 | textFieldDatabaseName.setFont(UiConsts.FONT_NORMAL); 102 | textFieldDatabaseUser.setFont(UiConsts.FONT_NORMAL); 103 | passwordFieldDatabasePassword.setFont(UiConsts.FONT_NORMAL); 104 | 105 | // 大小 106 | labelDatabaseType.setPreferredSize(UiConsts.LABLE_SIZE_ITEM); 107 | labelDatabaseHost.setPreferredSize(UiConsts.LABLE_SIZE_ITEM); 108 | labelDatabaseName.setPreferredSize(UiConsts.LABLE_SIZE_ITEM); 109 | labelDatabaseUser.setPreferredSize(UiConsts.LABLE_SIZE_ITEM); 110 | labelDatabasePassword.setPreferredSize(UiConsts.LABLE_SIZE_ITEM); 111 | comboxDatabaseType.setPreferredSize(UiConsts.TEXT_FIELD_SIZE_ITEM); 112 | textFieldDatabaseHost.setPreferredSize(UiConsts.TEXT_FIELD_SIZE_ITEM); 113 | textFieldDatabaseName.setPreferredSize(UiConsts.TEXT_FIELD_SIZE_ITEM); 114 | textFieldDatabaseUser.setPreferredSize(UiConsts.TEXT_FIELD_SIZE_ITEM); 115 | passwordFieldDatabasePassword.setPreferredSize(UiConsts.TEXT_FIELD_SIZE_ITEM); 116 | 117 | // 组合元素 118 | panelGridSetting.add(labelDatabaseType); 119 | panelGridSetting.add(comboxDatabaseType); 120 | panelGridSetting.add(labelDatabaseHost); 121 | panelGridSetting.add(textFieldDatabaseHost); 122 | panelGridSetting.add(labelDatabaseName); 123 | panelGridSetting.add(textFieldDatabaseName); 124 | panelGridSetting.add(labelDatabaseUser); 125 | panelGridSetting.add(textFieldDatabaseUser); 126 | panelGridSetting.add(labelDatabasePassword); 127 | panelGridSetting.add(passwordFieldDatabasePassword); 128 | 129 | panelCenter.add(panelGridSetting); 130 | return panelCenter; 131 | } 132 | 133 | /** 134 | * 底部面板 135 | * 136 | * @return 137 | */ 138 | private JPanel getDownPanel() { 139 | JPanel panelDown = new JPanel(); 140 | panelDown.setBackground(UiConsts.MAIN_BACK_COLOR); 141 | panelDown.setLayout(new FlowLayout(FlowLayout.RIGHT, UiConsts.MAIN_H_GAP, 15)); 142 | 143 | buttonTestLink = new MyIconButton(UiConsts.ICON_TEST_LINK, UiConsts.ICON_TEST_LINK_ENABLE, 144 | UiConsts.ICON_TEST_LINK_DISABLE, ""); 145 | buttonSave = new MyIconButton(UiConsts.ICON_SAVE, UiConsts.ICON_SAVE_ENABLE, 146 | UiConsts.ICON_SAVE_DISABLE, ""); 147 | panelDown.add(buttonTestLink); 148 | panelDown.add(buttonSave); 149 | 150 | return panelDown; 151 | } 152 | 153 | /** 154 | * 设置文本区内容 155 | */ 156 | public static void setContent() { 157 | textFieldDatabaseHost.setText(ConstantsTools.CONFIGER.getHostFrom()); 158 | textFieldDatabaseName.setText(ConstantsTools.CONFIGER.getNameFrom()); 159 | 160 | String password = ""; 161 | String user = ""; 162 | try { 163 | DESPlus des = new DESPlus(); 164 | password = des.decrypt(ConstantsTools.CONFIGER.getPasswordFrom()); 165 | user = des.decrypt(ConstantsTools.CONFIGER.getUserFrom()); 166 | } catch (Exception e) { 167 | logger.error(PropertyUtil.getProperty("ds.ui.database.from.err.decode") + e.toString()); 168 | e.printStackTrace(); 169 | } 170 | textFieldDatabaseUser.setText(user); 171 | passwordFieldDatabasePassword.setText(password); 172 | 173 | } 174 | 175 | /** 176 | * 为相关组件添加事件监听 177 | */ 178 | private void addListener() { 179 | buttonSave.addActionListener(e -> { 180 | 181 | try { 182 | ConstantsTools.CONFIGER.setHostFrom(textFieldDatabaseHost.getText()); 183 | ConstantsTools.CONFIGER.setNameFrom(textFieldDatabaseName.getText()); 184 | 185 | String password = ""; 186 | String user = ""; 187 | try { 188 | DESPlus des = new DESPlus(); 189 | user = des.encrypt(textFieldDatabaseUser.getText()); 190 | password = des.encrypt(new String(passwordFieldDatabasePassword.getPassword())); 191 | } catch (Exception e1) { 192 | logger.error(PropertyUtil.getProperty("ds.ui.database.from.err.encode") + e1.toString()); 193 | e1.printStackTrace(); 194 | } 195 | ConstantsTools.CONFIGER.setUserFrom(user); 196 | ConstantsTools.CONFIGER.setPasswordFrom(password); 197 | 198 | JOptionPane.showMessageDialog(App.databasePanel, PropertyUtil.getProperty("ds.ui.save.success"), PropertyUtil.getProperty("ds.ui.tips"), 199 | JOptionPane.PLAIN_MESSAGE); 200 | 201 | } catch (Exception e1) { 202 | JOptionPane.showMessageDialog(App.databasePanel, PropertyUtil.getProperty("ds.ui.save.fail") + e1.getMessage(), PropertyUtil.getProperty("ds.ui.tips"), 203 | JOptionPane.ERROR_MESSAGE); 204 | logger.error("Write to xml file error" + e1.toString()); 205 | } 206 | 207 | }); 208 | 209 | buttonTestLink.addActionListener(e -> { 210 | 211 | try { 212 | DbUtilSQLServer dbSQLServer = DbUtilSQLServer.getInstance(); 213 | String dburl = textFieldDatabaseHost.getText(); 214 | String dbname = textFieldDatabaseName.getText(); 215 | String dbuser = textFieldDatabaseUser.getText(); 216 | String dbpassword = new String(passwordFieldDatabasePassword.getPassword()); 217 | Connection conn = dbSQLServer.testConnection(dburl, dbname, dbuser, dbpassword); 218 | if (conn == null) { 219 | JOptionPane.showMessageDialog(App.databasePanel, PropertyUtil.getProperty("ds.ui.database.err.link.fail"), PropertyUtil.getProperty("ds.ui.tips"), 220 | JOptionPane.ERROR_MESSAGE); 221 | } else { 222 | JOptionPane.showMessageDialog(App.databasePanel, PropertyUtil.getProperty("ds.ui.database.err.link.success"), PropertyUtil.getProperty("ds.ui.tips"), 223 | JOptionPane.PLAIN_MESSAGE); 224 | } 225 | 226 | } catch (Exception e1) { 227 | JOptionPane.showMessageDialog(App.databasePanel, PropertyUtil.getProperty("ds.ui.database.err.link.fail") + "\n" + e1.getMessage(), PropertyUtil.getProperty("ds.ui.tips"), 228 | JOptionPane.ERROR_MESSAGE); 229 | } 230 | 231 | }); 232 | } 233 | 234 | } -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/ui/panel/DatabasePanelTo.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.ui.panel; 2 | 3 | import com.luoboduner.wesync.App; 4 | import com.luoboduner.wesync.ui.UiConsts; 5 | import com.luoboduner.wesync.ui.component.MyIconButton; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import com.luoboduner.wesync.tools.ConstantsTools; 9 | import com.luoboduner.wesync.tools.DESPlus; 10 | import com.luoboduner.wesync.tools.DbUtilMySQL; 11 | import com.luoboduner.wesync.tools.PropertyUtil; 12 | 13 | import javax.swing.*; 14 | import java.awt.*; 15 | import java.sql.Connection; 16 | 17 | /** 18 | * 目标数据库面板 19 | * 20 | * @author Bob 21 | */ 22 | public class DatabasePanelTo extends JPanel { 23 | 24 | private static final long serialVersionUID = 1L; 25 | 26 | private static MyIconButton buttonTestLink; 27 | private static MyIconButton buttonSave; 28 | private static JTextField textFieldDatabaseHost; 29 | private static JTextField textFieldDatabaseName; 30 | private static JTextField textFieldDatabaseUser; 31 | private static JPasswordField passwordFieldDatabasePassword; 32 | 33 | private static final Logger logger = LoggerFactory.getLogger(DatabasePanelTo.class); 34 | 35 | /** 36 | * 构造 37 | */ 38 | public DatabasePanelTo() { 39 | initialize(); 40 | addComponent(); 41 | setContent(); 42 | addListener(); 43 | } 44 | 45 | /** 46 | * 初始化 47 | */ 48 | private void initialize() { 49 | this.setBackground(UiConsts.MAIN_BACK_COLOR); 50 | this.setLayout(new BorderLayout()); 51 | } 52 | 53 | /** 54 | * 添加组件 55 | */ 56 | private void addComponent() { 57 | 58 | this.add(getCenterPanel(), BorderLayout.CENTER); 59 | this.add(getDownPanel(), BorderLayout.SOUTH); 60 | 61 | } 62 | 63 | /** 64 | * 中部面板 65 | * 66 | * @return 67 | */ 68 | private JPanel getCenterPanel() { 69 | // 中间面板 70 | JPanel panelCenter = new JPanel(); 71 | panelCenter.setBackground(UiConsts.MAIN_BACK_COLOR); 72 | panelCenter.setLayout(new GridLayout(2, 1)); 73 | 74 | // 设置Grid 75 | JPanel panelGridSetting = new JPanel(); 76 | panelGridSetting.setBackground(UiConsts.MAIN_BACK_COLOR); 77 | panelGridSetting.setLayout(new FlowLayout(FlowLayout.LEFT, UiConsts.MAIN_H_GAP, 0)); 78 | 79 | // 初始化组件 80 | JLabel labelDatabaseType = new JLabel(PropertyUtil.getProperty("ds.ui.database.type")); 81 | JLabel labelDatabaseHost = new JLabel(PropertyUtil.getProperty("ds.ui.database.host")); 82 | JLabel labelDatabaseName = new JLabel(PropertyUtil.getProperty("ds.ui.database.name")); 83 | JLabel labelDatabaseUser = new JLabel(PropertyUtil.getProperty("ds.ui.database.user")); 84 | JLabel labelDatabasePassword = new JLabel(PropertyUtil.getProperty("ds.ui.database.password")); 85 | JComboBox comboxDatabaseType = new JComboBox(); 86 | comboxDatabaseType.addItem("MySQL"); 87 | comboxDatabaseType.setEditable(false); 88 | textFieldDatabaseHost = new JTextField(); 89 | textFieldDatabaseName = new JTextField(); 90 | textFieldDatabaseUser = new JTextField(); 91 | passwordFieldDatabasePassword = new JPasswordField(); 92 | 93 | // 字体 94 | labelDatabaseType.setFont(UiConsts.FONT_NORMAL); 95 | labelDatabaseHost.setFont(UiConsts.FONT_NORMAL); 96 | labelDatabaseName.setFont(UiConsts.FONT_NORMAL); 97 | labelDatabaseUser.setFont(UiConsts.FONT_NORMAL); 98 | labelDatabasePassword.setFont(UiConsts.FONT_NORMAL); 99 | comboxDatabaseType.setFont(UiConsts.FONT_NORMAL); 100 | textFieldDatabaseHost.setFont(UiConsts.FONT_NORMAL); 101 | textFieldDatabaseName.setFont(UiConsts.FONT_NORMAL); 102 | textFieldDatabaseUser.setFont(UiConsts.FONT_NORMAL); 103 | passwordFieldDatabasePassword.setFont(UiConsts.FONT_NORMAL); 104 | 105 | // 大小 106 | labelDatabaseType.setPreferredSize(UiConsts.LABLE_SIZE_ITEM); 107 | labelDatabaseHost.setPreferredSize(UiConsts.LABLE_SIZE_ITEM); 108 | labelDatabaseName.setPreferredSize(UiConsts.LABLE_SIZE_ITEM); 109 | labelDatabaseUser.setPreferredSize(UiConsts.LABLE_SIZE_ITEM); 110 | labelDatabasePassword.setPreferredSize(UiConsts.LABLE_SIZE_ITEM); 111 | comboxDatabaseType.setPreferredSize(UiConsts.TEXT_FIELD_SIZE_ITEM); 112 | textFieldDatabaseHost.setPreferredSize(UiConsts.TEXT_FIELD_SIZE_ITEM); 113 | textFieldDatabaseName.setPreferredSize(UiConsts.TEXT_FIELD_SIZE_ITEM); 114 | textFieldDatabaseUser.setPreferredSize(UiConsts.TEXT_FIELD_SIZE_ITEM); 115 | passwordFieldDatabasePassword.setPreferredSize(UiConsts.TEXT_FIELD_SIZE_ITEM); 116 | 117 | // 组合元素 118 | panelGridSetting.add(labelDatabaseType); 119 | panelGridSetting.add(comboxDatabaseType); 120 | panelGridSetting.add(labelDatabaseHost); 121 | panelGridSetting.add(textFieldDatabaseHost); 122 | panelGridSetting.add(labelDatabaseName); 123 | panelGridSetting.add(textFieldDatabaseName); 124 | panelGridSetting.add(labelDatabaseUser); 125 | panelGridSetting.add(textFieldDatabaseUser); 126 | panelGridSetting.add(labelDatabasePassword); 127 | panelGridSetting.add(passwordFieldDatabasePassword); 128 | 129 | panelCenter.add(panelGridSetting); 130 | return panelCenter; 131 | } 132 | 133 | /** 134 | * 底部面板 135 | * 136 | * @return 137 | */ 138 | private JPanel getDownPanel() { 139 | JPanel panelDown = new JPanel(); 140 | panelDown.setBackground(UiConsts.MAIN_BACK_COLOR); 141 | panelDown.setLayout(new FlowLayout(FlowLayout.RIGHT, UiConsts.MAIN_H_GAP, 15)); 142 | 143 | buttonTestLink = new MyIconButton(UiConsts.ICON_TEST_LINK, UiConsts.ICON_TEST_LINK_ENABLE, 144 | UiConsts.ICON_TEST_LINK_DISABLE, ""); 145 | buttonSave = new MyIconButton(UiConsts.ICON_SAVE, UiConsts.ICON_SAVE_ENABLE, 146 | UiConsts.ICON_SAVE_DISABLE, ""); 147 | panelDown.add(buttonTestLink); 148 | panelDown.add(buttonSave); 149 | 150 | return panelDown; 151 | } 152 | 153 | /** 154 | * 设置文本区内容 155 | */ 156 | public static void setContent() { 157 | textFieldDatabaseHost.setText(ConstantsTools.CONFIGER.getHostTo()); 158 | textFieldDatabaseName.setText(ConstantsTools.CONFIGER.getNameTo()); 159 | 160 | String user = ""; 161 | String password = ""; 162 | try { 163 | DESPlus des = new DESPlus(); 164 | user = des.decrypt(ConstantsTools.CONFIGER.getUserTo()); 165 | password = des.decrypt(ConstantsTools.CONFIGER.getPasswordTo()); 166 | } catch (Exception e) { 167 | logger.error(PropertyUtil.getProperty("ds.ui.database.to.err.decode") + e.toString()); 168 | e.printStackTrace(); 169 | } 170 | textFieldDatabaseUser.setText(user); 171 | passwordFieldDatabasePassword.setText(password); 172 | 173 | } 174 | 175 | /** 176 | * 为相关组件添加事件监听 177 | */ 178 | private void addListener() { 179 | buttonSave.addActionListener(e -> { 180 | 181 | try { 182 | ConstantsTools.CONFIGER.setHostTo(textFieldDatabaseHost.getText()); 183 | ConstantsTools.CONFIGER.setNameTo(textFieldDatabaseName.getText()); 184 | 185 | String password = ""; 186 | String user = ""; 187 | try { 188 | DESPlus des = new DESPlus(); 189 | user = des.encrypt(textFieldDatabaseUser.getText()); 190 | password = des.encrypt(new String(passwordFieldDatabasePassword.getPassword())); 191 | } catch (Exception e1) { 192 | logger.error(PropertyUtil.getProperty("ds.ui.database.to.err.encode") + e1.toString()); 193 | e1.printStackTrace(); 194 | } 195 | ConstantsTools.CONFIGER.setUserTo(user); 196 | ConstantsTools.CONFIGER.setPasswordTo(password); 197 | 198 | JOptionPane.showMessageDialog(App.databasePanel, PropertyUtil.getProperty("ds.ui.save.success"), PropertyUtil.getProperty("ds.ui.tips"), 199 | JOptionPane.PLAIN_MESSAGE); 200 | } catch (Exception e1) { 201 | JOptionPane.showMessageDialog(App.databasePanel, PropertyUtil.getProperty("ds.ui.save.fail") + e1.getMessage(), PropertyUtil.getProperty("ds.ui.tips"), 202 | JOptionPane.ERROR_MESSAGE); 203 | logger.error("Write to xml file error" + e1.toString()); 204 | } 205 | 206 | }); 207 | 208 | buttonTestLink.addActionListener(e -> { 209 | 210 | try { 211 | DbUtilMySQL dbMySQL = DbUtilMySQL.getInstance(); 212 | String dburl = textFieldDatabaseHost.getText(); 213 | String dbname = textFieldDatabaseName.getText(); 214 | String dbuser = textFieldDatabaseUser.getText(); 215 | String dbpassword = new String(passwordFieldDatabasePassword.getPassword()); 216 | Connection conn = dbMySQL.testConnection(dburl, dbname, dbuser, dbpassword); 217 | if (conn == null) { 218 | JOptionPane.showMessageDialog(App.databasePanel, PropertyUtil.getProperty("ds.ui.database.err.link.fail"), PropertyUtil.getProperty("ds.ui.tips"), 219 | JOptionPane.ERROR_MESSAGE); 220 | } else { 221 | JOptionPane.showMessageDialog(App.databasePanel, PropertyUtil.getProperty("ds.ui.database.err.link.success"), PropertyUtil.getProperty("ds.ui.tips"), 222 | JOptionPane.PLAIN_MESSAGE); 223 | } 224 | 225 | } catch (Exception e1) { 226 | JOptionPane.showMessageDialog(App.databasePanel, PropertyUtil.getProperty("ds.ui.database.err.link.fail") + e1.getMessage(), PropertyUtil.getProperty("ds.ui.tips"), 227 | JOptionPane.ERROR_MESSAGE); 228 | } 229 | 230 | }); 231 | 232 | } 233 | } 234 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/ui/panel/SettingPanel.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.ui.panel; 2 | 3 | import com.luoboduner.wesync.App; 4 | import com.luoboduner.wesync.ui.UiConsts; 5 | import com.luoboduner.wesync.tools.PropertyUtil; 6 | 7 | import javax.swing.*; 8 | import java.awt.*; 9 | import java.awt.event.MouseEvent; 10 | import java.awt.event.MouseListener; 11 | 12 | /** 13 | * 设置面板 14 | * 15 | * @author Bob 16 | */ 17 | public class SettingPanel extends JPanel { 18 | 19 | private static final long serialVersionUID = 1L; 20 | 21 | private static JPanel panelOption; 22 | private static JPanel panelAbout; 23 | public static JPanel settingPanelMain; 24 | private static JPanel settingPanelOption; 25 | private static JPanel settingPanelAbout; 26 | 27 | /** 28 | * 构造 29 | */ 30 | public SettingPanel() { 31 | initialize(); 32 | addComponent(); 33 | addListener(); 34 | } 35 | 36 | /** 37 | * 初始化 38 | */ 39 | private void initialize() { 40 | this.setBackground(UiConsts.MAIN_BACK_COLOR); 41 | this.setLayout(new BorderLayout()); 42 | settingPanelOption = new SettingPanelOption(); 43 | settingPanelAbout = new SettingPanelAbout(); 44 | } 45 | 46 | /** 47 | * 添加组件 48 | */ 49 | private void addComponent() { 50 | 51 | this.add(getUpPanel(), BorderLayout.NORTH); 52 | this.add(getCenterPanel(), BorderLayout.CENTER); 53 | 54 | } 55 | 56 | /** 57 | * 上部面板 58 | * 59 | * @return 60 | */ 61 | private JPanel getUpPanel() { 62 | JPanel panelUp = new JPanel(); 63 | panelUp.setBackground(UiConsts.MAIN_BACK_COLOR); 64 | panelUp.setLayout(new FlowLayout(FlowLayout.LEFT, UiConsts.MAIN_H_GAP, 5)); 65 | 66 | JLabel labelTitle = new JLabel(PropertyUtil.getProperty("ds.ui.setting.title")); 67 | labelTitle.setFont(UiConsts.FONT_TITLE); 68 | labelTitle.setForeground(UiConsts.TOOL_BAR_BACK_COLOR); 69 | panelUp.add(labelTitle); 70 | 71 | return panelUp; 72 | } 73 | 74 | /** 75 | * 中部面板 76 | * 77 | * @return 78 | */ 79 | private JPanel getCenterPanel() { 80 | // 中间面板 81 | JPanel panelCenter = new JPanel(); 82 | panelCenter.setBackground(UiConsts.MAIN_BACK_COLOR); 83 | panelCenter.setLayout(new BorderLayout()); 84 | 85 | // 列表Panel 86 | JPanel panelList = new JPanel(); 87 | Dimension preferredSize = new Dimension(245, UiConsts.MAIN_WINDOW_HEIGHT); 88 | panelList.setPreferredSize(preferredSize); 89 | panelList.setBackground(new Color(62, 62, 62)); 90 | panelList.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); 91 | 92 | panelOption = new JPanel(); 93 | panelOption.setBackground(new Color(69, 186, 121)); 94 | panelOption.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 13)); 95 | Dimension preferredSizeListItem = new Dimension(245, 48); 96 | panelOption.setPreferredSize(preferredSizeListItem); 97 | panelAbout = new JPanel(); 98 | panelAbout.setBackground(UiConsts.TOOL_BAR_BACK_COLOR); 99 | panelAbout.setLayout(new FlowLayout(FlowLayout.LEFT, 30, 13)); 100 | panelAbout.setPreferredSize(preferredSizeListItem); 101 | 102 | JLabel labelOption = new JLabel(PropertyUtil.getProperty("ds.ui.setting.option")); 103 | JLabel labelAbout = new JLabel(PropertyUtil.getProperty("ds.ui.setting.about")); 104 | Font fontListItem = new Font(PropertyUtil.getProperty("ds.ui.font.family"), 0, 15); 105 | labelOption.setFont(fontListItem); 106 | labelAbout.setFont(fontListItem); 107 | labelOption.setForeground(Color.white); 108 | labelAbout.setForeground(Color.white); 109 | panelOption.add(labelOption); 110 | panelAbout.add(labelAbout); 111 | 112 | panelList.add(panelOption); 113 | panelList.add(panelAbout); 114 | 115 | // 设置Panel 116 | settingPanelMain = new JPanel(); 117 | settingPanelMain.setBackground(UiConsts.MAIN_BACK_COLOR); 118 | settingPanelMain.setLayout(new BorderLayout()); 119 | settingPanelMain.add(settingPanelOption); 120 | 121 | panelCenter.add(panelList, BorderLayout.WEST); 122 | panelCenter.add(settingPanelMain, BorderLayout.CENTER); 123 | 124 | return panelCenter; 125 | } 126 | 127 | /** 128 | * 为相关组件添加事件监听 129 | */ 130 | private void addListener() { 131 | panelOption.addMouseListener(new MouseListener() { 132 | 133 | @Override 134 | public void mouseReleased(MouseEvent e) { 135 | // TODO Auto-generated method stub 136 | 137 | } 138 | 139 | @Override 140 | public void mousePressed(MouseEvent e) { 141 | // TODO Auto-generated method stub 142 | 143 | } 144 | 145 | @Override 146 | public void mouseExited(MouseEvent e) { 147 | // TODO Auto-generated method stub 148 | 149 | } 150 | 151 | @Override 152 | public void mouseEntered(MouseEvent e) { 153 | 154 | } 155 | 156 | @Override 157 | public void mouseClicked(MouseEvent e) { 158 | panelOption.setBackground(new Color(69, 186, 121)); 159 | panelAbout.setBackground(UiConsts.TOOL_BAR_BACK_COLOR); 160 | 161 | SettingPanel.settingPanelMain.removeAll(); 162 | SettingPanelOption.setCurrentOption(); 163 | SettingPanel.settingPanelMain.add(settingPanelOption); 164 | App.settingPanel.updateUI(); 165 | 166 | } 167 | }); 168 | 169 | panelAbout.addMouseListener(new MouseListener() { 170 | 171 | @Override 172 | public void mouseReleased(MouseEvent e) { 173 | // TODO Auto-generated method stub 174 | 175 | } 176 | 177 | @Override 178 | public void mousePressed(MouseEvent e) { 179 | // TODO Auto-generated method stub 180 | 181 | } 182 | 183 | @Override 184 | public void mouseExited(MouseEvent e) { 185 | // TODO Auto-generated method stub 186 | 187 | } 188 | 189 | @Override 190 | public void mouseEntered(MouseEvent e) { 191 | 192 | } 193 | 194 | @Override 195 | public void mouseClicked(MouseEvent e) { 196 | panelAbout.setBackground(new Color(69, 186, 121)); 197 | panelOption.setBackground(UiConsts.TOOL_BAR_BACK_COLOR); 198 | 199 | SettingPanel.settingPanelMain.removeAll(); 200 | SettingPanel.settingPanelMain.add(settingPanelAbout); 201 | App.settingPanel.updateUI(); 202 | 203 | } 204 | }); 205 | 206 | } 207 | } -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/ui/panel/SettingPanelAbout.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.ui.panel; 2 | 3 | import com.luoboduner.wesync.ui.UiConsts; 4 | import com.luoboduner.wesync.ui.component.MyIconButton; 5 | import com.luoboduner.wesync.tools.PropertyUtil; 6 | 7 | import javax.swing.*; 8 | import java.awt.*; 9 | 10 | /** 11 | * 关于面板 12 | * 13 | * @author Bob 14 | */ 15 | public class SettingPanelAbout extends JPanel { 16 | 17 | private static final long serialVersionUID = 1L; 18 | 19 | /** 20 | * 构造 21 | */ 22 | public SettingPanelAbout() { 23 | initialize(); 24 | addComponent(); 25 | } 26 | 27 | /** 28 | * 初始化 29 | */ 30 | private void initialize() { 31 | this.setBackground(UiConsts.MAIN_BACK_COLOR); 32 | this.setLayout(new BorderLayout()); 33 | } 34 | 35 | /** 36 | * 添加组件 37 | */ 38 | private void addComponent() { 39 | 40 | this.add(getCenterPanel(), BorderLayout.CENTER); 41 | this.add(getDownPanel(), BorderLayout.SOUTH); 42 | 43 | } 44 | 45 | /** 46 | * 中部面板 47 | * 48 | * @return 49 | */ 50 | private JPanel getCenterPanel() { 51 | // 中间面板 52 | JPanel panelCenter = new JPanel(); 53 | panelCenter.setBackground(UiConsts.MAIN_BACK_COLOR); 54 | panelCenter.setLayout(new GridLayout(3, 1)); 55 | 56 | // 图标、版本Grid 57 | JPanel panelGridIcon = new JPanel(); 58 | panelGridIcon.setBackground(UiConsts.MAIN_BACK_COLOR); 59 | panelGridIcon.setLayout(new FlowLayout(FlowLayout.LEFT, UiConsts.MAIN_H_GAP, 0)); 60 | 61 | // 初始化组件 62 | MyIconButton icon = new MyIconButton(UiConsts.ICON_DATA_SYNC, UiConsts.ICON_DATA_SYNC, 63 | UiConsts.ICON_DATA_SYNC, ""); 64 | JLabel labelName = new JLabel(UiConsts.APP_NAME); 65 | JLabel labelVersion = new JLabel(UiConsts.APP_VERSION); 66 | 67 | // 字体 68 | labelName.setFont(UiConsts.FONT_NORMAL); 69 | labelVersion.setFont(UiConsts.FONT_NORMAL); 70 | 71 | // 大小 72 | Dimension size = new Dimension(200, 30); 73 | labelName.setPreferredSize(size); 74 | labelVersion.setPreferredSize(size); 75 | 76 | // 组合元素 77 | panelGridIcon.add(icon); 78 | panelGridIcon.add(labelName); 79 | panelGridIcon.add(labelVersion); 80 | 81 | // 建议帮助 Grid 82 | JPanel panelGridHelp = new JPanel(); 83 | panelGridHelp.setBackground(UiConsts.MAIN_BACK_COLOR); 84 | panelGridHelp.setLayout(new FlowLayout(FlowLayout.LEFT, UiConsts.MAIN_H_GAP, 0)); 85 | 86 | // 初始化组件 87 | JLabel labelAdvice = new JLabel(PropertyUtil.getProperty("ds.ui.app.advice")); 88 | JLabel labelHelp = new JLabel(PropertyUtil.getProperty("ds.ui.app.help")); 89 | 90 | // 字体 91 | labelAdvice.setFont(UiConsts.FONT_NORMAL); 92 | labelHelp.setFont(UiConsts.FONT_NORMAL); 93 | 94 | // 大小 95 | labelAdvice.setPreferredSize(UiConsts.LABLE_SIZE); 96 | labelHelp.setPreferredSize(UiConsts.LABLE_SIZE); 97 | 98 | // 组合元素 99 | panelGridHelp.add(labelAdvice); 100 | panelGridHelp.add(labelHelp); 101 | 102 | panelCenter.add(panelGridIcon); 103 | // panelCenter.add(panelGridHelp); 104 | return panelCenter; 105 | } 106 | 107 | /** 108 | * 底部面板 109 | * 110 | * @return 111 | */ 112 | private JPanel getDownPanel() { 113 | JPanel panelDown = new JPanel(); 114 | panelDown.setBackground(UiConsts.MAIN_BACK_COLOR); 115 | panelDown.setLayout(new FlowLayout(FlowLayout.LEFT, UiConsts.MAIN_H_GAP, 15)); 116 | 117 | JLabel labelInfo = new JLabel(PropertyUtil.getProperty("ds.ui.app.info")); 118 | labelInfo.setFont(UiConsts.FONT_NORMAL); 119 | labelInfo.setForeground(Color.gray); 120 | 121 | panelDown.add(labelInfo); 122 | 123 | return panelDown; 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /src/main/java/com/luoboduner/wesync/ui/panel/ToolBarPanel.java: -------------------------------------------------------------------------------- 1 | package com.luoboduner.wesync.ui.panel; 2 | 3 | import com.luoboduner.wesync.App; 4 | import com.luoboduner.wesync.ui.UiConsts; 5 | import com.luoboduner.wesync.ui.component.MyIconButton; 6 | import com.luoboduner.wesync.tools.PropertyUtil; 7 | 8 | import javax.swing.*; 9 | import java.awt.*; 10 | 11 | /** 12 | * 工具栏面板 13 | * 14 | * @author Bob 15 | */ 16 | public class ToolBarPanel extends JPanel { 17 | 18 | private static final long serialVersionUID = 1L; 19 | 20 | private static MyIconButton buttonStatus; 21 | private static MyIconButton buttonDatabase; 22 | private static MyIconButton buttonSchedule; 23 | private static MyIconButton buttonBackup; 24 | private static MyIconButton buttonSetting; 25 | 26 | /** 27 | * 构造 28 | */ 29 | public ToolBarPanel() { 30 | initialize(); 31 | addButtion(); 32 | addListener(); 33 | } 34 | 35 | /** 36 | * 初始化 37 | */ 38 | private void initialize() { 39 | Dimension preferredSize = new Dimension(48, UiConsts.MAIN_WINDOW_HEIGHT); 40 | this.setPreferredSize(preferredSize); 41 | this.setMaximumSize(preferredSize); 42 | this.setMinimumSize(preferredSize); 43 | this.setBackground(UiConsts.TOOL_BAR_BACK_COLOR); 44 | this.setLayout(new GridLayout(2, 1)); 45 | } 46 | 47 | /** 48 | * 添加工具按钮 49 | */ 50 | private void addButtion() { 51 | 52 | JPanel panelUp = new JPanel(); 53 | panelUp.setBackground(UiConsts.TOOL_BAR_BACK_COLOR); 54 | panelUp.setLayout(new FlowLayout(-2, -2, -4)); 55 | JPanel panelDown = new JPanel(); 56 | panelDown.setBackground(UiConsts.TOOL_BAR_BACK_COLOR); 57 | panelDown.setLayout(new BorderLayout(0, 0)); 58 | 59 | buttonStatus = new MyIconButton(UiConsts.ICON_STATUS_ENABLE, UiConsts.ICON_STATUS_ENABLE, 60 | UiConsts.ICON_STATUS, PropertyUtil.getProperty("ds.ui.status.title")); 61 | buttonDatabase = new MyIconButton(UiConsts.ICON_DATABASE, UiConsts.ICON_DATABASE_ENABLE, 62 | UiConsts.ICON_DATABASE, PropertyUtil.getProperty("ds.ui.database.title")); 63 | buttonSchedule = new MyIconButton(UiConsts.ICON_SCHEDULE, UiConsts.ICON_SCHEDULE_ENABLE, 64 | UiConsts.ICON_SCHEDULE, PropertyUtil.getProperty("ds.ui.schedule.title")); 65 | buttonBackup = new MyIconButton(UiConsts.ICON_BACKUP, UiConsts.ICON_BACKUP_ENABLE, 66 | UiConsts.ICON_BACKUP, PropertyUtil.getProperty("ds.ui.backup.title")); 67 | buttonSetting = new MyIconButton(UiConsts.ICON_SETTING, UiConsts.ICON_SETTING_ENABLE, 68 | UiConsts.ICON_SETTING, PropertyUtil.getProperty("ds.ui.setting.title")); 69 | 70 | panelUp.add(buttonStatus); 71 | panelUp.add(buttonDatabase); 72 | panelUp.add(buttonSchedule); 73 | panelUp.add(buttonBackup); 74 | 75 | panelDown.add(buttonSetting, BorderLayout.SOUTH); 76 | this.add(panelUp); 77 | this.add(panelDown); 78 | 79 | } 80 | 81 | /** 82 | * 为各按钮添加事件动作监听 83 | */ 84 | private void addListener() { 85 | buttonStatus.addActionListener(e -> { 86 | 87 | buttonStatus.setIcon(UiConsts.ICON_STATUS_ENABLE); 88 | buttonDatabase.setIcon(UiConsts.ICON_DATABASE); 89 | buttonSchedule.setIcon(UiConsts.ICON_SCHEDULE); 90 | buttonBackup.setIcon(UiConsts.ICON_BACKUP); 91 | buttonSetting.setIcon(UiConsts.ICON_SETTING); 92 | 93 | App.mainPanelCenter.removeAll(); 94 | StatusPanel.setContent(); 95 | App.mainPanelCenter.add(App.statusPanel, BorderLayout.CENTER); 96 | 97 | App.mainPanelCenter.updateUI(); 98 | 99 | }); 100 | 101 | buttonDatabase.addActionListener(e -> { 102 | 103 | buttonStatus.setIcon(UiConsts.ICON_STATUS); 104 | buttonDatabase.setIcon(UiConsts.ICON_DATABASE_ENABLE); 105 | buttonSchedule.setIcon(UiConsts.ICON_SCHEDULE); 106 | buttonBackup.setIcon(UiConsts.ICON_BACKUP); 107 | buttonSetting.setIcon(UiConsts.ICON_SETTING); 108 | 109 | App.mainPanelCenter.removeAll(); 110 | DatabasePanelFrom.setContent(); 111 | DatabasePanelTo.setContent(); 112 | App.mainPanelCenter.add(App.databasePanel, BorderLayout.CENTER); 113 | 114 | App.mainPanelCenter.updateUI(); 115 | 116 | }); 117 | 118 | buttonSchedule.addActionListener(e -> { 119 | 120 | buttonStatus.setIcon(UiConsts.ICON_STATUS); 121 | buttonDatabase.setIcon(UiConsts.ICON_DATABASE); 122 | buttonSchedule.setIcon(UiConsts.ICON_SCHEDULE_ENABLE); 123 | buttonBackup.setIcon(UiConsts.ICON_BACKUP); 124 | buttonSetting.setIcon(UiConsts.ICON_SETTING); 125 | 126 | App.mainPanelCenter.removeAll(); 127 | App.schedulePanel.setCurrentSchedule(); 128 | App.mainPanelCenter.add(App.schedulePanel, BorderLayout.CENTER); 129 | 130 | App.mainPanelCenter.updateUI(); 131 | 132 | }); 133 | 134 | buttonBackup.addActionListener(e -> { 135 | 136 | buttonStatus.setIcon(UiConsts.ICON_STATUS); 137 | buttonDatabase.setIcon(UiConsts.ICON_DATABASE); 138 | buttonSchedule.setIcon(UiConsts.ICON_SCHEDULE); 139 | buttonBackup.setIcon(UiConsts.ICON_BACKUP_ENABLE); 140 | buttonSetting.setIcon(UiConsts.ICON_SETTING); 141 | 142 | BackupPanel.initTableData(); 143 | BackupPanel.tableFrom.validate(); 144 | 145 | App.mainPanelCenter.removeAll(); 146 | App.mainPanelCenter.add(App.backupPanel, BorderLayout.CENTER); 147 | 148 | App.mainPanelCenter.updateUI(); 149 | 150 | }); 151 | 152 | buttonSetting.addActionListener(e -> { 153 | 154 | buttonStatus.setIcon(UiConsts.ICON_STATUS); 155 | buttonDatabase.setIcon(UiConsts.ICON_DATABASE); 156 | buttonSchedule.setIcon(UiConsts.ICON_SCHEDULE); 157 | buttonBackup.setIcon(UiConsts.ICON_BACKUP); 158 | buttonSetting.setIcon(UiConsts.ICON_SETTING_ENABLE); 159 | 160 | App.mainPanelCenter.removeAll(); 161 | SettingPanelOption.setCurrentOption(); 162 | App.mainPanelCenter.add(App.settingPanel, BorderLayout.CENTER); 163 | 164 | App.mainPanelCenter.updateUI(); 165 | 166 | }); 167 | } 168 | } 169 | -------------------------------------------------------------------------------- /src/main/resources/icon/WeSync.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/WeSync.ico -------------------------------------------------------------------------------- /src/main/resources/icon/WeSync.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/WeSync.png -------------------------------------------------------------------------------- /src/main/resources/icon/WeSync.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/WeSync.psd -------------------------------------------------------------------------------- /src/main/resources/icon/WeSyncInstaller.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/WeSyncInstaller.ico -------------------------------------------------------------------------------- /src/main/resources/icon/about.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/about.png -------------------------------------------------------------------------------- /src/main/resources/icon/backup.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/backup.png -------------------------------------------------------------------------------- /src/main/resources/icon/backupEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/backupEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/clearAllBaks.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/clearAllBaks.png -------------------------------------------------------------------------------- /src/main/resources/icon/clearAllBaksDisable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/clearAllBaksDisable.png -------------------------------------------------------------------------------- /src/main/resources/icon/clearAllBaksEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/clearAllBaksEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/clearLog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/clearLog.png -------------------------------------------------------------------------------- /src/main/resources/icon/clearLogDisable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/clearLogDisable.png -------------------------------------------------------------------------------- /src/main/resources/icon/clearLogEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/clearLogEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/database.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/database.png -------------------------------------------------------------------------------- /src/main/resources/icon/databaseEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/databaseEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/deleteBak.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/deleteBak.png -------------------------------------------------------------------------------- /src/main/resources/icon/deleteBakDisable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/deleteBakDisable.png -------------------------------------------------------------------------------- /src/main/resources/icon/deleteBakEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/deleteBakEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/newBak.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/newBak.png -------------------------------------------------------------------------------- /src/main/resources/icon/newBakDisable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/newBakDisable.png -------------------------------------------------------------------------------- /src/main/resources/icon/newBakEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/newBakEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/recoverBak.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/recoverBak.png -------------------------------------------------------------------------------- /src/main/resources/icon/recoverBakDisable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/recoverBakDisable.png -------------------------------------------------------------------------------- /src/main/resources/icon/recoverBakEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/recoverBakEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/saveButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/saveButton.png -------------------------------------------------------------------------------- /src/main/resources/icon/saveButtonDisable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/saveButtonDisable.png -------------------------------------------------------------------------------- /src/main/resources/icon/saveButtonEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/saveButtonEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/schedule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/schedule.png -------------------------------------------------------------------------------- /src/main/resources/icon/scheduleEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/scheduleEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/setting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/setting.png -------------------------------------------------------------------------------- /src/main/resources/icon/settingEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/settingEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/start.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/start.png -------------------------------------------------------------------------------- /src/main/resources/icon/startDisable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/startDisable.png -------------------------------------------------------------------------------- /src/main/resources/icon/startEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/startEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/startSchedule.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/startSchedule.png -------------------------------------------------------------------------------- /src/main/resources/icon/startScheduleDisable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/startScheduleDisable.png -------------------------------------------------------------------------------- /src/main/resources/icon/startScheduleEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/startScheduleEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/status.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/status.png -------------------------------------------------------------------------------- /src/main/resources/icon/statusEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/statusEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/stop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/stop.png -------------------------------------------------------------------------------- /src/main/resources/icon/stopDisable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/stopDisable.png -------------------------------------------------------------------------------- /src/main/resources/icon/stopEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/stopEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/syncNow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/syncNow.png -------------------------------------------------------------------------------- /src/main/resources/icon/syncNowDisable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/syncNowDisable.png -------------------------------------------------------------------------------- /src/main/resources/icon/syncNowEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/syncNowEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/tableFiled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/tableFiled.png -------------------------------------------------------------------------------- /src/main/resources/icon/tableFiledDisable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/tableFiledDisable.png -------------------------------------------------------------------------------- /src/main/resources/icon/tableFiledEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/tableFiledEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/testLinkButton.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/testLinkButton.png -------------------------------------------------------------------------------- /src/main/resources/icon/testLinkButtonDisable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/testLinkButtonDisable.png -------------------------------------------------------------------------------- /src/main/resources/icon/testLinkButtonEnable.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/testLinkButtonEnable.png -------------------------------------------------------------------------------- /src/main/resources/icon/textButton.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/textButton.psd -------------------------------------------------------------------------------- /src/main/resources/icon/textButton206_30.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/textButton206_30.psd -------------------------------------------------------------------------------- /src/main/resources/icon/textButton82_30.psd: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rememberber/WeSync/622ae9523fc9a194e044b8dd776bfd336a6a8366/src/main/resources/icon/textButton82_30.psd -------------------------------------------------------------------------------- /src/main/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 6 | 7 | 8 | 9 | 10 | 11 | ./logs/WeSync.%d{yyyy-MM-dd}.log 12 | 13 | 14 | %date{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | --------------------------------------------------------------------------------