From c8e1ff0c4c295805b36806e023c96fffb7c254b8 Mon Sep 17 00:00:00 2001 From: "Hyunjong.park" Date: Tue, 14 Oct 2014 13:18:21 +0900 Subject: [PATCH] thread : change the canvas composite of detail view to the text composite. Signed-off-by: Hyunjong.park Change-Id: I9cb229918695bd6eea49865d3d70b8cc861c90d0 Signed-off-by: Hyunjong.park --- .../tizen/dynamicanalyzer/nl/ThreadPageLabels.java | 4 +- .../dynamicanalyzer/nl/ThreadPageLabels.properties | 4 +- .../ui/thread/ThreadDetailInfoView.java | 174 +++++++++++---------- 3 files changed, 93 insertions(+), 89 deletions(-) diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/ThreadPageLabels.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/ThreadPageLabels.java index bcfca4b..29201d5 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/ThreadPageLabels.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/ThreadPageLabels.java @@ -100,8 +100,8 @@ public class ThreadPageLabels extends NLS { /* Thread Details */ public static String THREAD_DETAILS_TID; - public static String THREAD_DETAILS_TTYPE; - public static String THREAD_DETAILS_TATTRTYPE; + public static String THREAD_DETAILS_TYPE; + public static String THREAD_DETAILS_ATTRTYPE; public static String THREAD_DETAILS_FUNCNAME; public static String THREAD_DETAILS_CLASSNAME; public static String THREAD_DETAILS_STARTTIME; diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/ThreadPageLabels.properties b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/ThreadPageLabels.properties index c72030e..bf4da2e 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/ThreadPageLabels.properties +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/nl/ThreadPageLabels.properties @@ -65,8 +65,8 @@ THREAD_API_LIST_VIEW_RETURN=Return THREAD_API_LIST_VIEW_ERRNO=Error Code THREAD_DETAILS_TID=Thread ID : -THREAD_DETAILS_TTYPE=Type : -THREAD_DETAILS_TATTRTYPE=Attr Type : +THREAD_DETAILS_TYPE=Type : +THREAD_DETAILS_ATTRTYPE=Attr Type : THREAD_DETAILS_FUNCNAME=Thread Function : THREAD_DETAILS_CLASSNAME=Thread Class : THREAD_DETAILS_STARTTIME=Start Time : diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/thread/ThreadDetailInfoView.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/thread/ThreadDetailInfoView.java index 2f95b56..225cafe 100644 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/thread/ThreadDetailInfoView.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/thread/ThreadDetailInfoView.java @@ -30,14 +30,13 @@ package org.tizen.dynamicanalyzer.ui.thread; import java.util.List; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; import org.eclipse.swt.layout.FillLayout; -import org.eclipse.swt.widgets.Canvas; +import org.eclipse.swt.layout.FormAttachment; +import org.eclipse.swt.layout.FormData; +import org.eclipse.swt.layout.FormLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Text; import org.tizen.dynamicanalyzer.common.DASelectionData; import org.tizen.dynamicanalyzer.constant.CommonConstants; import org.tizen.dynamicanalyzer.nl.AnalyzerLabels; @@ -50,19 +49,25 @@ import org.tizen.dynamicanalyzer.widgets.da.view.DAViewComposite; import org.tizen.dynamicanalyzer.widgets.da.view.DAViewData; public class ThreadDetailInfoView extends DAViewComposite { + private Composite contents = null; + private Text detailText = null; + + private final static String leftFormAttachment = CommonConstants.SPACE + + CommonConstants.SPACE; + private final static String heightFormAttachment = CommonConstants.NEW_LINE + + CommonConstants.NEW_LINE; + public static final int LEFT_MARGIN = 10; public static final int HEIGHT_MARGIN = 20; - private Canvas canvas = null; private String tid = AnalyzerLabels.EMPTY_STRING; private String type = AnalyzerLabels.EMPTY_STRING; private String funcName = AnalyzerLabels.EMPTY_STRING; - private String className = AnalyzerLabels.EMPTY_STRING; + private String className = AnalyzerLabels.EMPTY_STRING; private String startTime = AnalyzerLabels.EMPTY_STRING; private String endTime = AnalyzerLabels.EMPTY_STRING; private String attrType = AnalyzerLabels.EMPTY_STRING; private ThreadPageData item = null; - private boolean select = false; private void init() { tid = AnalyzerLabels.EMPTY_STRING; @@ -72,7 +77,7 @@ public class ThreadDetailInfoView extends DAViewComposite { startTime = AnalyzerLabels.EMPTY_STRING; endTime = AnalyzerLabels.EMPTY_STRING; attrType = AnalyzerLabels.EMPTY_STRING; - select = false; + detailText.setText(CommonConstants.EMPTY); } public ThreadDetailInfoView(Composite parent, int style) { @@ -81,77 +86,35 @@ public class ThreadDetailInfoView extends DAViewComposite { setTitle(ThreadPageLabels.THREAD_DETAILS_TITLE); - Composite contents = getContentArea(); - contents.setBackground(ColorResources.VIEW_BG_COLOR); - contents.setLayout(new FillLayout()); - canvas = new Canvas(contents, SWT.TRANSPARENT); - canvas.addPaintListener(new PaintListener() { - - @Override - public void paintControl(PaintEvent e) { - Rectangle rect = canvas.getBounds(); - e.gc.setBackground(ColorResources.VIEW_BG_COLOR); - e.gc.fillRectangle(rect.x, rect.y, rect.width, rect.height); - e.gc.setForeground(ColorResources.TABLE_CONTENTS_FONT_COLOR); - e.gc.setFont(FontResources.DETAIL_INFO_FONT); - - if (false == select) { - return; - } - - int y = HEIGHT_MARGIN; - Point p = e.gc.textExtent(type, SWT.DRAW_MNEMONIC); - e.gc.drawText(ThreadPageLabels.THREAD_DETAILS_TTYPE + type, - LEFT_MARGIN, y); - y += (p.y + HEIGHT_MARGIN); + Composite detailCom = getContentArea(); + detailCom.setBackground(ColorResources.VIEW_BG_COLOR); + detailCom.setLayout(new FormLayout()); + FormData labelData = new FormData(); + labelData.top = new FormAttachment(0, 0); + labelData.left = new FormAttachment(0, 0); + labelData.right = new FormAttachment(100, 0); + labelData.bottom = new FormAttachment(100, 0); + detailCom.setLayoutData(labelData); - if (null != tid && !(tid.equals(CommonConstants.EMPTY))) { - e.gc.drawText(ThreadPageLabels.THREAD_DETAILS_TID + tid, - LEFT_MARGIN, y); - p = e.gc.textExtent(tid, SWT.DRAW_MNEMONIC); - y += (p.y + HEIGHT_MARGIN); - } - // tizen thread : show thread class name - // other thread (e.g. pthread) : show thread function name - if (type.equals(ThreadPageLabels.THREAD_ITEM_TYPE_TIZEN)) { - if (null != className && !(className.equals(CommonConstants.EMPTY))) { - e.gc.drawText(ThreadPageLabels.THREAD_DETAILS_CLASSNAME + className, - LEFT_MARGIN, y); - p = e.gc.textExtent(tid, SWT.DRAW_MNEMONIC); - y += (p.y + HEIGHT_MARGIN); - } - } else { - if (null != funcName && !(funcName.equals(CommonConstants.EMPTY))) { - e.gc.drawText(ThreadPageLabels.THREAD_DETAILS_FUNCNAME + funcName, - LEFT_MARGIN, y); - p = e.gc.textExtent(tid, SWT.DRAW_MNEMONIC); - y += (p.y + HEIGHT_MARGIN); - } - } + contents = detailCom; + contents.setBackground(ColorResources.VIEW_BG_COLOR); + contents.setLayout(new FormLayout()); - if (null != startTime - && !(startTime.equals(CommonConstants.EMPTY))) { - e.gc.drawText(ThreadPageLabels.THREAD_DETAILS_STARTTIME - + startTime, LEFT_MARGIN, y); - p = e.gc.textExtent(startTime, SWT.DRAW_MNEMONIC); - y += (p.y + HEIGHT_MARGIN); - } + detailText = new Text(contents, SWT.BORDER | SWT.V_SCROLL + | SWT.H_SCROLL); + detailText.setBackground(ColorResources.VIEW_BG_COLOR); + detailText.setForeground(ColorResources.TABLE_CONTENTS_FONT_COLOR); + detailText.setFont(FontResources.DETAIL_INFO_FONT); - if (null != endTime && !(endTime.equals(CommonConstants.EMPTY))) { - e.gc.drawText(ThreadPageLabels.THREAD_DETAILS_ENDTIME - + endTime, LEFT_MARGIN, y); - p = e.gc.textExtent(ThreadPageLabels.THREAD_DETAILS_ENDTIME - + endTime, SWT.DRAW_MNEMONIC); - y += (p.y + HEIGHT_MARGIN); - } + FormData buttonData = new FormData(); + buttonData.top = new FormAttachment(contents, 0); + buttonData.left = new FormAttachment(0, 0); + buttonData.right = new FormAttachment(100, 0); + buttonData.bottom = new FormAttachment(100, 0); + detailText.setLayoutData(buttonData); + detailText.getVerticalBar().setVisible(true); + detailText.getHorizontalBar().setVisible(true); - if (null != attrType - && !(attrType.equals(CommonConstants.EMPTY))) { - e.gc.drawText(ThreadPageLabels.THREAD_DETAILS_TATTRTYPE - + attrType, LEFT_MARGIN, y); - } - } - }); } private void updateDetails() { @@ -194,8 +157,46 @@ public class ThreadDetailInfoView extends DAViewComposite { attrType = str; } } - select = true; - canvas.redraw(); + + StringBuffer strDetailView = new StringBuffer(heightFormAttachment); + addDetailInfo(strDetailView, ThreadPageLabels.THREAD_DETAILS_TYPE + + type); + if (null != tid && !(tid.equals(CommonConstants.EMPTY))) { + addDetailInfo(strDetailView, ThreadPageLabels.THREAD_DETAILS_TID + + tid); + } + if (type.equals(ThreadPageLabels.THREAD_ITEM_TYPE_TIZEN)) { + if (null != className && !(className.equals(CommonConstants.EMPTY))) { + addDetailInfo(strDetailView, + ThreadPageLabels.THREAD_DETAILS_CLASSNAME + className); + } + } else { + if (null != funcName && !(funcName.equals(CommonConstants.EMPTY))) { + addDetailInfo(strDetailView, + ThreadPageLabels.THREAD_DETAILS_FUNCNAME + funcName); + } + } + + if (null != startTime && !(startTime.equals(CommonConstants.EMPTY))) { + addDetailInfo(strDetailView, + ThreadPageLabels.THREAD_DETAILS_STARTTIME + startTime); + } + + if (null != endTime && !(endTime.equals(CommonConstants.EMPTY))) { + addDetailInfo(strDetailView, + ThreadPageLabels.THREAD_DETAILS_ENDTIME + endTime); + } + + if (null != attrType && !(attrType.equals(CommonConstants.EMPTY))) { + addDetailInfo(strDetailView, + ThreadPageLabels.THREAD_DETAILS_ATTRTYPE + attrType); + } + detailText.setText(strDetailView.toString()); + detailText.redraw(); + } + + private void addDetailInfo(StringBuffer strDetailView, String info) { + strDetailView.append(leftFormAttachment + info + heightFormAttachment); } private boolean isChange() { @@ -206,16 +207,20 @@ public class ThreadDetailInfoView extends DAViewComposite { if (!type.equals(((ThreadPageThreadData) item).getTypeString())) { return true; } - if (!funcName.equals(((ThreadPageThreadData) item).getThreadFuncName())) { + if (!funcName.equals(((ThreadPageThreadData) item) + .getThreadFuncName())) { return true; } - if (!className.equals(((ThreadPageThreadData) item).getThreadClassName())) { + if (!className.equals(((ThreadPageThreadData) item) + .getThreadClassName())) { return true; } - if (!startTime.equals(((ThreadPageThreadData) item).getStartTimeString())) { + if (!startTime.equals(((ThreadPageThreadData) item) + .getStartTimeString())) { return true; } - if (!endTime.equals(((ThreadPageThreadData) item).getEndTimeString())) { + if (!endTime.equals(((ThreadPageThreadData) item) + .getEndTimeString())) { return true; } if (!attrType.equals(item.getAttrType())) { @@ -251,7 +256,6 @@ public class ThreadDetailInfoView extends DAViewComposite { item = (ThreadPageData) data.getData(); } else { item = null; - select = false; } updateDetails(); @@ -260,13 +264,13 @@ public class ThreadDetailInfoView extends DAViewComposite { @Override public Control getControl() { - return canvas; + return contents; } @Override public void clear() { init(); - canvas.redraw(); + detailText.redraw(); } } \ No newline at end of file -- 2.7.4