use of org.eclipse.ui.part.FileEditorInput in project translationstudio8 by heartsome.
the class MatchViewPart method reLoadMatches.
public void reLoadMatches(IXliffEditor editor, int rowIndex) {
// 修复 Bug #3064 编辑匹配--更换记忆库后再编辑原记忆库匹配,出现异常.刷新问题
// handler.getTransUnit(rowId);
TransUnitBean transUnit = editor.getRowTransUnitBean(rowIndex);
if (transUnit == null) {
return;
}
XLFHandler handler = editor.getXLFHandler();
if (handler == null) {
return;
}
IProject prj = null;
if (editor instanceof IEditorPart) {
IEditorPart p = (IEditorPart) editor;
FileEditorInput input = (FileEditorInput) p.getEditorInput();
prj = input.getFile().getProject();
}
if (prj == null) {
return;
}
String rowId = handler.getRowId(rowIndex);
TransUnitInfo2TranslationBean tuInfoBean = getTuInfoBean(transUnit, handler, rowId);
executeMatch(editor, rowId, transUnit, tuInfoBean, prj);
}
use of org.eclipse.ui.part.FileEditorInput in project translationstudio8 by heartsome.
the class MatchViewPart method manualExecSimpleTranslation.
public void manualExecSimpleTranslation(int rowIndex, IXliffEditor editor, ISimpleMatcher simpleMatcher) {
if (rowIndex == -1) {
return;
}
// handler.getTransUnit(rowId);
TransUnitBean transUnit = editor.getRowTransUnitBean(rowIndex);
if (transUnit == null) {
return;
}
XLFHandler handler = editor.getXLFHandler();
if (handler == null) {
return;
}
IProject prj = null;
if (editor instanceof IEditorPart) {
IEditorPart p = (IEditorPart) editor;
FileEditorInput input = (FileEditorInput) p.getEditorInput();
prj = input.getFile().getProject();
}
if (prj == null) {
return;
}
String rowId = handler.getRowId(rowIndex);
TransUnitInfo2TranslationBean tuInfo = getTuInfoBean(transUnit, handler, rowId);
TranslationTaskData data = new TranslationTaskData(simpleMatcher, transUnit, tuInfo, editor, rowIndex, prj);
synchronized (manualTranslationTaskContainer) {
manualTranslationTaskContainer.pushTranslationTask(data);
manualTranslationTaskContainer.notify();
}
}
use of org.eclipse.ui.part.FileEditorInput in project translationstudio8 by heartsome.
the class MatchViewPart method manualExecComplexTranslation.
public void manualExecComplexTranslation(int rowIndex, IXliffEditor editor, IComplexMatch complexMatcher) {
if (rowIndex == -1) {
return;
}
// handler.getTransUnit(rowId);
TransUnitBean transUnit = editor.getRowTransUnitBean(rowIndex);
if (transUnit == null) {
return;
}
XLFHandler handler = editor.getXLFHandler();
if (handler == null) {
return;
}
IProject prj = null;
if (editor instanceof IEditorPart) {
IEditorPart p = (IEditorPart) editor;
FileEditorInput input = (FileEditorInput) p.getEditorInput();
prj = input.getFile().getProject();
}
if (prj == null) {
return;
}
String rowId = handler.getRowId(rowIndex);
TransUnitInfo2TranslationBean tuInfo = getTuInfoBean(transUnit, handler, rowId);
TranslationTaskData data = new TranslationTaskData(complexMatcher, transUnit, tuInfo, editor, rowIndex, prj);
synchronized (manualTranslationTaskContainer) {
manualTranslationTaskContainer.pushTranslationTask(data);
manualTranslationTaskContainer.notify();
}
}
use of org.eclipse.ui.part.FileEditorInput in project translationstudio8 by heartsome.
the class XLIFFEditorImplWithNatTable method saveAs.
/**
* 另存文件
* @param newInput
* @param oldFile
* @param monitor
* ;
*/
private void saveAs(IEditorInput newInput, File oldFile, IProgressMonitor monitor) {
if (newInput == null || oldFile == null) {
return;
}
boolean success = false;
try {
if (newInput instanceof FileEditorInput) {
IFile newFile = (IFile) newInput.getAdapter(IFile.class);
if (newFile != null) {
FileInputStream fis = new FileInputStream(oldFile);
BufferedInputStream bis = new BufferedInputStream(fis);
if (newFile.exists()) {
newFile.setContents(bis, false, true, monitor);
} else {
newFile.create(bis, true, monitor);
}
bis.close();
fis.close();
}
} else if (newInput instanceof FileStoreEditorInput) {
FileStoreEditorInput storeEditorInput = (FileStoreEditorInput) newInput;
File newFile = new File(storeEditorInput.getURI());
copyFile(oldFile, newFile);
}
success = true;
} catch (CoreException e) {
LOGGER.error("", e);
final IStatus status = e.getStatus();
if (status == null || status.getSeverity() != IStatus.CANCEL) {
String title = Messages.getString("editor.XLIFFEditorImplWithNatTable.msgTitle1");
String msg = MessageFormat.format(Messages.getString("editor.XLIFFEditorImplWithNatTable.msg2"), e.getMessage());
MessageDialog.openError(getSite().getShell(), title, msg);
}
} catch (FileNotFoundException e) {
LOGGER.error("", e);
e.printStackTrace();
} catch (IOException e) {
LOGGER.error("", e);
e.printStackTrace();
} finally {
if (success) {
setInput(newInput);
}
}
if (monitor != null) {
monitor.setCanceled(!success);
}
}
use of org.eclipse.ui.part.FileEditorInput in project tdi-studio-se by Talend.
the class Problems method computeCompilationUnit.
@SuppressWarnings("restriction")
private static List<Problem> computeCompilationUnit(IFile file, ProblemType type, Item item) throws CoreException {
ERepositoryObjectType itemType = ERepositoryObjectType.getItemType(item);
// FIXME, only for standard job first, also for JobLaunchShortcut.launch
if (itemType == null || !itemType.equals(ERepositoryObjectType.PROCESS)) {
return Collections.emptyList();
}
List<Problem> compilProblems = new ArrayList<Problem>();
final ICompilationUnit unit = JavaPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(new FileEditorInput(file), false);
if (unit != null) {
CompilationUnit ast = unit.reconcile(ASTProvider.SHARED_AST_LEVEL, ICompilationUnit.FORCE_PROBLEM_DETECTION, null, null);
IProblem[] problems = ast.getProblems();
if (problems != null) {
for (IProblem p : problems) {
String[] arguments = p.getArguments();
int id = p.getID();
String message = p.getMessage();
int sourceLineNumber = p.getSourceLineNumber();
int sourceStart = p.getSourceStart();
int sourceEnd = p.getSourceEnd();
String uniName = null;
IPath location = file.getLocation();
if (location != null) {
String path = location.toString();
uniName = setErrorMark(path, sourceLineNumber);
}
ProblemStatus status = ProblemStatus.WARNING;
if (p.isError()) {
status = ProblemStatus.ERROR;
}
TalendProblem tp = new TalendProblem(status, item, null, message, sourceLineNumber, uniName, sourceStart, sourceEnd, type);
compilProblems.add(tp);
}
}
}
return compilProblems;
}
Aggregations