use of net.heartsome.cat.ts.core.bean.TransUnitBean in project translationstudio8 by heartsome.
the class StyledTextCellEditor method isApprovedOrLocked.
/**
* 是否批准或者锁定
* @return ;
*/
public boolean isApprovedOrLocked() {
int rowIndex = hsCellEditor.getRowIndex();
if (rowIndex == -1) {
return true;
}
if (!xliffEditor.isHorizontalLayout()) {
// 是垂直布局
// 得到实际的行索引
rowIndex = rowIndex / VerticalNatTableConfig.ROW_SPAN;
}
TransUnitBean tu = xliffEditor.getRowTransUnitBean(rowIndex);
String translate = tu.getTuProps().get("translate");
if (translate != null && "no".equalsIgnoreCase(translate)) {
return true;
}
return false;
}
use of net.heartsome.cat.ts.core.bean.TransUnitBean in project translationstudio8 by heartsome.
the class MatchViewPart method selectionChanged.
/**
* 监听XLFEditor的选择事件
*/
public void selectionChanged(final IWorkbenchPart part, final ISelection selection) {
if (part == null || selection == null) {
return;
}
if (!(part instanceof IEditorPart)) {
updateActionState();
return;
}
if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) {
updateActionState();
return;
}
IXliffEditor editor = (IXliffEditor) part;
IStructuredSelection structuredSelecion = (IStructuredSelection) selection;
final Object object = structuredSelecion.getFirstElement();
if (object instanceof Integer) {
int rowIndex = -1;
int selRowIndex = (Integer) object;
if (rowIndex == selRowIndex) {
if (gridTable.getItemCount() != 0) {
updateActionState();
}
return;
} else {
rowIndex = selRowIndex;
}
XLFHandler handler = editor.getXLFHandler();
String rowId = handler.getRowId(rowIndex);
// handler.getTransUnit(rowId);
TransUnitBean transUnit = editor.getRowTransUnitBean(rowIndex);
if (transUnit == null) {
updateActionState();
return;
}
TransUnitInfo2TranslationBean tuInfoBean = getTuInfoBean(transUnit, handler, rowId);
FileEditorInput input = (FileEditorInput) getSite().getPage().getActiveEditor().getEditorInput();
IProject currentProject = input.getFile().getProject();
copyEnable.resetSelection();
gridTable.removeAll();
altTransCacheList.clear();
menuMgr.setEditor(editor);
menuMgr.setRowIndex(rowIndex);
executeMatch(editor, rowId, transUnit, tuInfoBean, currentProject);
}
}
use of net.heartsome.cat.ts.core.bean.TransUnitBean in project translationstudio8 by heartsome.
the class TerminologyViewPart method createAction.
/**
* 创建视图工具栏的按钮。
*/
private void createAction() {
firstAction = new Action() {
@Override
public void run() {
if (rowIndex < 0) {
return;
}
if (tempEditor == null || rowIndex < 0) {
return;
}
TransUnitBean transUnit = tempEditor.getRowTransUnitBean(rowIndex);
Hashtable<String, String> tuProp = transUnit.getTuProps();
if (tuProp != null) {
String translate = tuProp.get("translate");
if (translate != null && translate.equalsIgnoreCase("no")) {
MessageDialog.openInformation(getSite().getShell(), Messages.getString("view.TerminologyViewPart.msgTitle"), Messages.getString("view.TerminologyViewPart.msg1"));
return;
}
}
String tarTerm = "";
GridItem[] items = gridTable.getSelection();
if (items.length <= 0) {
return;
} else {
tarTerm = items[0].getText(2);
}
try {
tempEditor.insertCell(rowIndex, tempEditor.getTgtColumnIndex(), tarTerm);
// tempEditor.setFocus(); // 焦点给回编辑器
} catch (ExecutionException e) {
if (Constant.RUNNING_MODE == Constant.MODE_DEBUG) {
e.printStackTrace();
}
MessageDialog.openInformation(parent.getShell(), Messages.getString("view.TerminologyViewPart.msgTitle"), Messages.getString("view.TerminologyViewPart.msg2") + e.getMessage());
}
}
};
firstAction.setText(Messages.getString("view.TerminologyViewPart.menu.inserttermtarget"));
firstAction.setImageDescriptor(Activator.getIconDescriptor(ImageConstants.ACCPTE_TERM));
firstAction.setToolTipText(Messages.getString("view.TerminologyViewPart.firstAction"));
firstAction.setEnabled(false);
//getViewSite().getActionBars().getToolBarManager().add(firstAction);
}
use of net.heartsome.cat.ts.core.bean.TransUnitBean in project translationstudio8 by heartsome.
the class TerminologyViewPart method selectionChanged.
/**
* 监听来自IHSEditor的选中改变事件。
* @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart,
* org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IWorkbenchPart part, ISelection selection) {
// UNDO 每次启动程序后,术语匹配面板无法识别出术语。 2012-06-21
if (part == null || selection == null) {
return;
}
if (part instanceof IXliffEditor) {
if (!part.equals(tempEditor)) {
IXliffEditor editor = (IXliffEditor) part;
tempEditor = editor;
tempEditor = (IXliffEditor) part;
FileEditorInput input = (FileEditorInput) getSite().getPage().getActiveEditor().getEditorInput();
IProject currProject = input.getFile().getProject();
matcher.setCurrentProject(currProject);
}
} else {
firstAction.setEnabled(false);
return;
}
if (selection.isEmpty() || !(selection instanceof IStructuredSelection)) {
firstAction.setEnabled(false);
return;
}
IStructuredSelection structuredSelecion = (IStructuredSelection) selection;
Object object = structuredSelecion.getFirstElement();
if (object instanceof Integer) {
rowIndex = (Integer) object;
IXliffEditor editor = (IXliffEditor) part;
// handler.getTransUnit(rowId);
TransUnitBean bean = editor.getRowTransUnitBean(rowIndex);
String pureText = bean.getSrcText();
srcLang = bean.getSrcLang();
tgtLang = bean.getTgtLang();
tgtLang = tgtLang == null || tgtLang.equals("") ? editor.getTgtColumnName() : tgtLang;
srcLang = srcLang == null || "".equals(srcLang) ? editor.getSrcColumnName() : srcLang;
if (srcLang == null || "".equals(srcLang) || tgtLang == null || "".equals(tgtLang)) {
return;
}
Language srcLangL = LocaleService.getLanguageConfiger().getLanguageByCode(srcLang);
Language tgtLangL = LocaleService.getLanguageConfiger().getLanguageByCode(tgtLang);
if (srcLangL.isBidi() || tgtLangL.isBidi()) {
gridTable.setOrientation(SWT.RIGHT_TO_LEFT);
} else {
gridTable.setOrientation(SWT.LEFT_TO_RIGHT);
}
srcTableColumn.setText(srcLang);
tgtTableColumn.setText(tgtLang);
loadData(pureText, srcLang, tgtLang, true);
}
}
use of net.heartsome.cat.ts.core.bean.TransUnitBean in project translationstudio8 by heartsome.
the class StatusPainter method getImages.
/**
* 通过LayerCell得到行号确定所要得到的TU对象,通过TU对象的各种属性确定其状态图片
* @param cell
* @param configRegistry
* @return ;
*/
protected List<Map<Integer, Image>> getImages(LayerCell cell, IConfigRegistry configRegistry) {
List<Map<Integer, Image>> images = new ArrayList<Map<Integer, Image>>();
int index = cell.getLayer().getRowIndexByPosition(cell.getRowPosition());
TransUnitBean tu = bodyDataProvider.getRowObject(index);
String matchType = tu.getTgtProps().get("hs:matchType");
machQuality = tu.getTgtProps().get("hs:quality");
if (matchType != null && machQuality != null) {
if (machQuality.endsWith("%")) {
machQuality = machQuality.substring(0, machQuality.lastIndexOf("%"));
}
cellBackground = TmUtils.getMatchTypeColor(matchType, machQuality);
}
String approved = null;
String translate = null;
String state = null;
String sendToTm = null;
String needReview = null;
int noteSize = 0;
if (tu != null && tu.getTuProps() != null) {
approved = tu.getTuProps().get("approved");
sendToTm = tu.getTuProps().get("hs:send-to-tm");
translate = tu.getTuProps().get("translate");
needReview = tu.getTuProps().get("hs:needs-review");
if (tu.getTgtProps() != null) {
state = tu.getTgtProps().get("state");
}
if (tu.getNotes() != null) {
noteSize = tu.getNotes().size();
}
}
if (translate != null && "no".equals(translate)) {
// 已锁定
addImage(images, XliffEditorGUIHelper.getImage(ImageName.LOCKED), 1);
} else if (state != null && "signed-off".equals(state)) {
// 已签发
addImage(images, XliffEditorGUIHelper.getImage(ImageName.SINGED_OFF), 1);
} else if (approved != null && "yes".equals(approved)) {
// 已批准
addImage(images, XliffEditorGUIHelper.getImage(ImageName.APPROVE), 1);
} else if (state != null && "translated".equals(state)) {
// 已翻译
addImage(images, XliffEditorGUIHelper.getImage(ImageName.TRANSLATED), 1);
} else if (state != null && "new".equals(state)) {
// 草稿
addImage(images, XliffEditorGUIHelper.getImage(ImageName.DRAFT), 1);
} else {
addImage(images, XliffEditorGUIHelper.getImage(ImageName.EMPTY), 1);
}
if (sendToTm != null && ("no").equals(sendToTm)) {
addImage(images, XliffEditorGUIHelper.getImage(ImageName.DONT_ADDDB), 2);
}
if (needReview != null && "yes".equals(needReview)) {
addImage(images, XliffEditorGUIHelper.getImage(ImageName.HAS_QUESTION), 3);
}
if (noteSize > 0) {
addImage(images, XliffEditorGUIHelper.getImage(ImageName.HAS_NOTE), 4);
}
return images;
}
Aggregations