From: Hyunjong,park Date: Wed, 13 Nov 2013 02:49:24 +0000 (+0900) Subject: [Title] bug fix. open trace X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d3344bb59880d9fdc2447c845f00d879b07a3cca;p=sdk%2Ftools%2Fdynamic-analyzer.git [Title] bug fix. open trace [Desc.] get db item count when opentrace [Issue] - --- diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java index 5151483..f93c62f 100755 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/sql/SqlManager.java @@ -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; + } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/calltrace/CallTraceTable.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/calltrace/CallTraceTable.java index 3deaa55..2e6c538 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/calltrace/CallTraceTable.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/timeline/calltrace/CallTraceTable.java @@ -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) { diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DAWindowingTableComposite.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DAWindowingTableComposite.java index 5190c9c..cc76d0e 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DAWindowingTableComposite.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/table/DAWindowingTableComposite.java @@ -99,7 +99,8 @@ public abstract class DAWindowingTableComposite extends Composite { private int preLogCount = -1; private int preSelectionScrollIndex = -1; List 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 makeTableInput() { @@ -822,4 +824,12 @@ public abstract class DAWindowingTableComposite extends Composite { private void setSavedDBList(List savedDBList) { this.savedTableInputList = savedDBList; } + + public int getDbInsetedItemCount() { + return dbInsetedItemCount; + } + + public void setDbInsetedItemCount(int dbInsetedItemCount) { + this.dbInsetedItemCount = dbInsetedItemCount; + } }