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 51375 Details for
Bug 16179
[Wizards] Wizard API: confusion over notifying of pages being entered, left
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
apply patch to org.eclipse.jface
oej-16179-v2.txt (text/plain), 17.84 KB, created by
Karice McIntyre
on 2006-10-03 16:13:42 EDT
(
hide
)
Description:
apply patch to org.eclipse.jface
Filename:
MIME Type:
Creator:
Karice McIntyre
Created:
2006-10-03 16:13:42 EDT
Size:
17.84 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface >Index: src/org/eclipse/jface/wizard/WizardDialog.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface/src/org/eclipse/jface/wizard/WizardDialog.java,v >retrieving revision 1.56 >diff -u -r1.56 WizardDialog.java >--- src/org/eclipse/jface/wizard/WizardDialog.java 27 Sep 2006 20:06:13 -0000 1.56 >+++ src/org/eclipse/jface/wizard/WizardDialog.java 3 Oct 2006 19:40:10 -0000 >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Chris Gross (schtoo@schtoo.com) - pactch for bug 16179 > *******************************************************************************/ > package org.eclipse.jface.wizard; > >@@ -23,8 +24,11 @@ > import org.eclipse.jface.dialogs.IMessageProvider; > import org.eclipse.jface.dialogs.IPageChangeProvider; > import org.eclipse.jface.dialogs.IPageChangedListener; >+import org.eclipse.jface.dialogs.IPageTransitionListener; >+import org.eclipse.jface.dialogs.IPageTransitionProvider; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.dialogs.PageChangedEvent; >+import org.eclipse.jface.dialogs.PageTransitionEvent; > import org.eclipse.jface.dialogs.TitleAreaDialog; > import org.eclipse.jface.operation.IRunnableWithProgress; > import org.eclipse.jface.operation.ModalContext; >@@ -70,7 +74,8 @@ > * is rarely required. > * </p> > */ >-public class WizardDialog extends TitleAreaDialog implements IWizardContainer2, IPageChangeProvider { >+public class WizardDialog extends TitleAreaDialog implements IWizardContainer2, >+ IPageChangeProvider, IPageTransitionProvider { > /** > * Image registry key for error message image (value <code>"dialog_title_error_image"</code>). > */ >@@ -136,6 +141,8 @@ > private boolean lockedUI = false; > > private ListenerList pageChangedListeners = new ListenerList(); >+ >+ private ListenerList pageTransitionListeners = new ListenerList(); > > /** > * A layout for a container which includes several pages, like >@@ -328,6 +335,11 @@ > // should never happen since we have already visited the page > return; > } >+ >+ // If page transition unsuccessful, do not change the page >+ if (!doPageTransition(PageTransitionEvent.EVENT_BACK)) >+ return; >+ > // set flag to indicate that we are moving back > isMovingToPreviousPage = true; > // show the page >@@ -756,9 +768,33 @@ > // something must have happend getting the next page > return; > } >+ >+ // If page transition unsuccessful, do not advance the page >+ if (!doPageTransition(PageTransitionEvent.EVENT_NEXT)) >+ return; >+ > // show the next page > showPage(page); > } >+ >+ /** >+ * Notifies page transition listeners and returns result of page transition >+ * processing to the sender. >+ * >+ * @param eventType >+ * @return <code>true</code> if page transition listener completes >+ * successfully, <code>false</code> otherwise >+ */ >+ private boolean doPageTransition(int eventType){ >+ PageTransitionEvent e = new PageTransitionEvent(this, getCurrentPage(), >+ eventType); >+ firePageTransitioning(e); >+ // Prevent navigation if necessary >+ if (e.doit == false){ >+ return false; >+ } >+ return true; >+ } > > /** > * Checks whether it is alright to close this wizard dialog >@@ -1363,4 +1399,62 @@ > }); > } > } >+ >+ /* >+ * <p> >+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >+ * part of a work in progress. There is a guarantee neither that this API will >+ * work nor that it will remain the same. Please do not use this API without >+ * consulting with the Platform/UI team. >+ * </p> >+ * >+ * (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IPageChangingProvider#addPageChangingListener(org.eclipse.jface.dialogs.IPageTransitionListener) >+ */ >+ public void addPageTransitionListener(IPageTransitionListener listener) { >+ pageTransitionListeners.add(listener); >+ } >+ >+ /* >+ * <p> >+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >+ * part of a work in progress. There is a guarantee neither that this API will >+ * work nor that it will remain the same. Please do not use this API without >+ * consulting with the Platform/UI team. >+ * </p> >+ * >+ * (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IPageChangingProvider#removePageChangingdListener(org.eclipse.jface.dialogs.IPageTransitionListener) >+ */ >+ public void removePageTransitionListener(IPageTransitionListener listener) { >+ pageTransitionListeners.remove(listener); >+ } >+ >+ /** >+ * <p> >+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >+ * part of a work in progress. There is a guarantee neither that this API will >+ * work nor that it will remain the same. Please do not use this API without >+ * consulting with the Platform/UI team. >+ * </p> >+ * >+ * Notifies any selection changing listeners that the selected page >+ * is changing. >+ * Only listeners registered at the time this method is called are notified. >+ * >+ * @param event a selection changing event >+ * >+ * @see IPageTransitionListener#pageTransition(PageTransitionEvent) >+ */ >+ protected void firePageTransitioning(final PageTransitionEvent event) { >+ Object[] listeners = pageTransitionListeners.getListeners(); >+ for (int i = 0; i < listeners.length; ++i) { >+ final IPageTransitionListener l = (IPageTransitionListener) listeners[i]; >+ SafeRunnable.run(new SafeRunnable() { >+ public void run() { >+ l.pageTransition(event); >+ } >+ }); >+ } >+ } > } >Index: src/org/eclipse/jface/wizard/Wizard.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface/src/org/eclipse/jface/wizard/Wizard.java,v >retrieving revision 1.13 >diff -u -r1.13 Wizard.java >--- src/org/eclipse/jface/wizard/Wizard.java 6 Sep 2006 19:43:39 -0000 1.13 >+++ src/org/eclipse/jface/wizard/Wizard.java 3 Oct 2006 19:40:10 -0000 >@@ -13,10 +13,13 @@ > import java.util.ArrayList; > import java.util.List; > >+import org.eclipse.core.runtime.Assert; > import org.eclipse.jface.dialogs.IDialogSettings; >+import org.eclipse.jface.dialogs.IPageTransitionListener; >+import org.eclipse.jface.dialogs.IPageTransitionProvider; >+import org.eclipse.jface.dialogs.PageTransitionEvent; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.resource.JFaceResources; >-import org.eclipse.core.runtime.Assert; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.RGB; > import org.eclipse.swt.widgets.Composite; >@@ -54,7 +57,7 @@ > * <code>IWizardPage</code>. > * </p> > */ >-public abstract class Wizard implements IWizard { >+public abstract class Wizard implements IWizard, IPageTransitionListener { > /** > * Image registry key of the default image for wizard pages (value > * <code>"org.eclipse.jface.wizard.Wizard.pageImage"</code>). >@@ -133,7 +136,67 @@ > page.setWizard(this); > } > >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IPageTransitionListener#pageTransition(org.eclipse.jface.dialogs.PageTransitionEvent) >+ */ >+ public void pageTransition(PageTransitionEvent event) { >+ int eventType = event.getType(); >+ if (eventType == PageTransitionEvent.EVENT_NEXT) { >+ event.doit = doNextPressed(); >+ } >+ else if (eventType == PageTransitionEvent.EVENT_BACK){ >+ event.doit = doBackPressed(); >+ } >+ } >+ >+ /** >+ * Add the listener that gets notified when a page is transitioning. >+ */ >+ private void hookPageTransitionProvider(){ >+ IPageTransitionProvider provider = getPageTransitionProvider(); >+ if (provider != null) >+ provider.addPageTransitionListener(this); >+ } >+ >+ /** >+ * Remove the listener that gets notified when a page is transitioning. >+ */ >+ private void unhookPageTransitionListener(){ >+ IPageTransitionProvider provider = getPageTransitionProvider(); >+ if (provider != null) >+ provider.removePageTransitionListener(this); >+ } >+ > /** >+ * Return the wizard container that facilitates the page transition events. >+ * >+ * @return IPageTransitionProvider the page transition provider >+ */ >+ private IPageTransitionProvider getPageTransitionProvider(){ >+ IWizardContainer container = getContainer(); >+ if (container instanceof IPageTransitionProvider){ >+ return (IPageTransitionProvider)container; >+ } >+ return null; >+ } >+ >+ /** >+ * This method is called when the next button of the wizard container is pressed. >+ * @return <code>true</code> if the next page should be shown, <code>false</code> otherwise >+ */ >+ protected boolean doNextPressed(){ >+ return true; >+ } >+ >+ /** >+ * This method is called when the back button of the wizard container is pressed. >+ * @return <code>true</code> if the previous page should be shown, <code>false</code> otherwise >+ */ >+ protected boolean doBackPressed(){ >+ return true; >+ } >+ >+ /** > * The <code>Wizard</code> implementation of this <code>IWizard</code> > * method does nothing. Subclasses should extend if extra pages need to be > * added before the wizard opens. New pages should be added by calling >@@ -183,6 +246,7 @@ > * disposed. > */ > public void dispose() { >+ unhookPageTransitionListener(); > // notify pages > for (int i = 0; i < pages.size(); i++) { > ((IWizardPage) pages.get(i)).dispose(); >@@ -352,6 +416,7 @@ > */ > public void setContainer(IWizardContainer wizardContainer) { > container = wizardContainer; >+ hookPageTransitionProvider(); > } > > /** >Index: src/org/eclipse/jface/dialogs/IPageTransitionProvider.java >=================================================================== >RCS file: src/org/eclipse/jface/dialogs/IPageTransitionProvider.java >diff -N src/org/eclipse/jface/dialogs/IPageTransitionProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/dialogs/IPageTransitionProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,54 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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: >+ * Chris Gross (schtoo@schtoo.com) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jface.dialogs; >+ >+/** >+ * <p> >+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >+ * part of a work in progress. There is a guarantee neither that this API will >+ * work nor that it will remain the same. Please do not use this API without >+ * consulting with the Platform/UI team. >+ * </p> >+ * >+ * Minimal interface to a page changing provider. Used for dialogs that >+ * transition between pages. >+ * >+ */ >+public interface IPageTransitionProvider { >+ /** >+ * Returns the currently selected page in the dialog. >+ * >+ * @return the selected page in the dialog or <code>null</code> if none is >+ * selected. The type may be domain specific. In the dialogs >+ * provided by JFace, this will be an instance of >+ * <code>IDialogPage</code>. >+ */ >+ Object getSelectedPage(); >+ >+ /** >+ * Adds a listener for page changes in this page changing provider. Has no >+ * effect if an identical listener is already registered. >+ * >+ * @param listener >+ * a page transition listener >+ */ >+ void addPageTransitionListener(IPageTransitionListener listener); >+ >+ /** >+ * Removes the given page changing listener from this page changing provider. >+ * Has no effect if an identical listener is not registered. >+ * >+ * @param listener >+ * a page transition listener >+ */ >+ void removePageTransitionListener(IPageTransitionListener listener); >+ >+} >Index: src/org/eclipse/jface/dialogs/PageTransitionEvent.java >=================================================================== >RCS file: src/org/eclipse/jface/dialogs/PageTransitionEvent.java >diff -N src/org/eclipse/jface/dialogs/PageTransitionEvent.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/dialogs/PageTransitionEvent.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,110 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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: >+ * Chris Gross (schtoo@schtoo.com) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jface.dialogs; >+ >+import java.util.EventObject; >+ >+import org.eclipse.core.runtime.Assert; >+ >+/** >+ * <p> >+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >+ * part of a work in progress. There is a guarantee neither that this API will >+ * work nor that it will remain the same. Please do not use this API without >+ * consulting with the Platform/UI team. >+ * </p> >+ * >+ * Event object describing a dialog page being changed. The source of these >+ * events is a page changing provider. >+ * >+ * @see IPageTransitionProvider >+ * @see IPageTransitionListener >+ * >+ */ >+public class PageTransitionEvent extends EventObject { >+ >+ >+ private static final long serialVersionUID = 1L; >+ >+ /** >+ * The selected page. >+ */ >+ protected Object selectedPage; >+ >+ /** >+ * The type of action that caused the page change event to be fired. >+ */ >+ protected int type; >+ >+ /** >+ * Constant describing a backward page navigation >+ */ >+ public static final int EVENT_BACK = 1; >+ /** >+ * Constant describing a forward page navigation >+ */ >+ public static final int EVENT_NEXT = 2; >+ >+ /** >+ * Public field that determines if page change will continue. >+ */ >+ public boolean doit = true; >+ >+ /** >+ * Creates a new event for the given source,selected page and direction. >+ * >+ * @param source >+ * the page changing provider >+ * @param selectedPage >+ * the selected page. In the JFace provided dialogs this will be >+ * an <code>IDialogPage</code>. >+ * @param eventType >+ * indicates the action that triggered the page change >+ */ >+ public PageTransitionEvent(IPageTransitionProvider source, Object selectedPage, >+ int eventType) { >+ super(source); >+ Assert.isNotNull(selectedPage); >+ Assert.isTrue(eventType == EVENT_BACK || eventType == EVENT_NEXT); >+ this.type = eventType; >+ this.selectedPage = selectedPage; >+ } >+ >+ /** >+ * Returns the selected page. >+ * >+ * @return the selected page. In dialogs implemented by JFace, >+ * this will be an <code>IDialogPage</code>. >+ */ >+ public Object getSelectedPage() { >+ return selectedPage; >+ } >+ >+ /** >+ * Returns the page change provider that is the source of this event. >+ * >+ * @return the originating page change provider >+ */ >+ public IPageTransitionProvider getPageTransitionProvider() { >+ return (IPageTransitionProvider) getSource(); >+ } >+ >+ /** >+ * Returns a integer constant indicating the action that triggered the >+ * change request. >+ * >+ * @return constant indicating the action that triggered the page change >+ */ >+ public int getType() { >+ return type; >+ } >+ >+} >Index: src/org/eclipse/jface/dialogs/IPageTransitionListener.java >=================================================================== >RCS file: src/org/eclipse/jface/dialogs/IPageTransitionListener.java >diff -N src/org/eclipse/jface/dialogs/IPageTransitionListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/dialogs/IPageTransitionListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,40 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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: >+ * Chris Gross (schtoo@schtoo.com) - initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.jface.dialogs; >+ >+/** >+ * <p> >+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as >+ * part of a work in progress. There is a guarantee neither that this API will >+ * work nor that it will remain the same. Please do not use this API without >+ * consulting with the Platform/UI team. >+ * </p> >+ * >+ * A listener which is notified when the current page of the multi-page dialog >+ * is changing. >+ * >+ * @see IPageTransitionProvider >+ * @see PageTransitionEvent >+ * >+ * @since 3.3 >+ */ >+public interface IPageTransitionListener { >+ >+ /** >+ * Notifies that the selected page is changing. The doit field of the >+ * PageTransitionEvent can be set to false to prevent the page from changing. >+ * >+ * @param event >+ * event object describing the change >+ */ >+ public void pageTransition(PageTransitionEvent event); >+ >+}
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 16179
:
24492
|
51264
| 51375 |
53025