From 0c6fcf83b4fe54ec61989f516d04d573b5e2ceaa Mon Sep 17 00:00:00 2001 From: "jy.exe.lee" Date: Tue, 17 Jul 2012 16:43:20 +0900 Subject: [PATCH] [Title] Open trace format fixed [Type] bug fixed [Module] Dynamic Analyzer [Priority] normal [CQ#] [Redmine#] [Problem] [Cause] [Solution] [TestCase] --- .../dynamicanalyzer/handlers/SaveTraceHandler.java | 117 ++++++++++----------- .../org/tizen/dynamicanalyzer/model/Project.java | 4 +- 2 files changed, 58 insertions(+), 63 deletions(-) diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/SaveTraceHandler.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/SaveTraceHandler.java index 9ed3c00..36e30fe 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/SaveTraceHandler.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/handlers/SaveTraceHandler.java @@ -1,3 +1,5 @@ + + package org.tizen.dynamicanalyzer.handlers; import java.io.File; @@ -15,68 +17,61 @@ import org.tizen.dynamicanalyzer.model.SnapshotData; import org.tizen.dynamicanalyzer.uirecorder.RecorderXml; import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; + public class SaveTraceHandler extends AbstractHandler { - public static final String ID = SaveTraceHandler.class.getName(); - - public static final String DEFAULT_DATE_FORMAT = "_yyyy-MM-dd-HH:mm:ss"; //$NON-NLS-1$ - - @Override - public Object execute(ExecutionEvent event) throws ExecutionException { - // copy temp save file to save folder - // renaming folder name to app name + date time - Project project = AnalyzerManager.getProject(); - String sourcePath = project.getSavePath(); - - SimpleDateFormat format = new SimpleDateFormat(DEFAULT_DATE_FORMAT, - Locale.KOREA); - Date date = new Date(); - String targetPath = AnalyzerConstants.SAVE_FOLDER_PATH + File.separator - + project.getAppName() + format.format(date); - String targetImagePath = targetPath - + AnalyzerConstants.IMAGE_FOLDER_NAME; - - File targetFolder = new File(targetImagePath); - if (!targetFolder.isDirectory()) { - targetFolder.mkdirs(); - } - String targetFilePath = targetPath + File.separator - + AnalyzerConstants.DATABASE_NAME; - String sourceFilePath = sourcePath + File.separator - + AnalyzerConstants.DATABASE_NAME; - AnalyzerUtil.copyFile(sourceFilePath, targetFilePath); - - String sourceUIRecorderPath = sourcePath + File.separator - + RecorderXml.xmlFileName; - String targetUIRecorderPath = targetPath + File.separator - + RecorderXml.xmlFileName; - if (new File(sourceUIRecorderPath).exists()) { - AnalyzerUtil.copyFile(sourceUIRecorderPath, targetUIRecorderPath); - } - - project.setSavePath(targetPath); - - // delete source file and folder - // save trace callstack - String sourceImgFolder = sourcePath - + AnalyzerConstants.IMAGE_FOLDER_NAME; - AnalyzerUtil.saveTraceImage(sourceImgFolder, targetImagePath); - try { - boolean success = AnalyzerUtil.deleteFile(new File(sourcePath)); - AnalyzerManager.removeFromProjectList(sourcePath); - if (success) { - // add snapshot model update - SnapshotData.getInstance().update(); - System.out.println("save complete!!"); //$NON-NLS-1$ - } else { - System.out.println("save fail..."); //$NON-NLS-1$ - } - } catch (Exception e) { - e.printStackTrace(); - return 1; - } - - return 0; - } + public static final String ID = SaveTraceHandler.class.getName(); + + public static final String DEFAULT_DATE_FORMAT = "_yyyy-MM-dd-HH:mm:ss"; //$NON-NLS-1$ + + @Override + public Object execute(ExecutionEvent event) throws ExecutionException { + // copy temp save file to save folder + // renaming folder name to app name + date time + Project project = AnalyzerManager.getProject(); + String sourcePath = project.getSavePath(); + + String[] splitSourcePath = sourcePath.split("\\/"); + String saveName = new String(splitSourcePath[splitSourcePath.length - 1]); + String targetPath = AnalyzerConstants.SAVE_FOLDER_PATH + File.separator + saveName; + String targetImagePath = targetPath + AnalyzerConstants.IMAGE_FOLDER_NAME; + + File targetFolder = new File(targetImagePath); + if (!targetFolder.isDirectory()) { + targetFolder.mkdirs(); + } + String targetFilePath = targetPath + File.separator + AnalyzerConstants.DATABASE_NAME; + String sourceFilePath = sourcePath + File.separator + AnalyzerConstants.DATABASE_NAME; + AnalyzerUtil.copyFile(sourceFilePath, targetFilePath); + + String sourceUIRecorderPath = sourcePath + File.separator + RecorderXml.xmlFileName; + String targetUIRecorderPath = targetPath + File.separator + RecorderXml.xmlFileName; + if (new File(sourceUIRecorderPath).exists()) { + AnalyzerUtil.copyFile(sourceUIRecorderPath, targetUIRecorderPath); + } + + project.setSavePath(targetPath); + + // delete source file and folder + // save trace callstack + String sourceImgFolder = sourcePath + AnalyzerConstants.IMAGE_FOLDER_NAME; + AnalyzerUtil.saveTraceImage(sourceImgFolder, targetImagePath); + try { + boolean success = AnalyzerUtil.deleteFile(new File(sourcePath)); + AnalyzerManager.removeFromProjectList(sourcePath); + if (success) { + // add snapshot model update + SnapshotData.getInstance().update(); + System.out.println("save complete!!"); //$NON-NLS-1$ + } else { + System.out.println("save fail..."); //$NON-NLS-1$ + } + } catch (Exception e) { + e.printStackTrace(); + return 1; + } + + return 0; + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/Project.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/Project.java index 5e38108..191aebc 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/Project.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/model/Project.java @@ -17,7 +17,7 @@ import org.tizen.dynamicanalyzer.constants.AnalyzerConstants; import org.tizen.sdblib.IDevice; public class Project { - private final String DEFAULT_TIME_FORMAT = "yyyy-MM-dd-HH-mm-ss";//$NON-NLS-1$ + private final String DEFAULT_TIME_FORMAT = "_yyyy-MM-dd-HH:mm:ss";//$NON-NLS-1$ private String appName = null; private List logCenters; @@ -125,7 +125,7 @@ public class Project { Date date = new Date(); savePath = AnalyzerConstants.TEMP_FOLDER_PATH + File.separator - + format.format(date); + + appName + format.format(date); File imgFolder = new File(savePath + AnalyzerConstants.IMAGE_FOLDER_NAME); if (!imgFolder.isDirectory()) { -- 2.7.4