[Title] bug fix. open trace
authorHyunjong,park <phjwithyou.park@samsung.com>
Wed, 13 Nov 2013 02:49:24 +0000 (11:49 +0900)
committerHyunjong,park <phjwithyou.park@samsung.com>
Wed, 13 Nov 2013 02:49:24 +0000 (11:49 +0900)
[Desc.] get db item count when opentrace
[Issue] -

org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/calltrace/CallTraceTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DAWindowingTableComposite.java

index 5151483..f93c62f 100755 (executable)
@@ -1410,4 +1410,54 @@ public class SqlManager {
                }
                return 0;
        }
+       
+       public int getTableItemCount(String tableName, String option) {
+               String query = null;
+               Statement stat = null;
+               ResultSet rs = null;
+               Connection conn = null;
+               try {
+                       conn = getConnection();
+                       if (null == conn) {
+                               return 0;
+                       }
+                       semaphoreAcquire();
+                       if (null == tableName || tableName.length() < 1) {
+                               System.out.println("tableName is null");
+                               return 0;
+                       }
+                       String optionQuery = CommonConstants.EMPTY;
+                       if (null != option) {
+                               optionQuery = "where " + option;//$NON-NLS-1$
+                       }
+
+                       query = String.format("select max(rid) from %s %s",//$NON-NLS-1$
+                                       tableName, optionQuery);
+
+                       stat = conn.createStatement();
+
+                       rs = stat.executeQuery(query);
+                       if (null == rs) {
+                               return 0;
+                       }
+
+                       while (rs.next()) {
+                               return rs.getInt(1);
+                       }
+               } catch (SQLException e) {
+                       do {
+                               System.out.println("query: " + query);
+                               System.out.println("Message: " + e.getMessage());
+                               System.out.println("SQL state: " + e.getSQLState());
+                               System.out.println("Vendor code: " + e.getErrorCode());
+                               e.printStackTrace();
+                       } while ((e = e.getNextException()) != null);
+               } finally {
+                       AnalyzerUtil.tryClose(stat, rs);
+                       if (null != conn) {
+                               semaphoreRelease();
+                       }
+               }
+               return 0;
+       }
 }
index 3deaa55..2e6c538 100644 (file)
@@ -366,7 +366,17 @@ public class CallTraceTable extends DAWindowingTableComposite {
        }
        
        protected int getItemCount() {
-               return LogDataFactory.getProfilingLogNum();
+               if (AnalyzerManager.isRunning()) { // trace
+                       setDbInsetedItemCount(LogDataFactory.getProfilingLogNum());
+               } else {
+                       if (getDbInsetedItemCount() == 0) { // open
+                               setDbInsetedItemCount(SqlManager.getInstance()
+                                               .getTableItemCount(getDBTableName(), dbOptionQuery));
+                       } else if (LogDataFactory.getProfilingLogNum() > 0) { // stop
+                               setDbInsetedItemCount(LogDataFactory.getProfilingLogNum());
+                       }
+               }
+               return getDbInsetedItemCount();
        }
 
        public void setSelectionByTime(long startTime, long endTime) {
index 5190c9c..cc76d0e 100644 (file)
@@ -99,7 +99,8 @@ public abstract class DAWindowingTableComposite extends Composite {
        private int preLogCount = -1;
        private int preSelectionScrollIndex = -1;
        List<LogData> savedLogDataList = null;
-
+       private int dbInsetedItemCount = 0;
+       
        protected Color rangeColor = ColorResources.TABLE_RANGE_COLOR_RANGE;
        protected Color secondSelectionColor = ColorResources.TABLE_RANGE_COLOR_SECOND_SELECTION;
        protected Color intersectColor = ColorResources.TABLE_RANGE_COLOR_RANGE_SECOND;
@@ -242,6 +243,7 @@ public abstract class DAWindowingTableComposite extends Composite {
                preDBTableItemsCount = 0;
                savedTableInputList = null;
                savedLogDataList = null;
+               dbInsetedItemCount = 0;
        }
 
        private List<TableInput> makeTableInput() {
@@ -822,4 +824,12 @@ public abstract class DAWindowingTableComposite extends Composite {
        private void setSavedDBList(List<TableInput> savedDBList) {
                this.savedTableInputList = savedDBList;
        }
+       
+       public int getDbInsetedItemCount() {
+               return dbInsetedItemCount;
+       }
+
+       public void setDbInsetedItemCount(int dbInsetedItemCount) {
+               this.dbInsetedItemCount = dbInsetedItemCount;
+       }
 }