@Override public Object[] getPages() { int pageCount = getPageCount(); Object[] result = new Object[pageCount]; for (int i = 0; i < pageCount; i++) { result[i] = Integer.valueOf(i); } return result; }
/** * Creates and adds a new page containing the given control to this * multi-page editor. The control may be <code>null</code>, allowing it * to be created and set later using <code>setControl</code>. * * @param control * the control, or <code>null</code> * @return the index of the new page * * @see MultiPageEditorPart#setControl(int, Control) */ public int addPage(Control control) { int index = getPageCount(); addPage(index, control); return index; }
/** * Creates and adds a new page containing the given editor to this * multi-page editor. This also hooks a property change listener on the * nested editor. * * @param editor * the nested editor * @param input * the input for the nested editor * @return the index of the new page * @exception PartInitException * if a new page could not be created * * @see MultiPageEditorPart#handlePropertyChange(int) the handler for * property change events from the nested editor */ public int addPage(IEditorPart editor, IEditorInput input) throws PartInitException { int index = getPageCount(); addPage(index, editor, input); return index; }
/** * 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()]); }
/** * {@inheritDoc} * @throws ExecutionException * if an exception occurred during execution */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { int n= getPageCount(); if (n == 0) return null; int i= getActivePage() - 1; if (i < 0) i= n - 1; setActivePage(i); return null; } });
/** * 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; } } }
/** * {@inheritDoc} * @throws ExecutionException * if an exception occurred during execution */ @Override public Object execute(ExecutionEvent event) throws ExecutionException { int n= getPageCount(); if (n == 0) return null; int i= getActivePage() + 1; if (i >= n) i= 0; setActivePage(i); return null; } });
/** * Sets the currently active page. * * @param pageIndex * the index of the page to be activated; the index must be valid */ protected void setActivePage(int pageIndex) { Assert.isTrue(pageIndex >= 0 && pageIndex < getPageCount()); getTabFolder().setSelection(pageIndex); pageChange(pageIndex); }
/** * 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(); } } }
if (pageIndex < 0 || pageIndex >= getPageCount() || immediate) {
Assert.isTrue(pageIndex >= 0 && pageIndex < getPageCount());