use of org.eclipse.ui.IEditorPart in project translationstudio8 by heartsome.
the class AddTermToTBHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof IXliffEditor) {
IXliffEditor xliffEditor = (IXliffEditor) editor;
IFile file = ((FileEditorInput) editor.getEditorInput()).getFile();
// ProjectConfiger projectConfig = ProjectConfigerFactory.getProjectConfiger(file.getProject());
// List<DatabaseModelBean> lstDatabase = projectConfig.getTermBaseDbs(true);
TbImporter.getInstance().setProject(file.getProject());
if (!TbImporter.getInstance().checkImporter()) {
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.getString("handler.AddTermToTBHandler.msgTitle"), Messages.getString("handler.AddTermToTBHandler.msg"));
return null;
}
StringBuffer srcTerm = new StringBuffer();
StringBuffer tgtTerm = new StringBuffer();
String srcAllText = xliffEditor.getRowTransUnitBean(xliffEditor.getSelectedRows()[0]).getSrcText();
xliffEditor.getSelectSrcOrTgtPureText(srcTerm, tgtTerm);
AddTermToTBDialog dialog = AddTermToTBDialog.getInstance(editor.getSite().getShell(), srcTerm.toString().trim(), tgtTerm.toString().trim(), AddTermToTBDialog.ADD_TYPE);
dialog.setProject(file.getProject());
dialog.setSrcLang(xliffEditor.getSrcColumnName());
dialog.setTgtLang(xliffEditor.getTgtColumnName());
dialog.setSrcAllText(srcAllText);
dialog.open();
}
return null;
}
use of org.eclipse.ui.IEditorPart in project translationstudio8 by heartsome.
the class TermViewerBodyMenu method addTerm.
void addTerm() {
IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
if (editor instanceof IXliffEditor) {
IXliffEditor xliffEditor = (IXliffEditor) editor;
IFile file = ((FileEditorInput) editor.getEditorInput()).getFile();
TbImporter.getInstance().setProject(file.getProject());
if (!TbImporter.getInstance().checkImporter()) {
MessageDialog.openInformation(editor.getSite().getShell(), Messages.getString("handler.AddTermToTBHandler.msgTitle"), Messages.getString("handler.AddTermToTBHandler.msg"));
return;
}
StringBuffer srcTerm = new StringBuffer();
StringBuffer tgtTerm = new StringBuffer();
String srcAllText = xliffEditor.getRowTransUnitBean(xliffEditor.getSelectedRows()[0]).getSrcText();
xliffEditor.getSelectSrcOrTgtPureText(srcTerm, tgtTerm);
AddTermToTBDialog dialog = AddTermToTBDialog.getInstance(editor.getSite().getShell(), srcTerm.toString().trim(), tgtTerm.toString().trim(), AddTermToTBDialog.ADD_TYPE);
dialog.setProject(file.getProject());
dialog.setSrcLang(xliffEditor.getSrcColumnName());
dialog.setTgtLang(xliffEditor.getTgtColumnName());
dialog.setSrcAllText(srcAllText);
dialog.open();
}
}
use of org.eclipse.ui.IEditorPart in project translationstudio8 by heartsome.
the class ColorConfigLoader method loadColor.
private void loadColor() {
Device device = Activator.getDefault().getWorkbench().getDisplay();
if (pfStore == null) {
pfStore = Activator.getDefault().getPreferenceStore();
pfStore.addPropertyChangeListener(this);
}
colorConfigBean.release();
colorConfigBean.setPtColor(getColor(device, IColorPreferenceConstant.PT_COLOR));
colorConfigBean.setQtColor(getColor(device, IColorPreferenceConstant.QT_COLOR));
colorConfigBean.setMtColor(getColor(device, IColorPreferenceConstant.MT_COLOR));
colorConfigBean.setTm101Color(getColor(device, IColorPreferenceConstant.TM_MATCH101_COLOR));
colorConfigBean.setTm100Color(getColor(device, IColorPreferenceConstant.TM_MATCH100_COLOR));
colorConfigBean.setTm90Color(getColor(device, IColorPreferenceConstant.TM_MATCH90_COLOR));
colorConfigBean.setTm80Color(getColor(device, IColorPreferenceConstant.TM_MATCH80_COLOR));
colorConfigBean.setTm70Color(getColor(device, IColorPreferenceConstant.TM_MATCH70_COLOR));
colorConfigBean.setTm0Color(getColor(device, IColorPreferenceConstant.TM_MATCH0_COLOR));
colorConfigBean.setSrcDiffFgColor(getColor(device, IColorPreferenceConstant.DIFFERENCE_FG_COLOR));
colorConfigBean.setSrcDiffBgColor(getColor(device, IColorPreferenceConstant.DIFFERENCE_BG_COLOR));
colorConfigBean.setTagFgColor(getColor(device, IColorPreferenceConstant.TAG_FG_COLOR));
colorConfigBean.setTagBgColor(getColor(device, IColorPreferenceConstant.TAG_BG_COLOR));
colorConfigBean.setWrongTagColor(getColor(device, IColorPreferenceConstant.WRONG_TAG_COLOR));
colorConfigBean.setErrorWordColor(getColor(device, IColorPreferenceConstant.WRONG_TAG_COLOR));
String strColor = colorConfigBean.toString();
IXliffEditor xliffEditor = null;
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
IEditorPart editor = page.getActiveEditor();
if (editor != null && editor instanceof IXliffEditor) {
xliffEditor = (IXliffEditor) editor;
}
}
}
if (strCurColor != null && !strCurColor.equals(strColor)) {
// 更改颜色设置后刷新界面
if (xliffEditor != null) {
xliffEditor.autoResize();
xliffEditor.refresh();
}
if (window != null) {
IWorkbenchPage page = window.getActivePage();
if (page != null) {
IViewPart viewPart = page.findView("net.heartsome.cat.ts.ui.translation.view.matchview");
if (viewPart != null) {
IMatchViewPart part = (IMatchViewPart) viewPart;
part.refreshTable();
}
}
}
strCurColor = strColor;
}
Color highlightedTermColor = colorConfigBean.getHighlightedTermColor();
RGB newRgb = StringConverter.asRGB(pfStore.getString(IColorPreferenceConstant.HIGHLIGHTED_TERM_COLOR));
if (highlightedTermColor == null || highlightedTermColor.isDisposed()) {
highlightedTermColor = new Color(device, newRgb);
} else if (!highlightedTermColor.getRGB().equals(newRgb)) {
highlightedTermColor.dispose();
highlightedTermColor = new Color(device, newRgb);
// had changed
if (xliffEditor != null) {
// 刷新
xliffEditor.highlightedTerms(0, null);
}
}
colorConfigBean.setHighlightedTermColor(highlightedTermColor);
}
use of org.eclipse.ui.IEditorPart in project translationstudio8 by heartsome.
the class NotSendToTMHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof XLIFFEditorImplWithNatTable) {
XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
List<String> selectedRowIds = xliffEditor.getSelectedRowIds();
if (selectedRowIds != null && selectedRowIds.size() > 0) {
boolean isSendtoTm = true;
XLFHandler handler = xliffEditor.getXLFHandler();
for (String rowId : selectedRowIds) {
if (!handler.isSendToTM(rowId) && isSendtoTm) {
isSendtoTm = false;
break;
}
}
NattableUtil util = NattableUtil.getInstance(xliffEditor);
util.changeSendToTmState(selectedRowIds, isSendtoTm ? "yes" : "no");
}
}
return null;
}
use of org.eclipse.ui.IEditorPart in project translationstudio8 by heartsome.
the class SplitPointSettingHandler method execute.
public Object execute(ExecutionEvent event) throws ExecutionException {
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof XLIFFEditorImplWithNatTable) {
XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor;
if (xliffEditor.isMultiFile()) {
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.getString("menu.BodyMenuConfiguration.msgTitle"), Messages.getString("menu.BodyMenuConfiguration.msg7"));
return null;
}
List<String> selectedRowIds = xliffEditor.getSelectedRowIds();
boolean isSplitPointExist = false;
if (selectedRowIds != null && selectedRowIds.size() > 0) {
for (String rowId : selectedRowIds) {
if (xliffEditor.getSplitXliffPoints().contains(rowId)) {
isSplitPointExist = true;
} else {
isSplitPointExist = false;
break;
}
}
if (!isSplitPointExist) {
String xlfPath = ((FileEditorInput) xliffEditor.getEditorInput()).getFile().getLocation().toOSString();
for (String rowId : selectedRowIds) {
// String firstTURowId = xliffEditor.getXLFHandler().getRowIdByXpath(xlfPath,
// "/xliff/file[1]/body/descendant::trans-unit[1]");
// if (firstTURowId != null && firstTURowId.equals(rowId)) {
// MessageDialog.openInformation(HandlerUtil.getActiveShell(event),
// Messages.getString("menu.BodyMenuConfiguration.msgTitle"),
// Messages.getString("menu.BodyMenuConfiguration.msg8"));
// continue;
// }
String lastTURowid = xliffEditor.getXLFHandler().getRowIdByXpath(xlfPath, "/xliff/file[last()]/body/descendant::trans-unit[last()]");
if (lastTURowid != null && lastTURowid.equals(rowId)) {
MessageDialog.openInformation(HandlerUtil.getActiveShell(event), Messages.getString("menu.BodyMenuConfiguration.msgTitle"), Messages.getString("menu.BodyMenuConfiguration.msg9"));
continue;
}
if (!xliffEditor.getSplitXliffPoints().contains(rowId)) {
// 将切割点的序列号添加到List中
xliffEditor.getSplitXliffPoints().add(rowId);
xliffEditor.getTable().redraw();
}
}
} else {
for (String rowId : selectedRowIds) {
if (xliffEditor.getSplitXliffPoints().contains(rowId)) {
// 删除切割点
int index = xliffEditor.getSplitXliffPoints().indexOf(rowId);
xliffEditor.getSplitXliffPoints().remove(index);
xliffEditor.getTable().redraw();
}
}
}
}
}
return null;
}
Aggregations