use of net.heartsome.cat.ts.ui.qa.export.ExportQAResult in project translationstudio8 by heartsome.
the class QAResultViewPart method createPropMenu.
/**
* 创建右键参数
*/
private void createPropMenu() {
Menu propMenu = new Menu(table);
table.setMenu(propMenu);
MenuItem deletWarnItem = new MenuItem(propMenu, SWT.NONE);
deletWarnItem.setText(Messages.getString("views.QAResultViewPart.deletWarnItem"));
deletWarnItem.setImage(deleteImage);
deletWarnItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
QAResultBean bean;
for (int i = 0; i < dataList.size(); i++) {
bean = dataList.get(i);
// 0为错误,1为警告
if (1 == bean.getLevel()) {
dataList.remove(bean);
i--;
}
}
tableModel.textRenderer.clearRowHeiMap();
table.redraw();
}
});
MenuItem deleteAllItem = new MenuItem(propMenu, SWT.NONE);
deleteAllItem.setText(Messages.getString("views.QAResultViewPart.deleteAllItem"));
deleteAllItem.setImage(deleteImage);
deleteAllItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dataList.clear();
tableModel.textRenderer.clearRowHeiMap();
table.redraw();
}
});
// 导出品质检查报告
exportItem = new MenuItem(propMenu, SWT.NONE);
exportItem.setText(Messages.getString("qa.views.QAResultViewPart.exportPopMenu"));
exportItem.setImage(exportImg);
exportItem.setEnabled(false);
exportItem.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
ExportQAResultDialog dialog = new ExportQAResultDialog(getSite().getShell());
int result = dialog.open();
if (result == IDialogConstants.OK_ID) {
final String exportFilePath = dialog.getExportFilePath();
if (exportFilePath == null || exportFilePath.isEmpty()) {
MessageDialog.openInformation(getSite().getShell(), Messages.getString("qa.all.dialog.info"), Messages.getString("qa.views.QAResultViewPart.msg.nullFilePath"));
return;
}
IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
monitor.beginTask("", 1);
while (!isQAEnd) {
try {
Thread.sleep(500);
} catch (Exception e2) {
logger.error("", e2);
}
if (monitor.isCanceled()) {
return;
}
}
List<QAResultBean> exportDataList = new ArrayList<QAResultBean>();
exportDataList.addAll(dataList);
ExportQAResult export = new ExportQAResult(isMultiFile, exportFilePath);
export.beginExport(dataList, filePathList, monitor);
monitor.done();
}
};
try {
new ProgressMonitorDialog(getSite().getShell()).run(true, true, runnable);
} catch (Exception e1) {
logger.error("", e1);
}
}
}
});
propMenu.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
if (deleteImage != null && !deleteImage.isDisposed()) {
deleteImage.dispose();
}
}
});
}
Aggregations