From 5eacf5941e61f85ac973b1770362d39653b56522 Mon Sep 17 00:00:00 2001 From: hangum Date: Sat, 17 Feb 2018 12:27:46 +0900 Subject: [PATCH] =?utf8?q?=EC=BF=BC=EB=A6=AC=20=EA=B2=B0=EA=B3=BC=20?= =?utf8?q?=EB=8B=A4=EC=9A=B4=EB=A1=9C=EB=93=9C=20=EA=B8=B0=EB=8A=A5?= =?utf8?q?=EC=97=90=EC=84=9C=20-=20=EC=BF=BC=EB=A6=AC=20=EA=B2=B0=EA=B3=BC?= =?utf8?q?=EA=B0=80=20=EC=97=86=EB=8A=94=20=EA=B2=BD=EC=9A=B0=20=ED=8C=8C?= =?utf8?q?=EC=9D=BC=EC=9D=84=20=EB=A7=8C=EB=93=A4=EC=88=98=20=EC=97=86?= =?utf8?q?=EB=8A=94=20=EA=B2=BD=EC=9A=B0=EC=97=90=20=EB=82=98=EC=98=A4?= =?utf8?q?=EB=8A=94=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../hangum/tadpole/rdb/core/messages.properties | 2 + .../hangum/tadpole/rdb/core/messages_ko.properties | 2 + .../src/com/hangum/tadpole/rdb/core/Messages.java | 3 +- .../export/sqlresult/ResultSetDownloadDialog.java | 78 +++++++++++++--------- .../hangum/tadpole/rdb/core/messages.properties | 2 + .../hangum/tadpole/rdb/core/messages_ko.properties | 2 + 6 files changed, 57 insertions(+), 32 deletions(-) diff --git a/com.hangum.tadpole.rdb.core/bin/com/hangum/tadpole/rdb/core/messages.properties b/com.hangum.tadpole.rdb.core/bin/com/hangum/tadpole/rdb/core/messages.properties index 7af280139..e27465a01 100644 --- a/com.hangum.tadpole.rdb.core/bin/com/hangum/tadpole/rdb/core/messages.properties +++ b/com.hangum.tadpole.rdb.core/bin/com/hangum/tadpole/rdb/core/messages.properties @@ -574,6 +574,8 @@ MySQLTableColumnDialog_3 = Add %s column MySQLTableColumnDialog_31 = An error occurred while adding a column name. +NoResultNoFile = If there is no query result, the file can not be generated. + NotFountObject = %s object not found. NotSupportDatabase = The database is not supported. diff --git a/com.hangum.tadpole.rdb.core/bin/com/hangum/tadpole/rdb/core/messages_ko.properties b/com.hangum.tadpole.rdb.core/bin/com/hangum/tadpole/rdb/core/messages_ko.properties index b6a7b8eb3..0210d95f6 100644 --- a/com.hangum.tadpole.rdb.core/bin/com/hangum/tadpole/rdb/core/messages_ko.properties +++ b/com.hangum.tadpole.rdb.core/bin/com/hangum/tadpole/rdb/core/messages_ko.properties @@ -591,6 +591,8 @@ MySQLTableColumnDialog_3 = %s \uCEEC\uB7FC \uCD94\uAC00 MySQLTableColumnDialog_31 = Column name\uC744 \uCD94\uAC00\uD558\uB294 \uC911\uC5D0 \uC624\uB958\uAC00\uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4.\n +NoResultNoFile = \uCFFC\uB9AC \uACB0\uACFC\uAC00 \uC5C6\uB294 \uACBD\uC6B0\uB294 \uD30C\uC77C\uC744 \uC0DD\uC131 \uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. + NotFountObject = %s \uAC1D\uCCB4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. NotSupportDatabase = \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uB370\uC774\uD130\uBCA0\uC774\uC2A4 \uC785\uB2C8\uB2E4. diff --git a/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/Messages.java b/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/Messages.java index ff33b2daa..48d30b0d6 100644 --- a/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/Messages.java +++ b/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/Messages.java @@ -726,7 +726,8 @@ public class Messages { public String TextResultView; public String TadpoleHistoryHubDataLocation; - + + public String NoResultNoFile; public static Messages get() { diff --git a/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/dialog/export/sqlresult/ResultSetDownloadDialog.java b/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/dialog/export/sqlresult/ResultSetDownloadDialog.java index 9d855845c..780ad56c1 100644 --- a/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/dialog/export/sqlresult/ResultSetDownloadDialog.java +++ b/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/dialog/export/sqlresult/ResultSetDownloadDialog.java @@ -600,41 +600,57 @@ public class ResultSetDownloadDialog extends Dialog { */ protected ExportResultDTO downloadFile(final String fileName, final ExportResultDTO exportDto, final String encoding) throws Exception { final File file = new File(exportDto.getFileFullName()); - String strExt = StringUtils.substringAfterLast(exportDto.getFileFullName(), "."); -// if(logger.isInfoEnabled()) { -// logger.info("#####[start]#####################[resource download]"); -// logger.info("\tfile ext : " + strExt); -// logger.info("\tfile size : " + file.length()); -// logger.info("#####[end]#####################[resource download]"); -// } - final byte[] bytesDatas = FileUtils.readFileToByteArray(file); - - // excel 파일의 경우 바이너리가 저장 되므로... 파일의 위치를 %user_home%/res/파일명 으로 남기도록 합니다. - if(exportDto.getExportMethod() == EXPORT_METHOD.EXCEL) { + if(file.exists()) { + String strExt = StringUtils.substringAfterLast(exportDto.getFileFullName(), "."); + // if(logger.isInfoEnabled()) { + // logger.info("#####[start]#####################[resource download]"); + // logger.info("\tfile ext : " + strExt); + // logger.info("\tfile size : " + file.length()); + // logger.info("#####[end]#####################[resource download]"); + // } + final byte[] bytesDatas = FileUtils.readFileToByteArray(file); - String strNewFile = ApplicationArgumentUtils.USER_RESOURCE_DIR + userSeq + PublicTadpoleDefine.DIR_SEPARATOR + System.currentTimeMillis() + file.getName(); - if(logger.isDebugEnabled()) logger.debug("==> new file location: " + strNewFile); - FileUtils.moveFile(file, new File(strNewFile)); + // excel 파일의 경우 바이너리가 저장 되므로... 파일의 위치를 %user_home%/res/파일명 으로 남기도록 합니다. + if(exportDto.getExportMethod() == EXPORT_METHOD.EXCEL) { + + String strNewFile = ApplicationArgumentUtils.USER_RESOURCE_DIR + userSeq + PublicTadpoleDefine.DIR_SEPARATOR + System.currentTimeMillis() + file.getName(); + if(logger.isDebugEnabled()) logger.debug("==> new file location: " + strNewFile); + FileUtils.moveFile(file, new File(strNewFile)); + + exportDto.setResultData("file location: " + strNewFile); + } else { + exportDto.setResultData(new String(bytesDatas)); + } - exportDto.setResultData("file location: " + strNewFile); + getShell().getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + try { + _downloadExtFile(fileName + "." + strExt, bytesDatas); //$NON-NLS-1$ + + // 사용후 파일을 삭제한다. + FileUtils.deleteDirectory(new File(file.getParent())); + } catch(Exception e) { + logger.error("download file", e); + } + } + }); } else { - exportDto.setResultData(new String(bytesDatas)); - } - - getShell().getDisplay().asyncExec(new Runnable() { - @Override - public void run() { - try { - _downloadExtFile(fileName + "." + strExt, bytesDatas); //$NON-NLS-1$ - - // 사용후 파일을 삭제한다. - FileUtils.deleteDirectory(new File(file.getParent())); - } catch(Exception e) { - logger.error("download file", e); + // 파일 결과가 없는 경우는 SQL문(INSERT, UPDATE 등)을 만드는데 SELECT ROW 결과가 없는 경우이다. + // INSERT INTO AA(A, B, C) VLAUES(?, ?, ?) 를 만들수가 없는 경우... + + getShell().getDisplay().asyncExec(new Runnable() { + @Override + public void run() { + try { + // Invalid thread access 에러 조심 + MessageDialog.openWarning(null, CommonMessages.get().Warning, Messages.get().NoResultNoFile); + } catch(Exception e) { + logger.error("download file", e); + } } - } - }); - + }); + } return exportDto; } diff --git a/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/messages.properties b/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/messages.properties index 7af280139..e27465a01 100644 --- a/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/messages.properties +++ b/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/messages.properties @@ -574,6 +574,8 @@ MySQLTableColumnDialog_3 = Add %s column MySQLTableColumnDialog_31 = An error occurred while adding a column name. +NoResultNoFile = If there is no query result, the file can not be generated. + NotFountObject = %s object not found. NotSupportDatabase = The database is not supported. diff --git a/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/messages_ko.properties b/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/messages_ko.properties index b6a7b8eb3..0210d95f6 100644 --- a/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/messages_ko.properties +++ b/com.hangum.tadpole.rdb.core/src/com/hangum/tadpole/rdb/core/messages_ko.properties @@ -591,6 +591,8 @@ MySQLTableColumnDialog_3 = %s \uCEEC\uB7FC \uCD94\uAC00 MySQLTableColumnDialog_31 = Column name\uC744 \uCD94\uAC00\uD558\uB294 \uC911\uC5D0 \uC624\uB958\uAC00\uBC1C\uC0DD\uD588\uC2B5\uB2C8\uB2E4.\n +NoResultNoFile = \uCFFC\uB9AC \uACB0\uACFC\uAC00 \uC5C6\uB294 \uACBD\uC6B0\uB294 \uD30C\uC77C\uC744 \uC0DD\uC131 \uD560 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. + NotFountObject = %s \uAC1D\uCCB4\uB97C \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4. NotSupportDatabase = \uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uB370\uC774\uD130\uBCA0\uC774\uC2A4 \uC785\uB2C8\uB2E4. -- 2.11.4.GIT