Java Code Examples for org.eclipse.ui.IEditorPart
The following examples show how to use
org.eclipse.ui.IEditorPart.
These examples are extracted from open source projects.
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 Project: tmxeditor8 Author: heartsome File: ShowNextSegmentHandler.java License: 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 lastRow = handler.countEditableTransUnit() - 1; if (lastSelectedRow == lastRow) { lastSelectedRow = lastRow - 1; } xliffEditor.jumpToRow(lastSelectedRow + 1); return null; }
Example #2
Source Project: IndentGuide Author: kiritsuku File: Starter.java License: MIT License | 6 votes |
public void earlyStartup() { PlatformUI.getWorkbench().getDisplay().asyncExec(new Runnable() { public void run() { IWorkbench workbench = PlatformUI.getWorkbench(); IWorkbenchWindow window = workbench.getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page = window.getActivePage(); if (page != null) { IEditorPart part = page.getActiveEditor(); if (part != null) { addListener(part); } } window.getPartService().addPartListener(new PartListener()); } workbench.addWindowListener(new WindowListener()); } }); }
Example #3
Source Project: birt Author: eclipse File: ScriptDebugUtil.java License: Eclipse Public License 1.0 | 6 votes |
/** * @return */ public static DebugJsEditor getActiveJsEditor( ) { IWorkbenchWindow window = PlatformUI.getWorkbench( ) .getActiveWorkbenchWindow( ); if ( window != null ) { IWorkbenchPage pg = window.getActivePage( ); if ( pg != null ) { IEditorPart editor = pg.getActiveEditor( ); if ( editor != null ) { if ( editor instanceof DebugJsEditor ) { return (DebugJsEditor) editor; } } } } return null; }
Example #4
Source Project: APICloud-Studio Author: apicloudcom File: EditorContextContributor.java License: GNU General Public License v3.0 | 6 votes |
public void modifyContext(CommandElement command, CommandContext context) { IEditorPart editor = this.getActiveEditor(); if (editor != null && command != null) { Ruby runtime = command.getRuntime(); if (runtime != null) { IRubyObject rubyInstance = ScriptUtils.instantiateClass(runtime, ScriptUtils.RUBLE_MODULE, EDITOR_RUBY_CLASS, JavaEmbedUtils.javaToRuby(runtime, editor)); context.put(EDITOR_PROPERTY_NAME, rubyInstance); } else { context.put(EDITOR_PROPERTY_NAME, null); } } }
Example #5
Source Project: tlaplus Author: tlaplus File: TraceExplorerDataProvider.java License: MIT License | 6 votes |
public void onDone() { super.onDone(); getTraceExpressionsInformation(); processTraceForTraceExplorer(); final IEditorPart activeEditor = UIHelper.getActiveEditor(); if (activeEditor != null) { if (activeEditor instanceof ModelEditor) { final ModelEditor activeModelEditor = (ModelEditor) activeEditor; if (activeModelEditor.getModel() != null) { UIHelper.runUIAsync(() -> { TLCErrorView.updateErrorView(activeModelEditor); }); } } } }
Example #6
Source Project: uima-uimaj Author: apache File: AnnotationEditorActionContributor.java License: Apache License 2.0 | 6 votes |
/** * Sets the active editor. * * @param part the new active editor */ @Override public void setActiveEditor(IEditorPart part) { super.setActiveEditor(part); if (mActiveEditorPart != part && part instanceof AnnotationEditor) { mActiveEditorPart = (AnnotationEditor) part; mActiveEditorPart.setStatusField(mStatusLineModeItem, ID); Type annotationType = mActiveEditorPart.getAnnotationMode(); if (annotationType != null) { mStatusLineModeItem.setText(annotationType.getShortName()); } } }
Example #7
Source Project: birt Author: eclipse File: MultiPageReportEditor.java License: Eclipse Public License 1.0 | 6 votes |
public void setSelection( ISelection selection ) { IEditorPart activeEditor = ( (FormEditor) getMultiPageEditor( ) ).getActivePageInstance( ); if ( activeEditor != null ) { ISelectionProvider selectionProvider = activeEditor.getSite( ) .getSelectionProvider( ); if ( selectionProvider != null ) selectionProvider.setSelection( selection ); } else { this.globalSelection = selection; fireSelectionChanged( new SelectionChangedEvent( this, globalSelection ) ); } }
Example #8
Source Project: doclipser Author: domeide File: DockerBuildLaunchShortcut.java License: Eclipse Public License 1.0 | 6 votes |
@Override public void launch(IEditorPart editor, String mode) { IEditorInput input = editor.getEditorInput(); IFile dockerfile = (IFile) input.getAdapter(IFile.class); IPath dockerfilePath = null; if (dockerfile != null) { dockerfilePath = dockerfile.getLocation().removeLastSegments(1); } if (dockerfilePath == null) { ILocationProvider locationProvider = (ILocationProvider) input.getAdapter(ILocationProvider.class); if (locationProvider != null) { dockerfilePath = locationProvider.getPath(input); } } if (dockerfilePath != null) { launch(dockerfile, dockerfilePath); } }
Example #9
Source Project: tlaplus Author: tlaplus File: ModelEditor.java License: MIT License | 6 votes |
/** * Returns the nested editor instance open on moduleName (without the .tla extension). * Returns null if no such editor is open in this model editor. * * @param moduleName * @return */ public ITextEditor getSavedModuleEditor(String moduleName) { for (int i = 0; i < getPageCount(); i++) { IEditorPart nestedEditor = getEditor(i); if (nestedEditor != null && nestedEditor instanceof ITextEditor && ((FileEditorInput) nestedEditor.getEditorInput()).getName().equals( ResourceHelper.getModuleFileName(moduleName))) { return (ITextEditor) nestedEditor; } } return null; }
Example #10
Source Project: xtext-eclipse Author: eclipse File: LanguageSpecificURIEditorOpener.java License: Eclipse Public License 2.0 | 6 votes |
@Override public IEditorPart open(final URI uri, final EReference crossReference, final int indexInList, final boolean select) { Iterator<Pair<IStorage, IProject>> storages = mapper.getStorages(uri.trimFragment()).iterator(); if (storages != null && storages.hasNext()) { try { IStorage storage = storages.next().getFirst(); IEditorInput editorInput = EditorUtils.createEditorInput(storage); IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage(); final IEditorPart editor = IDE.openEditor(activePage, editorInput, getEditorId()); selectAndReveal(editor, uri, crossReference, indexInList, select); return EditorUtils.getXtextEditor(editor); } catch (WrappedException e) { logger.error("Error while opening editor part for EMF URI '" + uri + "'", e.getCause()); } catch (PartInitException partInitException) { logger.error("Error while opening editor part for EMF URI '" + uri + "'", partInitException); } } return null; }
Example #11
Source Project: XPagesExtensionLibrary Author: OpenNTF File: BluemixUtil.java License: Apache License 2.0 | 6 votes |
public static IDominoDesignerProject getDominoDesignerProject (IEditorPart editorPart) { if ( editorPart != null ) { if ( editorPart.getEditorInput() instanceof IFileEditorInput ) { IFileEditorInput file = (IFileEditorInput)editorPart.getEditorInput(); IProject prj = file.getFile().getProject(); try { IDominoDesignerProject desPrj = DominoResourcesPlugin.getDominoDesignerProject(prj); return desPrj; } catch (NsfException e) { if (BluemixLogger.BLUEMIX_LOGGER.isErrorEnabled()) { BluemixLogger.BLUEMIX_LOGGER.errorp(BluemixUtil.class, "getDominoDesignerProject", e, "Failed to get Domino Designer Project"); // $NON-NLS-1$ $NLE-BluemixUtil.FailedtogetDominoDesignerProject-2$ } } } if (editorPart instanceof ManifestMultiPageEditor) { return ((ManifestMultiPageEditor)editorPart).getDesignerProject(); } } return null; }
Example #12
Source Project: translationstudio8 Author: heartsome File: ExecuteGoogleTransHandler.java License: GNU General Public License v2.0 | 5 votes |
/** * (non-Javadoc) * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) */ public Object execute(ExecutionEvent event) throws ExecutionException { final IWorkbenchWindow window = HandlerUtil.getActiveWorkbenchWindow(event); IEditorPart editor = HandlerUtil.getActiveEditor(event); if (!(editor instanceof IXliffEditor)) { return null; } PrefrenceParameters ps = PrefrenceParameters.getInstance(); if (!ps.isGoogleState()) { MessageDialog.openError(window.getShell(), Messages.getString("handler.ExecuteGoogleTransHandler.msgTitle"), Messages.getString("handler.ExecuteGoogleTransHandler.msg")); return null; } final IXliffEditor xliffEditor = (IXliffEditor) editor; final int[] selectedRowIndexs = xliffEditor.getSelectedRows(); if (selectedRowIndexs.length == 0) { return null; } ISimpleMatcher matcher = new SimpleMatcherGoogleImpl(); IViewPart viewPart = window.getActivePage().findView(MatchViewPart.ID); if (viewPart != null && viewPart instanceof MatchViewPart) { MatchViewPart matchView = (MatchViewPart) viewPart; matchView.manualExecSimpleTranslation(selectedRowIndexs[0], xliffEditor, matcher); } return null; }
Example #13
Source Project: thym Author: eclipse File: IconsPage.java License: Eclipse Public License 1.0 | 5 votes |
private IProject getProject() { IEditorPart editorPart = HybridUI.getDefault().getWorkbench() .getActiveWorkbenchWindow().getActivePage().getActiveEditor(); if (editorPart.getEditorInput() instanceof IFileEditorInput) { IFileEditorInput input = (IFileEditorInput) editorPart .getEditorInput(); IProject activeProject = input.getFile().getProject(); return activeProject; } else { return null; } }
Example #14
Source Project: lapse-plus Author: OWASP File: LapseView.java License: GNU General Public License v3.0 | 5 votes |
public static IOpenable getJavaInput(IEditorPart part) { IEditorInput editorInput= part.getEditorInput(); if (editorInput != null) { IJavaElement input= (IJavaElement)editorInput.getAdapter(IJavaElement.class); if (input instanceof IOpenable) { return (IOpenable) input; } } return null; }
Example #15
Source Project: XPagesExtensionLibrary Author: OpenNTF File: AbstractTreeNodePanel.java License: Apache License 2.0 | 5 votes |
private void removeAndUpdateUndoActions(Node n, IAction undo, IAction redo, CommandStack stack, IActionBars bars) { RemoveNodeCommand cmd = new RemoveNodeCommand(n); XPagesEditorUtils.executeCommand(cmd, (IEditorPart)null); if(stack != null){ if(undo != null){ undo.setEnabled(stack.canUndo()); } if(redo != null){ redo.setEnabled(stack.canRedo()); } if(bars != null){ bars.updateActionBars(); } } }
Example #16
Source Project: tlaplus Author: tlaplus File: UIHelper.java License: MIT License | 5 votes |
/** * @return Returns the {@link IEditorPart} for the given editor id without * opening the editor or null if no editor with the given id exists. * Contrary to the Eclipse facilities to find and editor, this method * does not initialize/render/configure the editor instance. It is left * to the callee to properly initialize the editor instance by e.g. * adding it to a MultipageEditor. * @throws CoreException */ public static IEditorPart findEditor(final String editorId) throws CoreException { final IExtensionRegistry registry = Platform.getExtensionRegistry(); final IConfigurationElement[] elements = registry.getConfigurationElementsFor(PlatformUI.PLUGIN_ID, "editors"); for (IConfigurationElement ice : elements) { if (editorId.equals(ice.getAttribute("id"))) { return (IEditorPart) ice.createExecutableExtension("class"); } } return null; }
Example #17
Source Project: Eclipse-Postfix-Code-Completion Author: trylimits File: EditorUtility.java License: Eclipse Public License 1.0 | 5 votes |
private static IEditorPart openInEditor(IFile file, boolean activate) throws PartInitException { if (file == null) throwPartInitException(JavaEditorMessages.EditorUtility_file_must_not_be_null); IWorkbenchPage p= JavaPlugin.getActivePage(); if (p == null) throwPartInitException(JavaEditorMessages.EditorUtility_no_active_WorkbenchPage); IEditorPart editorPart= IDE.openEditor(p, file, activate); initializeHighlightRange(editorPart); return editorPart; }
Example #18
Source Project: e4macs Author: MulgaSoft File: WindowJoinCmd.java License: Eclipse Public License 1.0 | 5 votes |
/** * Close any duplicate editors that match this one * * @param editor * @return true if any were closed */ boolean closeOthers(IEditorPart editor) { IWorkbenchPage page = EmacsPlusUtils.getWorkbenchPage(); int pre = EmacsPlusUtils.getSortedEditors(page).length; if (isSplitSelf()) { try { EmacsPlusUtils.executeCommand(IEmacsPlusCommandDefinitionIds.CLOSE_OTHER_INSTANCES, null, editor); } catch (Exception e) {} } return (pre != EmacsPlusUtils.getSortedEditors(page).length); }
Example #19
Source Project: txtUML Author: ELTE-Soft File: SaveUtils.java License: Eclipse Public License 1.0 | 5 votes |
private static Object[] openSaveDialog(Shell shell, Collection<IEditorPart> editors) { ListSelectionDialog lsd = new ListSelectionDialog(shell, editors, new ArrayContentProvider(), getLabelProvider(), "Select resources to save:"); lsd.setInitialSelections(editors.toArray()); lsd.setTitle("Save and Launch"); lsd.open(); return lsd.getResult(); }
Example #20
Source Project: wildwebdeveloper Author: eclipse File: AbstractDebugAdapterLaunchShortcut.java License: Eclipse Public License 2.0 | 5 votes |
@Override public ILaunchConfiguration[] getLaunchConfigurations(IEditorPart editorpart) { IResource launchableResource = getLaunchableResource(editorpart); if (launchableResource != null) { return getLaunchConfigurations(launchableResource.getLocation().toFile()); } return getLaunchConfigurations(SelectionUtils.getFile(editorpart.getEditorInput(), this::canLaunch)); }
Example #21
Source Project: translationstudio8 Author: heartsome File: ShowFirstSegmentHandler.java License: 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; } XLIFFEditorImplWithNatTable xliffEditor = (XLIFFEditorImplWithNatTable) editor; xliffEditor.jumpToRow(0); return null; }
Example #22
Source Project: xds-ide Author: excelsior-oss File: CoreEditorUtils.java License: Eclipse Public License 1.0 | 5 votes |
/** * Sets the current selection for the given range. * * @param editor the editor to be operated on * @param offset the offset of the range, must not be negative * @param length the length of the range, must not be negative */ public static void setSelection(IEditorPart editor, int offset, int length) { ISelectionProvider provider = editor.getEditorSite().getSelectionProvider(); if (provider != null) { IWorkbenchPart activePart = WorkbenchUtils.getActivePart(); if (activePart instanceof IEditorPart) { IWorkbenchPage page = WorkbenchUtils.getActivePage(); page.getNavigationHistory().markLocation((IEditorPart) activePart); } provider.setSelection(new TextSelection(offset, length)); } }
Example #23
Source Project: translationstudio8 Author: heartsome File: WebSearchHandler.java License: GNU General Public License v2.0 | 5 votes |
/** (non-Javadoc) * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { IEditorPart editor = HandlerUtil.getActiveEditor(event); String selectPureText =""; if (editor instanceof IXliffEditor) { IXliffEditor xliffEditor = (IXliffEditor) editor; selectPureText= xliffEditor.getSelectPureText(); } try { IViewPart showView = getActivePage().showView(BrowserViewPart.ID); if(showView instanceof BrowserViewPart){ BrowserViewPart browserViewPart = (BrowserViewPart) showView; browserViewPart.setKeyWord(selectPureText,true); } } catch (PartInitException e) { e.printStackTrace(); logger.error("", e); } // 暂时去掉VIEW弹出显示 // IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); // if (activePage instanceof WorkbenchPage) { // WorkbenchPage workbenchPage = (WorkbenchPage) activePage; // IViewReference findViewReference = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() // .findViewReference(BrowserViewPart.ID); // workbenchPage.detachView(findViewReference); // } return null; }
Example #24
Source Project: Eclipse-Postfix-Code-Completion Author: trylimits File: JavaSearchPage.java License: Eclipse Public License 1.0 | 5 votes |
private IEditorPart getActiveEditor() { IWorkbenchPage activePage= JavaPlugin.getActivePage(); if (activePage != null) { return activePage.getActiveEditor(); } return null; }
Example #25
Source Project: Eclipse-Postfix-Code-Completion Author: trylimits File: JavaContentAssistHandler.java License: Eclipse Public License 1.0 | 5 votes |
private ITextEditor getActiveEditor() { IWorkbenchWindow window= PlatformUI.getWorkbench().getActiveWorkbenchWindow(); if (window != null) { IWorkbenchPage page= window.getActivePage(); if (page != null) { IEditorPart editor= page.getActiveEditor(); if (editor instanceof ITextEditor) return (JavaEditor) editor; } } return null; }
Example #26
Source Project: bonita-studio Author: bonitasoft File: EditorFinder.java License: GNU General Public License v2.0 | 5 votes |
public static Optional<IEditorPart> findOpenedEditor(Function<IEditorPart, Boolean> editorInstanceValidator) { if (PlatformUI.isWorkbenchRunning() && PlatformUI.getWorkbench().getActiveWorkbenchWindow() != null && PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() != null) { return Arrays.asList(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences()) .stream() .map(ref -> ref.getEditor(false)) .filter(editorInstanceValidator::apply) .findFirst(); } return Optional.empty(); }
Example #27
Source Project: e4macs Author: MulgaSoft File: BufferLocal.java License: Eclipse Public License 1.0 | 5 votes |
public boolean hasVariable(IEditorPart editor, String variable) { boolean result = false; if (editor != null && variable != null) { Map<String, Object> table = bufferlocal.get(editor); if (table != null) { result = table.containsKey(variable); } } return result; }
Example #28
Source Project: Eclipse-Postfix-Code-Completion Author: trylimits File: PropertiesCorrectionProcessor.java License: Eclipse Public License 1.0 | 5 votes |
private PropertiesAssistContext createAssistContext(IQuickAssistInvocationContext invocationContext) { IEditorPart editorPart= fAssistant.getEditor(); IFile file= (IFile) editorPart.getEditorInput().getAdapter(IFile.class); ISourceViewer sourceViewer= invocationContext.getSourceViewer(); IType accessorType= ((PropertiesFileEditor) editorPart).getAccessorType(); return new PropertiesAssistContext(sourceViewer, invocationContext.getOffset(), invocationContext.getLength(), file, sourceViewer.getDocument(), accessorType); }
Example #29
Source Project: Eclipse-Postfix-Code-Completion Author: trylimits File: JavaSearchResultPage.java License: Eclipse Public License 1.0 | 5 votes |
private void showWithMarker(IEditorPart editor, IFile file, int offset, int length) throws PartInitException { try { IMarker marker= file.createMarker(NewSearchUI.SEARCH_MARKER); HashMap<String, Integer> attributes= new HashMap<String, Integer>(4); attributes.put(IMarker.CHAR_START, new Integer(offset)); attributes.put(IMarker.CHAR_END, new Integer(offset + length)); marker.setAttributes(attributes); IDE.gotoMarker(editor, marker); marker.delete(); } catch (CoreException e) { throw new PartInitException(SearchMessages.JavaSearchResultPage_error_marker, e); } }
Example #30
Source Project: CogniCrypt Author: eclipse-cognicrypt File: UIUtils.java License: Eclipse Public License 2.0 | 5 votes |
/** * This method closes the currently open editor. * * @param editor */ public static void closeEditor(final IEditorPart editor) { final IWorkbenchPage workbenchPage = UIUtils.getCurrentlyOpenPage(); if (workbenchPage != null) { workbenchPage.closeEditor(editor, true); } }