use of com.tencent.wstt.apt.action.StartTestAction in project GT by Tencent.
the class DevicesView method makeActions.
/**
* 初始化action
*/
private void makeActions() {
/**
* 测试按钮
*/
testAction = new StartTestAction();
testAction.setText("Start");
testAction.setToolTipText("开始检测");
testAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/start.png"));
/**
* 刷新按钮
*/
refreshAction = new Action() {
public void run() {
refreshGetPkgInfo();
}
};
refreshAction.setText("获取手机上的进程列表");
refreshAction.setToolTipText("获取手机上的进程列表");
refreshAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/refresh.png"));
/**
* 打开log目录
*/
openResultDirAction = new Action() {
public void run() {
try {
if (PCInfo.OSName.toLowerCase().indexOf("window") != -1) {
Runtime.getRuntime().exec("explorer.exe " + Constant.LOG_FOLDER_ON_PC + File.separator + TestSence.getInstance().curDir);
} else {
Runtime.getRuntime().exec("open " + Constant.LOG_FOLDER_ON_PC + File.separator + TestSence.getInstance().curDir);
}
} catch (IOException e) {
e.printStackTrace();
APTConsoleFactory.getInstance().APTPrint("打开测试结果文件夹失败");
}
}
};
openResultDirAction.setText("打开测试结果保存目录");
openResultDirAction.setToolTipText("打开测试结果保存目录");
openResultDirAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/open_pc.png"));
/**
* 打开log
*/
openLogWithChartAction = new Action() {
public void run() {
FileDialog dialog = new FileDialog(sourcePkgTableViewer.getControl().getShell(), SWT.OPEN);
//设置初始路径
dialog.setFilterPath(Constant.LOG_FOLDER_ON_PC);
//返回的全路径(路径+文件名)
final String fileName = dialog.open();
if (fileName == null) {
return;
}
final APTLogFileHeader afh = APTLogFileParse.pareseAPTLogFileHeader(fileName);
if (afh == null) {
APTConsoleFactory.getInstance().APTPrint("文件头格式不兼容");
return;
}
//在数据量比较大时,解析会比较大
APTState.getInstance().DealWithEventBefore(APTEventEnum.OPENLOG_OPER);
APTConsoleFactory.getInstance().APTPrint("正解析log数据,请稍候......");
final CPUView cpuViewPart = (CPUView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(CPUView.ID);
final MemoryView memViewPart = (MemoryView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(MemoryView.ID);
cpuViewPart.setCpuTableViewerFilter(null);
cpuViewPart.setJiffiesTableViewerFilter(null);
memViewPart.setTableViewerFilter(null);
Thread parseLogThread = new Thread(new Runnable() {
@Override
public void run() {
final JfreeChartDatas datas = APTLogFileParse.getData(fileName, afh);
if (datas == null) {
APTConsoleFactory.getInstance().APTPrint("文件格式不兼容");
return;
}
if (datas.monitorItem.equals(Constant.TEXT_ITEM_TITLES[Constant.CPU_INDEX])) {
cpuViewPart.cpuRealTimeChart.fillData(datas);
} else {
memViewPart.memRealTimeChart.fillData(datas);
}
}
});
parseLogThread.start();
try {
//TODO 这里使用会不会存在很卡的情况,打开比较大的文件的时候
parseLogThread.join();
for (int i = 0; i < afh.pkgNames.length; i++) {
PkgInfo item = new PkgInfo();
item.contents[PkgInfo.NAME_INDEX] = afh.pkgNames[i];
item.contents[PkgInfo.PID_INDEX] = "-1";
addDataItem(targetPkgTableViewer, item);
}
APTState.getInstance().DealWithEventAfter(APTEventEnum.OPENLOG_OPER);
//APTConsoleFactory.getInstance().APTPrint("打开log更新");
GetCurCheckedStateUtil.update();
APTConsoleFactory.getInstance().APTPrint("log打开完毕");
} catch (InterruptedException e) {
e.printStackTrace();
}
}
};
openLogWithChartAction.setText("用JFreechart打开log");
openLogWithChartAction.setToolTipText("用JFreechart打开log");
openLogWithChartAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/generate_chart.png"));
/**
* 复制数据
*/
copyAction = new CopyAllFromTableViewAction(sourcePkgTableViewer);
copyAction.setText("复制");
copyAction.setToolTipText("复制当前显示的表格数据到剪切板");
ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/save.png");
copyAction.setImageDescriptor(descriptor);
/**
* 添加菜单
*/
addPkgAction = new Action() {
@Override
public void run() {
if (isSupportAddOrDeleteOper) {
super.run();
APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
IStructuredSelection iss = (IStructuredSelection) sourcePkgTableViewer.getSelection();
if (iss == null) {
return;
}
PkgInfo itemData = (PkgInfo) iss.getFirstElement();
addDataItem(targetPkgTableViewer, itemData);
APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
} else {
APTConsoleFactory.getInstance().APTPrint("Operation forbid");
}
}
};
addPkgAction.setText("添加");
addPkgAction.setToolTipText("添加该进程到被测进程列表");
addPkgAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/add.png"));
/**
* 删除菜单
*/
removePkgAction = new Action() {
@Override
public void run() {
if (isSupportAddOrDeleteOper) {
super.run();
APTState.getInstance().DealWithEventBefore(APTEventEnum.CONFIGRURE_OPER);
TableItem[] selectData = targetPkgTableViewer.getTable().getSelection();
if (selectData == null || selectData.length == 0) {
return;
}
PkgInfo itemData = (PkgInfo) selectData[0].getData();
targetPkgTableViewer.remove(itemData);
APTState.getInstance().DealWithEventAfter(APTEventEnum.CONFIGRURE_OPER);
} else {
APTConsoleFactory.getInstance().APTPrint("Operation forbid");
}
}
};
removePkgAction.setText("删除");
removePkgAction.setToolTipText("从被测进程列表中删除该进程");
removePkgAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/remove.png"));
pmapAction = new GetPMAPInfoAction(sourcePkgTableViewer);
pmapAction.setText("PMAP");
pmapAction.setToolTipText("PMAP");
pmapAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/pmap.png"));
smapAction = new GetSMAPInfoAction(sourcePkgTableViewer);
smapAction.setText("SMAP");
smapAction.setToolTipText("SMAP");
smapAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/pmap.png"));
dumpHprofAction = new DumpHprofAction();
dumpHprofAction.setText("DumpHprof");
dumpHprofAction.setToolTipText("DumpHprof");
dumpHprofAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/dump.png"));
gcAction = new GCAction();
gcAction.setText("GC");
gcAction.setToolTipText("GC");
gcAction.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(Constant.PLUGIN_ID, "icons/gc.png"));
}
Aggregations