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;
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;
startTime = AnalyzerLabels.EMPTY_STRING;
endTime = AnalyzerLabels.EMPTY_STRING;
attrType = AnalyzerLabels.EMPTY_STRING;
- select = false;
+ detailText.setText(CommonConstants.EMPTY);
}
public ThreadDetailInfoView(Composite parent, int style) {
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() {
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() {
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())) {
item = (ThreadPageData) data.getData();
} else {
item = null;
- select = false;
}
updateDetails();
@Override
public Control getControl() {
- return canvas;
+ return contents;
}
@Override
public void clear() {
init();
- canvas.redraw();
+ detailText.redraw();
}
}
\ No newline at end of file