use of org.eclipse.ui.part.FileEditorInput in project translationstudio8 by heartsome.
the class WordsFA method printWordsFAReslut.
//-------------------------------------------------------------------------------------------//
//---------------------------------下面的代码主要是报表部份---------------------------------------//
//-------------------------------------------------------------------------------------------//
/**
* 输出字数统计结果到结果窗体中
* @param WordsFAResultMap
*/
public void printWordsFAReslut() {
String htmlPath = createFAResultHtml();
try {
model.getAnalysisIFileList().get(0).getProject().getFolder("Intermediate").getFolder("Report").refreshLocal(IResource.DEPTH_INFINITE, null);
} catch (CoreException e1) {
e1.printStackTrace();
}
final FileEditorInput input = new FileEditorInput(ResourceUtils.fileToIFile(htmlPath));
if (PlatformUI.getWorkbench().isClosing()) {
return;
}
Display.getDefault().asyncExec(new Runnable() {
public void run() {
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, QAConstant.FA_HtmlBrowserEditor, true);
} catch (PartInitException e) {
logger.error(Messages.getString("qa.fileAnalysis.WordsFA.log5"), e);
e.printStackTrace();
}
}
});
}
use of org.eclipse.ui.part.FileEditorInput in project translationstudio8 by heartsome.
the class QAResultViewPart method openMultiFilesEditor.
/**
* 处理合并打开文件 nattable editor的相关问题
* @return ;
*/
public IXliffEditor openMultiFilesEditor() {
IXliffEditor xliffEditor = null;
FileEditorInput fileInput = new FileEditorInput(oper.getCurMultiTempFile());
IEditorReference[] editorRefer = window.getActivePage().findEditors(fileInput, XLIFF_EDITOR_ID, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
IEditorPart editorPart = null;
if (editorRefer.length >= 1) {
editorPart = editorRefer[0].getEditor(true);
xliffEditor = (IXliffEditor) editorPart;
// 若该文件未激活,激活此文件
if (window.getActivePage().getActiveEditor() != editorPart) {
window.getActivePage().activate(editorPart);
}
// 对于已经打开过的文件,进行重排序
xliffEditor.resetOrder();
} else {
// 如果文件没有打开,那么先打开文件
try {
// 如果保存合并打开所有信息的临时文件已经被删除,那么,重新生成临时文件
if (!oper.getCurMultiTempFile().getLocation().toFile().exists()) {
// 检查这两个文件是否重新进行合并打开了的。
IFile findMultiTempIfile = oper.getMultiFilesTempIFile(true);
if (findMultiTempIfile != null) {
fileInput = new FileEditorInput(findMultiTempIfile);
oper.setCurMultiTempFile(findMultiTempIfile);
} else {
//先验证这些所处理的文件是否有已经被打开的
List<IFile> openedFileList = oper.getOpenedIfile();
if (openedFileList.size() > 0) {
String openFileStr = "";
for (IFile ifile : openedFileList) {
openFileStr += "\t" + ifile.getFullPath().toOSString() + "\n";
}
MessageDialog.openInformation(getSite().getShell(), Messages.getString("views.QAResultViewPart.msgTitle"), MessageFormat.format(Messages.getString("qa.views.QAResultViewPart.addTip1"), openFileStr));
return null;
}
// 如果选中的文件没有合并打开,那么就重新打开它们
IFile multiIFile = oper.createMultiTempFile();
if (multiIFile != null && multiIFile.exists()) {
fileInput = new FileEditorInput(multiIFile);
oper.setCurMultiTempFile(multiIFile);
} else {
MessageDialog.openInformation(getSite().getShell(), Messages.getString("views.QAResultViewPart.msgTitle"), Messages.getString("views.QAResultViewPart.msg1"));
return null;
}
xliffEditor = (IXliffEditor) window.getActivePage().openEditor(fileInput, XLIFF_EDITOR_ID, true, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
}
}
} catch (PartInitException e) {
e.printStackTrace();
logger.error(Messages.getString("qa.views.QAResultViewPart.log2"), e);
}
}
return xliffEditor;
}
use of org.eclipse.ui.part.FileEditorInput 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 org.eclipse.ui.part.FileEditorInput 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 org.eclipse.ui.part.FileEditorInput 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;
}
Aggregations