use of net.heartsome.cat.ts.ui.external.ExportConfig in project translationstudio8 by heartsome.
the class AbstractExportHandler method initExportConfig.
public boolean initExportConfig(ExecutionEvent event) throws ExecutionException {
config = new ExportConfig();
Shell shell = HandlerUtil.getActiveShell(event);
String partId = HandlerUtil.getActivePartId(event);
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()) {
for (Object obj : selection.toList()) {
if (obj instanceof IFile) {
addXLFFile((IFile) obj);
} else if (obj instanceof IFolder) {
traversalFile((IFolder) obj);
} else if (obj instanceof IProject) {
IProject proj = (IProject) obj;
traversalFile(proj.getFolder(XLF));
}
}
if (config.getProjects() == null || config.getProjects().size() < 1) {
MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("xlf2tmx.info.notfoundxlf"));
return false;
}
}
} 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);
IEditorPart editor = HandlerUtil.getActiveEditor(event);
IXliffEditor xliffEditor = (IXliffEditor) editor;
if (xliffEditor.isMultiFile()) {
MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ExportDocxHandler.msg2"));
return false;
} else if (iFile.getFileExtension() != null && CommonFunction.validXlfExtension(iFile.getFileExtension())) {
addXLFFile(iFile);
}
}
return true;
}
Aggregations