use of net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable in project translationstudio8 by heartsome.
the class FindReplaceDialog method refreshMsgAndTable.
/**
* 刷新提示信息和 Nattable
*/
private void refreshMsgAndTable() {
// 更换条件查找,当查找不到结果时,清除之前标记的红色文本
ActiveCellRegion.setActiveCellRegion(null);
statusLabel.setText(msg);
XLIFFEditorImplWithNatTable editor = XLIFFEditorImplWithNatTable.getCurrent();
editor.setFocus();
if (editor != null) {
editor.refresh();
}
}
use of net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable in project translationstudio8 by heartsome.
the class NatTableSortModel method sort.
public void sort(int columnIndex, SortDirectionEnum direction, boolean accumulate) {
String columnName = null;
XLIFFEditorImplWithNatTable xliffEditor = XLIFFEditorImplWithNatTable.getCurrent();
if (xliffEditor == null) {
return;
}
if (xliffEditor.isHorizontalLayout()) {
if (columnIndex == xliffEditor.getSrcColumnIndex()) {
columnName = "source";
} else if (columnIndex == xliffEditor.getTgtColumnIndex()) {
columnName = "target";
}
} else {
if (columnIndex == VerticalNatTableConfig.SOURCE_COL_INDEX) {
columnName = "source";
}
}
if (columnName == null) {
return;
}
HsMultiActiveCellEditor.commit(true);
clear();
sortedColumnIndexes.add(columnIndex);
sortOrders.add(columnIndex);
sortDirections.add(direction);
switch(direction) {
case NONE:
handler.resetRowIdsToUnsorted();
break;
case ASC:
handler.sort(columnName, true);
break;
case DESC:
handler.sort(columnName, false);
break;
default:
break;
}
xliffEditor.autoResize();
// Bug #2317:选中文本段后排序,不会刷新状态栏中的序号
xliffEditor.updateStatusLine();
HsMultiCellEditorControl.activeSourceAndTargetCell(xliffEditor);
}
use of net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable in project translationstudio8 by heartsome.
the class RemoveAllTagsOperation method refreshNatTable.
private void refreshNatTable() {
if (XLIFFEditorImplWithNatTable.getCurrent() != null) {
XLIFFEditorImplWithNatTable xliffEditor = XLIFFEditorImplWithNatTable.getCurrent();
xliffEditor.autoResize();
xliffEditor.refresh();
}
}
use of net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable in project translationstudio8 by heartsome.
the class ImportDocxHandler method execute.
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
XLIFFEditorImplWithNatTable xliffEditor = null;
Shell shell = HandlerUtil.getActiveShell(event);
String partId = HandlerUtil.getActivePartId(event);
IFile file = null;
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof XLIFFEditorImplWithNatTable) {
xliffEditor = (XLIFFEditorImplWithNatTable) editor;
}
if (partId.equals("net.heartsome.cat.common.ui.navigator.view")) {
// 导航视图处于激活状态
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart viewPart = page.findView("net.heartsome.cat.common.ui.navigator.view");
StructuredSelection selection = (StructuredSelection) viewPart.getSite().getSelectionProvider().getSelection();
if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
List<?> lstObj = ((IStructuredSelection) selection).toList();
ArrayList<IFile> lstXliff = new ArrayList<IFile>();
for (Object obj : lstObj) {
if (obj instanceof IFile) {
IFile tempFile = (IFile) obj;
// Linux 下的文本文件无扩展名,因此要先判断扩展名是否为空
if (tempFile.getFileExtension() != null && CommonFunction.validXlfExtension(tempFile.getFileExtension())) {
lstXliff.add(tempFile);
}
}
}
if (lstXliff.size() > 1) {
MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxHandler.msg1"));
return null;
}
if (lstXliff.size() == 1) {
file = lstXliff.get(0);
}
}
} else if (partId.equals("net.heartsome.cat.ts.ui.xliffeditor.nattable.editor")) {
// nattable 处于激活状态
IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
IEditorInput editorInput = ((IEditorPart) part).getEditorInput();
IFile iFile = (IFile) editorInput.getAdapter(IFile.class);
if (xliffEditor.isMultiFile()) {
MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxHandler.msg2"));
return null;
} else if (iFile.getFileExtension() != null && CommonFunction.validXlfExtension(iFile.getFileExtension())) {
file = iFile;
}
}
if (file != null) {
XLFValidator.resetFlag();
if (!XLFValidator.validateXliffFile(file)) {
return null;
}
XLFValidator.resetFlag();
}
ImportDocxDialog dialog = new ImportDocxDialog(shell, xliffEditor, file == null ? "" : file.getFullPath().toOSString(), file == null ? "" : ResourceUtils.iFileToOSPath(file));
dialog.open();
return null;
}
use of net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable in project translationstudio8 by heartsome.
the class ImportExternal method execute.
@SuppressWarnings("deprecation")
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
XLIFFEditorImplWithNatTable xliffEditor = null;
final Shell shell = HandlerUtil.getActiveShell(event);
String partId = HandlerUtil.getActivePartId(event);
IFile file = null;
IEditorPart editor = HandlerUtil.getActiveEditor(event);
if (editor instanceof XLIFFEditorImplWithNatTable) {
xliffEditor = (XLIFFEditorImplWithNatTable) editor;
}
if (partId.equals("net.heartsome.cat.common.ui.navigator.view")) {
// 导航视图处于激活状态
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart viewPart = page.findView("net.heartsome.cat.common.ui.navigator.view");
StructuredSelection selection = (StructuredSelection) viewPart.getSite().getSelectionProvider().getSelection();
if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
List<?> lstObj = ((IStructuredSelection) selection).toList();
ArrayList<IFile> lstXliff = new ArrayList<IFile>();
for (Object obj : lstObj) {
if (obj instanceof IFile) {
IFile tempFile = (IFile) obj;
// Linux 下的文本文件无扩展名,因此要先判断扩展名是否为空
if (tempFile.getFileExtension() != null && CommonFunction.validXlfExtension(tempFile.getFileExtension())) {
lstXliff.add(tempFile);
}
}
}
if (lstXliff.size() > 1) {
MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxHandler.msg1"));
return null;
}
if (lstXliff.size() == 1) {
file = lstXliff.get(0);
}
}
} else if (partId.equals("net.heartsome.cat.ts.ui.xliffeditor.nattable.editor")) {
// nattable 处于激活状态
IWorkbenchPart part = HandlerUtil.getActivePartChecked(event);
IEditorInput editorInput = ((IEditorPart) part).getEditorInput();
IFile iFile = (IFile) editorInput.getAdapter(IFile.class);
if (xliffEditor.isMultiFile()) {
MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxHandler.msg2"));
return null;
} else if (iFile.getFileExtension() != null && CommonFunction.validXlfExtension(iFile.getFileExtension())) {
file = iFile;
}
}
if (file != null) {
XLFValidator.resetFlag();
if (!XLFValidator.validateXliffFile(file)) {
return null;
}
XLFValidator.resetFlag();
}
final ImportConfig config = new ImportConfig();
config.setShell(shell);
config.set_xliff(file == null ? "" : file.getFullPath().toOSString());
config.setXliffEditor(xliffEditor);
config.setXliffFile(file == null ? "" : ResourceUtils.iFileToOSPath(file));
HsMultiActiveCellEditor.commit(true);
ImportExternalDialog dialog = new ImportExternalDialog(shell, xliffEditor, config);
if (Dialog.OK == dialog.open()) {
config.doImport();
if (xliffEditor != null) {
// reopen if need
if (xliffEditor.getXLFHandler().getVnMap().get(config.getXliffFile()) != null) {
Map<String, Object> resultMap = xliffEditor.getXLFHandler().openFile(config.getXliffFile());
if (resultMap == null || Constant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) resultMap.get(Constant.RETURNVALUE_RESULT)) {
// 打开文件失败。
MessageDialog.openWarning(shell, Messages.getString("all.dialog.warning"), MessageFormat.format(Messages.getString("ImportDocxDialog.ok.parseError"), config.get_xliff()));
LOGGER.error(MessageFormat.format(Messages.getString("ImportDocxDialog.ok.parseError"), config.get_xliff()));
return null;
}
xliffEditor.reloadData();
HsMultiCellEditorControl.activeSourceAndTargetCell(xliffEditor);
}
}
}
return null;
}
Aggregations