Java Code Examples for org.eclipse.jface.viewers.StructuredSelection#isEmpty()
The following examples show how to use
org.eclipse.jface.viewers.StructuredSelection#isEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MakrosComposite.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
@Override public void run(){ StructuredSelection selection = (StructuredSelection) viewer.getSelection(); if (selection != null && !selection.isEmpty()) { for (Object obj : selection.toList()) { if (obj instanceof MakroDTO) { MakroDTO makro = (MakroDTO) obj; if (copyExists(makro)) { if (MessageDialog.openConfirm(getShell(), "Makro kopieren", "Das Makro " + makro.getMakroName() + " existiert bei " + user.getLabel() + " bereits. Wollen Sie das Makro überschreiben?")) { copy(makro); } } else { copy(makro); } } } } }
Example 2
Source File: PatientPropertyPage.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
@Override protected void performApply(){ StructuredSelection genderSelection = (StructuredSelection) comboGeschlecht.getSelection(); if (genderSelection != null && !genderSelection.isEmpty()) { pat.setGender((Gender) genderSelection.getFirstElement()); } else { SWTHelper.showError(Messages.PatientErfassenDialog_Error_Sex, Messages.PatientErfassenDialog_Sex_must_be_specified); return; } Date bd = geburtsdatum.getSelection(); if (bd != null) { pat.setDateOfBirth(LocalDateTime.ofInstant(bd.toInstant(), ZoneId.systemDefault())); } pat.setLastName(textNachname.getText()); pat.setFirstName(textVorname.getText()); pat.setEmail(textEmail.getText()); pat.setPhone1(textTelefon1.getText()); pat.setPhone2(textTelefon2.getText()); pat.setMobile(textHandy.getText()); pat.setComment(textBemerkungen.getText()); pat.setFax(textFax.getText()); CoreModelServiceHolder.get().save(pat); }
Example 3
Source File: SendMailDialog.java From elexis-3-core with Eclipse Public License 1.0 | 6 votes |
private String getValidation(){ StructuredSelection accountSelection = (StructuredSelection) accountsViewer.getSelection(); if (accountSelection == null || accountSelection.isEmpty()) { return "Kein Konto ausgewählt."; } String accountId = (String) accountSelection.getFirstElement(); Optional<MailAccount> optionalAccount = MailClientComponent.getMailClient().getAccount(accountId); if (!optionalAccount.isPresent()) { return "Kein Konto ausgewählt."; } else { account = optionalAccount.get(); } String to = toText.getText(); if(to == null || to.isEmpty()) { return "Keine an E-Mail Adresse."; } toString = to; subjectString = subjectText.getText(); textString = textText.getText(); return null; }
Example 4
Source File: ConditionHelpers.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
@Override public boolean test() throws Exception { StructuredSelection eventsTableSelection = getEventsTableSelection(); if (eventsTableSelection.isEmpty()) { return false; } fCurValue = ((ITmfEvent) eventsTableSelection.getFirstElement()).getTimestamp().getValue(); return fCurValue == fSelectionTime; }
Example 5
Source File: InvoiceListHeaderComposite.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
/** * * @return the int value of the selected {@link InvoiceState} or <code>null</code> if no valid * selection */ Integer getSelectedInvoiceStateNo(){ StructuredSelection ss = (StructuredSelection) comboViewerStatus.getSelection(); if (!ss.isEmpty()) { Object firstElement = ss.getFirstElement(); if (firstElement instanceof InvoiceState) { return ((InvoiceState) firstElement).numericValue(); } } return null; }
Example 6
Source File: BreadcrumbNavigationView.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
private IModelNode getFirstElementInSelection() { StructuredSelection currentSelection = (StructuredSelection) getSelection(); if (currentSelection == null || currentSelection.isEmpty()) { return null; } return (IModelNode) currentSelection.getFirstElement(); }
Example 7
Source File: TemplateSelectionPage.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public void selectionChanged(SelectionChangedEvent event) { StructuredSelection selection = (StructuredSelection) event.getSelection(); if (!selection.isEmpty()) { setPreviewContent(((TemplateElement) selection.getFirstElement())); } else { setPreviewContent(null); } }
Example 8
Source File: EditorBreadcrumb.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean doOpen(ISelection selection) { if (!(selection instanceof StructuredSelection)) return false; StructuredSelection structuredSelection= (StructuredSelection) selection; if (structuredSelection.isEmpty()) return false; return open(structuredSelection.getFirstElement()); }
Example 9
Source File: InvoiceCorrectionView.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public DiagnosesDTO getSelection(){ if (tableViewer != null) { StructuredSelection structuredSelection = (StructuredSelection) tableViewer.getSelection(); if (!structuredSelection.isEmpty()) { return (DiagnosesDTO) structuredSelection.getFirstElement(); } } return null; }
Example 10
Source File: ZestContentViewer.java From gef with Eclipse Public License 2.0 | 5 votes |
@Override public void setSelection(ISelection selection, boolean reveal) { if (selection.isEmpty()) { getSelectionModel().clearSelection(); } else if (selection instanceof StructuredSelection) { StructuredSelection structuredSelection = (StructuredSelection) selection; if (!structuredSelection.isEmpty()) { List<IContentPart<? extends javafx.scene.Node>> toBeSelectedParts = new ArrayList<>(); for (Object toBeSelectedContent : structuredSelection.toArray()) { IContentPart<? extends javafx.scene.Node> toBeSelectedPart = viewer.getContentPartMap() .get(toBeSelectedContent); if (toBeSelectedPart != null) { toBeSelectedParts.add(toBeSelectedPart); if (reveal) { // TODO: we need to reveal all in a single step viewer.reveal(toBeSelectedPart); } } else { throw new IllegalArgumentException( toBeSelectedContent + " is not visualized by a content part of this viewer."); } } getSelectionModel().prependToSelection(toBeSelectedParts); } } else { throw new IllegalArgumentException( "A non-empty selection of unsupported type '" + selection.getClass() + "' was passed in."); } }
Example 11
Source File: EigenartikelSelector.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
@Override public void selectionChanged(SelectionChangedEvent event){ TreeViewer tv = (TreeViewer) event.getSource(); StructuredSelection ss = (StructuredSelection) tv.getSelection(); tvfa.updateSelection(ss.isEmpty() ? null : ss.getFirstElement()); if (!ss.isEmpty()) { IArticle ea = (IArticle) ss.getFirstElement(); ContextServiceHolder.get().getRootContext() .setNamed("ch.elexis.core.ui.eigenartikel.selection", ea); } else { ContextServiceHolder.get().getRootContext() .setNamed("ch.elexis.core.ui.eigenartikel.selection", null); } }
Example 12
Source File: EditorBreadcrumb.java From birt with Eclipse Public License 1.0 | 5 votes |
private boolean doReveal( ISelection selection ) { if ( !( selection instanceof StructuredSelection ) ) return false; StructuredSelection structuredSelection = (StructuredSelection) selection; if ( structuredSelection.isEmpty( ) ) return false; return reveal( structuredSelection.getFirstElement( ) ); }
Example 13
Source File: InvoiceCorrectionView.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public LeistungDTO getSelection(){ if (tableViewer != null) { StructuredSelection structuredSelection = (StructuredSelection) tableViewer.getSelection(); if (!structuredSelection.isEmpty()) { return (LeistungDTO) structuredSelection.getFirstElement(); } } return null; }
Example 14
Source File: ImportArticleDialog.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
private void doImport(){ StringBuffer buf = new StringBuffer(); // check for store availability // check for stock availability StructuredSelection iSelection = (StructuredSelection) comboStockType.getSelection(); if (iSelection.isEmpty()) { buf.append("Bitte wählen Sie ein Lager aus."); } else { final Stock stock = (Stock) iSelection.getFirstElement(); // check src file String path = tFilePath.getText(); if (path != null && !path.isEmpty() && path.toLowerCase().endsWith("xls")) { try (FileInputStream is = new FileInputStream(tFilePath.getText())) { ExcelWrapper xl = new ExcelWrapper(); if (xl.load(is, 0)) { xl.setFieldTypes(new Class[] { Integer.class, String.class, String.class, String.class, String.class, String.class, Integer.class, String.class, String.class, String.class }); MessageDialog dialog = new MessageDialog(getShell(), "Datenimport", null, "Wie sollen die Datenbestände importiert werden ?", MessageDialog.QUESTION, 0, "Datenbestand 'exakt' importieren", "Datenbestand 'aufaddieren'"); int ret = dialog.open(); if (ret >= 0) { runImport(buf, stock, xl, ret == 0); } return; } } catch (IOException e) { MessageDialog.openError(getShell(), "Import error", "Import fehlgeschlagen.\nDatei nicht importierbar: " + path); LoggerFactory.getLogger(ImportArticleDialog.class) .error("cannot import file at " + path, e); } } else { buf.append( "Die Quelldatei ist ungültig. Bitte überprüfen Sie diese Datei.\n" + path); } } if (buf.length() > 0) { MessageDialog.openInformation(getShell(), "Import Ergebnis", buf.toString()); } else { MessageDialog.openWarning(getShell(), "Import Ergebnis", "Import nicht möglich.\nÜberprüfen Sie das Log-File."); } }
Example 15
Source File: EndLocalDocumentHandler.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException{ IEclipseContext iEclipseContext = PlatformUI.getWorkbench().getService(IEclipseContext.class); StructuredSelection selection = (StructuredSelection) iEclipseContext .get(event.getCommand().getId().concat(".selection")); iEclipseContext.remove(event.getCommand().getId().concat(".selection")); if (selection != null && !selection.isEmpty()) { List<?> selected = selection.toList(); Shell parentShell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(); for (Object object : selected) { LocalDocumentServiceHolder.getService().ifPresent(service -> { if (service.contains(object)) { Optional<LocalLock> lock = LocalLock.getManagedLock(object); lock.ifPresent(localDocumentLock -> localDocumentLock.unlock()); if (!service.save(object)) { MessageDialog.openError(parentShell, Messages.EndLocalDocumentHandler_errorttitle, Messages.EndLocalDocumentHandler_errormessage); } service.remove(object, new IConflictHandler() { @Override public Result getResult(){ if (MessageDialog.openQuestion(parentShell, Messages.EndLocalDocumentHandler_conflicttitle, Messages.EndLocalDocumentHandler_conflictmessage)) { return Result.OVERWRITE; } else { return Result.ABORT; } } }); } else { MessageDialog.openInformation(parentShell, Messages.EndLocalDocumentHandler_infotitle, Messages.EndLocalDocumentHandler_infomessage); } }); } } return null; }
Example 16
Source File: ExportRTFHandler.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { String tshelp = System.getProperties().getProperty("TSHelp"); String tsstate = System.getProperties().getProperty("TSState"); if (tshelp == null || !"true".equals(tshelp) || tsstate == null || !"true".equals(tsstate)) { LoggerFactory.getLogger(ExportRTFHandler.class).error("Exception:key hs008 is lost.(Can't find the key)"); System.exit(0); } Shell shell = HandlerUtil.getActiveShell(event); String partId = HandlerUtil.getActivePartId(event); IFile file = null; 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(); // ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) { List<?> lstObj = ((IStructuredSelection) selection).toList(); ArrayList<IFile> lstXliff = new ArrayList<IFile>(); for (Object obj : lstObj) { if (obj instanceof IFile) { IFile tempFile = (IFile) obj; // Linux 下的文本文件无扩展名,因此要先判断扩展名是否为空 if (tempFile.getFileExtension() != null && CommonFunction.validXlfExtension(tempFile.getFileExtension())) { lstXliff.add(tempFile); } } } if (lstXliff.size() > 1) { MessageDialog.openInformation(shell, Messages.getString("handler.ExportRTFHandler.msg.title"), Messages.getString("handler.ExportRTFHandler.msg1")); return null; } if (lstXliff.size() == 1) { file = lstXliff.get(0); } } } 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("handler.ExportRTFHandler.msg.title"), Messages.getString("handler.ExportRTFHandler.msg2")); return null; } else if (iFile.getFileExtension() != null && CommonFunction.validXlfExtension(iFile.getFileExtension())) { file = iFile; } } if (file != null) { XLFValidator.resetFlag(); if (!XLFValidator.validateXliffFile(file)) { return null; } XLFValidator.resetFlag(); } ExportRTFDilaog dialog = new ExportRTFDilaog(shell, file == null ? "" : file.getFullPath().toOSString(), file == null ? "" : ResourceUtils.iFileToOSPath(file)); dialog.open(); return null; }
Example 17
Source File: ImportExternal.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
@SuppressWarnings("deprecation") @Override public Object execute(ExecutionEvent event) throws ExecutionException { XLIFFEditorImplWithNatTable xliffEditor = null; final Shell shell = HandlerUtil.getActiveShell(event); String partId = HandlerUtil.getActivePartId(event); IFile file = null; IEditorPart editor = HandlerUtil.getActiveEditor(event); if (editor instanceof XLIFFEditorImplWithNatTable) { xliffEditor = (XLIFFEditorImplWithNatTable) editor; } 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() && selection instanceof IStructuredSelection) { List<?> lstObj = ((IStructuredSelection) selection).toList(); ArrayList<IFile> lstXliff = new ArrayList<IFile>(); for (Object obj : lstObj) { if (obj instanceof IFile) { IFile tempFile = (IFile) obj; // Linux 下的文本文件无扩展名,因此要先判断扩展名是否为空 if (tempFile.getFileExtension() != null && CommonFunction.validXlfExtension(tempFile.getFileExtension())) { lstXliff.add(tempFile); } } } if (lstXliff.size() > 1) { MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxHandler.msg1")); return null; } if (lstXliff.size() == 1) { file = lstXliff.get(0); } } } 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); if (xliffEditor.isMultiFile()) { MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxHandler.msg2")); return null; } else if (iFile.getFileExtension() != null && CommonFunction.validXlfExtension(iFile.getFileExtension())) { file = iFile; } } if (file != null) { XLFValidator.resetFlag(); if (!XLFValidator.validateXliffFile(file)) { return null; } XLFValidator.resetFlag(); } final ImportConfig config = new ImportConfig(); config.setShell(shell); config.set_xliff(file == null ? "" : file.getFullPath().toOSString()); config.setXliffEditor(xliffEditor); config.setXliffFile(file == null ? "" : ResourceUtils.iFileToOSPath(file)); HsMultiActiveCellEditor.commit(true); ImportExternalDialog dialog = new ImportExternalDialog(shell, xliffEditor, config); if (Dialog.OK == dialog.open()) { config.doImport(); if (xliffEditor != null) { // reopen if need if (xliffEditor.getXLFHandler().getVnMap().get(config.getXliffFile()) != null) { Map<String, Object> resultMap = xliffEditor.getXLFHandler().openFile(config.getXliffFile()); if (resultMap == null || Constant.RETURNVALUE_RESULT_SUCCESSFUL != (Integer) resultMap .get(Constant.RETURNVALUE_RESULT)) { // 打开文件失败。 MessageDialog.openWarning( shell, Messages.getString("all.dialog.warning"), MessageFormat.format(Messages.getString("ImportDocxDialog.ok.parseError"), config.get_xliff())); LOGGER.error(MessageFormat.format(Messages.getString("ImportDocxDialog.ok.parseError"), config.get_xliff())); return null; } xliffEditor.reloadData(); HsMultiCellEditorControl.activeSourceAndTargetCell(xliffEditor); } } } return null; }
Example 18
Source File: AbstractExportHandler.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
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; }
Example 19
Source File: ExportDocxHandler.java From translationstudio8 with GNU General Public License v2.0 | votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { Shell shell = HandlerUtil.getActiveShell(event); String partId = HandlerUtil.getActivePartId(event); IFile file = null; 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(); // ISelection selection = HandlerUtil.getCurrentSelection(event); if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) { List<?> lstObj = ((IStructuredSelection) selection).toList(); ArrayList<IFile> lstXliff = new ArrayList<IFile>(); for (Object obj : lstObj) { if (obj instanceof IFile) { IFile tempFile = (IFile) obj; // Linux 下的文本文件无扩展名,因此要先判断扩展名是否为空 if (tempFile.getFileExtension() != null && CommonFunction.validXlfExtension(tempFile.getFileExtension())) { lstXliff.add(tempFile); } } } if (lstXliff.size() > 1) { MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ExportDocxHandler.msg1")); return null; } if (lstXliff.size() == 1) { file = lstXliff.get(0); } } } 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 null; } else if (iFile.getFileExtension() != null && CommonFunction.validXlfExtension(iFile.getFileExtension())) { file = iFile; } } if (file != null) { XLFValidator.resetFlag(); if (!XLFValidator.validateXliffFile(file)) { return null; } XLFValidator.resetFlag(); } ExportDocxDialog dialog = new ExportDocxDialog(shell, file == null ? "" : file.getFullPath().toOSString(), file == null ? "" : ResourceUtils.iFileToOSPath(file)); dialog.open(); return null; }
Example 20
Source File: ImportDocxHandler.java From translationstudio8 with GNU General Public License v2.0 | votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { XLIFFEditorImplWithNatTable xliffEditor = null; Shell shell = HandlerUtil.getActiveShell(event); String partId = HandlerUtil.getActivePartId(event); IFile file = null; IEditorPart editor = HandlerUtil.getActiveEditor(event); if (editor instanceof XLIFFEditorImplWithNatTable) { xliffEditor = (XLIFFEditorImplWithNatTable) editor; } 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() && selection instanceof IStructuredSelection) { List<?> lstObj = ((IStructuredSelection) selection).toList(); ArrayList<IFile> lstXliff = new ArrayList<IFile>(); for (Object obj : lstObj) { if (obj instanceof IFile) { IFile tempFile = (IFile) obj; // Linux 下的文本文件无扩展名,因此要先判断扩展名是否为空 if (tempFile.getFileExtension() != null && CommonFunction.validXlfExtension(tempFile.getFileExtension())) { lstXliff.add(tempFile); } } } if (lstXliff.size() > 1) { MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxHandler.msg1")); return null; } if (lstXliff.size() == 1) { file = lstXliff.get(0); } } } 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); if (xliffEditor.isMultiFile()) { MessageDialog.openInformation(shell, Messages.getString("all.dialog.ok.title"), Messages.getString("ImportDocxHandler.msg2")); return null; } else if (iFile.getFileExtension() != null && CommonFunction.validXlfExtension(iFile.getFileExtension())) { file = iFile; } } if (file != null) { XLFValidator.resetFlag(); if (!XLFValidator.validateXliffFile(file)) { return null; } XLFValidator.resetFlag(); } ImportDocxDialog dialog = new ImportDocxDialog(shell, xliffEditor, file == null ? "" : file.getFullPath().toOSString(), file == null ? "" : ResourceUtils.iFileToOSPath(file)); dialog.open(); return null; }