From: woojin Date: Tue, 17 Jun 2014 02:57:24 +0000 (+0900) Subject: Thread Analysis : thread items are now sorted by tid in thread chart X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F67%2F23067%2F1;p=sdk%2Ftools%2Fdynamic-analyzer.git Thread Analysis : thread items are now sorted by tid in thread chart Thread items in Thread chart are sorted by tid both in thread chart mode and sync chart mode Change-Id: I828ff43274255fe40680b2c6c57cc771e8b157e1 Signed-off-by: woojin --- diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chartBoard/DAChartBoard.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chartBoard/DAChartBoard.java index eb68590..2f1e64a 100644 --- a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chartBoard/DAChartBoard.java +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chartBoard/DAChartBoard.java @@ -28,6 +28,7 @@ package org.tizen.dynamicanalyzer.widgets.chartBoard; import java.util.ArrayList; +import java.util.Comparator; import java.util.List; import org.eclipse.jface.window.DefaultToolTip; @@ -503,6 +504,14 @@ public class DAChartBoard extends Composite { int listHeight = itemList.getListHeight(); itemList.setSize(itemListScrollComp.getClientArea().width, listHeight); } + // for sorting of chart items + protected void registerItem(DAChartBoardItem item, + Comparator c) { + itemList.registerItem(item, c); + + int listHeight = itemList.getListHeight(); + itemList.setSize(itemListScrollComp.getClientArea().width, listHeight); + } public DAChartBoardItemList getItemList() { return itemList; diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chartBoard/DAChartBoardItem.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chartBoard/DAChartBoardItem.java index 85d7812..ec7b0e1 100644 --- a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chartBoard/DAChartBoardItem.java +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chartBoard/DAChartBoardItem.java @@ -26,6 +26,7 @@ */ package org.tizen.dynamicanalyzer.widgets.chartBoard; +import java.util.Comparator; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Font; import org.eclipse.swt.graphics.Image; @@ -49,6 +50,7 @@ public class DAChartBoardItem extends Composite { public final static int DEFAULT_NAME_CELL_WIDTH = 102; private int depth = 0; + private Object sortObj = null; private void initWidget(String name, Image icon, int chartStyle) { heightRatio = getBoardItemHeightRatio(); @@ -72,6 +74,15 @@ public class DAChartBoardItem extends Composite { initWidget(itemName, null, DAChart.CHART_STYLE_NORMAL); parentBoard.registerItem(this); } + // for sorting of chart items + public DAChartBoardItem(DAChartBoard parent, String itemName, + Object o, Comparator c) { + super(parent.getItemList(), SWT.NONE); + parentBoard = parent; + sortObj = o; + initWidget(itemName, null, DAChart.CHART_STYLE_NORMAL); + parentBoard.registerItem(this, c); + } public DAChartBoardItem(DAChartBoard parent, String itemName, Image icon, int chartStyle) { @@ -88,6 +99,16 @@ public class DAChartBoardItem extends Composite { initWidget(itemName, null, DAChart.CHART_STYLE_NORMAL); parentItem.registerItem(this); } + // for sorting of chart items + public DAChartBoardItem(DAChartBoardItem parent, String itemName, + Object o, Comparator c) { + super(parent.getChildItemList(), SWT.NONE); + parentItem = parent; + depth = parent.getDepth() + 1; + sortObj = o; + initWidget(itemName, null, DAChart.CHART_STYLE_NORMAL); + parentItem.registerItem(this, c); + } public DAChartBoardItem(DAChartBoardItem parent, String itemName, Image icon, int chartStyle) { @@ -167,7 +188,20 @@ public class DAChartBoardItem extends Composite { callNotifyResizeChild(); } + // for sorting of chart items + private void registerItem(DAChartBoardItem child, Comparator c) { + if (childItemList.getItemSize() == 0) { + itemCell.addChildFoldToggleButton(); + } + childItemList.registerItem(child, c); + FormData childDListata = (FormData) childItemList.getLayoutData(); + childDListata.height = childItemList.getListHeight(); + childItemList.setLayoutData(childDListata); + + callNotifyResizeChild(); + } + void foldChild() { childFolded = true; @@ -396,4 +430,8 @@ public class DAChartBoardItem extends Composite { public DAChartBoard getChartBoard() { return parentBoard; } + + public Object getSortObject() { + return sortObj; + } } diff --git a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chartBoard/DAChartBoardItemList.java b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chartBoard/DAChartBoardItemList.java index 5f1f92f..426947b 100644 --- a/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chartBoard/DAChartBoardItemList.java +++ b/org.tizen.dynamicanalyzer.widgets/src/org/tizen/dynamicanalyzer/widgets/chartBoard/DAChartBoardItemList.java @@ -29,6 +29,8 @@ package org.tizen.dynamicanalyzer.widgets.chartBoard; import java.util.ArrayList; import java.util.List; +import java.util.Comparator; +import java.util.Collections; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FormAttachment; @@ -69,7 +71,40 @@ public class DAChartBoardItemList extends Composite { childItems.add(item); this.layout(); } + // for sorting of chart items + public void registerItem(DAChartBoardItem item, Comparator c) { + int itemHeight = (int) (DAChartBoard.DEFAULT_ITEM_HEIGHT * getBoardItemHeightRatio()); + FormData data = new FormData(); + int itemSize = childItems.size(); + if (0 == itemSize) { + data.top = new FormAttachment(0, 0); + } else { + data.top = new FormAttachment(childItems.get(itemSize - 1), 0); + } + data.left = new FormAttachment(0, 0); + data.right = new FormAttachment(100, 0); + + data.height = itemHeight; + item.setLayoutData(data); + + childItems.add(item); + + Collections.sort(childItems, c); + itemSize = childItems.size(); + // readjust top position of each items after sorting + for(int i = 0; i < itemSize; i++) { + FormData formdata = (FormData) childItems.get(i).getLayoutData(); + if (i == 0) { + formdata.top = new FormAttachment(0, 0); + } else { + formdata.top = new FormAttachment(childItems.get(i - 1), 0); + } +// childItems.get(i).setLayoutData(formdata); + } + this.layout(); + } + public int getListHeight() { int listHeight = 0; for(DAChartBoardItem childItem : childItems) { @@ -222,6 +257,11 @@ public class DAChartBoardItemList extends Composite { } return childItems.get(index); } + + public void sort(Comparator c) { + Collections.sort(childItems, c); + return; + } protected int getItemYPos(int index) { int pos = 0; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/thread/sync/ThreadPageSyncDataManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/thread/sync/ThreadPageSyncDataManager.java index fb23cc3..6bb1451 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/thread/sync/ThreadPageSyncDataManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/thread/sync/ThreadPageSyncDataManager.java @@ -4,6 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: + * WooJin Jung * yeongtaik byeon * Juyoung Kim * @@ -28,6 +29,7 @@ package org.tizen.dynamicanalyzer.ui.thread.sync; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Comparator; import org.tizen.dynamicanalyzer.constant.CommonConstants; import org.tizen.dynamicanalyzer.logparser.LogCenterConstants; @@ -420,6 +422,37 @@ public class ThreadPageSyncDataManager { chart.redraw(); return true; } + // for sorting of child item of sync chart + private boolean createSyncBoardItem(ThreadPageSyncData parent, + ThreadPageSyncData sync, Comparator c) { + DAChartBoardItem item; + DAChart chart; + Integer tid = Integer.valueOf(sync.getTid()); + + if (null == parent) { + item = new DAChartBoardItem(board, sync.getType() + + ThreadPageLabels.THREAD_CHART_NAME_PREFIX + + ThreadPageLabels.THREAD_CHART_NAME_OBJ + sync.getKey() + + ThreadPageLabels.THREAD_CHART_NAME_POSTFIX); + item.useExpand(true); + chart = item.getChart(); + initSyncChart(chart, true); + } else { + DAChartBoardItem parentItem = parent.getItem(); + item = new DAChartBoardItem(parentItem, + ThreadPageLabels.THREAD_CHART_NAME_TID + + sync.getTid(), tid, c); + item.useExpand(true); + chart = item.getChart(); + initSyncChart(chart, false); + } + + sync.setItem(item); + item.setData(sync); + chart.setData(sync); + chart.redraw(); + return true; + } private void chartFilteringByPid() { if(null == board || null == board.getItemList()){ @@ -505,7 +538,15 @@ public class ThreadPageSyncDataManager { return pid; } - + private int getSortObject(DAChartBoardItem item) { + Object sortObj = item.getSortObject(); + if (sortObj instanceof Integer) { + return (Integer) sortObj; + } else { // should never go here + return -1; + } + } + public void checkUpdate() { chartFilteringByPid(); @@ -546,7 +587,13 @@ public class ThreadPageSyncDataManager { getSyncTypeString(event.getType()), syncVal, pid, event.getTid(), attrType); parent.pushSync(data); - createSyncBoardItem(parent, data); + createSyncBoardItem(parent, data, + new Comparator() { + public int compare(DAChartBoardItem item1, + DAChartBoardItem item2) { + return getSortObject(item1) - getSortObject(item2); + } + }); } data.pushEvent(event); syncEventQueue.remove(0); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/thread/thread/ThreadPageThreadDataManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/thread/thread/ThreadPageThreadDataManager.java index dc4e122..6180957 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/thread/thread/ThreadPageThreadDataManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/thread/thread/ThreadPageThreadDataManager.java @@ -4,6 +4,7 @@ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved. * * Contact: + * WooJin Jung * yeongtaik byeon * Juyoung Kim * @@ -28,6 +29,7 @@ package org.tizen.dynamicanalyzer.ui.thread.thread; import java.util.ArrayList; import java.util.HashMap; import java.util.List; +import java.util.Comparator; import org.tizen.dynamicanalyzer.common.AnalyzerManager; import org.tizen.dynamicanalyzer.constant.CommonConstants; @@ -53,7 +55,6 @@ import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseEventListener; import org.tizen.dynamicanalyzer.ui.common.TimelineChartMouseTrackAdapter; import org.tizen.dynamicanalyzer.ui.summary.SummaryDataManager; import org.tizen.dynamicanalyzer.ui.summary.warning.WarningCase; -import org.tizen.dynamicanalyzer.ui.summary.warning.WarningData; import org.tizen.dynamicanalyzer.ui.thread.ThreadPageData; import org.tizen.dynamicanalyzer.ui.thread.sync.ThreadPageSyncData; import org.tizen.dynamicanalyzer.ui.thread.sync.ThreadPageSyncDataEvent; @@ -140,7 +141,32 @@ public class ThreadPageThreadDataManager { chart.setData(data); chart.redraw(); } + // for sorting of thread chart item + private void createBoardItem(ThreadPageThreadData data, + Comparator c) { + // DACustomChartBoardItem item = new DACustomChartBoardItem(board, + // data.getName()); + Integer tid = Integer.valueOf(data.getTid()); + + DAChartBoardItem item = new DAChartBoardItem(board, data.getType() + + ThreadPageLabels.THREAD_CHART_NAME_PREFIX + + ThreadPageLabels.THREAD_CHART_NAME_PID + data.getPid() + + ThreadPageLabels.THREAD_CHART_NAME_COMMA + + ThreadPageLabels.THREAD_CHART_NAME_TID + data.getKey() + + ThreadPageLabels.THREAD_CHART_NAME_POSTFIX, tid, c); + + item.useExpand(true); + DAChart chart = item.getChart(); + setChartSeries(chart); + + setChartStyle(chart); + data.setItem(item); + item.setData(data); + chart.setData(data); + chart.redraw(); + } + private void initSyncChart(DAChart chart) { if (null == chart) { return; @@ -1178,8 +1204,16 @@ public class ThreadPageThreadDataManager { } return pid; } - - +// TODO: syncDataManager has same method : move this method to proper class + private int getSortObject(DAChartBoardItem item) { + Object sortObj = item.getSortObject(); + if (sortObj instanceof Integer) { + return (Integer) sortObj; + } else { // should never go here + return -1; + } + } + public void checkUpdate() { if (false == hasUpdate && preSelectionPid == @@ -1194,7 +1228,13 @@ public class ThreadPageThreadDataManager { ThreadPageThreadData data; for (int i = 0; i < size; i++) { data = rowsQueue.get(0); - createBoardItem(data); + // sort chart items at each insertion + createBoardItem(data, new Comparator() { + public int compare(DAChartBoardItem item1, + DAChartBoardItem item2) { + return getSortObject(item1) - getSortObject(item2); + } + }); rows.add(data); rowsQueue.remove(0); }