/** * Returns the input definition for this view. * * @return The input definition. */ @Override public InputDefinition getInputDefinition() { InputDefinition inputDefinition = (InputDefinition) getEditorInput().getAdapter(InputDefinition.class); Assert.isNotNull(inputDefinition); return inputDefinition; }
/** * Return the <code>IFile</code> associated with the current * editor input. Will return <code>null</code> if the current * editor input is for an external file */ public IFile getFile() { IEditorInput input= getEditorInput(); return (IFile) input.getAdapter(IFile.class); }
public IResource getResource() { Object adapter = getEditorInput().getAdapter(IResource.class); if (adapter != null) { return (IResource) adapter; } return null; }
protected static IResource getResource(IEditorPart editor) { IEditorInput editorInput = editor.getEditorInput(); IResource resource = (IResource) editorInput.getAdapter(IFile.class); if (resource == null) { resource = ResourcesPlugin.getWorkspace().getRoot(); } return resource; }
public static boolean inputInProjects(IEditorInput input, List projects) { IResource res = (IResource) input.getAdapter(IRESOURCE_CLASS); IProject project = res == null ? null : res.getProject(); if (project == null) return false; for (int i = 0; i < projects.size(); i++) { if (project.equals(projects.get(i))) return true; } return false; }
@Override public boolean isShownInEditor(Match match, IEditorPart editor) { Object element= match.getElement(); if (element instanceof IJavaElement) { element= ((IJavaElement) element).getOpenable(); // class file or compilation unit return element != null && element.equals(editor.getEditorInput().getAdapter(IJavaElement.class)); } else if (element instanceof IFile) { return element.equals(editor.getEditorInput().getAdapter(IFile.class)); } return false; }
@Override public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) { IEditorInput editorInput = editor.getEditorInput(); IJavaElement element = editorInput.getAdapter(IJavaElement.class); if (element != null) { Set<Match> matches = new HashSet<>(); collectMatches(matches, element); return matches.toArray(new Match[matches.size()]); } return super.computeContainedMatches(result, editor); }
private static void ensureUpdatedAnnotations(ITextEditor editor) { Object inputElement= editor.getEditorInput().getAdapter(IJavaElement.class); if (inputElement instanceof ICompilationUnit) { SharedASTProviderCore.getAST((ICompilationUnit) inputElement, SharedASTProviderCore.WAIT_ACTIVE_ONLY, null); } }
private IProject getProject(IEditorInput input) { IAdapterManager adapterManager = Platform.getAdapterManager(); Object o; if ((o = input.getAdapter(IResource.class)) != null || (o = adapterManager.getAdapter(input, IResource.class)) != null) { return ((IFile) o).getProject(); } if ((o = input.getAdapter(IProject.class)) != null || (o = adapterManager.getAdapter(input, IProject.class)) != null) { return (IProject) o; } return null; } }
private static ITypeRoot getEditorInputJavaElement(IEditorInput editorInput, boolean primaryOnly) { if (editorInput == null) return null; ICompilationUnit cu= JavaPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput, primaryOnly); if (cu != null) return cu; IJavaElement je= editorInput.getAdapter(IJavaElement.class); if (je instanceof ITypeRoot) return (ITypeRoot)je; return null; }
protected IOperationApprover getUndoRedoOperationApprover(IUndoContext undoContext) { IEditorInput input= getEditorInput(); if (input != null && input.getAdapter(IResource.class) != null) return new NonLocalUndoUserApprover(undoContext, this, new Object [] { input }, IResource.class); return super.getUndoRedoOperationApprover(undoContext); }
@Override public Object getLaunchObject() { Object file = fEditor.getEditorInput().getAdapter(IFile.class); if (file != null) return file; IProductModel model = (IProductModel) fEditor.getAggregateModel(); if (model == null) { return null; } return model.getUnderlyingResource(); }
@Override protected IOperationApprover getUndoRedoOperationApprover(IUndoContext undoContext) { IEditorInput input= getEditorInput(); if (input != null && input.getAdapter(IResource.class) != null) return new NonLocalUndoUserApprover(undoContext, this, new Object [] { input }, IResource.class); return super.getUndoRedoOperationApprover(undoContext); }
public void launch(IEditorPart editor, String mode) { IEditorInput input = editor.getEditorInput(); IJavaElement je = (IJavaElement) input.getAdapter(IJavaElement.class); if (je != null) { IJavaProject jproject = je.getJavaProject(); if (jproject != null) { launch(jproject, mode); } } }
public IPath getLocation() { if (fEditorInput instanceof IFileEditorInput) { return ((IFileEditorInput) fEditorInput).getFile().getLocation(); } ILocationProvider locationProvider = fEditorInput.getAdapter(ILocationProvider.class); if (locationProvider != null) { return locationProvider.getPath(fEditorInput); } return null; }
private static ITypeRoot getEditorInputJavaElement(IEditorInput editorInput, boolean primaryOnly) { if (editorInput == null) return null; ICompilationUnit cu= JavaPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput, primaryOnly); if (cu != null) return cu; IJavaElement je= editorInput.getAdapter(IJavaElement.class); if (je instanceof ITypeRoot) return (ITypeRoot)je; return null; }
/** * @see ILaunchShortcut#launch(IEditorPart, String) */ public void launch(IEditorPart editor, String mode) { IEditorInput input = editor.getEditorInput(); IJavaElement je = (IJavaElement) input.getAdapter(IJavaElement.class); if (je != null) { searchAndLaunch(new Object[] {je}, mode, getTypeSelectionTitle(), getEditorEmptyMessage()); } }
/** * Gets the resource which is being edited in the editor. * * @return the resource being edited or <code>null</code>s */ private IResource getResource() { if (getTextEditor() != null && getTextEditor().getEditorInput() != null) return getTextEditor().getEditorInput().getAdapter(IResource.class); return null; }
@Override protected void handleEditorInputChanged() { final IDocumentProvider provider= getDocumentProvider(); IEditorInput input= getEditorInput(); if (provider != null && input != null) { if (!isDirty() && input.getAdapter(IFile.class) != null) { if (Platform.getPreferencesService().getBoolean(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PREF_LIGHTWEIGHT_AUTO_REFRESH, false, null)) return; } } super.handleEditorInputChanged(); }
private PropertiesAssistContext createAssistContext(IQuickAssistInvocationContext invocationContext) { IEditorPart editorPart= fAssistant.getEditor(); IFile file= 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); } }