IEditorPart editorPart = getSite().getWorkbenchWindow().getActivePage().getActiveEditor(); if(editorPart != null) { IFileEditorInput input = (IFileEditorInput)editorPart.getEditorInput() ; IFile file = input.getFile(); IProject activeProject = file.getProject(); String activeProjectName = activeProject.getName(); //... use activeProjectName }
protected ActionRegistry getEditorActionRegistry() { return (ActionRegistry) editor.getAdapter(ActionRegistry.class); } protected CommandStack commandStack;
@Override public boolean isDirty() { for (IEditorPart e : innerEditors) { if (e.isDirty()) { return true; } } return false; }
NavigationHistoryEditorInfo(IEditorPart part) { editorID = part.getSite().getId(); editorInput = part.getEditorInput(); }
/** * Convenience constructor to use the {@link IProject} and {@link Shell} of * the {@link IEditorPart}. * * @param editor * {@link IEditorPart}. */ public ClasspathFileInput(IEditorPart editor) { this(ProjectConfigurationContext.getProject(editor.getEditorInput()), editor.getEditorSite().getShell()); }
@Override public void setActiveEditor(IAction action, IEditorPart targetEditor) { fWindow= null; if (targetEditor != null) { fWindow= targetEditor.getSite().getWorkbenchWindow(); } }
public void setActiveEditor(IAction action, IEditorPart targetEditor) { workbenchPart = targetEditor; fDelegateAction = action; if (targetEditor != null && targetEditor.getEditorSite() != null && targetEditor.getEditorSite().getSelectionProvider() != null) { updateWith(targetEditor.getEditorSite().getSelectionProvider().getSelection()); } }
/** * Saves the multi-page editor's document as another file. Also updates the * text for page 0's tab, and updates this multi-page editor's input to * correspond to the nested editor's. */ public void doSaveAs() { IEditorPart editor = getEditor(0); editor.doSaveAs(); setPageText(0, editor.getTitle()); setInput(editor.getEditorInput()); }
@Override public void doSave(IProgressMonitor monitor) { for (IEditorPart e : innerEditors) { e.doSave(monitor); } }
/** * Constructs a NavigationLocation with its editor part. * * @param editorPart */ protected NavigationLocation(IEditorPart editorPart) { this.page = editorPart.getSite().getPage(); this.input = editorPart.getEditorInput(); }
/** * Convenience constructor to use the {@link IProject} and {@link Shell} of * the {@link IEditorPart}. * * @param editor * {@link IEditorPart}. */ public ClasspathClassInput(IEditorPart editor) { this(ProjectConfigurationContext.getProject(editor.getEditorInput()), editor.getEditorSite().getShell()); }
public static void registerEditorPart(IEditorPart editorPart) { IWorkbenchPage page = editorPart.getSite().getPage(); if (pageMap.containsKey(page)) { pageMap.get(page).add(editorPart); } else { Set<IEditorPart> editorParts = new HashSet<>(); editorParts.add(editorPart); pageMap.put(page, editorParts); page.addPartListener(ValidationPartListener.getInstance()); } }
public void setActiveEditor(IAction action, IEditorPart targetEditor) { workbenchPart = targetEditor; fDelegateAction = action; if (targetEditor != null && targetEditor.getEditorSite() != null && targetEditor.getEditorSite().getSelectionProvider() != null) { updateWith(targetEditor.getEditorSite().getSelectionProvider().getSelection()); } }
/** * Saves the multi-page editor's document as another file. Also updates the * text for page 0's tab, and updates this multi-page editor's input to * correspond to the nested editor's. */ public void doSaveAs() { IEditorPart editor = getEditor(0); editor.doSaveAs(); setPageText(0, editor.getTitle()); setInput(editor.getEditorInput()); }
public void doSave(IProgressMonitor monitor) { if (_activeEditor != null) { _activeEditor.doSave(monitor); } }
public void setActiveEditor(IAction action, IEditorPart editor) { if (editor != null && editor.getEditorInput() instanceof IFileEditorInput) { fEditor= editor; } else { fEditor= null; } super.setActiveEditor(action, editor); }
private void updateActiveEditorSources(MPart part) { IEditorPart editor = getEditor(part); window.getContext().set(ISources.ACTIVE_EDITOR_ID_NAME, editor == null ? null : editor.getSite().getId()); window.getContext().set(ISources.ACTIVE_EDITOR_NAME, editor); window.getContext().set(ISources.ACTIVE_EDITOR_INPUT_NAME, editor == null ? null : editor.getEditorInput()); if (editor != null) { navigationHistory.markEditor(editor); } actionSwitcher.updateTopEditor(editor); }
protected ActionRegistry getEditorActionRegistry(IEditorPart editor) { return (ActionRegistry) editor.getAdapter(ActionRegistry.class); } }
public static void unregisterEditorPart(IEditorPart editorPart) { IWorkbenchPage page = editorPart.getSite().getPage(); if (pageMap.containsKey(page)) { pageMap.get(page).remove(editorPart); if (pageMap.get(page).isEmpty()) { pageMap.remove(page); page.removePartListener(ValidationPartListener.getInstance()); } } }