org.eclipse.ui.IEditorPart Java Examples
The following examples show how to use
org.eclipse.ui.IEditorPart.
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: BluemixUtil.java From XPagesExtensionLibrary with 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 #2
Source File: DockerBuildLaunchShortcut.java From doclipser with 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 #3
Source File: Starter.java From IndentGuide with 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 #4
Source File: MultiPageReportEditor.java From birt with 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 #5
Source File: ModelEditor.java From tlaplus with 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 #6
Source File: AnnotationEditorActionContributor.java From uima-uimaj with 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 File: LanguageSpecificURIEditorOpener.java From xtext-eclipse with 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 #8
Source File: TraceExplorerDataProvider.java From tlaplus with 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 #9
Source File: EditorContextContributor.java From APICloud-Studio with 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 #10
Source File: ScriptDebugUtil.java From birt with 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 #11
Source File: ShowNextSegmentHandler.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 lastRow = handler.countEditableTransUnit() - 1; if (lastSelectedRow == lastRow) { lastSelectedRow = lastRow - 1; } xliffEditor.jumpToRow(lastSelectedRow + 1); return null; }
Example #12
Source File: JavaSearchResultPage.java From Eclipse-Postfix-Code-Completion with 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 #13
Source File: ClipboardOperationAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private IProgressService getProgressService() { IEditorPart editor= getTextEditor(); if (editor != null) { IWorkbenchPartSite site= editor.getSite(); if (site != null) return (IWorkbenchSiteProgressService) editor.getSite().getAdapter(IWorkbenchSiteProgressService.class); } return PlatformUI.getWorkbench().getProgressService(); }
Example #14
Source File: PropertiesCorrectionProcessor.java From Eclipse-Postfix-Code-Completion with 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 #15
Source File: UIUtils.java From CogniCrypt with 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); } }
Example #16
Source File: OpenModuleHandler.java From tlaplus with MIT License | 5 votes |
/** * This was the body of the <code>execute</code>, but was pulled out so it could be * used in other places to open a module. * * @param moduleName */ public static void openModule(String moduleName) { if (moduleName == null) { throw new RuntimeException("Module was null" ); } Spec spec = Activator.getSpecManager().getSpecLoaded(); final IFile module = ResourceHelper.getLinkedFile(spec.getProject(), ResourceHelper.getModuleFileName(moduleName)); if (module == null) { throw new RuntimeException("Module " + moduleName + " could not be found" ); } // open the editor IEditorPart part = UIHelper.openEditor(OpenSpecHandler.TLA_EDITOR, new FileEditorInput(module)); part.addPropertyListener(new IPropertyListener() { public void propertyChanged(Object source, int propId) { if (IWorkbenchPartConstants.PROP_DIRTY == propId) { // here the listeners to editor changes go into } } }); }
Example #17
Source File: WebSearchHandler.java From translationstudio8 with 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 #18
Source File: CoreEditorUtils.java From xds-ide with 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 #19
Source File: AbstractSarlLaunchShortcut.java From sarl with Apache License 2.0 | 5 votes |
@Override public IResource getLaunchableResource(IEditorPart editorpart) { final XtextEditor xtextEditor = EditorUtils.getXtextEditor(editorpart); if (xtextEditor != null) { return xtextEditor.getResource(); } return null; }
Example #20
Source File: ExecuteGoogleTransHandler.java From translationstudio8 with 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 #21
Source File: EditorPool.java From saros with GNU General Public License v2.0 | 5 votes |
/** * Returns the {@linkplain saros.filesystem.IFile file} for the corresponding editor. * * @return the file for the corresponding editor or <code>null</code> if the editor is not managed * by this pool */ public saros.filesystem.IFile getFile(final IEditorPart editorPart) { if (!isManaged(editorPart)) return null; for (final Entry<saros.filesystem.IFile, Set<IEditorPart>> entry : editorParts.entrySet()) { if (entry.getValue().contains(editorPart)) return entry.getKey(); } // assert false : should never been reached return null; }
Example #22
Source File: CompilerLaunchShortcut.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
@Override public void launch(IEditorPart editor, String mode) { IResource resource = ResourceUtils.getEditorInput(editor); if (resource != null) { launch(resource, mode); } }
Example #23
Source File: GraphicalEditorWithFlyoutPalette.java From birt with Eclipse Public License 1.0 | 5 votes |
public void shellActivated( ShellEvent e ) { if ( !shellActiveFlag ) { shellActiveFlag = true; // Pre-fetch shell from site in case it could be disposed before async execution final Shell siteShell = getSite( ).getShell( ); Display.getCurrent( ).asyncExec( new Runnable( ) { public void run( ) { if ( lastActiveShell == siteShell ) { // don't active the current active editor shellActiveFlag = false; return; } else { lastActiveShell = getSite( ).getShell( ); IEditorPart editor = UIUtil.getActiveEditor( true ); if ( editor instanceof IPartListener ) { // update the SessionHandleAdapter's model. // If old selection is dataset or datasource, // the selection status will lost. ( (IPartListener) editor ).partActivated( editor ); } shellActiveFlag = false; } } } ); } }
Example #24
Source File: SCTSourceDisplay.java From statecharts with Eclipse Public License 1.0 | 5 votes |
@Override public synchronized void displaySource(Object element, IWorkbenchPage page, boolean forceSourceLookup) { IDebugTarget debugTarget = unwrapTarget(element); if (debugTarget == null || getDiagram(debugTarget) == null) return; setActiveLaunch(debugTarget); IEditorPart editorPart = openEditor(debugTarget, page); IDynamicNotationHandler notationHandler = getHandler(editorPart); notationHandler.display(debugTarget.getAdapter(ExecutionContext.class)); restoreActiveEditors(); }
Example #25
Source File: MultiPageEditorContributor.java From uima-uimaj with Apache License 2.0 | 5 votes |
@Override public void setActivePage(IEditorPart part) { IActionBars actionBars = getActionBars(); if (actionBars != null) { ITextEditor textEditor = (part instanceof XMLEditor) ? (ITextEditor) part : null; actionBars.setGlobalActionHandler(ActionFactory.DELETE.getId(), getAction1(textEditor, ITextEditorActionConstants.DELETE)); actionBars.setGlobalActionHandler(ActionFactory.UNDO.getId(), getAction1(textEditor, ITextEditorActionConstants.UNDO)); actionBars.setGlobalActionHandler(ActionFactory.REDO.getId(), getAction1(textEditor, ITextEditorActionConstants.REDO)); actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), getAction1(textEditor, ITextEditorActionConstants.CUT)); actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), getAction1(textEditor, ITextEditorActionConstants.COPY)); actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), getAction1(textEditor, ITextEditorActionConstants.PASTE)); actionBars.setGlobalActionHandler(ActionFactory.SELECT_ALL.getId(), getAction1(textEditor, ITextEditorActionConstants.SELECT_ALL)); actionBars.setGlobalActionHandler(ActionFactory.FIND.getId(), getAction1(textEditor, ITextEditorActionConstants.FIND)); actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction1(textEditor, IDEActionFactory.BOOKMARK.getId())); actionBars.updateActionBars(); } }
Example #26
Source File: SortMembersAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private boolean containsRelevantMarkers(IEditorPart editor) { IAnnotationModel model= JavaUI.getDocumentProvider().getAnnotationModel(editor.getEditorInput()); Iterator<Annotation> iterator= model.getAnnotationIterator(); while (iterator.hasNext()) { Annotation element= iterator.next(); if (element instanceof IJavaAnnotation) { IJavaAnnotation annot= (IJavaAnnotation) element; if (!annot.isMarkedDeleted() && annot.isPersistent() && !annot.isProblem()) return true; } } return false; }
Example #27
Source File: AddProjectToSessionWizard.java From saros with GNU General Public License v2.0 | 5 votes |
private Collection<IEditorPart> getOpenEditorsForSharedProjects(Collection<IProject> projects) { List<IEditorPart> openEditors = new ArrayList<IEditorPart>(); Set<IEditorPart> editors = EditorAPI.getOpenEditors(); for (IProject project : projects) { for (IEditorPart editor : editors) { if (editor.getEditorInput() instanceof IFileEditorInput) { IFile file = ((IFileEditorInput) editor.getEditorInput()).getFile(); if (project.equals(file.getProject())) openEditors.add(editor); } } } return openEditors; }
Example #28
Source File: OrderElementControl.java From statecharts with Eclipse Public License 1.0 | 5 votes |
public void selectionChanged(SelectionChangedEvent event) { IEditorPart lastActiveEditor = ActiveEditorTracker.getLastActiveEditor(); EObject selectedObject = getSelectedObject(); if (lastActiveEditor instanceof DiagramDocumentEditor && selectedObject != null) { IGraphicalEditPart editPart = EditPartUtils.findEditPartForSemanticElement( ((DiagramDocumentEditor) lastActiveEditor).getDiagramGraphicalViewer().getRootEditPart(), selectedObject); if (editPart != null) { ((DiagramDocumentEditor) lastActiveEditor).getDiagramGraphicalViewer().select(editPart); ((DiagramDocumentEditor) lastActiveEditor).getDiagramGraphicalViewer().reveal(editPart); } } }
Example #29
Source File: OppositeFileOpenerContributor.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
protected IStorage getStorage(IEditorPart editor) { try { if (editor.getEditorInput() instanceof IStorageEditorInput) return ((IStorageEditorInput) editor.getEditorInput()).getStorage(); return null; } catch (CoreException e) { LOG.error(e.getMessage(), e); return null; } }
Example #30
Source File: AbstractManageDiagramWizard.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
public boolean deleteDiagrams(final List<DiagramFileStore> files, ContentViewer viewer) { if (!files.isEmpty()) { try { for (final DiagramFileStore file : files) { for (final AbstractProcess process : file.getProcesses()) { final String uuid = ModelHelper.getEObjectID(process); final IRepositoryFileStore confFile = getConfigurationRepositoryStore() .getChild(uuid + "." + ProcessConfigurationRepositoryStore.CONF_EXT, true); if (confFile != null) { confFile.delete(); } } for (final IEditorPart editor : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage() .getDirtyEditors()) { if (editor.getEditorInput().getName().equals(file.getName())) { file.save(editor); break; } } final Map<String, Object> parameters = new HashMap<String, Object>(); parameters.put(AbstractFileStore.ASK_ACTION_ON_CLOSE, false); file.setParameters(parameters); file.close(); file.delete(); } if (viewer != null) { viewer.setInput(getDiagramRepositoryStore()); } return true; } catch (final Exception e1) { BonitaStudioLog.error(e1); } } return false; }