Search in sources :

Example 16 with FileEditorInput

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;
}
Also used : IEditorReference(org.eclipse.ui.IEditorReference) IFile(org.eclipse.core.resources.IFile) FileEditorInput(org.eclipse.ui.part.FileEditorInput) CoreException(org.eclipse.core.runtime.CoreException) PartInitException(org.eclipse.ui.PartInitException) IXliffEditor(net.heartsome.cat.ts.ui.editors.IXliffEditor)

Example 17 with FileEditorInput

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;
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IEditorReference(org.eclipse.ui.IEditorReference) FileEditorInput(org.eclipse.ui.part.FileEditorInput) ExecutionException(org.eclipse.core.commands.ExecutionException) IXliffEditor(net.heartsome.cat.ts.ui.editors.IXliffEditor)

Example 18 with FileEditorInput

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);
            }
        }
    });
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) FileEditorInput(org.eclipse.ui.part.FileEditorInput) PartInitException(org.eclipse.ui.PartInitException)

Example 19 with FileEditorInput

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);
            }
        }
    });
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) FileEditorInput(org.eclipse.ui.part.FileEditorInput) PartInitException(org.eclipse.ui.PartInitException)

Example 20 with FileEditorInput

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);
    }
}
Also used : XLIFFEditorImplWithNatTable(net.heartsome.cat.ts.ui.xliffeditor.nattable.editor.XLIFFEditorImplWithNatTable) IFile(org.eclipse.core.resources.IFile) FileEditorInput(org.eclipse.ui.part.FileEditorInput) QAXmlHandler(net.heartsome.cat.ts.core.qa.QAXmlHandler) ArrayList(java.util.ArrayList) MultiFilesOper(net.heartsome.cat.ts.ui.util.MultiFilesOper) QAModel(net.heartsome.cat.ts.ui.qa.model.QAModel)

Aggregations

FileEditorInput (org.eclipse.ui.part.FileEditorInput)262 IFile (org.eclipse.core.resources.IFile)187 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)99 PartInitException (org.eclipse.ui.PartInitException)96 IEditorPart (org.eclipse.ui.IEditorPart)64 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)58 IPath (org.eclipse.core.runtime.IPath)57 IEditorInput (org.eclipse.ui.IEditorInput)55 CoreException (org.eclipse.core.runtime.CoreException)51 IResource (org.eclipse.core.resources.IResource)39 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)38 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)37 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)35 SaveAsDialog (org.eclipse.ui.dialogs.SaveAsDialog)35 EObject (org.eclipse.emf.ecore.EObject)33 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)33 HashMap (java.util.HashMap)32 Resource (org.eclipse.emf.ecore.resource.Resource)32 ISelection (org.eclipse.jface.viewers.ISelection)32 URI (org.eclipse.emf.common.util.URI)31