[SRADA-177] Implement Detail table
authordongkyu6 lee <dongkyu6.lee@samsung.com>
Tue, 22 Mar 2016 08:21:44 +0000 (17:21 +0900)
committerdongkyu6 lee <dongkyu6.lee@samsung.com>
Tue, 22 Mar 2016 08:21:44 +0000 (17:21 +0900)
 - Implement MemoryDetailsTable

Change-Id: Id084d20ee7ae885ce78c35e3acd03a180758b612
Signed-off-by: dongkyu6 lee <dongkyu6.lee@samsung.com>
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/MemoryPageLabels.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/MemoryPageLabels.properties
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/MemoryDetailsTableView.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/AllocateDBTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/MemoryDataManager.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/ProcessMemoryDBTable.java [changed mode: 0644->0755]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/data/SystemMemoryDBTable.java [changed mode: 0644->0755]
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/table/MemoryDetailsTable.java
org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/memory/table/MemoryStatisticsTable.java

index 89afa82..bfcfa96 100755 (executable)
@@ -11,6 +11,7 @@ public class MemoryPageLabels extends NLS {
        public static String MEMORY_DETAILS_VIEW_TITLE;
        public static String MEMORY_STATISTICS_VIEW_TITLE;
        public static String MEMORY_ALLOCATION_TRACE_VIEW_TITLE;
+       public static String MEMORY_MAIN_EXCUTABLE;
 
        public static String MEMORY_DETAILS_VIEW_ITEM;
        public static String MEMORY_DETAILS_VIEW_CURRENT;
index 5801397..f8abc77 100755 (executable)
@@ -4,6 +4,7 @@ MEMORY_CALLSTACK_VIEW_TITLE=CallStack
 MEMORY_DETAILS_VIEW_TITLE=Details\r
 MEMORY_STATISTICS_VIEW_TITLE=Statistics\r
 MEMORY_ALLOCATION_TRACE_VIEW_TITLE=Allocation Trace\r
+MEMORY_MAIN_EXCUTABLE=Main Executable\r
 \r
 MEMORY_DETAILS_VIEW_ITEM\r
 MEMORY_DETAILS_VIEW_CURRENT=current\r
index 0e5f22b..a974a56 100755 (executable)
@@ -4,14 +4,11 @@ import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.FillLayout;
 import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
-import org.tizen.dynamicanalyzer.common.AnalyzerConstants;
 import org.tizen.dynamicanalyzer.common.AnalyzerManager;
 import org.tizen.dynamicanalyzer.nl.MemoryPageLabels;
 import org.tizen.dynamicanalyzer.resources.ColorResources;
 import org.tizen.dynamicanalyzer.ui.memory.data.MemorySelectionData;
 import org.tizen.dynamicanalyzer.ui.memory.table.MemoryDetailsTable;
-import org.tizen.dynamicanalyzer.ui.widgets.table.DefaultTableComparator;
-import org.tizen.dynamicanalyzer.ui.widgets.table.TableColumnSizePackListener;
 import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite;
 import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData;
 
index 29791e4..399b9b2 100755 (executable)
@@ -1,3 +1,27 @@
+/*
+ *  Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Dongkye Lee <dongkyu6.lee@samsung.com>
+ * Jaeyong Lee <jae-yong.lee@@samsung.com>
+ * Gihun Chang <gihun.chang@@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
 package org.tizen.dynamicanalyzer.ui.memory.data;
 
 import java.sql.PreparedStatement;
index 1b8dd2f..376c131 100755 (executable)
@@ -96,13 +96,13 @@ public class MemoryDataManager extends PageDataManager {
                processMemoryDBTable = new ProcessMemoryDBTable();\r
                allocateDBTable = new AllocateDBTable();\r
                freeDBTable = new FreeDBTable();\r
-               allocateCallStackDBTable = new AllocateCallStackDBTable();\r
+               //allocateCallStackDBTable = new AllocateCallStackDBTable();\r
                \r
                systemMemoryDBInserter = makeInserter(systemMemoryDBTable);\r
                processMemoryDBInserter = makeInserter(processMemoryDBTable);\r
                allocateDBInserter = makeInserter(allocateDBTable);\r
                freeDBInserter = makeInserter(freeDBTable);\r
-               allocateCallStackDBInserter = makeInserter(allocateCallStackDBTable); \r
+               //allocateCallStackDBInserter = makeInserter(allocateCallStackDBTable); \r
        }\r
 \r
        public void setChartMemoryChartBoard(DAChartBoard board) {\r
@@ -265,33 +265,108 @@ public class MemoryDataManager extends PageDataManager {
                        return new ArrayList<List<Object>>();\r
                }\r
        }\r
+       \r
+       public List<Long> getSystemMemoryMinMaxFromDB(long start, long end) {\r
+               List<Long> output = null;\r
+               \r
+               String tableName = systemMemoryDBTable.getTableName();\r
+               String columnName = SystemMemoryDBTable.MEMORY_USAGE_SYSTEM;\r
+               String timecolumn = SystemMemoryDBTable.SAMPLING_TIME;\r
 \r
-       public Map<Integer, List<List<Object>>> getTargetProcessDataFromDB(long start, long end,\r
-                       int targetPID) {\r
-               Map<Integer, List<List<Object>>> processedResult = new HashMap<Integer, List<List<Object>>>();\r
-               String where = "WHERE SAMPLING_TIME BETWEEN " + start + " AND " + end;\r
+               output = getColumnLongFromDB(tableName, columnName, timecolumn, start, end);\r
+               \r
+               return output;\r
+       }\r
+       \r
+       public List<Long> getColumnLongFromDB(String tableName, String columnName, String timecolumn, long start, long end) {\r
+               List<Long> output = new ArrayList<Long>();\r
+               String query;\r
+               \r
+               if(start == 0 && end == 0) {\r
+                       query = String.format("SELECT %s FROM %s",\r
+                                       columnName, tableName);\r
+               }\r
+               else {\r
+                       query = String.format("SELECT %s FROM %s WHERE %s BETWEEN %s and %s",\r
+                                       columnName, tableName, timecolumn, start, end);\r
+               }\r
+               \r
+               ResultSet rs = SqlConnectionManager.executeQueryRS(query);\r
+               if (rs != null) {\r
+                       try {\r
+                               while (rs.next()) {\r
+                                       output.add(rs.getLong(1));\r
+                               }\r
+                       } catch (SQLException e) {\r
+                               Logger.exception(e);\r
+                       } finally {\r
+                               SqlConnectionManager.releaseResultSet(rs);\r
+                       }\r
+               }\r
+               \r
+               return output;\r
+       }\r
+       \r
+       public List<Long> getColumnLongFromDB(String tableName, String columnName, String timecolumn, \r
+                       int targetID, long start, long end) {\r
+               List<Long> output = new ArrayList<Long>();\r
+               String query;\r
+               \r
+               if(start == 0 && end == 0) {\r
+                       query = String.format("SELECT %s FROM %s WHERE PID = %s",\r
+                                       columnName, tableName, targetID);\r
+               }\r
+               else {\r
+                       query = String.format("SELECT %s FROM %s WHERE %s BETWEEN %s and %s AND PID = ",\r
+                                       columnName, tableName, timecolumn, start, end, targetID);\r
+               }\r
+               \r
+               ResultSet rs = SqlConnectionManager.executeQueryRS(query);\r
+               if (rs != null) {\r
+                       try {\r
+                               while (rs.next()) {\r
+                                       output.add(rs.getLong(1));\r
+                               }\r
+                       } catch (SQLException e) {\r
+                               Logger.exception(e);\r
+                       } finally {\r
+                               SqlConnectionManager.releaseResultSet(rs);\r
+                       }\r
+               }\r
+               \r
+               return output;\r
+       }\r
+\r
+       public List<List<Object>> getTargetProcessDataFromDB(long start, long end, int targetPID) {\r
+               List<List<Object>> processedResult = new ArrayList<List<Object>>();\r
+               \r
+               String where = "WHERE";         \r
+               if (start != 0 || end != 0) {\r
+                       where += String.format(" %s BETWENN %s and %s", ProcessMemoryDBTable.SAMPLING_TIME, Long.toString(start), Long.toString(end));\r
+               }\r
+               \r
                if (targetPID > 0) {\r
-                       where += " AND PID = " + targetPID;\r
+                       if (start != 0 || end != 0) \r
+                               where += " AND";\r
+                       \r
+                       where += String.format(" %s = %s", ProcessMemoryDBTable.PID, Integer.toString(targetPID));\r
                } else {\r
                        // Do nothing. Get information from all processes.\r
                }\r
-               where += " ORDER BY SAMPLING_TIME";\r
+               \r
+               if(where == "WHERE") {\r
+                       where = "";\r
+               }\r
+               \r
+               where += " ORDER BY " + ProcessMemoryDBTable.SAMPLING_TIME;\r
 \r
                List<List<Object>> queryResult = processMemoryDBTable.selectAllColumnData(where);\r
                if (queryResult == null) {\r
                        return processedResult;\r
                }\r
-\r
-               for (int i = 0; i < queryResult.size(); i++) {\r
-                       List<Object> row = queryResult.get(i);\r
-                       Integer pid = (Integer) row.get(ProcessMemoryDBTable.COLUMN.PID.ordinal());\r
-                       List<List<Object>> processData = processedResult.get(pid);\r
-                       if (processData == null) {\r
-                               processData = new ArrayList<List<Object>>();\r
-                               processedResult.put(pid, processData);\r
-                       }\r
-                       processData.add(row);\r
-               }\r
+               \r
+               processedResult = queryResult;\r
+               \r
                return processedResult;\r
        }\r
 \r
@@ -331,6 +406,11 @@ public class MemoryDataManager extends PageDataManager {
                } else {\r
                        // Do nothing. Get information from all processes.\r
                }\r
+               \r
+               if(where == "WHERE") {\r
+                       where = "";\r
+               }\r
+               \r
                where += " ORDER BY " + AllocateDBTable.COLUMN.SEQUENCE_NUMBER.name;\r
 \r
                List<List<Object>> queryResult = allocateDBTable.selectAllColumnData(where);\r
@@ -358,6 +438,11 @@ public class MemoryDataManager extends PageDataManager {
                } else {\r
                        // Do nothing. Get information from all processes.\r
                }\r
+               \r
+               if(where == "WHERE") {\r
+                       where = "";\r
+               }\r
+               \r
                where += " ORDER BY " + FreeDBTable.COLUMN.SEQUENCE_NUMBER.name;\r
 \r
                List<List<Object>> queryResult = freeDBTable.selectAllColumnData(where);\r
old mode 100644 (file)
new mode 100755 (executable)
index 7aed34c..88a2bb6
@@ -1,3 +1,28 @@
+/*
+ *  Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Dongkye Lee <dongkyu6.lee@samsung.com>
+ * Jaeyong Lee <jae-yong.lee@@samsung.com>
+ * Gihun Chang <gihun.chang@@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+
 package org.tizen.dynamicanalyzer.ui.memory.data;
 
 import java.sql.PreparedStatement;
@@ -48,6 +73,10 @@ public class ProcessMemoryDBTable extends DBTable {
        public String getTableName() {
                return TABLENAME;
        }
+       
+       public static String getTablename() {
+               return TABLENAME;
+       }
 
        public ProcessMemoryDBTable() {
                addColumn(new DBColumn(SAMPLING_TIME, DBConstants.NOT_NULL, DBConstants.DBTYPE_LONG));
old mode 100644 (file)
new mode 100755 (executable)
index 8673f46..bf85b7c
@@ -1,3 +1,28 @@
+/*
+ *  Dynamic Analyzer
+ *
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: 
+ * Dongkye Lee <dongkyu6.lee@samsung.com>
+ * Jaeyong Lee <jae-yong.lee@@samsung.com>
+ * Gihun Chang <gihun.chang@@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ */
+
+
 package org.tizen.dynamicanalyzer.ui.memory.data;
 
 import java.sql.PreparedStatement;
index 134e229..57a23a2 100755 (executable)
@@ -1,22 +1,64 @@
+/*\r
+ *  Dynamic Analyzer\r
+ *\r
+ * Copyright (c) 2000 - 2016 Samsung Electronics Co., Ltd. All rights reserved.\r
+ *\r
+ * Contact: \r
+ * Dongkye Lee <dongkyu6.lee@samsung.com>\r
+ * Jaeyong Lee <jae-yong.lee@@samsung.com>\r
+ * Gihun Chang <gihun.chang@@samsung.com>\r
+ *\r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ * http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ * \r
+ */\r
+\r
 package org.tizen.dynamicanalyzer.ui.memory.table;\r
 \r
+import java.util.ArrayList;\r
+import java.util.HashMap;\r
 import java.util.List;\r
+import java.util.Map;\r
 \r
+import org.eclipse.nebula.widgets.grid.GridItem;\r
 import org.eclipse.swt.SWT;\r
+import org.eclipse.swt.events.MouseEvent;\r
+import org.eclipse.swt.events.MouseListener;\r
 import org.eclipse.swt.widgets.Composite;\r
+import org.eclipse.swt.widgets.Event;\r
+import org.eclipse.swt.widgets.Listener;\r
 import org.tizen.dynamicanalyzer.common.AnalyzerConstants;\r
-import org.tizen.dynamicanalyzer.model.TableInput;\r
+import org.tizen.dynamicanalyzer.common.Global;\r
+import org.tizen.dynamicanalyzer.model.TreeInput;\r
 import org.tizen.dynamicanalyzer.nl.MemoryPageLabels;\r
-import org.tizen.dynamicanalyzer.ui.widgets.table.DATableComposite;\r
+import org.tizen.dynamicanalyzer.project.BinaryInfo;\r
+import org.tizen.dynamicanalyzer.project.Project;\r
+import org.tizen.dynamicanalyzer.ui.memory.data.MemoryDataManager;\r
+import org.tizen.dynamicanalyzer.ui.memory.data.ProcessMemoryDBTable;\r
+import org.tizen.dynamicanalyzer.ui.toolbar.Toolbar;\r
+import org.tizen.dynamicanalyzer.ui.widgets.table.DATableDataFormat;\r
+import org.tizen.dynamicanalyzer.ui.widgets.table.DATreeComposite;\r
 import org.tizen.dynamicanalyzer.ui.widgets.table.DefaultTableComparator;\r
 import org.tizen.dynamicanalyzer.ui.widgets.table.TableColumnSizePackListener;\r
+import org.tizen.dynamicanalyzer.util.Logger;\r
 \r
-public class MemoryDetailsTable extends DATableComposite {\r
+public class MemoryDetailsTable extends DATreeComposite {\r
 \r
        private int[] columnSizes = { 200, 90, 90, 90, 90, 90, 90 };\r
-       private boolean[] columnVisibility = { false, false, false, false, false, false, false };\r
-       private int[] columnAlignment = { SWT.LEFT, SWT.LEFT, SWT.LEFT, SWT.LEFT, 
-                       SWT.LEFT, SWT.LEFT, SWT.LEFT };
+       private boolean[] columnVisibility = { true, true, true, true, true, true, true };\r
+       private int[] columnAlignment = { SWT.LEFT, SWT.RIGHT, SWT.RIGHT, SWT.RIGHT, 
+                       SWT.RIGHT, SWT.RIGHT, SWT.RIGHT };\r
+       \r
+       private int keyindex = 0;
        
        private String[] columnNames = { 
                        MemoryPageLabels.MEMORY_DETAILS_VIEW_ITEM,
@@ -28,10 +70,10 @@ public class MemoryDetailsTable extends DATableComposite {
                        MemoryPageLabels.MEMORY_DETAILS_VIEW_MAX
        };
        
-       int[] sortTypes = { AnalyzerConstants.SORT_TYPE_STRING, AnalyzerConstants.SORT_TYPE_NUM,
-                       AnalyzerConstants.SORT_TYPE_NUM, AnalyzerConstants.SORT_TYPE_NUM,
-                       AnalyzerConstants.SORT_TYPE_NUM, AnalyzerConstants.SORT_TYPE_NUM,
-                       AnalyzerConstants.SORT_TYPE_NUM
+       int[] sortTypes = { AnalyzerConstants.SORT_TYPE_NONE, AnalyzerConstants.SORT_TYPE_NONE,
+                       AnalyzerConstants.SORT_TYPE_NONE, AnalyzerConstants.SORT_TYPE_NONE,
+                       AnalyzerConstants.SORT_TYPE_NONE, AnalyzerConstants.SORT_TYPE_NONE,
+                       AnalyzerConstants.SORT_TYPE_NONE
        };\r
 \r
        public MemoryDetailsTable(Composite parent, int style, int tableStyle) {\r
@@ -42,6 +84,7 @@ public class MemoryDetailsTable extends DATableComposite {
                setTableName(MemoryPageLabels.MEMORY_DETAILS_VIEW_TITLE);\r
                setComparator(new DefaultTableComparator());\r
 \r
+               setTree(true);\r
                setSortTypes(sortTypes);\r
                setColumnAlignment(columnAlignment);\r
                setColumns(columnNames);\r
@@ -50,18 +93,367 @@ public class MemoryDetailsTable extends DATableComposite {
                \r
                setTableToolTipEnable(false);\r
                \r
-               comparator.setType(AnalyzerConstants.SORT_TYPE_NUM);\r
+               comparator.setType(AnalyzerConstants.SORT_TYPE_NONE);\r
                comparator.setColumn(0);\r
                \r
                parent.addControlListener(new TableColumnSizePackListener(this, columnSizes));\r
+               \r
+               table.addListener(SWT.Expand, new Listener() {\r
+\r
+                       @Override\r
+                       public void handleEvent(Event event) {\r
+                               GridItem item = (GridItem) event.item;\r
+                               setExpand(item, true);\r
+                       }\r
+               });\r
+\r
+               table.addListener(SWT.Collapse, new Listener() {\r
+                       @Override\r
+                       public void handleEvent(Event event) {\r
+                               GridItem item = (GridItem) event.item;\r
+                               setExpand(item, false);\r
+                       }\r
+               });\r
+               \r
+               table.addMouseListener(new MouseListener() {\r
+\r
+                       @Override\r
+                       public void mouseUp(MouseEvent e) {\r
+                               // do nothing\r
+                       }\r
+\r
+                       @Override\r
+                       public void mouseDown(MouseEvent e) {\r
+                               // do nothing\r
+                       }\r
+\r
+                       @Override\r
+                       public void mouseDoubleClick(MouseEvent e) {\r
+                               GridItem[] items = (GridItem[]) table.getSelection();\r
+                               if (null == items || items.length == 0) {\r
+                                       return;\r
+                               }\r
+                               GridItem item = items[0];\r
+                               if (item.isExpanded()) {\r
+                                       setExpand(item, false);\r
+                               } else {\r
+                                       setExpand(item, true);\r
+                               }\r
+                               updateTree();\r
+                       }\r
+               });\r
        }\r
 \r
        @Override\r
-       protected List<TableInput> makeTableInput() {\r
-               // TODO Auto-generated method stub\r
-               return null;\r
+       public List<TreeInput> makeTreeInput() {\r
+               List<TreeInput> output = new ArrayList<TreeInput>();\r
+               \r
+               if(Global.getProject() == null) {\r
+                       return output;\r
+               }\r
+               List<Integer> pidlist = new ArrayList<Integer>();\r
+               keyindex = 0;\r
+               \r
+               int[] pids = Global.getProject().getProcessIDs();\r
+               int targetPID = Toolbar.INSTANCE.getSelectedPid();\r
+               \r
+               if(targetPID > 0) {\r
+                       pidlist.add(targetPID);\r
+               }\r
+               else {\r
+                       for (int i = 0; i < pids.length; i++) {\r
+                               pidlist.add(pids[i]);\r
+                       }       \r
+               }\r
+               \r
+               TreeInput systemMemdata = makeSystemMemory();\r
+               output.add(systemMemdata);\r
+               \r
+               for(int i = 0 ; i < pidlist.size() ; i++) {\r
+                       try {\r
+                               TreeInput processMemdata = makeprocessMemory(pidlist.get(i));                   \r
+                               \r
+                               if(processMemdata != null) {\r
+                                       output.add(processMemdata);\r
+                               }\r
+                       }\r
+                       catch (Exception ex){\r
+                               Logger.error("Process memory is invaild.");\r
+                       }\r
+                       \r
+                       try {\r
+                               TreeInput heapdata = makeHeapData(pidlist.get(i));\r
+                               \r
+                               if(heapdata != null) {\r
+                                       output.add(heapdata);\r
+                               }\r
+                       }\r
+                       catch (Exception ex){\r
+                               Logger.error("Heap memory is invaild.");\r
+                       }\r
+               }\r
+               \r
+               return output;\r
+       }\r
+       \r
+       private TreeInput makeSystemMemory() {          \r
+               List<Long> memorylist = MemoryDataManager.getInstance().getSystemMemoryMinMaxFromDB(0, 0);\r
+               \r
+               List<Long> sorteddata = SortMemoryData(memorylist);\r
+               \r
+               DATableDataFormat tableData = new DATableDataFormat(keyindex++);\r
+               tableData.setObject("SystemMemory");\r
+\r
+               List<String> text = new ArrayList<String>();\r
+               List<Object> data = new ArrayList<Object>();\r
+               \r
+               text.add("System (Used KB)");\r
+               \r
+               for(int i = 0 ; i < sorteddata.size() ; i++) {\r
+                       text.add(String.format("%,d", sorteddata.get(i) / 1024));\r
+                       data.add(sorteddata.get(i));\r
+               }\r
+               \r
+               TreeInput output = new TreeInput();\r
+               output.setText(text);\r
+               tableData.getData().addAll(data);\r
+               output.setData(tableData);\r
+               output.setParent("SystemMemory");\r
+               \r
+               return output;\r
+       }\r
+\r
+       private TreeInput makeprocessMemory(int targetID) {\r
+               DATableDataFormat tableData = new DATableDataFormat(keyindex++);\r
+               String parentString = String.format("Process #%s (Total KB)", targetID);\r
+               \r
+               tableData.setObject(parentString);\r
+               \r
+               TreeInput output = new TreeInput();\r
+               List<String> text = new ArrayList<String>();\r
+               List<Object> data = new ArrayList<Object>();\r
+               \r
+               String tablename = ProcessMemoryDBTable.getTablename();         \r
+               String timeString = ProcessMemoryDBTable.SAMPLING_TIME;\r
+               \r
+               // These columns will be changed to 'memps' data.\r
+               String columnNamePSS = ProcessMemoryDBTable.MEMORY_PSS;\r
+               String columnNameRSS = ProcessMemoryDBTable.MEMORY_RESIDENT;\r
+               String columnNameVSS = ProcessMemoryDBTable.MEMORY_VIRTUAL;\r
+               \r
+               // This data will be changed to Total data.\r
+               List<Long> processPSS = \r
+                               MemoryDataManager.getInstance().getColumnLongFromDB(tablename, columnNamePSS, timeString, targetID, 0, 0);\r
+               \r
+               if(processPSS.size() == 0) {\r
+                       return null;\r
+               }\r
+               \r
+               List<Long> sorteddataPSS = SortMemoryData(processPSS);\r
+                       \r
+               text.add(parentString);\r
+               data.add(targetID);\r
+                       \r
+               for(int i = 0 ; i < sorteddataPSS.size() ; i++) {\r
+                       text.add(String.format("%,d", sorteddataPSS.get(i) / 1024));\r
+                       data.add(sorteddataPSS.get(i));\r
+               }\r
+               \r
+               output.setText(text);\r
+               tableData.getData().addAll(data);\r
+               output.setData(tableData);\r
+               output.setParent(parentString);\r
+               \r
+               // Make children data\r
+               List<Long> processRSS = \r
+                               MemoryDataManager.getInstance().getColumnLongFromDB(tablename, columnNameRSS, timeString, targetID, 0, 0);\r
+               List<Long> processVSS = \r
+                               MemoryDataManager.getInstance().getColumnLongFromDB(tablename, columnNameVSS, timeString, targetID, 0, 0);                      \r
+               \r
+               List<Long> sorteddataRSS = SortMemoryData(processRSS);\r
+               List<Long> sorteddataVSS = SortMemoryData(processVSS);\r
+               \r
+               Map<String, List<Long>> childrenDataMap = new HashMap<String, List<Long>>();\r
+               \r
+               childrenDataMap.put("RSS", sorteddataRSS);\r
+               childrenDataMap.put("VSS", sorteddataVSS);\r
+               \r
+               for(Map.Entry<String, List<Long>> entry : childrenDataMap.entrySet()) {\r
+                       makeChildTree(entry.getValue(), output, entry.getKey(), parentString);\r
+               }\r
+               \r
+               return output;\r
+       }\r
+       \r
+       private TreeInput makeHeapData(int targetID) {\r
+               List<List<Object>> processDataList = null;\r
+               Long start = (long) 0;\r
+               Long end = (long) 0;\r
+               \r
+               DATableDataFormat tableData = new DATableDataFormat(keyindex++);\r
+               String parentString = "Heap (Total KB)";\r
+               \r
+               tableData.setObject(parentString);\r
+               \r
+               TreeInput output = new TreeInput();\r
+               List<String> text = new ArrayList<String>();\r
+               List<Object> data = new ArrayList<Object>();\r
+               \r
+               processDataList = MemoryDataManager.getInstance().getTargetProcessDataFromDB(start, end, targetID);\r
+               \r
+               if(processDataList.size() == 0)\r
+                       return null;\r
+               \r
+               Map<String, List<Long>> sortedheapdata = sortHeapData(processDataList);\r
+               \r
+               for(Map.Entry<String, List<Long>> entry : sortedheapdata.entrySet()) {\r
+                       if( entry.getKey() == "AllHeapSize" ) {\r
+                               List<Long> parentsdata = entry.getValue();\r
+                               \r
+                               text.add(parentString);\r
+                               data.add(targetID);\r
+                                       \r
+                               for(int i = 0 ; i < parentsdata.size() ; i++) {\r
+                                       text.add(String.format("%,d", parentsdata.get(i) / 1024));\r
+                                       data.add(parentsdata.get(i));\r
+                               }\r
+                               \r
+                               output.setText(text);\r
+                               tableData.getData().addAll(data);\r
+                               output.setData(tableData);\r
+                               output.setParent(parentString);\r
+                       }\r
+                       else {\r
+                               makeChildTree(entry.getValue(), output, entry.getKey(), parentString);\r
+                       }\r
+               }\r
+               return output;\r
+       }\r
+       \r
+       private void makeChildTree(List<Long> childdata, TreeInput parent, String childName, String parentName) {               \r
+               DATableDataFormat tableData = new DATableDataFormat(keyindex++);\r
+               tableData.setObject(childName);\r
+               \r
+               TreeInput output = new TreeInput();\r
+               \r
+               List<String> text = new ArrayList<String>();\r
+               List<Object> data = new ArrayList<Object>();\r
+               \r
+               text.add(childName);\r
+               data.add(childName);\r
+                       \r
+               for(int i = 0 ; i < childdata.size() ; i++) {\r
+                       text.add(String.format("%,d", childdata.get(i) / 1024));\r
+                       data.add(childdata.get(i));\r
+               }\r
+               \r
+               output.setText(text);\r
+               tableData.getData().addAll(data);\r
+               output.setData(tableData);\r
+               \r
+               parent.getChildren().add(output);\r
+               output.setParent(parentName);\r
        }\r
        \r
+       private List<Long> SortMemoryData(List<Long> memorylist) {\r
+               List<Long> output = new ArrayList<Long> ();\r
+               \r
+               Long start = memorylist.get(0);\r
+               Long end = memorylist.get(memorylist.size() - 1);\r
+               Long min = memorylist.get(0);\r
+               Long max = memorylist.get(0);\r
+               \r
+               for(int i = 1; i < memorylist.size() ; i++) {\r
+                       if(min > memorylist.get(i))\r
+                               min = memorylist.get(i);\r
+                       else if(max < memorylist.get(i))\r
+                               max = memorylist.get(i);\r
+               }\r
+               \r
+               output.add((long) 0); // current\r
+               output.add(start);\r
+               output.add(end);\r
+               output.add(end - start); // delta\r
+               output.add(min);\r
+               output.add(max);\r
+               \r
+               return output;\r
+       }\r
+       \r
+       private Map<String, List<Long>> sortHeapData(List<List<Object>> processDataList) {\r
+               Map<String, List<Long>> output = new HashMap<String, List<Long>>();\r
+               output.put("AllHeapSize", new ArrayList<Long>());\r
+               \r
+               Map<Integer, List<Long>> heapdata = new HashMap<Integer, List<Long>>();\r
+               Project project = Global.getProject();\r
+               \r
+               for(int k = 0 ; k < processDataList.size() ; k++) {\r
+                       List<Object> processData = processDataList.get(k);\r
+                       // 9 : HEAP_ALLOCATION_BINARY_ID\r
+                       List<Object> binaryIDList =  cast(processData.get(9));\r
+                       \r
+                       // 10 : allocated size by libraries\r
+                       List<Object> allocByteList = cast(processData.get(10));\r
+                       \r
+                       for(int i = 0; i < binaryIDList.size() ; i++) {\r
+                               Integer binaryID = (Integer) binaryIDList.get(i);\r
+                               Long allocByte = (Long) allocByteList.get(i);\r
+                               \r
+                               if(!heapdata.containsKey(binaryID)) {\r
+                                       heapdata.put(binaryID, new ArrayList<Long>());\r
+                                       heapdata.get(binaryID).add(allocByte);\r
+                               }\r
+                               else {\r
+                                       heapdata.get(binaryID).add(allocByte);\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               for(Map.Entry<Integer, List<Long>> entry : heapdata.entrySet()) {\r
+                       int binaryId = entry.getKey();\r
+                       String libname;\r
+                       \r
+                       // -10 == target application\r
+                       if(binaryId == -10) {\r
+                               libname = MemoryPageLabels.MEMORY_MAIN_EXCUTABLE;\r
+                       }\r
+                       else {\r
+                               BinaryInfo binaryInfo = project.getDeviceStatusInfo().getBinaryInfo(binaryId);\r
+                               \r
+                               if(binaryInfo == null) {\r
+                                       libname = "Unknown";\r
+                               }\r
+                               else {\r
+                                       libname = binaryInfo.getTargetBinaryPath();\r
+                               }\r
+                       }\r
+                       \r
+                       output.put(libname, SortMemoryData(entry.getValue()));\r
+               }\r
+               \r
+               List<Long> allheapsize = new ArrayList<Long>();\r
+               \r
+               for(int i = 0; i < 6; i++) {\r
+                       allheapsize.add((long)0);\r
+               }\r
+               \r
+               for(Map.Entry<String, List<Long>> entry : output.entrySet()) {\r
+                       for(int i = 0 ; i < entry.getValue().size() ; i++){\r
+                               Long sumsize = allheapsize.get(i) + entry.getValue().get(i);\r
+                               allheapsize.set(i, sumsize);\r
+                       }\r
+               }\r
+               \r
+               output.put("AllHeapSize", allheapsize);\r
+               \r
+               return output;\r
+       }\r
+       \r
+       @SuppressWarnings("unchecked")\r
+       private static <T extends List<?>> T cast(Object obj) {\r
+           return (T) obj;\r
+       }\r
+               \r
        public void removeSelection() {\r
                table.removeAll();\r
                updateTable();\r
index 172f343..bbb356f 100755 (executable)
@@ -81,45 +81,6 @@ public class MemoryStatisticsTable extends DATableComposite {
                setColumnVisibility(columnVisibility);\r
                \r
                parent.addControlListener(new TableColumnSizePackListener(this, columnSizes));\r
-               \r
-               table.addSelectionListener(new SelectionListener() {\r
-\r
-                       @Override\r
-                       public void widgetSelected(SelectionEvent e) {\r
-\r
-                               GridItem[] items = table.getSelection();\r
-                               if (null == items) {\r
-                                       return;\r
-                               }\r
-                               long startTime = 0;\r
-                               long endTime = 0;\r
-\r
-                               DATableDataFormat dataFormat = null;\r
-                               long itemTime;\r
-                               for (int i = 0; i < items.length; i++) {\r
-                                       dataFormat = (DATableDataFormat) items[i].getData();\r
-                                       itemTime = dataFormat.getLogData().getTime();\r
-                                       if (0 == startTime) {\r
-                                               startTime = itemTime;\r
-                                       }\r
-                                       if (startTime > itemTime) {\r
-                                               startTime = itemTime;\r
-                                       }\r
-                                       if (endTime < itemTime) {\r
-                                               endTime = itemTime;\r
-                                       }\r
-                               }\r
-                               DASelectionData selData = new DASelectionData(MemoryStatisticsTableView.ID, startTime,\r
-                                               endTime, items, table);\r
-\r
-                               AnalyzerManager.getCurrentPage().updateView(selData);\r
-                       }\r
-\r
-                       @Override\r
-                       public void widgetDefaultSelected(SelectionEvent e) {\r
-                               // TODO Auto-generated method stub\r
-                       }\r
-               });\r
        }\r
 \r
        @Override\r
@@ -242,7 +203,7 @@ public class MemoryStatisticsTable extends DATableComposite {
                String libname = path;\r
                \r
                if(path == Global.getCurrentApplication().getMainApp().getExecPath()) {\r
-                       libname = "Main Executable";\r
+                       libname = MemoryPageLabels.MEMORY_MAIN_EXCUTABLE;\r
                }\r
                \r
                text.add(libname);\r