Community
Participate
Working Groups
This suggestion is inspired from the accessibility talk we had Jul/30/01. Currently I don't think it is possible to move between editors using the keyboard. You can move between views using tab or shift-tab and get to the editor area to activate the last active editor. Once in the editor area, you can shift-tab to get out (tab will add a tab in the editor text) but you can not scroll through the editors. You can even use the keyboard to switch perspectives (alt-up/alt-down). We can add alt-left/alt-right to scroll through the editors. I have been using these shortcuts myself for a while and I find it very useful (especially going back and forth between two editors). We can also add alt-Enter for zooming on the editor/view. NOTES: JEL (02/08/2001 10:24:39 AM) Here is a class that performs the action (note: a couple accessor methods would need to be added to EditorPresentation and EditorWorkbook). ================================================ package org.eclipse.ui.internal; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchPart; import org.eclipse.ui.IEditorPart; import org.eclipse.swt.SWT; import java.util.ArrayList; public class NextEditorAction extends ActiveEditorAction { private int increment = 1; /** * Constructor for NextEditorAction * increment > 0: next editor * increment < 0: previous editor */ public NextEditorAction(String label, int increment, IWorkbenchWindow window) { super(label, window); this.increment = increment; setEnabled(false); } /* (non-Javadoc) * Method declared on IAction. * * Override the default implementation since we * want to show the user ALT+LEFT and ALT+RIGHT in * the menu, not LEFT_ARROW and RIGHT_ARROW. */ public int getAccelerator() { int accel = SWT.ALT; accel |= (increment < 0) ? SWT.ARROW_LEFT : SWT.ARROW_RIGHT; return accel; } /* (non-Javadoc) * Method declared on PartEventAction. */ public void partClosed(IWorkbenchPart part) { super.partClosed(part); updateState(); } /** * Update the state of the action. The action * is enabled if there is an active editor and * another editor. */ protected void updateState() { WorkbenchPage activePage = (WorkbenchPage)getActivePage(); if (activePage == null) { setEnabled(false); } else { setEnabled( (getActiveEditor() != null) && (activePage.getEditors().length > 1) ); } } /** * @see Action#run() */ public void run() { WorkbenchPage activePage = (WorkbenchPage)getActivePage(); if ( (activePage == null) ) { return; } if (activePage.getEditors().length < 2) { return; } EditorWorkbook activeEditorWorkbook = activePage.getEditorPresentation().getActiveEditorWorkbook(); ArrayList editorWorkbooks = activeEditorWorkbook.getEditorArea().getEditorWorkbooks(); IEditorPart[] editors = activeEditorWorkbook.getEditors(); IEditorPart visibleEditor = activePage.getEditorPresentation().getVisibleEditor(); int workbookIndex = editorWorkbooks.lastIndexOf(activeEditorWorkbook); int index; for (index = 0; index < editors.length; index++) { if ( editors[index] == visibleEditor ) break; } index += increment; if (index >= editors.length) { workbookIndex += increment; if ( workbookIndex >= editorWorkbooks.size() ) { workbookIndex = 0; } editors = ( (EditorWorkbook)editorWorkbooks.get(workbookIndex) ).getEditors(); index = 0; } else if (index < 0) { workbookIndex += increment; if ( workbookIndex < 0 ) { workbookIndex = editorWorkbooks.size() - 1; } editors = ( (EditorWorkbook)editorWorkbooks.get(workbookIndex) ).getEditors(); index = editors.length - 1; } activePage.activate(editors[index]); } } JEL (02/08/2001 10:38:15 AM) Here are the accessor methods I had to add: org.eclipse.ui.internal.EditorPresentation: /** * Returns the active editor workbook */ public EditorWorkbook getActiveEditorWorkbook() { return editorArea.getActiveWorkbook(); } org.eclipse.ui.internal.EditorWorkbook: /** * Returns a list of the editors open for the editor presentation. * <p> * The editors are returned in the order they appear in the editor * workbook, not the order they were created. * </p> * * @return a list of open editors */ public IEditorPart[] getEditors() { int nSize = editors.size(); IEditorPart[] retArray = new IEditorPart[nSize]; for (int i = 0; i < nSize; i++) { retArray[i] = ( (EditorPane)editors.get(i) ).getEditorPart(); } return retArray; }
PRODUCT VERSION: 125
Editors can be accessed using Ctrl+F6 in build 20020108