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 80790 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 v02
cyclePages-v02.txt (text/plain), 16.79 KB, created by
Paul Webster
on 2007-10-19 14:21:19 EDT
(
hide
)
Description:
cycling pages v02
Filename:
MIME Type:
Creator:
Paul Webster
Created:
2007-10-19 14:21:19 EDT
Size:
16.79 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.ui.workbench >Index: Eclipse UI/org/eclipse/ui/part/IPageBookViewPage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/IPageBookViewPage.java,v >retrieving revision 1.8 >diff -u -r1.8 IPageBookViewPage.java >--- Eclipse UI/org/eclipse/ui/part/IPageBookViewPage.java 16 Mar 2007 18:00:34 -0000 1.8 >+++ Eclipse UI/org/eclipse/ui/part/IPageBookViewPage.java 19 Oct 2007 18:09:25 -0000 >@@ -15,10 +15,12 @@ > /** > * Interface for a page in a pagebook view. > * <p> >- * Pages should implement this interface. >+ * Pages should extend Page, although you can implement this interface >+ * directly. > * </p> > * @see PageBookView > * @see Page >+ * @see IPageBookViewPage2 > */ > public interface IPageBookViewPage extends IPage { > /** >Index: Eclipse UI/org/eclipse/ui/part/PageBookView.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/PageBookView.java,v >retrieving revision 1.36 >diff -u -r1.36 PageBookView.java >--- Eclipse UI/org/eclipse/ui/part/PageBookView.java 16 Mar 2007 18:00:34 -0000 1.36 >+++ Eclipse UI/org/eclipse/ui/part/PageBookView.java 19 Oct 2007 18:09:25 -0000 >@@ -16,8 +16,10 @@ > import java.util.Map; > import java.util.Set; > >+import org.eclipse.core.commands.Command; >+import org.eclipse.core.commands.ParameterizedCommand; > import org.eclipse.core.commands.common.EventManager; >-import org.eclipse.core.runtime.Platform; >+import org.eclipse.core.runtime.SafeRunner; > import org.eclipse.jface.action.IAction; > import org.eclipse.jface.util.IPropertyChangeListener; > import org.eclipse.jface.util.PropertyChangeEvent; >@@ -31,12 +33,20 @@ > import org.eclipse.swt.SWT; > import org.eclipse.swt.widgets.Composite; > import org.eclipse.swt.widgets.Control; >+import org.eclipse.swt.widgets.Table; >+import org.eclipse.swt.widgets.TableItem; > import org.eclipse.ui.IActionBars; > import org.eclipse.ui.IPartListener; > import org.eclipse.ui.IViewSite; >+import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.PartInitException; > import org.eclipse.ui.SubActionBars; >+import org.eclipse.ui.commands.ICommandService; >+import org.eclipse.ui.handlers.IHandlerService; >+import org.eclipse.ui.internal.CycleBaseHandler; >+import org.eclipse.ui.internal.WorkbenchMessages; >+import org.eclipse.ui.internal.WorkbenchPage; > import org.eclipse.ui.internal.WorkbenchPlugin; > import org.eclipse.ui.internal.util.Util; > >@@ -101,6 +111,9 @@ > * </p> > */ > public abstract class PageBookView extends ViewPart implements IPartListener { >+ private static final String NEXT_PAGE_ID = "org.eclipse.ui.navigate.nextPage"; //$NON-NLS-1$ >+ private static final String PREVIOUS_PAGE_ID = "org.eclipse.ui.navigate.previousPage"; //$NON-NLS-1$ >+ > /** > * The pagebook control, or <code>null</code> if not initialized. > */ >@@ -170,6 +183,94 @@ > private SelectionProvider selectionProvider = new SelectionProvider(); > > /** >+ * The handler for <code>PageBookView</code> that will cycle the pages of >+ * the pagebook. >+ * <p> >+ * This handler may be instantiated. It should not be extended. >+ * </p> >+ * >+ * @since 3.4 >+ */ >+ private final class CyclePageBookViewHandler extends CycleBaseHandler { >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.internal.CycleBaseHandler#activate(org.eclipse.ui.part.IPage) >+ */ >+ protected void activate(IWorkbenchPage page, Object selection) { >+ IPage selectedPage = (IPage) selection; >+ PageRec pageRec = PageBookView.this.getPageRec(selectedPage); >+ PageBookView.this.showPageRec(pageRec); >+ } >+ >+ /* >+ * (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) { >+ PageBookView pageBookView = PageBookView.this; >+ >+ Object[] pageRecs = pageBookView.getPageRecs(); >+ for (int i = pageRecs.length - 1; i >= 0; i--) { >+ PageRec pageRec = (PageRec) pageRecs[i]; >+ final Object selection = pageRec.page; >+ TableItem item = new TableItem(table, SWT.NONE); >+ String label = pageRec.part.getTitle(); >+ if (pageRec.page instanceof IPageBookViewPage2) { >+ label = ((IPageBookViewPage2) pageRec.page) >+ .getLabel(); >+ if (label==null) { >+ label = "part " + selection.hashCode(); //$NON-NLS-1$ >+ } >+ } >+ item.setText(label); >+ item.setImage(pageBookView.getTitleImage()); >+ item.setData(selection); >+ } >+ } >+ >+ /* >+ * (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(PREVIOUS_PAGE_ID); >+ ParameterizedCommand commandBack = new ParameterizedCommand( >+ command, null); >+ return commandBack; >+ } >+ >+ /* >+ * (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(NEXT_PAGE_ID); >+ ParameterizedCommand commandBack = new ParameterizedCommand( >+ command, null); >+ return commandBack; >+ } >+ >+ /* >+ * (non-Javadoc) >+ * >+ * @see org.eclipse.ui.internal.CycleBaseHandler#getTableHeader() >+ */ >+ protected String getTableHeader() { >+ return WorkbenchMessages.CyclePageBookAction_header; >+ } >+ >+ } >+ >+ /** > * A data structure used to store the information about a single page within > * a pagebook view. > */ >@@ -241,7 +342,7 @@ > Object[] listeners = getListeners(); > for (int i = 0; i < listeners.length; ++i) { > final ISelectionChangedListener l = (ISelectionChangedListener) listeners[i]; >- Platform.run(new SafeRunnable() { >+ SafeRunner.run(new SafeRunnable() { > public void run() { > l.selectionChanged(event); > } >@@ -990,4 +1091,27 @@ > protected SelectionProvider getSelectionProvider() { > return selectionProvider; > } >+ >+ /** >+ * Returns the pages from the pagebook. >+ * @return an array of type <code>IPage</code> >+ */ >+ private Object[] getPageRecs(){ >+ return mapPartToRec.values().toArray(); >+ } >+ >+ /** >+ * Can be called from createPartControl(Composite) to enabled the cycle page >+ * functionality for this page book view. The subclass should also set the >+ * text label on Page (which inherits from IPageBookViewPage2) >+ * >+ * @since 3.4 >+ */ >+ protected void registerPageSwitchingHandlers() { >+ IHandlerService service = (IHandlerService) getSite().getService( >+ IHandlerService.class); >+ CyclePageBookViewHandler handler = new CyclePageBookViewHandler(); >+ service.activateHandler(NEXT_PAGE_ID, handler); >+ service.activateHandler(PREVIOUS_PAGE_ID, handler); >+ } > } >Index: Eclipse UI/org/eclipse/ui/part/Page.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/part/Page.java,v >retrieving revision 1.9 >diff -u -r1.9 Page.java >--- Eclipse UI/org/eclipse/ui/part/Page.java 8 May 2006 20:55:33 -0000 1.9 >+++ Eclipse UI/org/eclipse/ui/part/Page.java 19 Oct 2007 18:09:25 -0000 >@@ -44,11 +44,12 @@ > * > * @see PageBookView > */ >-public abstract class Page implements IPageBookViewPage { >+public abstract class Page implements IPageBookViewPage2 { > /** > * The site which contains this page > */ > private IPageSite site; >+ private String label = null; > > /* > * Creates a new page for a pagebook view. >@@ -108,6 +109,7 @@ > */ > public void init(IPageSite pageSite) { > site = pageSite; >+ label = ""; //$NON-NLS-1$ > } > > /** >@@ -124,4 +126,21 @@ > * does nothing. Subclasses must implement. > */ > public abstract void setFocus(); >+ >+ /** >+ * Returns the page's label. >+ * @return A <code>String</code> that identifies the page. >+ */ >+ public String getLabel() { >+ return label; >+ } >+ >+ /** >+ * Sets the page's label. >+ * @param label >+ * The text shown to the user that will identify this page. >+ */ >+ public void setLabel(String label) { >+ this.label = label; >+ } > } >Index: Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java,v >retrieving revision 1.93 >diff -u -r1.93 WorkbenchMessages.java >--- Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java 2 Oct 2007 18:49:52 -0000 1.93 >+++ Eclipse UI/org/eclipse/ui/internal/WorkbenchMessages.java 19 Oct 2007 18:09:25 -0000 >@@ -238,6 +238,7 @@ > public static String CyclePerspectiveAction_prev_text; > public static String CyclePerspectiveAction_prev_toolTip; > public static String CyclePerspectiveAction_header; >+ public static String CyclePageBookAction_header; > public static String ActivateEditorAction_text; > public static String ActivateEditorAction_toolTip; > public static String MaximizePartAction_text; >Index: Eclipse UI/org/eclipse/ui/internal/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/messages.properties,v >retrieving revision 1.363 >diff -u -r1.363 messages.properties >--- Eclipse UI/org/eclipse/ui/internal/messages.properties 2 Oct 2007 18:49:52 -0000 1.363 >+++ Eclipse UI/org/eclipse/ui/internal/messages.properties 19 Oct 2007 18:09:25 -0000 >@@ -197,6 +197,7 @@ > CyclePerspectiveAction_prev_text = Previo&us Perspective > CyclePerspectiveAction_prev_toolTip = Previous Perspective > CyclePerspectiveAction_header=Perspectives >+CyclePageBookAction_header= Pages > ActivateEditorAction_text = &Activate Editor > ActivateEditorAction_toolTip = Activate Editor > MaximizePartAction_text = Ma&ximize Active View or Editor >Index: Eclipse UI/org/eclipse/ui/part/IPageBookViewPage2.java >=================================================================== >RCS file: Eclipse UI/org/eclipse/ui/part/IPageBookViewPage2.java >diff -N Eclipse UI/org/eclipse/ui/part/IPageBookViewPage2.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ Eclipse UI/org/eclipse/ui/part/IPageBookViewPage2.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,29 @@ >+/******************************************************************************* >+ * 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; >+ >+/** >+ * Interface for a page in a pagebook view that allows switching between pages. >+ * <p> >+ * Clients should extend Page over implementing this interface directly. >+ * </p> >+ * >+ * @since 3.4 >+ */ >+public interface IPageBookViewPage2 extends IPageBookViewPage { >+ /** >+ * A label to display while flipping pages. >+ * >+ * @return the page name >+ */ >+ public String getLabel(); >+} >#P org.eclipse.ui.console >Index: src/org/eclipse/ui/console/TextConsolePage.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.ui.console/src/org/eclipse/ui/console/TextConsolePage.java,v >retrieving revision 1.26 >diff -u -r1.26 TextConsolePage.java >--- src/org/eclipse/ui/console/TextConsolePage.java 27 Mar 2007 01:39:13 -0000 1.26 >+++ src/org/eclipse/ui/console/TextConsolePage.java 19 Oct 2007 18:09:25 -0000 >@@ -50,7 +50,7 @@ > import org.eclipse.ui.internal.console.ConsoleResourceBundleMessages; > import org.eclipse.ui.internal.console.FollowHyperlinkAction; > import org.eclipse.ui.internal.console.IConsoleHelpContextIds; >-import org.eclipse.ui.part.IPageBookViewPage; >+import org.eclipse.ui.part.IPageBookViewPage2; > import org.eclipse.ui.part.IPageSite; > import org.eclipse.ui.texteditor.FindReplaceAction; > import org.eclipse.ui.texteditor.IUpdate; >@@ -70,7 +70,7 @@ > * </p> > * @since 3.1 > */ >-public class TextConsolePage implements IPageBookViewPage, IPropertyChangeListener, IAdaptable { >+public class TextConsolePage implements IPageBookViewPage2, IPropertyChangeListener, IAdaptable { > private IPageSite fSite; > private TextConsole fConsole; > private IConsoleView fConsoleView; >@@ -106,6 +106,7 @@ > public TextConsolePage(TextConsole console, IConsoleView view) { > fConsole = console; > fConsoleView = view; >+ > } > > /** >@@ -398,4 +399,8 @@ > public void setViewer(TextConsoleViewer viewer) { > this.fViewer = viewer; > } >+ >+ public String getLabel() { >+ return fConsole.getName(); >+ } > } >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 19 Oct 2007 18:09:25 -0000 >@@ -439,6 +439,7 @@ > if (extensions.length > 0) { > fOpenConsoleAction = new OpenConsoleAction(); > } >+ registerPageSwitchingHandlers(); > } > > protected void configureToolBar(IToolBarManager mgr) { >#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 19 Oct 2007 18:09:26 -0000 >@@ -174,6 +174,9 @@ > command.next.name = Next > command.nextEditor.description = Switch to the next editor > command.nextEditor.name = Next Editor >+command.nextPage.name = Next Page >+command.next.navigationPageParameter.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 >@@ -189,8 +192,11 @@ > command.preferences.preferencePageIdParameter = Preference Page > command.previous.description = Navigate to the previous item > command.previous.name = Previous >+command.previous.navigationPageParameter.name = Previous Page > command.previousEditor.description = Switch to the previous editor > command.previousEditor.name = Previous Editor >+command.previousPage.description = Switch to the previous page >+command.previousPage.name = 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.408 >diff -u -r1.408 plugin.xml >--- plugin.xml 16 Oct 2007 14:17:54 -0000 1.408 >+++ plugin.xml 19 Oct 2007 18:09:26 -0000 >@@ -625,6 +625,18 @@ > parentId="org.eclipse.ui.defaultAcceleratorConfiguration" > id="org.eclipse.ui.emacsAcceleratorConfiguration"> > </scheme> >+ <key >+ commandId="org.eclipse.ui.navigate.nextPage" >+ contextId="org.eclipse.ui.contexts.window" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" >+ sequence="ALT+PAGE_UP"> >+ </key> >+ <key >+ commandId="org.eclipse.ui.navigate.previousPage" >+ contextId="org.eclipse.ui.contexts.window" >+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration" >+ sequence="ALT+PAGE_DOWN"> >+ </key> > </extension> > > <extension >@@ -1074,6 +1086,18 @@ > description="%command.toggleCoolbar.description" > id="org.eclipse.ui.ToggleCoolbarAction" > name="%command.toggleCoolbar.name"/> >+ <command >+ categoryId="org.eclipse.ui.category.navigate" >+ description="%command.nextPage.description" >+ id="org.eclipse.ui.navigate.nextPage" >+ name="%command.nextPage.name"> >+ </command> >+ <command >+ categoryId="org.eclipse.ui.category.navigate" >+ description="%command.previousPage.description" >+ id="org.eclipse.ui.navigate.previousPage" >+ name="%command.previousPage.name"> >+ </command> > </extension> > > <extension
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