From 604ff5e52a0a7656d78fff8a6d5419f1405a05f6 Mon Sep 17 00:00:00 2001 From: greatim Date: Fri, 25 Apr 2014 15:30:07 +0900 Subject: [PATCH] [Title] db bug fix that close at stop tracing [Desc.] [Issue] Change-Id: I2b5d984b3f3cf55a8d053e2d9c0bf983f295f2d4 --- .../org/tizen/dynamicanalyzer/project/Project.java | 3 +++ .../swap/logparser/MessageParser.java | 10 ++++---- .../dynamicanalyzer/ui/toolbar/SaveAsDialog.java | 29 +++++++++++----------- .../ui/toolbar/StopLogProcessor.java | 1 - 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java index 7f7e95f..9b5fbdb 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/project/Project.java @@ -314,6 +314,9 @@ public class Project { AnalyzerManager.setProject(this); + // close previous database connection + SqlConnectionManager.closeConnection(); + // establish database connection boolean conn_res = SqlConnectionManager .establishConnection(getSavePath() + File.separator diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java index c75faae..1ff71d0 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/swap/logparser/MessageParser.java @@ -76,7 +76,7 @@ import org.tizen.dynamicanalyzer.widgets.da.base.DADialog; public class MessageParser { private static final DALogger DA_LOG = DALogger.getInstance(); - static final boolean PRINT_DATA_LOG_TOFILE = true; + static final boolean PRINT_DATA_LOG_TOFILE = false; static final int MSG_ID_INDEX = 0; static final int MSG_LENGTH_INDEX = 1; @@ -235,12 +235,12 @@ public class MessageParser { if (0 == startSec && 0 == startNano) { // original code (before webapp support) -// startTime.setSec(sec); -// startTime.setNano(nano); + startTime.setSec(sec); + startTime.setNano(nano); // for webapp support - startTime.setSec(ByteUtils.toInt(data, 8)); - startTime.setNano(ByteUtils.toInt(data, 12)); +// startTime.setSec(ByteUtils.toInt(data, 8)); +// startTime.setNano(ByteUtils.toInt(data, 12)); AnalyzerManager.getProject().setProfileStartTime(startTime); } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/SaveAsDialog.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/SaveAsDialog.java index 7a32fa7..a59b441 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/SaveAsDialog.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/SaveAsDialog.java @@ -66,7 +66,7 @@ import org.tizen.dynamicanalyzer.widgets.da.base.DAText; public class SaveAsDialog extends DAMessageBox { private static final DALogger DA_LOG = DALogger.getInstance(); - + private int MAX_SAVE_FILE_NAME_LENGTH = 35; private DAText textBox = null; @@ -106,7 +106,7 @@ public class SaveAsDialog extends DAMessageBox { textBox.setBackground(ColorResources.VIEW_BG_COLOR); textBox.getControl().addKeyListener(keyListener); - info = new Label(shell, SWT.TRANSPARENT); + info = new Label(shell, SWT.TRANSPARENT); data = new FormData(); data.top = new FormAttachment(textBox.getControl(), 5); data.left = new FormAttachment(0, 9); @@ -116,7 +116,7 @@ public class SaveAsDialog extends DAMessageBox { info.setBackground(ColorResources.DIALOG_BG_UPPER); info.setForeground(ColorResources.RED); info.setFont(FontResources.COMBO); - + Composite buttonComp = new Composite(shell, SWT.NONE); buttonComp.setLayout(new FormLayout()); buttonComp.setBackground(ColorResources.DIALOG_BG_LOWER); @@ -251,12 +251,11 @@ public class SaveAsDialog extends DAMessageBox { private boolean executeSaveTrace() { Project project = AnalyzerManager.getProject(); String sourcePath = project.getSavePath(); - String targetPath = PathManager.DA_SAVE_PATH - + File.separator + saveFileName; + String targetPath = PathManager.DA_SAVE_PATH + File.separator + + saveFileName; SqlManager.getInstance().closeConnection(); SqlConnectionManager.closeConnection(); - project.setSavePath(targetPath); File sourceFolder = new File(sourcePath); if (!sourceFolder.isDirectory()) { @@ -274,17 +273,21 @@ public class SaveAsDialog extends DAMessageBox { } } AnalyzerUtil.copyDirectory(sourceFolder, targetFolder); + project.setSavePath(targetPath); boolean success = AnalyzerUtil.deleteFile(new File(sourcePath)); if (success) { // add snapshot model update DA_LOG.debug("save complete!!"); //$NON-NLS-1$ - } else { DA_LOG.debug("save fail..."); //$NON-NLS-1$ - return false; } - return true; + + // establish db connection with new path + SqlConnectionManager.establishConnection(project.getSavePath() + + File.separator + AnalyzerConstants.DATABASE_NAME); + + return success; } private boolean checkValidFileName(String str) { @@ -298,14 +301,10 @@ public class SaveAsDialog extends DAMessageBox { || str.contains(CommonConstants.CMD_SPLIT)) { info.setText("name contains invalid character"); return false; - } - else if(str.isEmpty()) - { + } else if (str.isEmpty()) { info.setText("file name is not empty"); return false; - } - else if (str.length() > MAX_SAVE_FILE_NAME_LENGTH) - { + } else if (str.length() > MAX_SAVE_FILE_NAME_LENGTH) { info.setText("file name is too long"); return false; } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/StopLogProcessor.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/StopLogProcessor.java index bb36933..1f1016c 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/StopLogProcessor.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/StopLogProcessor.java @@ -126,7 +126,6 @@ public class StopLogProcessor implements Runnable { SqlManager.getInstance().saveProfilingChildData(); SqlManager.getInstance().saveApiNames(); SqlManager.getInstance().closeConnection(); - SqlConnectionManager.closeConnection(); DA_LOG.debug("insert to db complete..."); //$NON-NLS-1$ percent += 10; StopProcessManager.getInstance().setValue(percent); -- 2.7.4