Java Code Examples for org.eclipse.ui.handlers.HandlerUtil#getActiveWorkbenchWindowChecked()
The following examples show how to use
org.eclipse.ui.handlers.HandlerUtil#getActiveWorkbenchWindowChecked() .
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: ShowNextUntranslatedHandler.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart editor = HandlerUtil.getActiveEditor(event); if (!(editor instanceof XLIFFEditorImplWithNatTable)) { return null; } XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; int[] selectedRows = xliffEditor.getSelectedRows(); if (selectedRows.length < 1) { return null; } Arrays.sort(selectedRows); int lastSelectedRow = selectedRows[selectedRows.length - 1]; XLFHandler handler = xliffEditor.getXLFHandler(); int row = handler.getNextUntranslatedSegmentIndex(lastSelectedRow); if (row != -1) { xliffEditor.jumpToRow(row); } else { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); MessageDialog.openWarning(window.getShell(), "", "不存在下一未翻译文本段。"); } return null; }
Example 2
Source File: ShowNextUntranslatedHandler.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart editor = HandlerUtil.getActiveEditor(event); if (!(editor instanceof XLIFFEditorImplWithNatTable)) { return null; } XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; int[] selectedRows = xliffEditor.getSelectedRows(); if (selectedRows.length < 1) { return null; } Arrays.sort(selectedRows); int lastSelectedRow = selectedRows[selectedRows.length - 1]; XLFHandler handler = xliffEditor.getXLFHandler(); int row = handler.getNextUntranslatedSegmentIndex(lastSelectedRow); if (row != -1) { xliffEditor.jumpToRow(row); } else { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); MessageDialog.openWarning(window.getShell(), "", "不存在下一未翻译文本段。"); } return null; }
Example 3
Source File: ShowNextUntranslatableHandler.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart editor = HandlerUtil.getActiveEditor(event); if (!(editor instanceof XLIFFEditorImplWithNatTable)) { return null; } XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; int[] selectedRows = xliffEditor.getSelectedRows(); if (selectedRows.length < 1) { return null; } Arrays.sort(selectedRows); int lastSelectedRow = selectedRows[selectedRows.length - 1]; XLFHandler handler = xliffEditor.getXLFHandler(); int row = handler.getNextUntranslatableSegmentIndex(lastSelectedRow); if (row != -1) { xliffEditor.jumpToRow(row); } else { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); MessageDialog.openWarning(window.getShell(), "", "不存在下一不可翻译文本段。"); } return null; }
Example 4
Source File: OpenXFindPanelHandler.java From xds-ide with Eclipse Public License 1.0 | 6 votes |
/** * {@inheritDoc} */ @Override // IHandler public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); IEditorPart part = window.getActivePage().getActiveEditor(); XFindPanel panel = XFindPanelManager.getXFindPanel(part, true); if (panel != null) { panel.showPanel(); } else { // failed to create XFindPanel, execute standard command "Find and Replace". IHandlerService handlerService = (IHandlerService)window.getService(IHandlerService.class); try { handlerService.executeCommand(IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE, null); } catch (Exception ex) { LogHelper.logError("Command " + IWorkbenchCommandConstants.EDIT_FIND_AND_REPLACE + " not found"); //$NON-NLS-1$ //$NON-NLS-2$ } } return null; }
Example 5
Source File: ShowPreviousUntranslatableHandler.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart editor = HandlerUtil.getActiveEditor(event); if (!(editor instanceof XLIFFEditorImplWithNatTable)) { return null; } XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; int[] selectedRows = xliffEditor.getSelectedRows(); if (selectedRows.length < 1) { return null; } Arrays.sort(selectedRows); int firstSelectedRow = selectedRows[0]; XLFHandler handler = xliffEditor.getXLFHandler(); int row = handler.getPreviousUntranslatableSegmentIndex(firstSelectedRow); if (row != -1) { xliffEditor.jumpToRow(row); } else { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); MessageDialog.openWarning(window.getShell(), "", "不存在上一不可翻译文本段。"); } return null; }
Example 6
Source File: ExportHandler.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IStructuredSelection currentSelection = getSelectionToUse(event); IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); IExportWizard wizard = getExportWizard(event); wizard.init(window.getWorkbench(), currentSelection); TSWizardDialog dialog = new TSWizardDialog(window.getShell(), wizard); dialog.create(); dialog.open(); return null; }
Example 7
Source File: DeleteAllSegmentNoteHandler.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart editor = HandlerUtil.getActiveEditor(event); if (!(editor instanceof XLIFFEditorImplWithNatTable)) { return null; } IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); boolean res = MessageDialog.openConfirm(window.getShell(), "删除确认", "确定要删除所有文本段的全部批注吗?"); if (res) { XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; XLFHandler handler = xliffEditor.getXLFHandler(); handler.deleteAllSegmentNote(); } return null; }
Example 8
Source File: SampleHandler.java From codeexamples-eclipse with Eclipse Public License 1.0 | 5 votes |
@Override public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); MessageDialog.openInformation( window.getShell(), "Testing", "Hello, Eclipse world"); return null; }
Example 9
Source File: DeleteAllSegmentNoteHandler.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart editor = HandlerUtil.getActiveEditor(event); if (!(editor instanceof XLIFFEditorImplWithNatTable)) { return null; } IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); boolean res = MessageDialog.openConfirm(window.getShell(), "删除确认", "确定要删除所有文本段的全部批注吗?"); if (res) { XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; XLFHandler handler = xliffEditor.getXLFHandler(); handler.deleteAllSegmentNote(); } return null; }
Example 10
Source File: CloseXFindPanelHandler.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override // IHandler public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); IEditorPart part = window.getActivePage().getActiveEditor(); XFindPanel panel = XFindPanelManager.getXFindPanel(part, false); if (panel != null) { panel.hidePanel(); } return null; }
Example 11
Source File: FindPreviousMatchHandler.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override // IHandler public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); IEditorPart part = window.getActivePage().getActiveEditor(); XFindPanel panel = XFindPanelManager.getXFindPanel(part, false); if (panel != null) { panel.findPrevious(); } return null; }
Example 12
Source File: QuickFindNextOccurrenceHandler.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override // IHandler public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); IEditorPart part = window.getActivePage().getActiveEditor(); if (part != null && !XFindPanelManager.isXFindPanelOpened(part)) { QuickXFind.findNext(part); } return null; }
Example 13
Source File: XFindTextSelectLineStartHandler.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override // IHandler public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); IEditorPart part = window.getActivePage().getActiveEditor(); XFindPanel panel = XFindPanelManager.getXFindPanel(part, false); if (panel != null) { panel.selectLineStart(); } return null; }
Example 14
Source File: PreTranslationHandler.java From translationstudio8 with GNU General Public License v2.0 | 5 votes |
@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; }
Example 15
Source File: ShowXFindSettingsHandler.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override // IHandler public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); IEditorPart part = window.getActivePage().getActiveEditor(); XFindPanel panel = XFindPanelManager.getXFindPanel(part, false); if (panel != null) { panel.showSettings(); } return null; }
Example 16
Source File: ShowXFindHistoryHandler.java From xds-ide with Eclipse Public License 1.0 | 5 votes |
/** * {@inheritDoc} */ @Override // IHandler public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); IEditorPart part = window.getActivePage().getActiveEditor(); XFindPanel panel = XFindPanelManager.getXFindPanel(part, false); if (panel != null) { panel.showHistoryMenu(); } return null; }
Example 17
Source File: DeveloperStudioAboutPageHandler.java From developer-studio with Apache License 2.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); Shell shell = window.getShell(); shell.setText("Developer Studio"); AboutDialog aboutDialog = new AboutDialog(shell); aboutDialog.open(); return null; }
Example 18
Source File: OpenToolBarHandler.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { final IWorkbenchWindow activeWorkbenchWindow = HandlerUtil.getActiveWorkbenchWindowChecked(event); if (activeWorkbenchWindow instanceof WorkbenchWindow) { WorkbenchWindow window = (WorkbenchWindow) activeWorkbenchWindow; window.toggleToolbarVisibility(); } ICommandService commandService = (ICommandService) PlatformUI.getWorkbench().getService(ICommandService.class); commandService.refreshElements(event.getCommand().getId(), null); return null; }
Example 19
Source File: MergeXliffHandler.java From translationstudio8 with GNU General Public License v2.0 | 4 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); final Shell shell = window.getShell(); ISelection currentSelection = HandlerUtil.getCurrentSelection(event); if (currentSelection != null && !currentSelection.isEmpty() && currentSelection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) currentSelection; if (structuredSelection.size() < 2) { MessageDialog.openInformation(shell, Messages.getString("handler.MergeXliffHandler.msgTitle1"), Messages.getString("handler.MergeXliffHandler.msg1")); return null; } Vector<IFile> seleFiles = new Vector<IFile>(); String notXlfFile = ""; @SuppressWarnings("rawtypes") Iterator selectIt = structuredSelection.iterator(); while (selectIt.hasNext()) { Object object = selectIt.next(); if (object instanceof IFile) { IFile selectFile = (IFile) object; String fileExtension = selectFile.getFileExtension(); // 如果后缀名不是xlf,那么就进行提示 if (fileExtension == null || !CommonFunction.validXlfExtension(fileExtension)) { notXlfFile += selectFile.getFullPath().toOSString() + ","; } seleFiles.add(selectFile); } } if (notXlfFile.length() > 0) { notXlfFile = notXlfFile.substring(0, notXlfFile.length() - 1); boolean isSure = MessageDialog.openConfirm(shell, Messages .getString("handler.MergeXliffHandler.msgTitle2"), MessageFormat.format( Messages.getString("handler.MergeXliffHandler.msg2"), new Object[] { notXlfFile })); if (!isSure) { return null; } } List<IFile> lstFiles = new ArrayList<IFile>(); XLFValidator.resetFlag(); for (IFile iFile : seleFiles) { if (!XLFValidator.validateXliffFile(iFile)) { lstFiles.add(iFile); } } XLFValidator.resetFlag(); seleFiles.removeAll(lstFiles); if (seleFiles.size() == 0) { return null; } if (seleFiles.size() > 0) { String projectPath = seleFiles.get(0).getProject().getFullPath().toOSString(); for (int i = 1; i < seleFiles.size(); i++) { if (!projectPath.equals(seleFiles.get(i).getProject().getFullPath().toOSString())) { MessageDialog.openInformation(shell, Messages.getString("handler.MergeXliffHandler.msgTitle1"), Messages.getString("handler.MergeXliffHandler.msg3")); return null; } } SplitOrMergeXlfModel model = new SplitOrMergeXlfModel(); model.setMergeXliffFile(seleFiles); MergeXliffWizard wizard = new MergeXliffWizard(model); TSWizardDialog dialog = new NattableWizardDialog(shell, wizard); dialog.open(); } } return null; }
Example 20
Source File: MergeXliffHandler.java From tmxeditor8 with GNU General Public License v2.0 | 4 votes |
public Object execute(ExecutionEvent event) throws ExecutionException { IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindowChecked(event); final Shell shell = window.getShell(); ISelection currentSelection = HandlerUtil.getCurrentSelection(event); if (currentSelection != null && !currentSelection.isEmpty() && currentSelection instanceof IStructuredSelection) { IStructuredSelection structuredSelection = (IStructuredSelection) currentSelection; if (structuredSelection.size() < 2) { MessageDialog.openInformation(shell, Messages.getString("handler.MergeXliffHandler.msgTitle1"), Messages.getString("handler.MergeXliffHandler.msg1")); return null; } Vector<IFile> seleFiles = new Vector<IFile>(); String notXlfFile = ""; @SuppressWarnings("rawtypes") Iterator selectIt = structuredSelection.iterator(); while (selectIt.hasNext()) { Object object = selectIt.next(); if (object instanceof IFile) { IFile selectFile = (IFile) object; String fileExtension = selectFile.getFileExtension(); // 如果后缀名不是xlf,那么就进行提示 if (fileExtension == null || !CommonFunction.validXlfExtension(fileExtension)) { notXlfFile += selectFile.getFullPath().toOSString() + ","; } seleFiles.add(selectFile); } } if (notXlfFile.length() > 0) { notXlfFile = notXlfFile.substring(0, notXlfFile.length() - 1); boolean isSure = MessageDialog.openConfirm(shell, Messages .getString("handler.MergeXliffHandler.msgTitle2"), MessageFormat.format( Messages.getString("handler.MergeXliffHandler.msg2"), new Object[] { notXlfFile })); if (!isSure) { return null; } } List<IFile> lstFiles = new ArrayList<IFile>(); XLFValidator.resetFlag(); for (IFile iFile : seleFiles) { if (!XLFValidator.validateXliffFile(iFile)) { lstFiles.add(iFile); } } XLFValidator.resetFlag(); seleFiles.removeAll(lstFiles); if (seleFiles.size() == 0) { return null; } if (seleFiles.size() > 0) { String projectPath = seleFiles.get(0).getProject().getFullPath().toOSString(); for (int i = 1; i < seleFiles.size(); i++) { if (!projectPath.equals(seleFiles.get(i).getProject().getFullPath().toOSString())) { MessageDialog.openInformation(shell, Messages.getString("handler.MergeXliffHandler.msgTitle1"), Messages.getString("handler.MergeXliffHandler.msg3")); return null; } } SplitOrMergeXlfModel model = new SplitOrMergeXlfModel(); model.setMergeXliffFile(seleFiles); MergeXliffWizard wizard = new MergeXliffWizard(model); TSWizardDialog dialog = new NattableWizardDialog(shell, wizard); dialog.open(); } } return null; }