Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 81450 Details for
Bug 146623
[Commands] Define command / retargetable action / keybinding for switching pages in a PageBookView
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
cycling pages v04
patch-CyclePageBook_v04.txt (text/plain), 24.60 KB, created by
Tim Mok
on 2007-10-29 09:49:25 EDT
(
hide
)
Description:
cycling pages v04
Filename:
MIME Type:
Creator:
Tim Mok
Created:
2007-10-29 09:49:25 EDT
Size:
24.60 KB
patch
obsolete
>### 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 13:47:17 -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 13:47:17 -0000 >@@ -625,6 +625,16 @@ > parentId="org.eclipse.ui.defaultAcceleratorConfiguration" > id="org.eclipse.ui.emacsAcceleratorConfiguration"> > </scheme> >+ <key >+ commandId="org.eclipse.ui.part.nextPage" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" >+ sequence="ALT+PAGE_UP"> >+ </key> >+ <key >+ commandId="org.eclipse.ui.part.previousPage" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" >+ sequence="ALT+PAGE_DOWN"> >+ </key> > </extension> > > <extension >@@ -1075,6 +1085,16 @@ > description="%command.toggleCoolbar.description" > id="org.eclipse.ui.ToggleCoolbarAction" > name="%command.toggleCoolbar.name"/> >+ <command >+ description="%command.nextPage.description" >+ id="org.eclipse.ui.part.nextPage" >+ name="%command.nextPage.name"> >+ </command> >+ <command >+ description="%command.previousPage.description" >+ id="org.eclipse.ui.part.previousPage" >+ name="%command.previousPage.name"> >+ </command> > </extension> > > <extension >@@ -1851,6 +1871,30 @@ > </with> > </enabledWhen> > </handler> >+ <handler >+ class="org.eclipse.ui.internal.handlers.CyclePageHandler" >+ commandId="org.eclipse.ui.part.nextPage"> >+ <enabledWhen> >+ <with >+ variable="activePart"> >+ <instanceof >+ value="org.eclipse.ui.part.IPageManager"> >+ </instanceof> >+ </with> >+ </enabledWhen> >+ </handler> >+ <handler >+ class="org.eclipse.ui.internal.handlers.CyclePageHandler" >+ commandId="org.eclipse.ui.part.previousPage"> >+ <enabledWhen> >+ <with >+ variable="activePart"> >+ <instanceof >+ value="org.eclipse.ui.part.IPageManager"> >+ </instanceof> >+ </with> >+ </enabledWhen> >+ </handler> > </extension> > <extension > point="org.eclipse.core.runtime.adapters"> >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/internal/CycleBaseHandler.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/CycleBaseHandler.java,v >retrieving revision 1.1 >diff -u -r1.1 CycleBaseHandler.java >--- Eclipse UI/org/eclipse/ui/internal/CycleBaseHandler.java 17 Apr 2007 12:06:16 -0000 1.1 >+++ Eclipse UI/org/eclipse/ui/internal/CycleBaseHandler.java 29 Oct 2007 13:47:18 -0000 >@@ -48,6 +48,8 @@ > import org.eclipse.ui.contexts.IContextService; > import org.eclipse.ui.handlers.HandlerUtil; > import org.eclipse.ui.keys.IBindingService; >+import org.eclipse.ui.part.IPageManager; >+import org.eclipse.ui.part.IPageSwitcher; > > /** > * Its a base class for switching between views/editors/perspectives. >@@ -104,7 +106,10 @@ > > IWorkbenchPage page = window.getActivePage(); > activePart = page.getActivePart(); >+ selection = null; >+ getTriggers(); > openDialog((WorkbenchPage) page); >+ clearTriggers(); > activate(page, selection); > > return null; >@@ -116,7 +121,6 @@ > protected void openDialog(WorkbenchPage page) { > final int MAX_ITEMS = 22; > >- selection = null; > final Shell dialog = new Shell(window.getShell(), SWT.MODELESS); > Display display = dialog.getDisplay(); > dialog.setLayout(new FillLayout()); >@@ -132,8 +136,8 @@ > > switch (tableItemCount) { > case 0: >- // do nothing; >- break; >+ cancel(dialog); >+ return; > case 1: > table.setSelection(0); > break; >@@ -191,25 +195,6 @@ > > dialog.setLocation(dialogBounds.x, dialogBounds.y); > >- /* >- * Fetch the key bindings for the forward and backward commands. They >- * will not change while the dialog is open, but the context will. Bug >- * 55581. >- */ >- commandForward = getForwardCommand(); >- commandBackward = getBackwardCommand(); >- /* >- * Fetch the key bindings for the forward and backward commands. They >- * will not change while the dialog is open, but the context will. Bug >- * 55581. >- */ >- final IBindingService bindingService = (IBindingService) window >- .getWorkbench().getService(IBindingService.class); >- forwardTriggerSequences = bindingService >- .getActiveBindingsFor(commandForward); >- backwardTriggerSequences = bindingService >- .getActiveBindingsFor(commandBackward); >- > final IContextService contextService = (IContextService) window > .getWorkbench().getService(IContextService.class); > try { >@@ -229,11 +214,33 @@ > cancel(dialog); > } > contextService.unregisterShell(dialog); >- forwardTriggerSequences = null; >- backwardTriggerSequences = null; > } > } > >+ /** >+ * Clears the forward and backward trigger sequences. >+ */ >+ protected void clearTriggers() { >+ forwardTriggerSequences = null; >+ backwardTriggerSequences = null; >+ } >+ >+ /** >+ * Fetch the key bindings for the forward and backward commands. They will >+ * not change while the dialog is open, but the context will. Bug 55581. >+ */ >+ protected void getTriggers() { >+ commandForward = getForwardCommand(); >+ commandBackward = getBackwardCommand(); >+ >+ final IBindingService bindingService = (IBindingService) window >+ .getWorkbench().getService(IBindingService.class); >+ forwardTriggerSequences = bindingService >+ .getActiveBindingsFor(commandForward); >+ backwardTriggerSequences = bindingService >+ .getActiveBindingsFor(commandBackward); >+ } >+ > protected void addKeyListener(final Table table, final Shell dialog) { > table.addKeyListener(new KeyListener() { > private boolean firstKey = true; >@@ -382,6 +389,11 @@ > page.setPerspective(persp); > } > >+ if (activePart instanceof IPageManager) { >+ IPageSwitcher pageSwitcher = ((IPageManager) activePart) >+ .getPageSwitcher(); >+ pageSwitcher.activatePage(selectedItem); >+ } > } > } > >Index: Eclipse UI/org/eclipse/ui/part/IPageSwitcher.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/part/IPageSwitcher.java >diff -N Eclipse UI/org/eclipse/ui/part/IPageSwitcher.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/part/IPageSwitcher.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,75 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.part; >+ >+import org.eclipse.jface.resource.ImageDescriptor; >+ >+/** >+ * Provides the behavior for switching pages in a view. A view may track pages >+ * however it wishes. >+ * <p> >+ * Clients that want their views to support page switching must implement this >+ * interface. This must not be extended. >+ * </p> >+ * >+ * @since 3.4 >+ * >+ */ >+public interface IPageSwitcher { >+ >+ /** >+ * 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 Object[] getPages(); >+ >+ /** >+ * Returns a readable name to identify the page. >+ * >+ * @param page >+ * the page to get the name >+ * @return the name of the page >+ */ >+ public String getName(Object page); >+ >+ /** >+ * >+ * @param page >+ * @return >+ */ >+ public ImageDescriptor getImageDescriptor(Object page); >+ >+ /** >+ * Displays the given page in the view. The page must already exist in the >+ * view. >+ * >+ * @param page >+ * the page to display >+ */ >+ public void activatePage(Object page); >+ >+ /** >+ * Returns the next page that would be displayed. >+ * >+ * @return a page, returns <code>null</code> if there are no pages >+ */ >+ public Object getNextPage(); >+ >+ /** >+ * Returns the previous page that would be displayed. >+ * >+ * @return a page, returns <code>null</code> if there are no pages >+ */ >+ public Object getPreviousPage(); >+} >Index: Eclipse UI/org/eclipse/ui/internal/handlers/CyclePageHandler.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/internal/handlers/CyclePageHandler.java >diff -N Eclipse UI/org/eclipse/ui/internal/handlers/CyclePageHandler.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/internal/handlers/CyclePageHandler.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,239 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.handlers; >+ >+import org.eclipse.core.commands.Command; >+import org.eclipse.core.commands.ExecutionEvent; >+import org.eclipse.core.commands.ExecutionException; >+import org.eclipse.core.commands.ParameterizedCommand; >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.swt.SWT; >+import org.eclipse.swt.events.FocusEvent; >+import org.eclipse.swt.events.FocusListener; >+import org.eclipse.swt.graphics.Rectangle; >+import org.eclipse.swt.layout.FillLayout; >+import org.eclipse.swt.widgets.Display; >+import org.eclipse.swt.widgets.Shell; >+import org.eclipse.swt.widgets.Table; >+import org.eclipse.swt.widgets.TableColumn; >+import org.eclipse.swt.widgets.TableItem; >+import org.eclipse.ui.commands.ICommandService; >+import org.eclipse.ui.contexts.IContextService; >+import org.eclipse.ui.internal.CycleBaseHandler; >+import org.eclipse.ui.internal.PartSite; >+import org.eclipse.ui.internal.WorkbenchPage; >+import org.eclipse.ui.part.IPageManager; >+import org.eclipse.ui.part.IPageSwitcher; >+import org.eclipse.ui.part.WorkbenchPart; >+ >+/** >+ * Displays a dialog for cycling through pages of a view. A view may implement >+ * its pages however it wishes. As long as the view provides >+ * {@link IPageManager} behavior to return a {@link IPageSwitcher} object, >+ * {@link CyclePageHandler} will handle the cycling of pages. >+ * >+ * @since 3.4 >+ * >+ */ >+public class CyclePageHandler extends CycleBaseHandler { >+ >+ 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$ >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.internal.CycleBaseHandler#addItems(org.eclipse.swt.widgets.Table, >+ * org.eclipse.ui.internal.WorkbenchPage) >+ */ >+ protected void addItems(Table table, WorkbenchPage page) { >+ if (!(activePart instanceof IPageManager)) { >+ return; >+ } >+ IPageSwitcher pageSwitcher = ((IPageManager) activePart) >+ .getPageSwitcher(); >+ Object[] pages = pageSwitcher.getPages(); >+ for (int i = 0; i < pages.length; i++) { >+ org.eclipse.swt.widgets.TableItem item = null; >+ item = new TableItem(table, SWT.NONE); >+ ImageDescriptor imageDescriptor = pageSwitcher >+ .getImageDescriptor(pages[i]); >+ if (imageDescriptor != null) { >+ item.setImage(imageDescriptor.createImage()); >+ } >+ item.setData(pages[i]); >+ item.setText(pageSwitcher.getName(pages[i])); >+ } >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.internal.CycleBaseHandler#getBackwardCommand() >+ */ >+ protected ParameterizedCommand getBackwardCommand() { >+ final ICommandService commandService = (ICommandService) window >+ .getWorkbench().getService(ICommandService.class); >+ final Command command = commandService >+ .getCommand(COMMAND_PREVIOUS_PAGE); >+ ParameterizedCommand commandF = new ParameterizedCommand(command, null); >+ return commandF; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.internal.CycleBaseHandler#getForwardCommand() >+ */ >+ protected ParameterizedCommand getForwardCommand() { >+ final ICommandService commandService = (ICommandService) window >+ .getWorkbench().getService(ICommandService.class); >+ final Command command = commandService.getCommand(COMMAND_NEXT_PAGE); >+ ParameterizedCommand commandF = new ParameterizedCommand(command, null); >+ return commandF; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.internal.CycleBaseHandler#getTableHeader() >+ */ >+ protected String getTableHeader() { >+ if (activePart instanceof WorkbenchPart) { >+ return ((WorkbenchPart) activePart).getPartName(); >+ } >+ >+ return activePart.getTitle(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.internal.CycleBaseHandler#execute(org.eclipse.core.commands.ExecutionEvent) >+ */ >+ public Object execute(ExecutionEvent event) throws ExecutionException { >+ if (event.getCommand().getId().equals(COMMAND_NEXT_PAGE)) { >+ gotoDirection = true; >+ } else { >+ gotoDirection = false; >+ } >+ return super.execute(event); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.internal.CycleBaseHandler#openDialog(org.eclipse.ui.internal.WorkbenchPage) >+ */ >+ protected void openDialog(WorkbenchPage page) { >+ final int MAX_ITEMS = 22; >+ >+ final Shell dialog = new Shell(window.getShell(), SWT.MODELESS); >+ Display display = dialog.getDisplay(); >+ dialog.setLayout(new FillLayout()); >+ >+ final Table table = new Table(dialog, SWT.SINGLE | SWT.FULL_SELECTION); >+ table.setHeaderVisible(true); >+ table.setLinesVisible(true); >+ TableColumn tc = new TableColumn(table, SWT.NONE); >+ tc.setResizable(false); >+ tc.setText(getTableHeader()); >+ addItems(table, page); >+ int tableItemCount = table.getItemCount(); >+ >+ switch (tableItemCount) { >+ case 0: >+ cancel(dialog); >+ return; >+ case 1: >+ table.setSelection(0); >+ break; >+ default: >+ table.setSelection(gotoDirection ? 1 : table.getItemCount() - 1); >+ } >+ >+ tc.pack(); >+ table.pack(); >+ dialog.pack(); >+ >+ Rectangle tableBounds = table.getBounds(); >+ tableBounds.height = Math.min(tableBounds.height, table.getItemHeight() >+ * MAX_ITEMS); >+ table.setBounds(tableBounds); >+ >+ dialog.setBounds(dialog.computeTrim(tableBounds.x, tableBounds.y, >+ tableBounds.width, tableBounds.height)); >+ >+ tc.setWidth(table.getClientArea().width); >+ table.setFocus(); >+ table.addFocusListener(new FocusListener() { >+ public void focusGained(FocusEvent e) { >+ // Do nothing >+ } >+ >+ public void focusLost(FocusEvent e) { >+ cancel(dialog); >+ } >+ }); >+ WorkbenchPart workbenchPart = (WorkbenchPart) activePart; >+ >+ Rectangle dialogBounds = dialog.getBounds(); >+ Rectangle viewBounds = ((PartSite) workbenchPart.getSite()).getPane() >+ .getBounds(); >+ Rectangle parentBounds = ((PartSite) workbenchPart.getSite()) >+ .getShell().getBounds(); >+ >+ // the bounds of the monitor that contains the currently active part. >+ Rectangle monitorBounds = activePart == null ? display >+ .getPrimaryMonitor().getBounds() : ((PartSite) activePart >+ .getSite()).getPane().getControl().getMonitor().getBounds(); >+ >+ // Place it in the center of its parent; >+ dialogBounds.x = parentBounds.x + viewBounds.x + (viewBounds.width / 2); >+ dialogBounds.y = parentBounds.y + viewBounds.y >+ + (viewBounds.height / 2); >+ >+ if (!monitorBounds.contains(dialogBounds.x, dialogBounds.y) >+ || !monitorBounds.contains(dialogBounds.x + dialogBounds.width, >+ dialogBounds.y + dialogBounds.height)) { >+ // Place it in the center of the monitor if it is not visible >+ // when placed in the center of its parent; >+ dialogBounds.x = monitorBounds.x >+ + (monitorBounds.width - dialogBounds.width) / 2; >+ dialogBounds.y = monitorBounds.y >+ + (monitorBounds.height - dialogBounds.height) / 2; >+ } >+ >+ dialog.setLocation(dialogBounds.x, dialogBounds.y); >+ >+ final IContextService contextService = (IContextService) window >+ .getWorkbench().getService(IContextService.class); >+ try { >+ dialog.open(); >+ addMouseListener(table, dialog); >+ contextService.registerShell(dialog, IContextService.TYPE_NONE); >+ addKeyListener(table, dialog); >+ addTraverseListener(table); >+ >+ while (!dialog.isDisposed()) { >+ if (!display.readAndDispatch()) { >+ display.sleep(); >+ } >+ } >+ } finally { >+ if (!dialog.isDisposed()) { >+ cancel(dialog); >+ } >+ contextService.unregisterShell(dialog); >+ } >+ } >+} >Index: Eclipse UI/org/eclipse/ui/part/IPageManager.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/part/IPageManager.java >diff -N Eclipse UI/org/eclipse/ui/part/IPageManager.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/part/IPageManager.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,33 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.part; >+ >+/** >+ * Provides the behavior to return an IPageSwitcher. >+ * <p> >+ * Clients must implement this for their views if they want page switching >+ * behavior. This must not be extended. >+ * </p> >+ * >+ * @since 3.4 >+ * >+ */ >+public interface IPageManager { >+ >+ /** >+ * Returns an IPageSwitcher that can be used for switching pages in the >+ * view. >+ * >+ * @return the IPageSwitcher >+ */ >+ public IPageSwitcher getPageSwitcher(); >+} >#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 13:47:21 -0000 >@@ -40,6 +40,8 @@ > import org.eclipse.ui.console.IConsoleView; > import org.eclipse.ui.part.IPage; > import org.eclipse.ui.part.IPageBookViewPage; >+import org.eclipse.ui.part.IPageManager; >+import org.eclipse.ui.part.IPageSwitcher; > import org.eclipse.ui.part.MessagePage; > import org.eclipse.ui.part.PageBook; > import org.eclipse.ui.part.PageBookView; >@@ -50,7 +52,8 @@ > * > * @since 3.0 > */ >-public class ConsoleView extends PageBookView implements IConsoleView, IConsoleListener, IPropertyChangeListener, IPartListener2 { >+public class ConsoleView extends PageBookView implements IConsoleView, >+ IConsoleListener, IPropertyChangeListener, IPartListener2, IPageManager { > > /** > * Whether this console is pinned. >@@ -712,4 +715,8 @@ > setPinned(true); > } > } >+ >+ public IPageSwitcher getPageSwitcher() { >+ return new ConsoleViewPageSwitcher(this); >+ } > } >Index: src/org/eclipse/ui/internal/console/ConsoleViewPageSwitcher.java >=================================================================== >RCS file: src/org/eclipse/ui/internal/console/ConsoleViewPageSwitcher.java >diff -N src/org/eclipse/ui/internal/console/ConsoleViewPageSwitcher.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/ui/internal/console/ConsoleViewPageSwitcher.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,118 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ ******************************************************************************/ >+ >+package org.eclipse.ui.internal.console; >+ >+import java.util.List; >+ >+import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.console.IConsole; >+import org.eclipse.ui.part.IPageSwitcher; >+ >+/** >+ * A helper class to switch pages within a view that has the notion of pages. >+ * >+ * @since 3.4 >+ * >+ */ >+public class ConsoleViewPageSwitcher implements IPageSwitcher { >+ >+ private ConsoleView part; >+ >+ public ConsoleViewPageSwitcher(IWorkbenchPart part) { >+ if (part instanceof ConsoleView) { >+ this.part = (ConsoleView) part; >+ } >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.part.PageSwitcher#activatePage(java.lang.Object) >+ */ >+ public void activatePage(Object page) { >+ if (page instanceof IConsole) { >+ IConsole console = (IConsole) page; >+ part.display(console); >+ } >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.part.PageSwitcher#getImageDescriptor(java.lang.Object) >+ */ >+ public ImageDescriptor getImageDescriptor(Object page) { >+ if (page instanceof IConsole) { >+ IConsole console = (IConsole) page; >+ return console.getImageDescriptor(); >+ } >+ >+ return null; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.part.PageSwitcher#getName(java.lang.Object) >+ */ >+ public String getName(Object page) { >+ if (page instanceof IConsole) { >+ IConsole console = (IConsole) page; >+ return console.getName(); >+ } >+ >+ return null; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.part.PageSwitcher#getNextPage() >+ */ >+ public Object getNextPage() { >+ List consoleStack = part.getConsoleStack(); >+ int size = consoleStack.size(); >+ >+ if (size == 0) { >+ return null; >+ } >+ >+ return consoleStack.get(0); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.part.PageSwitcher#getPages() >+ */ >+ public Object[] getPages() { >+ return part.getConsoleStack().toArray(); >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.part.PageSwitcher#getPreviousPage() >+ */ >+ public Object getPreviousPage() { >+ List consoleStack = part.getConsoleStack(); >+ int size = consoleStack.size(); >+ >+ if (size == 0) { >+ return null; >+ } >+ >+ return consoleStack.get(size - 1); >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 146623
:
80703
|
80790
|
81304
|
81450
|
81463
|
83339
|
83877
|
83898