use of org.eclipse.swt.events.DisposeListener 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();
}
}
});
}
use of org.eclipse.swt.events.DisposeListener in project translationstudio8 by heartsome.
the class Comparator method Compare.
/**
* 用于比较的参照文本(不含内部标记)
* @param referenceText
* @param text
* ;
*/
public static void Compare(String referenceText, StyledText text) {
ColorConfigBean colorCfgBean = ColorConfigBean.getInstance();
final Color differencefg = colorCfgBean.getSrcDiffFgColor();
final Color differencebg = colorCfgBean.getSrcDiffBgColor();
Position[] tagRanges = InnerTagUtil.getStyledTagRanges(text.getText());
TokenComparator left = new TokenComparator(InnerTagUtil.getDisplayValueWithoutTags(text.getText()));
TokenComparator right = new TokenComparator(referenceText);
ArrayList<StyleRange> styleRanges = new ArrayList<StyleRange>();
RangeDifference[] e = RangeDifferencer.findRanges(left, right);
for (int i = 0; i < e.length; i++) {
RangeDifference es = e[i];
int leftStart = es.leftStart();
int leftEnd = es.leftEnd();
int lStart = left.getTokenStart(leftStart);
int lEnd = left.getTokenStart(leftEnd);
if (es.kind() == RangeDifference.CHANGE) {
int start = lStart;
int end = lEnd;
if (tagRanges.length > 0) {
for (Position tagRange : tagRanges) {
int tagStart = tagRange.getOffset();
int tagEnd = tagRange.getOffset() + tagRange.getLength();
if (tagStart <= start) {
start += tagRange.getLength();
end += tagRange.getLength();
} else if (start < tagStart && tagStart < end) {
StyleRange range = new StyleRange(start, tagStart - start, differencefg, differencebg);
styleRanges.add(range);
start = tagEnd;
end += tagRange.getLength();
} else {
break;
}
}
}
StyleRange range = new StyleRange(start, end - start, differencefg, differencebg);
styleRanges.add(range);
}
}
for (int i = 0; i < styleRanges.size(); i++) {
text.setStyleRange(styleRanges.get(i));
text.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
differencefg.dispose();
differencebg.dispose();
}
});
}
}
use of org.eclipse.swt.events.DisposeListener in project translationstudio8 by heartsome.
the class AutoResizeColumnAction method run.
public void run(NatTable natTable, MouseEvent event) {
if (gc == null) {
gc = new GC(natTable);
natTable.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
gc.dispose();
}
});
}
Point clickPoint = new Point(event.x, event.y);
int column = CellEdgeDetectUtil.getColumnPositionToResize(natTable, clickPoint);
InitializeAutoResizeColumnsCommand command = new InitializeAutoResizeColumnsCommand(natTable, column, natTable.getConfigRegistry(), gc);
natTable.doCommand(command);
}
use of org.eclipse.swt.events.DisposeListener in project translationstudio8 by heartsome.
the class AutoResizeRowAction method run.
public void run(NatTable natTable, MouseEvent event) {
if (gc == null) {
gc = new GC(natTable);
natTable.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
gc.dispose();
}
});
}
Point clickPoint = new Point(event.x, event.y);
int row = CellEdgeDetectUtil.getRowPositionToResize(natTable, clickPoint);
InitializeAutoResizeRowsCommand command = new InitializeAutoResizeRowsCommand(natTable, row, natTable.getConfigRegistry(), gc);
natTable.doCommand(command);
}
use of org.eclipse.swt.events.DisposeListener in project translationstudio8 by heartsome.
the class ColumnResizeCursorAction method run.
public void run(NatTable natTable, MouseEvent event) {
if (columnResizeCursor == null) {
columnResizeCursor = new Cursor(Display.getDefault(), SWT.CURSOR_SIZEWE);
natTable.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
columnResizeCursor.dispose();
}
});
}
natTable.setCursor(columnResizeCursor);
}
Aggregations