[Title] fix. replay editor
authorHyunjong,park <phjwithyou.park@samsung.com>
Fri, 6 Dec 2013 05:54:28 +0000 (14:54 +0900)
committerHyunjong,park <phjwithyou.park@samsung.com>
Fri, 6 Dec 2013 05:54:28 +0000 (14:54 +0900)
[Desc.] get db data by time and rid value
[Issue] -

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/configuration/ConfigurationDialogFeaturesTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/toolbar/replayEditor/ReplayEditDialogDataManager.java

index 8b6aeb0..e75009b 100755 (executable)
@@ -1679,7 +1679,7 @@ public class SqlManager {
                                }
                        }
                        stat = conn.createStatement();
-                       rs = stat.executeQuery("select * from replay;");
+                       rs = stat.executeQuery("select * from replay order by time, rid");
                        if (null == rs) {
                                return null;
                        }
index d3c5b67..d533981 100644 (file)
@@ -120,7 +120,7 @@ public class ConfigurationDialogFeaturesTable extends DATreeComposite {
 
        @Override
        public List<TreeInput> makeTreeInput() {
-               List<TreeInput> output = new ArrayList<TreeInput>();
+       List<TreeInput> output = new ArrayList<TreeInput>();
                String[] featuresList = ConfigurationDialogDataManager.getInstance()
                                .getTableFeature();
                for (int i = 0; i < featuresList.length; i++) {
index f069187..749f708 100644 (file)
@@ -34,6 +34,7 @@ import org.tizen.dynamicanalyzer.common.AnalyzerManager;
 import org.tizen.dynamicanalyzer.common.CommonConstants;
 import org.tizen.dynamicanalyzer.nl.ReplayEditLabels;
 import org.tizen.dynamicanalyzer.sql.SqlManager;
+import org.tizen.dynamicanalyzer.swap.model.DATime;
 import org.tizen.dynamicanalyzer.swap.model.RecordEventObject;
 import org.tizen.dynamicanalyzer.swap.model.data.ReplayData;
 import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;
@@ -72,9 +73,6 @@ public class ReplayEditDialogDataManager {
 
        private int insertDBRid = 0;
        private int insertkeySequence = 1;
-       private int insertSecTimeSequence = 0;
-
-       private long preMouseUpTime = 0;
 
        private static ReplayEditDialogDataManager instance = null;
        private ReplayData replayDBData = null;
@@ -162,7 +160,14 @@ public class ReplayEditDialogDataManager {
                        ReplayData dbData) {
                int size = dbData.getRecordEvent().size();
                for (int i = 0; i < size; i++) {
+
                        RecordEventObject reo = dbData.getRecordEvent().get(i);
+                       long time = getTimeValue(reo.getEventTime().getSec(), reo
+                                       .getEventTime().getNano());
+                       DATime daTime = getDATimeValue(time);
+                       System.out.println(i + " : " + time + " sec : " + daTime.getSec()
+                                       + " nano : " + daTime.getNano());
+
                        if (reo.getEventType() == 0) { // event end log
                                continue;
                        }
@@ -365,8 +370,6 @@ public class ReplayEditDialogDataManager {
        private void cleanInsertData() {
                insertDBRid = 0;
                insertkeySequence = 1;
-               insertSecTimeSequence = 0;
-               preMouseUpTime = 0;
        }
 
        private void insertDBData(boolean isSave, String dbPath) {
@@ -420,73 +423,33 @@ public class ReplayEditDialogDataManager {
                return strPoint;
        }
 
-       private long getEventNanoTime(long time) {
-               int startSec = AnalyzerManager.getProject().getProfileStartTime()
-                               .getSec();
-               int startNano = AnalyzerManager.getProject().getProfileStartTime()
-                               .getNano();
-               long startTime = startSec / 1000000 + startNano / 1000;
-
-               long mouseEventSec = (startSec + insertSecTimeSequence);
-               long mouseDelaytime = time - startTime;
-               if (mouseDelaytime == 0) {
-                       return startNano;
-               }
-               if ((time - startTime) < 1) {
-                       return startNano;
-               }
-               long mouseDelaySec = (mouseEventSec - startSec) * 1000000;
-               long mouseEventNano = ((mouseDelaytime - mouseDelaySec) * 1000)
-                               + startNano;
-               return mouseEventNano;
-       }
-
-       private String getSecTime() {
-               int startSec = AnalyzerManager.getProject().getProfileStartTime()
-                               .getSec();
-               long mouseDownEventSec = (startSec + insertSecTimeSequence);
-               return Long.toString(mouseDownEventSec);
-       }
-
-       private String getMouseDownNanoTime(List<String> item) {
-               String itemMouseDownTime = getDBTime(item
-                               .get(EVENT_MOUSE_DOWN_TIME_TABLE_INDEX));
-               long downTime = Long.parseLong(itemMouseDownTime);
-               if (preMouseUpTime > 0 && downTime - preMouseUpTime > 1000000) {
-                       long delayTime = (downTime - preMouseUpTime) / 1000000;
-                       insertSecTimeSequence += delayTime;
-               }
-
-               long mouseDownEventNano = getEventNanoTime(downTime);
-               while (mouseDownEventNano > 1000000000) {
-                       insertSecTimeSequence++;
-                       mouseDownEventNano = getEventNanoTime(downTime);
-               }
-
-               return Long.toString(mouseDownEventNano);
+       public long getTimeValue(long sec, long nano) {
+               DATime startTime = AnalyzerManager.getProject().getProfileStartTime();
+               long startSec = startTime.getSec();
+               long startNano = startTime.getNano();
+               long resultSec = sec - startSec;
+               long resultNano = nano - startNano;
+               long time = resultSec * 1000000 + resultNano / 1000;
+               return time;
        }
 
-       private String getMouseUpNanoTime(List<String> item) {
-               String itemMouseDownTime = getDBTime(item
-                               .get(EVENT_MOUSE_DOWN_TIME_TABLE_INDEX));
-               String itemMouseUpTime = getDBTime(item
-                               .get(EVENT_MOUSE_UP_TIME_TABLE_INDEX));
-               long downTime = Long.parseLong(itemMouseDownTime);
-               long upTime = Long.parseLong(itemMouseUpTime);
-
-               if (upTime - downTime > 1000000) {
-                       long delayTime = (downTime - downTime) / 1000000;
-                       insertSecTimeSequence += delayTime;
+       private DATime getDATimeValue(long time) {
+               DATime startTime = AnalyzerManager.getProject().getProfileStartTime();
+               long startSec = startTime.getSec();
+               long startNano = startTime.getNano();
+               long secTime = startSec;
+               long nanoTime = 0;
+               long resultSec = (secTime - startSec);
+               nanoTime = ((time - (resultSec * 1000000)) * 1000) + startNano;
+               while (nanoTime > 1000000000) {
+                       secTime++;
+                       resultSec = (secTime - startSec);
+                       nanoTime = ((time - (resultSec * 1000000)) * 1000) + startNano;
                }
-
-               long mouseUpEventNano = getEventNanoTime(upTime);
-               while (mouseUpEventNano > 1000000000) {
-                       insertSecTimeSequence++;
-                       mouseUpEventNano = getEventNanoTime(upTime);
-               }
-
-               preMouseUpTime = upTime;
-               return Long.toString(mouseUpEventNano);
+               DATime resultTime = new DATime();
+               resultTime.setSec((int) secTime);
+               resultTime.setNano((int) nanoTime);
+               return resultTime;
        }
 
        private String getKeyValue(List<String> item) {
@@ -513,54 +476,57 @@ public class ReplayEditDialogDataManager {
                                .get(EVENT_MOUSE_DOWN_TIME_TABLE_INDEX));
                String itemMouseUpTime = getDBTime(item
                                .get(EVENT_MOUSE_UP_TIME_TABLE_INDEX));
-               String mouseDownNanoTime = getMouseDownNanoTime(item);
-               String mouseUpNanoTime = getMouseUpNanoTime(item);
+               DATime mouseDownTime = getDATimeValue(Long.parseLong(itemMouseDownTime));
+               DATime mouseUpTime = getDATimeValue(Long.parseLong(itemMouseUpTime));
                String itemValue1 = getKeyValue(item);
-               int sec = Integer.parseInt(getSecTime());
 
                List<List<String>> dbKeyDataList = new ArrayList<List<String>>();
                for (int i = 0; i < 4; i++) {
                        List<String> keyData = new ArrayList<String>();
                        if (i == 0) {
-                               keyData.add(Integer.toString(sec + insertDBRid++));
+                               keyData.add(Integer.toString(mouseDownTime.getSec()
+                                               + insertDBRid++));
                                keyData.add(Integer.toString(MESSAGE_ID));
                                keyData.add(Integer.toString(8815));
                                keyData.add(itemMouseDownTime);
-                               keyData.add(getSecTime());
-                               keyData.add(mouseDownNanoTime);
+                               keyData.add(Long.toString(mouseDownTime.getSec()));
+                               keyData.add(Long.toString(mouseDownTime.getNano()));
                                keyData.add("1");
                                keyData.add(Integer.toString(KEY));
                                keyData.add(itemValue1);
                                keyData.add("1");
                        } else if (i == 1) {
-                               keyData.add(Integer.toString(sec + insertDBRid++));
+                               keyData.add(Integer.toString(mouseUpTime.getSec()
+                                               + insertDBRid++));
                                keyData.add(Integer.toString(MESSAGE_ID));
                                keyData.add(Integer.toString(8815));
                                keyData.add(itemMouseDownTime);
-                               keyData.add(getSecTime());
-                               keyData.add(mouseDownNanoTime);
+                               keyData.add(Long.toString(mouseDownTime.getSec()));
+                               keyData.add(Long.toString(mouseDownTime.getNano()));
                                keyData.add("1");
                                keyData.add("0");
                                keyData.add("0");
                                keyData.add("0");
                        } else if (i == 2) {
-                               keyData.add(Integer.toString(sec + insertDBRid++));
+                               keyData.add(Integer.toString(mouseUpTime.getSec()
+                                               + insertDBRid++));
                                keyData.add(Integer.toString(MESSAGE_ID));
                                keyData.add(Integer.toString(8815));
                                keyData.add(itemMouseUpTime);
-                               keyData.add(getSecTime());
-                               keyData.add(mouseUpNanoTime);
+                               keyData.add(Long.toString(mouseUpTime.getSec()));
+                               keyData.add(Long.toString(mouseUpTime.getNano()));
                                keyData.add("1");
                                keyData.add(Integer.toString(KEY));
                                keyData.add(itemValue1);
                                keyData.add("0");
                        } else if (i == 3) {
-                               keyData.add(Integer.toString(sec + insertDBRid++));
+                               keyData.add(Integer.toString(mouseUpTime.getSec()
+                                               + insertDBRid++));
                                keyData.add(Integer.toString(MESSAGE_ID));
                                keyData.add(Integer.toString(8815));
                                keyData.add(itemMouseUpTime);
-                               keyData.add(getSecTime());
-                               keyData.add(mouseUpNanoTime);
+                               keyData.add(Long.toString(mouseUpTime.getSec()));
+                               keyData.add(Long.toString(mouseUpTime.getNano()));
                                keyData.add("1");
                                keyData.add("0");
                                keyData.add("0");
@@ -576,89 +542,95 @@ public class ReplayEditDialogDataManager {
                                .get(EVENT_MOUSE_DOWN_TIME_TABLE_INDEX));
                String itemMouseUpTime = getDBTime(item
                                .get(EVENT_MOUSE_UP_TIME_TABLE_INDEX));
-               String mouseDownNanoTime = getMouseDownNanoTime(item);
-               String mouseUpNanoTime = getMouseUpNanoTime(item);
+               DATime mouseDownTime = getDATimeValue(Long.parseLong(itemMouseDownTime));
+               DATime mouseUpTime = getDATimeValue(Long.parseLong(itemMouseUpTime));
                String itemValue1 = item.get(EVENT_VALUE1_TABLE_INDEX);
                String itemValue2 = item.get(EVENT_VALUE2_TABLE_INDEX);
 
-               int sec = Integer.parseInt(getSecTime());
                List<List<String>> dbKeyDataList = new ArrayList<List<String>>();
                for (int i = 0; i < 7; i++) {
                        List<String> keyData = new ArrayList<String>();
                        if (i == 0) {
-                               keyData.add(Integer.toString(sec + insertDBRid++));
+                               keyData.add(Integer.toString(mouseDownTime.getSec()
+                                               + insertDBRid++));
                                keyData.add(Integer.toString(MESSAGE_ID));
                                keyData.add(Integer.toString(8815));
                                keyData.add(itemMouseDownTime);
-                               keyData.add(getSecTime());
-                               keyData.add(mouseDownNanoTime);
+                               keyData.add(Long.toString(mouseDownTime.getSec()));
+                               keyData.add(Long.toString(mouseDownTime.getNano()));
                                keyData.add("0");
                                keyData.add(Integer.toString(TOUCH));
                                keyData.add(Integer
                                                .toString(TOUCH_EVENT_CODE_MOUSED_DOWN_START));
                                keyData.add(Integer.toString(insertkeySequence++));
                        } else if (i == 1) {
-                               keyData.add(Integer.toString(sec + insertDBRid++));
+                               keyData.add(Integer.toString(mouseDownTime.getSec()
+                                               + insertDBRid++));
                                keyData.add(Integer.toString(MESSAGE_ID));
                                keyData.add(Integer.toString(8815));
                                keyData.add(itemMouseDownTime);
-                               keyData.add(getSecTime());
-                               keyData.add(mouseDownNanoTime);
+                               keyData.add(Long.toString(mouseDownTime.getSec()));
+                               keyData.add(Long.toString(mouseDownTime.getNano()));
                                keyData.add("0");
                                keyData.add(Integer.toString(TOUCH));
                                keyData.add(Integer.toString(TOUCH_EVENT_CODE_SECOND_ITEM));
                                keyData.add(Integer.toString(TOUCH_EVENT_VALUE_SECOND_ITEM));
                        } else if (i == 2) {
-                               keyData.add(Integer.toString(sec + insertDBRid++));
+                               keyData.add(Integer.toString(mouseDownTime.getSec()
+                                               + insertDBRid++));
                                keyData.add(Integer.toString(MESSAGE_ID));
                                keyData.add(Integer.toString(8815));
                                keyData.add(itemMouseDownTime);
-                               keyData.add(getSecTime());
-                               keyData.add(mouseDownNanoTime);
+                               keyData.add(Long.toString(mouseDownTime.getSec()));
+                               keyData.add(Long.toString(mouseDownTime.getNano()));
                                keyData.add("0");
                                keyData.add(Integer.toString(TOUCH));
                                keyData.add(Integer.toString(TOUCH_EVENT_CODE_X));
                                keyData.add(getDBPoint(itemValue1));
                        } else if (i == 3) {
-                               keyData.add(Integer.toString(sec + insertDBRid++));
+                               keyData.add(Integer.toString(mouseDownTime.getSec()
+                                               + insertDBRid++));
                                keyData.add(Integer.toString(MESSAGE_ID));
                                keyData.add(Integer.toString(8815));
                                keyData.add(itemMouseDownTime);
-                               keyData.add(getSecTime());
-                               keyData.add(mouseDownNanoTime);
+                               keyData.add(Long.toString(mouseDownTime.getSec()));
+                               keyData.add(Long.toString(mouseDownTime.getNano()));
                                keyData.add("0");
                                keyData.add(Integer.toString(TOUCH));
                                keyData.add(Integer.toString(TOUCH_EVENT_CODE_Y));
                                keyData.add(getDBPoint(itemValue2));
                        } else if (i == 4) {
-                               keyData.add(Integer.toString(sec + insertDBRid++));
+                               keyData.add(Integer.toString(mouseDownTime.getSec()
+                                               + insertDBRid++));
                                keyData.add(Integer.toString(MESSAGE_ID));
                                keyData.add(Integer.toString(8815));
                                keyData.add(itemMouseDownTime);
-                               keyData.add(getSecTime());
-                               keyData.add(mouseDownNanoTime);
+                               keyData.add(Long.toString(mouseDownTime.getSec()));
+                               keyData.add(Long.toString(mouseDownTime.getNano()));
                                keyData.add("0");
                                keyData.add("0");
                                keyData.add("0");
                                keyData.add("0");
                        } else if (i == 5) {
-                               keyData.add(Integer.toString(sec + insertDBRid++));
+                               keyData.add(Integer.toString(mouseDownTime.getSec()
+                                               + insertDBRid++));
                                keyData.add(Integer.toString(MESSAGE_ID));
                                keyData.add(Integer.toString(9164));
                                keyData.add(itemMouseUpTime);
-                               keyData.add(getSecTime());
-                               keyData.add(mouseUpNanoTime);
+                               keyData.add(Long.toString(mouseUpTime.getSec()));
+                               keyData.add(Long.toString(mouseUpTime.getNano()));
                                keyData.add("0");
                                keyData.add(Integer.toString(TOUCH));
                                keyData.add(Integer.toString(TOUCH_EVENT_CODE_MOUSED_UP_START));
                                keyData.add("-1");
                        } else if (i == 6) {
-                               keyData.add(Integer.toString(sec + insertDBRid++));
+                               keyData.add(Integer.toString(mouseDownTime.getSec()
+                                               + insertDBRid++));
                                keyData.add(Integer.toString(MESSAGE_ID));
                                keyData.add(Integer.toString(9164));
                                keyData.add(itemMouseUpTime);
-                               keyData.add(getSecTime());
-                               keyData.add(mouseUpNanoTime);
+                               keyData.add(Long.toString(mouseUpTime.getSec()));
+                               keyData.add(Long.toString(mouseUpTime.getNano()));
                                keyData.add("0");
                                keyData.add("0");
                                keyData.add("0");