use of org.eclipse.swt.events.DisposeEvent in project translationstudio8 by heartsome.
the class SrxConfigurationDialog method createHelpToolItem.
/**
* 添加帮助按钮,备注,这里的配置与其他的不一样
* robert 2012-09-06
*/
protected Control createHelpToolItem(Composite parent) {
// ROBERTHELP 分段规则管理器
String language = CommonFunction.getSystemLanguage();
final String helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch05s03#segmentation-rule-manager", language);
Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
toolBar.setCursor(cursor);
toolBar.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
cursor.dispose();
}
});
ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
helpItem.setImage(helpImage);
//$NON-NLS-1$
helpItem.setToolTipText(JFaceResources.getString("helpToolTip"));
helpItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
}
});
return toolBar;
}
use of org.eclipse.swt.events.DisposeEvent in project translationstudio8 by heartsome.
the class XmlConverterConfigurationDialog method createHelpToolItem.
/**
* 添加帮助按钮,备注,这里的配置与其他的不一样
* robert 2012-09-06
*/
protected Control createHelpToolItem(Composite parent) {
// ROBERTHELP xml 转换器配置
String language = CommonFunction.getSystemLanguage();
final String helpUrl = MessageFormat.format("/net.heartsome.cat.ts.ui.help/html/{0}/ch08.html#configure-xml-converter", language);
Image helpImage = JFaceResources.getImage(DLG_IMG_HELP);
ToolBar toolBar = new ToolBar(parent, SWT.FLAT | SWT.NO_FOCUS);
toolBar.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
final Cursor cursor = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
toolBar.setCursor(cursor);
toolBar.addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
cursor.dispose();
}
});
ToolItem helpItem = new ToolItem(toolBar, SWT.NONE);
helpItem.setImage(helpImage);
//$NON-NLS-1$
helpItem.setToolTipText(JFaceResources.getString("helpToolTip"));
helpItem.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
PlatformUI.getWorkbench().getHelpSystem().displayHelpResource(helpUrl);
}
});
return toolBar;
}
use of org.eclipse.swt.events.DisposeEvent 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.DisposeEvent 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.DisposeEvent 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);
}
Aggregations