/** * Returns the active nested editor if there is one. * <p> * Subclasses should not override this method * </p> * * @nooverride * @return the active nested editor, or <code>null</code> if none */ protected IEditorPart getActiveEditor() { int index = getActivePage(); if (index != -1) { return getEditor(index); } return null; }
IEditorPart activeEditor = getEditor(newPageIndex);
/** * Find the editors contained in this multi-page editor * whose editor input match the provided input. * @param input the editor input * @return the editors contained in this multi-page editor * whose editor input match the provided input * @since 3.3 */ public final IEditorPart[] findEditors(IEditorInput input) { List result = new ArrayList(); int count = getPageCount(); for (int i = 0; i < count; i++) { IEditorPart editor = getEditor(i); if (editor != null && editor.getEditorInput() != null && editor.getEditorInput().equals(input)) { result.add(editor); } } return (IEditorPart[]) result.toArray(new IEditorPart[result.size()]); }
/** * Set the active page of this multi-page editor to the * page that contains the given editor part. This method has * no effect of the given editor part is not contained in this * multi-page editor. * @param editorPart the editor part * @since 3.3 */ public final void setActiveEditor(IEditorPart editorPart) { int count = getPageCount(); for (int i = 0; i < count; i++) { IEditorPart editor = getEditor(i); if (editor == editorPart) { setActivePage(i); break; } } }
/** * Returns the selected page for the current active page index, either the * IEditorPart for editors or the Control for other pages. * <p> * <b>Note:</b> clients may override this method to return a page * appropriate for their editors. Maybe be <code>null</code>. * </p> * * @return The IEditorPart or Control representing the current active page, * or <code>null</code> if there are no active pages. * @since 3.5 * @see #getActivePage() */ @Override public Object getSelectedPage() { int index = getActivePage(); if (index == -1) { return null; } IEditorPart editor = getEditor(index); if (editor != null) { return editor; } return getControl(index); }
/** * Sets focus to the control for the given page. If the page has an editor, * this calls its <code>setFocus()</code> method. Otherwise, this calls * <code>setFocus</code> on the control for the page. * * @param pageIndex * the index of the page */ private void setFocus(int pageIndex) { if (pageIndex < 0 || pageIndex >= getPageCount()) { // page index out of bounds, don't set focus. return; } final IEditorPart editor = getEditor(pageIndex); if (editor != null) { editor.setFocus(); } else { // Give the page's control focus. final Control control = getControl(pageIndex); if (control != null) { control.setFocus(); } } }
Assert.isTrue(pageIndex >= 0 && pageIndex < getPageCount()); IEditorPart editor = getEditor(pageIndex);
final IEditorPart editor = getEditor(pageIndex);
IEditorPart part = getEditor(0); if (part!=null) { final IServiceLocator serviceLocator = part.getEditorSite();