From: yeongtaik.byeon Date: Tue, 17 Jul 2012 10:35:11 +0000 (+0900) Subject: [Title]thread page chart item add X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=316c0bdcef9b60ad55bc2f3ded4d9f7188d38d14;p=sdk%2Ftools%2Fdynamic-analyzer.git [Title]thread page chart item add [Type]feature [Module]thread page [Priority]high [CQ#] [Redmine#]5322 [Problem] [Cause] [Solution] [TestCase] --- diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/CommonPageLables.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/CommonPageLables.java index 21c459e..b971c9b 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/CommonPageLables.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/CommonPageLables.java @@ -4,6 +4,7 @@ import org.eclipse.osgi.util.NLS; public class CommonPageLables extends NLS { private static final String BUNDLE_NAME = "org.tizen.dynamicanalyzer.nl.CommonPageLables"; //$NON-NLS-1$ + public static String COMMON_DATA_COLUMN_KEY; public static String COMMON_DATA_COLUMN_NUMBER; public static String COMMON_DATA_COLUMN_TIME; public static String COMMON_DATA_COLUMN_NAME; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/CommonPageLables.properties b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/CommonPageLables.properties index 76e50d5..7692614 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/CommonPageLables.properties +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/CommonPageLables.properties @@ -1,3 +1,4 @@ +COMMON_DATA_COLUMN_KEY=Key COMMON_DATA_COLUMN_NUMBER=# COMMON_DATA_COLUMN_TIME=Time COMMON_DATA_COLUMN_NAME=Name diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/pageInfo/PageChartGraphItem.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/pageInfo/PageChartGraphItem.java new file mode 100644 index 0000000..851ece0 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/pageInfo/PageChartGraphItem.java @@ -0,0 +1,48 @@ +package org.tizen.dynamicanalyzer.ui.views.pageInfo; + +import org.eclipse.swt.graphics.Color; + +public class PageChartGraphItem { + private String name; + private int PageDataItemIndex; + private long time; + private Color eventColor; + + public PageChartGraphItem(int PageDataItemIndex, long time, Color eventColor) { + this.PageDataItemIndex = PageDataItemIndex; + this.time = time; + this.eventColor = eventColor; + } + + public int getPageDataItemIndex() { + return PageDataItemIndex; + } + + public void setPageDataItemIndex(int pageDataItemIndex) { + PageDataItemIndex = pageDataItemIndex; + } + + public Color getEventColor() { + return eventColor; + } + + public void setEventColor(Color eventColor) { + this.eventColor = eventColor; + } + + public long getTime() { + return time; + } + + public void setTime(long time) { + this.time = time; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/pageInfo/PageChartItem.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/pageInfo/PageChartItem.java new file mode 100644 index 0000000..9a82332 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/pageInfo/PageChartItem.java @@ -0,0 +1,92 @@ +package org.tizen.dynamicanalyzer.ui.views.pageInfo; + +import java.util.ArrayList; +import java.util.List; + +import org.tizen.dynamicanalyzer.ui.widgets.DAPageChart.DAPageChart; + +public class PageChartItem { + private String text; + private DAPageChart chart = null; + private PageChartItem parent = null; + private List children = new ArrayList(); + private List graphItems = new ArrayList(); + + public PageChartItem(DAPageChart chart, String text) { + // super(chart, SWT.NONE); + // TODO Auto-generated constructor stub + this.chart = chart; + this.text = text; + } + + public PageChartItem(DAPageChart chart, String text, + PageChartGraphItem praphItem) { + this(chart, text); + + // TODO Auto-generated constructor stub + graphItems.add(praphItem); + } + + public String GetText() { + return text; + } + + public void SetText(String text) { + this.text = text; + } + + public DAPageChart GetChart() { + return chart; + } + + public PageChartItem GetParent() { + return parent; + } + + public PageChartItem AddChild(PageChartItem child) { + children.add(child); + child.parent = this; + PageChartItem parent = this.parent; + while (null != parent) { + parent.AddGraphItems(child.GetGraphItem()); + parent = parent.parent; + } + // FIXME : redraw + // chart.printItems(); + return this; + } + + public List GetChildren() { + return children; + } + + public List GetGraphItem() { + return graphItems; + } + + public void AddGraphItem(PageChartGraphItem item) { + int i; + for (i = graphItems.size(); i > 0; i--) { + if (graphItems.get(i - 1).getTime() <= item.getTime()) + break; + } + graphItems.add(i, item); + + PageChartItem parent = this.parent; + while (null != parent) { + parent.AddGraphItem(item); + parent = parent.parent; + } + + // FIXME : redraw + // chart.printItems(); + } + + public void AddGraphItems(List items) { + for (int i = 0; i < items.size(); i++) { + AddGraphItem(items.get(i)); + } + // FIXME : redraw + // chart.printItems(); + } +} diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/pageInfo/PageDataManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/pageInfo/PageDataManager.java index 190584c..99a82a7 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/pageInfo/PageDataManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/pageInfo/PageDataManager.java @@ -3,26 +3,40 @@ package org.tizen.dynamicanalyzer.ui.views.pageInfo; import java.util.ArrayList; import java.util.List; -import org.eclipse.jface.viewers.TableViewer; +import org.tizen.dynamicanalyzer.ColorResources; import org.tizen.dynamicanalyzer.model.FailedData; -import org.tizen.dynamicanalyzer.model.FileChartItemData; import org.tizen.dynamicanalyzer.model.LogPackage; -import org.tizen.dynamicanalyzer.model.WarningData; -import org.tizen.dynamicanalyzer.ui.views.filePage.fileChart.FileChartManager; +import org.tizen.dynamicanalyzer.ui.widgets.DAPageChart.DAPageChart; public abstract class PageDataManager { - protected List rows = null; + protected List rows = new ArrayList(); protected PageDataColumn column = RegistePageDataColumn(); + // private List warning = null; protected List failed = null; - protected static int PAGE_COLUMN_NUMBER = 0; - protected static int PAGE_COLUMN_TIME = 1; - protected static int PAGE_COLUMN_NAME = 2; - protected static int PAGE_COLUMN_PARAMETER = 3; - protected static int PAGE_COLUMN_THREADID = 4; - protected static int PAGE_COLUMN_RETURN = 5; - protected static int PAGE_COLUMN_ERRNO = 6; + protected DAPageChart pageChart = null; + + private boolean useSecondKey = false; + private int secondKeyIndex = 0; + + protected static int PAGE_COLUMN_KEY = 0; + protected static int PAGE_COLUMN_NUMBER = 1; + protected static int PAGE_COLUMN_TIME = 2; + protected static int PAGE_COLUMN_NAME = 3; + protected static int PAGE_COLUMN_PARAMETER = 4; + protected static int PAGE_COLUMN_THREADID = 5; + protected static int PAGE_COLUMN_RETURN = 6; + protected static int PAGE_COLUMN_ERRNO = 7; + public void SetPageChart(DAPageChart pageChart){ + this.pageChart = pageChart; + } + + public void SetPageChart(DAPageChart pageChart, int secondKeyIndex){ + this.pageChart = pageChart; + this.useSecondKey = true; + this.secondKeyIndex = secondKeyIndex; + } private void AddErrorData(FailedData data){ if(null == failed) @@ -36,10 +50,9 @@ public abstract class PageDataManager { // warning.add(data); // } - protected void AddPageDataItem(PageDataItem data){ - if(null == rows) - rows = new ArrayList(); + protected int AddPageDataItem(PageDataItem data){ rows.add(data); + return rows.size()-1; } private int FindInsertIndex(PageDataItem data, int Index){ @@ -89,6 +102,59 @@ public abstract class PageDataManager { public void SetPageDataColumn(PageDataColumn column){ this.column = column; } + + private boolean isItemExist(PageChartItem item, String key){ //FIXME + if(null == item) + return false; + if(item.GetText().compareTo(key) == 0) + return true; + else + return false; + } + public void AddPageChartItem(PageDataItem dataItem, int itemIndex){ + List items = pageChart.GetItems(); + int itemSize = items.size(); + PageChartGraphItem graphItem = new PageChartGraphItem(itemIndex, Long.parseLong(dataItem.GetText(PAGE_COLUMN_TIME)), ColorResources.BLUE); + PageChartItem newItem; + + if(null != items && 0 != itemSize){ + for(int i=0;i children = item.GetChildren(); + int childrenSize = children.size(); + for(int j=0; j> inputs = GetLogsFromLogPackage(logPack); @@ -108,9 +174,14 @@ public abstract class PageDataManager { } //add page data - PageDataItem item = MakePageData(input); - AddPageDataItem(item); + PageDataItem item = MakePageData(input); + int itemIndex = AddPageDataItem(item); + //add page chart data + if(null!=pageChart){ + AddPageChartItem(item, itemIndex); + } + } } @@ -133,6 +204,14 @@ public abstract class PageDataManager { } } +// public void AddPageChartItem(PageDataItem item, int itemIndex){ +// //find key +// for(int i=0; i> GetLogsFromLogPackage(LogPackage logPack); public abstract PageDataItem MakePageData(List input); diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/threadPage/ThreadChartView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/threadPage/ThreadChartView.java index a7f7d38..00b3e0e 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/threadPage/ThreadChartView.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/threadPage/ThreadChartView.java @@ -1,5 +1,6 @@ package org.tizen.dynamicanalyzer.ui.views.threadPage; +import org.eclipse.swt.SWT; import org.eclipse.swt.layout.FillLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; @@ -8,9 +9,11 @@ import org.tizen.dynamicanalyzer.model.DAView; import org.tizen.dynamicanalyzer.model.LogPackage; import org.tizen.dynamicanalyzer.nl.ThreadPageLables; import org.tizen.dynamicanalyzer.ui.widgets.ViewContainer; +import org.tizen.dynamicanalyzer.ui.widgets.DAPageChart.DAPageChart; public class ThreadChartView extends DAView { public static final String ID = ThreadChartView.class.getName(); + private DAPageChart threadChart; public ThreadChartView(Composite parent, int style) { super(parent, style); @@ -21,6 +24,7 @@ public class ThreadChartView extends DAView { Composite contents = viewContainer.getContentArea(); contents.setBackground(ColorResources.WINDOW_BG_COLOR); contents.setLayout(new FillLayout()); + threadChart = new DAPageChart(contents, SWT.NONE); } @Override @@ -29,7 +33,6 @@ public class ThreadChartView extends DAView { @Override public void updateLog(LogPackage logPack) { - System.out.println("updateLog:"+ logPack); } @Override @@ -39,7 +42,7 @@ public class ThreadChartView extends DAView { @Override public Control getControl() { - return null; + return threadChart; } } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/threadPage/ThreadPage.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/threadPage/ThreadPage.java index bb8e4f0..c6b4cff 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/threadPage/ThreadPage.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/threadPage/ThreadPage.java @@ -8,12 +8,14 @@ import org.eclipse.swt.widgets.Composite; import org.tizen.dynamicanalyzer.constants.DesignConstants; import org.tizen.dynamicanalyzer.model.LogPackage; import org.tizen.dynamicanalyzer.ui.views.base.DAPageComposite; +import org.tizen.dynamicanalyzer.ui.widgets.DAPageChart.DAPageChart; public class ThreadPage extends DAPageComposite { public final static int THREADCHART_INDEX = 0; public final static int THREAD_API_LIST_INDEX = 1; public final static int INFO_VIEW_INDEX = 2; public final static int THREAD_DETAIL = 3; + private ThreadChartView threadChartView; // 10 : offset private final double DEFAULT_WIDTH = DesignConstants.SNAPSHOT_VIEW_WIDTH + 10; @@ -23,73 +25,23 @@ public class ThreadPage extends DAPageComposite { SashForm baseForm; SashForm leftForm; SashForm rightForm; - + ThreadPageDataManager tManager = ThreadPageDataManager.getInstance(); public ThreadPage(Composite parent, int style) { super(parent, style); - + this.setLayout(new FillLayout()); baseForm = new SashForm(this, SWT.HORIZONTAL); baseForm.setLayout(new FillLayout()); leftForm = new SashForm(baseForm, SWT.VERTICAL); // FILECHART_INDEX = 0; - ThreadChartView threadChartView = new ThreadChartView(leftForm, SWT.NONE); + threadChartView = new ThreadChartView(leftForm, SWT.NONE); addView(threadChartView); - /* - - // FILE_API_LIST_INDEX = 1; - FileApiListView fileApiListView = new FileApiListView(leftForm, - SWT.NONE); - addView(fileApiListView); - - leftForm.setWeights(new int[] { 60, 40 }); - - rightForm = new SashForm(baseForm, SWT.VERTICAL); - // INFO_VIEW_INDEX = 2; - DATabComposite tabView = new DATabComposite(rightForm, SWT.NONE); - addView(tabView); - { - CallstackView callstack = new CallstackView( - tabView.getContentComposite(), SWT.NONE); - tabView.addView(callstack, - InformationViewLables.CALLSTACK_VIEW_TITLE); - } - - // FILE_DETAIL = 3; - FileDetailInfoView detailInfo = new FileDetailInfoView(rightForm, - SWT.NONE); - addView(detailInfo); - - rightForm.setWeights(new int[] { 50, 50 }); - - baseForm.setWeights(new int[] { 75, 25 }); - - this.addControlListener(new ControlListener() { - - @Override - public void controlResized(ControlEvent e) { - Composite composite = (Composite) e.widget; - Rectangle rect = composite.getBounds(); - int pageWidth = rect.width; - int pageHeight = rect.height; - - int wRate = (int) (DEFAULT_WIDTH * 100 / pageWidth); - int hRate = (int) (DEFAULT_HEIGHT * 100 / pageHeight); - wRate = (wRate >= 100) ? 100 : wRate; - hRate = (hRate >= 100) ? 100 : hRate; - - baseForm.setWeights(new int[] { 100 - wRate, wRate }); - rightForm.setWeights(new int[] { hRate, 100 - hRate }); - } - - @Override - public void controlMoved(ControlEvent e) { - } - }); - */ + tManager.SetPageChart((DAPageChart) threadChartView.getControl()); } + public void updateLog(LogPackage logPack) { tManager.ParsePageData(logPack); } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/threadPage/ThreadPageDataManager.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/threadPage/ThreadPageDataManager.java index adfd280..4a23c31 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/threadPage/ThreadPageDataManager.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/views/threadPage/ThreadPageDataManager.java @@ -15,16 +15,20 @@ import org.tizen.dynamicanalyzer.utils.AnalyzerUtil; public class ThreadPageDataManager extends PageDataManager { private static ThreadPageDataManager instance = null; - private static int THREAD_PAGE_COLUMN_COUNT = 7; - - private static String[] columnNames = { CommonPageLables.COMMON_DATA_COLUMN_NUMBER, + private static int THREAD_PAGE_COLUMN_COUNT = 8; + + private static String[] columnNames = { + CommonPageLables.COMMON_DATA_COLUMN_KEY, + CommonPageLables.COMMON_DATA_COLUMN_NUMBER, CommonPageLables.COMMON_DATA_COLUMN_TIME, CommonPageLables.COMMON_DATA_COLUMN_NAME, CommonPageLables.COMMON_DATA_COLUMN_PARAMETER, CommonPageLables.COMMON_DATA_COLUMN_THREADID, CommonPageLables.COMMON_DATA_COLUMN_RETURN, CommonPageLables.COMMON_DATA_COLUMN_ERRNO }; - private static Integer[] columnAttribute = { PageDataColumn.COLUMN_ATTRIBUTE_LONG, + private static Integer[] columnAttribute = { + PageDataColumn.COLUMN_ATTRIBUTE_STRING, + PageDataColumn.COLUMN_ATTRIBUTE_LONG, PageDataColumn.COLUMN_ATTRIBUTE_TIME, PageDataColumn.COLUMN_ATTRIBUTE_STRING, PageDataColumn.COLUMN_ATTRIBUTE_STRING, @@ -39,13 +43,14 @@ public class ThreadPageDataManager extends PageDataManager { return instance; } - private ThreadPageDataManager(){ + private ThreadPageDataManager() { } @Override public PageDataColumn RegistePageDataColumn() { // TODO Auto-generated method stub - PageDataColumn pageColumn = new PageDataColumn(THREAD_PAGE_COLUMN_COUNT, columnNames, columnAttribute); + PageDataColumn pageColumn = new PageDataColumn( + THREAD_PAGE_COLUMN_COUNT, columnNames, columnAttribute); return pageColumn; } @@ -80,32 +85,43 @@ public class ThreadPageDataManager extends PageDataManager { public PageDataItem MakePageData(List input) { // TODO Auto-generated method stub PageDataItem data = new PageDataItem(column); - //number - data.SetText(PAGE_COLUMN_NUMBER, input.get(LogCenterConstants.SEQUENCE_NUMBER_INDEX)); - //time + // key(object address) + data.SetText(PAGE_COLUMN_KEY, + input.get(LogCenterConstants.RESOURCE_FDVALUE_INDEX)); + // number + data.SetText(PAGE_COLUMN_NUMBER, + input.get(LogCenterConstants.SEQUENCE_NUMBER_INDEX)); + // time data.SetText(PAGE_COLUMN_TIME, input.get(LogCenterConstants.TIME_INDEX)); - //name - data.SetText(PAGE_COLUMN_NAME, input.get(LogCenterConstants.APINAME_INDEX)); - //parameter - data.SetText(PAGE_COLUMN_PARAMETER, input.get(LogCenterConstants.INPUTPARM_INDEX)); - //thread id - data.SetText(PAGE_COLUMN_THREADID, input.get(LogCenterConstants.THREAD_ID_INDEX)); - //return - data.SetText(PAGE_COLUMN_RETURN, input.get(LogCenterConstants.RETURN_INDEX)); - //errno - data.SetText(PAGE_COLUMN_ERRNO, input.get(LogCenterConstants.ERROR_INDEX)); + // name + data.SetText(PAGE_COLUMN_NAME, + input.get(LogCenterConstants.APINAME_INDEX)); + // parameter + data.SetText(PAGE_COLUMN_PARAMETER, + input.get(LogCenterConstants.INPUTPARM_INDEX)); + // thread id + data.SetText(PAGE_COLUMN_THREADID, + input.get(LogCenterConstants.THREAD_ID_INDEX)); + // return + data.SetText(PAGE_COLUMN_RETURN, + input.get(LogCenterConstants.RETURN_INDEX)); + // errno + data.SetText(PAGE_COLUMN_ERRNO, + input.get(LogCenterConstants.ERROR_INDEX)); return data; } -// @Override -// public abstract PageChartDataItem MakePageChartData(PageDataItem){ //FIXME -//} + + // @Override + // public abstract PageChartDataItem MakePageChartData(PageDataItem){ + // //FIXME + // } @Override public boolean ErrorCheck(List input) { // TODO Auto-generated method stub return false; } - - public void clear(){ + + public void clear() { super.clear(); instance = null; } diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/DAPageChart/DAPageChart.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/DAPageChart/DAPageChart.java new file mode 100644 index 0000000..3f74795 --- /dev/null +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/widgets/DAPageChart/DAPageChart.java @@ -0,0 +1,63 @@ +package org.tizen.dynamicanalyzer.ui.widgets.DAPageChart; + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.swt.widgets.Composite; +import org.tizen.dynamicanalyzer.ui.views.pageInfo.PageChartGraphItem; +import org.tizen.dynamicanalyzer.ui.views.pageInfo.PageChartItem; + +public class DAPageChart extends Composite { + + private List items = new ArrayList(); + + public DAPageChart(Composite parent, int style) { + super(parent, style); + // TODO Auto-generated constructor stub + } + + public void AddItem(PageChartItem item) { + items.add(item); + // printItem(items,0); + // FIXME : redraw + } + + public List GetItems() { + return items; + } + + public void printItem(List items, int depth) { + PageChartItem item; + PageChartGraphItem graphItem; + List graphItems; + if (items != null && items.size() != 0) { + for (int i = 0; i < items.size(); i++) { + for (int j = 0; j < depth; j++) { + System.out.print(" -"); + } + item = items.get(i); + System.out.print(item.GetText() + " : <"); + graphItems = item.GetGraphItem(); + if (graphItems != null && graphItems.size() != 0) { + for (int k = 0; k < graphItems.size(); k++) { + graphItem = graphItems.get(k); + System.out.print(graphItem.getPageDataItemIndex() + + ", "); + } + } + System.out.println(">"); + if (item.GetChildren() != null + && item.GetChildren().size() != 0) + printItem(item.GetChildren(), depth + 1); + } + } else { + if (depth == 0) + System.out.println("no item!!!"); + } + System.out.println("\n"); + } + + public void printItems() { + printItem(items, 0); + } +}