### Eclipse Workspace Patch 1.0 #P org.eclipse.ui Index: plugin.properties =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui/plugin.properties,v retrieving revision 1.196 diff -u -r1.196 plugin.properties --- plugin.properties 2 Oct 2007 18:49:57 -0000 1.196 +++ plugin.properties 29 Oct 2007 14:57:47 -0000 @@ -174,6 +174,8 @@ command.next.name = Next command.nextEditor.description = Switch to the next editor command.nextEditor.name = Next Editor +command.nextPage.name = Next Page +command.nextPage.description = Switch to the next page command.nextPerspective.description = Switch to the next perspective command.nextPerspective.name = Next Perspective command.nextView.description = Switch to the next view @@ -191,6 +193,8 @@ command.previous.name = Previous command.previousEditor.description = Switch to the previous editor command.previousEditor.name = Previous Editor +command.previousPage.name = Previous Page +command.previousPage.description = Switch to the previous page command.previousPerspective.description = Switch to the previous perspective command.previousPerspective.name = Previous Perspective command.previousView.description = Switch to the previous view Index: plugin.xml =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui/plugin.xml,v retrieving revision 1.409 diff -u -r1.409 plugin.xml --- plugin.xml 22 Oct 2007 16:46:57 -0000 1.409 +++ plugin.xml 29 Oct 2007 14:57:47 -0000 @@ -625,6 +625,16 @@ parentId="org.eclipse.ui.defaultAcceleratorConfiguration" id="org.eclipse.ui.emacsAcceleratorConfiguration"> + + + + + + + + + * Clients that want their views to support page switching must implement this + * class. This must not be extended. + *

+ * + * @since 3.4 + * + */ +public abstract class PageSwitcher { + + private static final String COMMAND_PREVIOUS_PAGE = "org.eclipse.ui.part.previousPage"; //$NON-NLS-1$ + private static final String COMMAND_NEXT_PAGE = "org.eclipse.ui.part.nextPage"; //$NON-NLS-1$ + + public PageSwitcher(IWorkbenchPart part) { + IHandlerService service = (IHandlerService) part.getSite() + .getService(IHandlerService.class); + service.activateHandler(COMMAND_NEXT_PAGE, new CyclePageHandler(this)); + service.activateHandler(COMMAND_PREVIOUS_PAGE, new CyclePageHandler(this)); + } + + /** + * Displays the given page in the view. The page must already exist in the + * view. + * + * @param page + * the page to display, never null. + */ + public abstract void activatePage(Object page); + + /** + * Returns an {@link ImageDescriptor} for the page. + * + * @param page + * the page to retrieve an {@link ImageDescriptor} + * @return An {@link ImageDescriptor} for the page, may be null. + */ + public abstract ImageDescriptor getImageDescriptor(Object page); + + /** + * Returns a readable name to identify the page. + * + * @param page + * the page to get the name + * @return the name of the page + */ + public abstract String getName(Object page); + + /** + * Returns the pages available in the view. These may be used for populating + * the pop-up dialog when switching pages. + * + * @return an array of pages + */ + public abstract Object[] getPages(); +} #P org.eclipse.ui.console Index: src/org/eclipse/ui/internal/console/ConsoleView.java =================================================================== RCS file: /cvsroot/eclipse/org.eclipse.ui.console/src/org/eclipse/ui/internal/console/ConsoleView.java,v retrieving revision 1.45 diff -u -r1.45 ConsoleView.java --- src/org/eclipse/ui/internal/console/ConsoleView.java 27 Mar 2007 01:39:13 -0000 1.45 +++ src/org/eclipse/ui/internal/console/ConsoleView.java 29 Oct 2007 14:57:48 -0000 @@ -20,6 +20,7 @@ import org.eclipse.core.runtime.SafeRunner; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.Separator; +import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.util.IPropertyChangeListener; import org.eclipse.jface.util.PropertyChangeEvent; import org.eclipse.jface.viewers.IBasicPropertyConstants; @@ -43,6 +44,7 @@ import org.eclipse.ui.part.MessagePage; import org.eclipse.ui.part.PageBook; import org.eclipse.ui.part.PageBookView; +import org.eclipse.ui.part.PageSwitcher; import org.eclipse.ui.progress.IWorkbenchSiteProgressService; /** @@ -95,6 +97,8 @@ private boolean fScrollLock; + private PageSwitcher pageSwitcher = null; + private boolean isAvailable() { return getPageBook() != null && !getPageBook().isDisposed(); } @@ -338,6 +342,7 @@ ConsoleManager consoleManager = (ConsoleManager) ConsolePlugin.getDefault().getConsoleManager(); consoleManager.removeConsoleListener(this); consoleManager.unregisterConsoleView(this); + pageSwitcher = null; } /** @@ -439,6 +444,38 @@ if (extensions.length > 0) { fOpenConsoleAction = new OpenConsoleAction(); } + + pageSwitcher = new PageSwitcher(this){ + + public void activatePage(Object page) { + if (page instanceof IConsole) { + IConsole console = (IConsole) page; + display(console); + } + } + + public ImageDescriptor getImageDescriptor(Object page) { + if (page instanceof IConsole) { + IConsole console = (IConsole) page; + return console.getImageDescriptor(); + } + + return null; + } + + public String getName(Object page) { + if (page instanceof IConsole) { + IConsole console = (IConsole) page; + return console.getName(); + } + + return null; + } + + public Object[] getPages() { + return getConsoleStack().toArray(); + } + }; } protected void configureToolBar(IToolBarManager mgr) {