use of org.eclipse.ui.part.FileEditorInput in project translationstudio8 by heartsome.
the class MultiFilesOper method validExist.
/**
* 验证该合并打开的文件是否已经重复被打开,如果被合并打开,则返回true,未被打开,返回false.
* @param selectIFiles
* @return ;
*/
public boolean validExist() {
IEditorReference[] editorRes = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences();
for (int i = 0; i < editorRes.length; i++) {
if (editorRes[i].getId().equals(XLIFF_EDITOR_ID)) {
try {
IFile iFile = ((FileEditorInput) editorRes[i].getEditorInput()).getFile();
if (!"xlp".equals(iFile.getFileExtension())) {
continue;
}
} catch (Exception e) {
LOGGER.error("", e);
}
boolean isRepeat = true;
IXliffEditor xlfEditor = (IXliffEditor) editorRes[i].getEditor(true);
List<IFile> mergerIFileList = ResourceUtils.filesToIFiles(xlfEditor.getMultiFileList());
if (mergerIFileList.size() == selectIFiles.size()) {
for (IFile curIFile : selectIFiles) {
if (mergerIFileList.indexOf(curIFile) < 0) {
isRepeat = false;
break;
}
}
} else {
isRepeat = false;
}
if (isRepeat) {
return true;
}
}
}
return false;
}
use of org.eclipse.ui.part.FileEditorInput in project translationstudio8 by heartsome.
the class PreTranslationHandler method execute.
@Override
public Object execute(ExecutionEvent event, List<IFile> list) {
// 首先验证是否是合并打开的文件 --robert 2012-10-17
if (isEditor) {
try {
IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event);
IEditorReference[] editorRefe = window.getActivePage().findEditors(new FileEditorInput(list.get(0)), XLIFF_EDITOR_ID, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
if (editorRefe.length <= 0) {
return null;
}
IXliffEditor xlfEditor = (IXliffEditor) editorRefe[0].getEditor(true);
// 针对合并打开
if (xlfEditor.isMultiFile()) {
list = ResourceUtils.filesToIFiles(xlfEditor.getMultiFileList());
}
} catch (ExecutionException e) {
logger.error("", e);
}
}
CommonFunction.removeRepeateSelect(list);
PreTransUitls.executeTranslation(list, shell);
return null;
}
use of org.eclipse.ui.part.FileEditorInput in project translationstudio8 by heartsome.
the class EditProgressFA method printTransProgFAReslut.
public void printTransProgFAReslut() {
String htmlPath = createFAResultHtml();
try {
model.getAnalysisIFileList().get(0).getProject().getFolder("Intermediate").getFolder("Report").refreshLocal(IResource.DEPTH_ONE, null);
} catch (CoreException e1) {
e1.printStackTrace();
logger.error(Messages.getString("qa.fileAnalysis.EditProgressFA.log1"), e1);
}
final FileEditorInput input = new FileEditorInput(ResourceUtils.fileToIFile(htmlPath));
Display.getDefault().asyncExec(new Runnable() {
public void run() {
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, QAConstant.FA_HtmlBrowserEditor, true);
} catch (PartInitException e) {
e.printStackTrace();
logger.error(Messages.getString("qa.fileAnalysis.EditProgressFA.log2"), e);
}
}
});
}
use of org.eclipse.ui.part.FileEditorInput in project translationstudio8 by heartsome.
the class TranslationProgressFA method printTransProgFAReslut.
public void printTransProgFAReslut() {
String htmlPath = createFAResultHtml();
try {
model.getAnalysisIFileList().get(0).getProject().getFolder("Intermediate").getFolder("Report").refreshLocal(IResource.DEPTH_ONE, null);
} catch (CoreException e1) {
e1.printStackTrace();
logger.error(Messages.getString("qa.fileAnalysis.TranslationProgressFA.log1"), e1);
}
final FileEditorInput input = new FileEditorInput(ResourceUtils.fileToIFile(htmlPath));
Display.getDefault().asyncExec(new Runnable() {
public void run() {
try {
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, QAConstant.FA_HtmlBrowserEditor, true);
} catch (PartInitException e) {
e.printStackTrace();
logger.error(Messages.getString("qa.fileAnalysis.TranslationProgressFA.log2"), e);
}
}
});
}
use of org.eclipse.ui.part.FileEditorInput in project translationstudio8 by heartsome.
the class AutomaticQA method setInitData.
public void setInitData(XLFHandler handler) {
this.handler = handler;
preferenceStore = Activator.getDefault().getPreferenceStore();
model = new QAModel();
window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
filterMap = getNotIncludePara();
root = ResourcesPlugin.getWorkspace().getRoot();
xmlHandler = new QAXmlHandler();
// 存储品质检查的检查项
model.setBatchQAItemIdList(getAutoQAItems());
// 存储品质检查的检查时不包括的文本段
model.setNotInclude(filterMap);
model.setShell(window.getShell());
XLIFFEditorImplWithNatTable nattable = XLIFFEditorImplWithNatTable.getCurrent();
boolean isMultiFile = nattable.isMultiFile();
if (isMultiFile) {
model.setMuliFiles(true);
IFile multiTempIFile = ((FileEditorInput) nattable.getEditorInput()).getFile();
ArrayList<IFile> selectIFiles = (ArrayList<IFile>) ResourceUtils.filesToIFiles(nattable.getMultiFileList());
model.setMultiOper(new MultiFilesOper(selectIFiles.get(0).getProject(), selectIFiles, multiTempIFile));
} else {
model.setMuliFiles(false);
}
}
Aggregations