IStructuredSelection sel = (IStructuredSelection) event
.getSelection();
if (sel.isEmpty()) {
tableViewer.setInput(null);
} else {
RequestInfo info = (RequestInfo) sel.getFirstElement();
tableViewer.setInput(info.getStackTrace());
StringBuilder bld = new StringBuilder();
bld.append("<form>");
bld.append("<p>");
bld.append("<b>Query:</b> " + info.getMessage());
bld.append("<br/>");
bld.append("<b>Count:</b> " + info.getCount());
bld.append("<br/>");
// bld.append("<b>Api time(ms):</b> "+info.getCost());
// if (info instanceof PutRequestInfo){
// PutRequestInfo pr=(PutRequestInfo) info;
// if (pr.entityWritesBytes!=0){
// bld.append("<br/>");
// bld.append("<b>Entity writes:</b> "+pr.entityWrites);
// bld.append(" <b>Entity writes bytes:</b> "+pr.entityWritesBytes);
// bld.append("<br/>");
// bld.append("<b>Index writes:</b> "+pr.indexWrites);
// bld.append(" <b>Index writes bytes:</b> "+pr.indexWriteBytes);
// bld.append("<br/>");
// }
// }
// else if (info instanceof GetRequestInfo){
// GetRequestInfo r=(GetRequestInfo) info;
// bld.append("<br/>");
// bld.append("<b>Entity count:</b> "+r.entityCount);
// bld.append("<br/><b>Result bytes:</b> "+r.resultBytes);
// bld.append("<br/>");
// }
// bld.append("</p>");
bld.append("</p></form>");
createFormText.setText(bld.toString(), true, true);
// createFormText.getParent().getParent().layout(true);
}
}
});
tableViewer.setLabelProvider(new LabelProvider() {
public Image getImage(Object element) {
return stackImage;
}
});
new TableSortController(tv, tableColumn, new Comparator<RequestInfo>() {
public int compare(RequestInfo o1, RequestInfo o2) {
return getReqestMessage(o1).compareTo(getReqestMessage(o2));
}
}, true, true);
new TableSortController(tv, countColumn, new Comparator<RequestInfo>() {
public int compare(RequestInfo o1, RequestInfo o2) {
return o1.getCount() - o2.getCount();
}
}, true, true);
TableSortController tableSortController = new TableSortController(tv,
costColumn, new Comparator<RequestInfo>() {
public int compare(RequestInfo o1, RequestInfo o2) {
if (o1 instanceof MemCacheStorageAttachment.GetFromMemcacheRequestInfo){
if (o2 instanceof MemCacheStorageAttachment.GetFromMemcacheRequestInfo){
MemCacheStorageAttachment.GetFromMemcacheRequestInfo m1=(GetFromMemcacheRequestInfo) o1;
MemCacheStorageAttachment.GetFromMemcacheRequestInfo m2=(GetFromMemcacheRequestInfo) o2;
return (int) ((m1.successes/(double)m1.totalCount)*1000-(m2.successes/(double)m2.totalCount)*1000);
}
}
if (o1 instanceof MemCacheStorageAttachment.GetFromMemcacheRequestInfo){
return -1;
}
if (o2 instanceof MemCacheStorageAttachment.GetFromMemcacheRequestInfo){
return 1;
}
return (int) (o2.getCost() - o1.getCost());
}
}, true, true);
tableSortController.stateChanged();
// tableSortController.stateChanged();
tableViewer.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
IStructuredSelection s = (IStructuredSelection) event
.getSelection();
StackTraceElement sm = (StackTraceElement) s.getFirstElement();
doOpenStacktrace(sm);
}
});
tv.addOpenListener(new IOpenListener() {
public void open(OpenEvent event) {
IStructuredSelection s = (IStructuredSelection) event
.getSelection();
RequestInfo sm = (RequestInfo) s.getFirstElement();
if (sm != null) {
doOpenStacktrace(sm.getStackTrace()[0]);
}
}
});
stack.setClient(tableViewer.getTable());
}