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 24492 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]
Adds Page Changing Events
patch_16179.txt (text/plain), 11.78 KB, created by
Chris Gross
on 2005-07-08 14:57:15 EDT
(
hide
)
Description:
Adds Page Changing Events
Filename:
MIME Type:
Creator:
Chris Gross
Created:
2005-07-08 14:57:15 EDT
Size:
11.78 KB
patch
obsolete
>Index: src/org/eclipse/jface/wizard/WizardDialog.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.jface/src/org/eclipse/jface/wizard/WizardDialog.java,v >retrieving revision 1.32 >diff -u -r1.32 WizardDialog.java >--- src/org/eclipse/jface/wizard/WizardDialog.java 15 Jun 2005 18:41:18 -0000 1.32 >+++ src/org/eclipse/jface/wizard/WizardDialog.java 8 Jul 2005 17:59:40 -0000 >@@ -22,8 +22,11 @@ > import org.eclipse.jface.dialogs.IMessageProvider; > import org.eclipse.jface.dialogs.IPageChangeProvider; > import org.eclipse.jface.dialogs.IPageChangedListener; >+import org.eclipse.jface.dialogs.IPageChangingListener; >+import org.eclipse.jface.dialogs.IPageChangingProvider; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.dialogs.PageChangedEvent; >+import org.eclipse.jface.dialogs.PageChangingEvent; > import org.eclipse.jface.dialogs.TitleAreaDialog; > import org.eclipse.jface.operation.IRunnableWithProgress; > import org.eclipse.jface.operation.ModalContext; >@@ -70,7 +73,7 @@ > * is rarely required. > * </p> > */ >-public class WizardDialog extends TitleAreaDialog implements IWizardContainer2, IPageChangeProvider { >+public class WizardDialog extends TitleAreaDialog implements IWizardContainer2, IPageChangeProvider, IPageChangingProvider { > /** > * Image registry key for error message image (value <code>"dialog_title_error_image"</code>). > */ >@@ -136,6 +139,8 @@ > private boolean lockedUI = false; > > private ListenerList pageChangedListeners = new ListenerList(3); >+ >+ private ListenerList pageChangingListeners = new ListenerList(3); > > /** > * A layout for a container which includes several pages, like >@@ -322,6 +327,14 @@ > if (page == null) > // should never happen since we have already visited the page > return; >+ >+ //Notify page changing listeners >+ PageChangingEvent e = new PageChangingEvent(this, getCurrentPage(),PageChangingEvent.DIRECTION_BACK); >+ firePageChanging(e); >+ //prevent navigation if necessary >+ if (e.doit == false) >+ return; >+ > // set flag to indicate that we are moving back > isMovingToPreviousPage = true; > // show the page >@@ -668,6 +681,14 @@ > * The Finish button has been pressed. > */ > protected void finishPressed() { >+ >+ //Notify page changing listeners >+ PageChangingEvent e = new PageChangingEvent(this, getCurrentPage(),PageChangingEvent.DIRECTION_FINISH); >+ firePageChanging(e); >+ //Prevent nagiviation if necessary >+ if (e.doit == false) >+ return; >+ > // Wizards are added to the nested wizards list in setWizard. > // This means that the current wizard is always the last wizard in the list. > // Note that we first call the current wizard directly (to give it a chance to >@@ -749,6 +770,14 @@ > // something must have happend getting the next page > return; > } >+ >+ //Notify page changing listeners >+ PageChangingEvent e = new PageChangingEvent(this, getCurrentPage(),PageChangingEvent.DIRECTION_NEXT); >+ firePageChanging(e); >+ //Prevent navigation if necessary >+ if (e.doit == false) >+ return; >+ > // show the next page > showPage(page); > } >@@ -1302,4 +1331,41 @@ > }); > } > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IPageChangingProvider#addPageChangingListener(org.eclipse.jface.dialogs.IPageChangingListener) >+ */ >+ public void addPageChangingListener(IPageChangingListener listener) { >+ pageChangingListeners.add(listener); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.jface.dialogs.IPageChangingProvider#removePageChangingdListener(org.eclipse.jface.dialogs.IPageChangingListener) >+ */ >+ public void removePageChangingdListener(IPageChangingListener listener) { >+ pageChangingListeners.remove(listener); >+ } >+ >+ /** >+ * 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 IPageChangingListener#pageChanging >+ * >+ * @since 3.2? >+ */ >+ protected void firePageChanging(final PageChangingEvent event) { >+ Object[] listeners = pageChangingListeners.getListeners(); >+ for (int i = 0; i < listeners.length; ++i) { >+ final IPageChangingListener l = (IPageChangingListener) listeners[i]; >+ SafeRunnable.run(new SafeRunnable() { >+ public void run() { >+ l.pageChanging(event); >+ } >+ }); >+ } >+ } > } >Index: src/org/eclipse/jface/dialogs/IPageChangingListener.java >=================================================================== >RCS file: src/org/eclipse/jface/dialogs/IPageChangingListener.java >diff -N src/org/eclipse/jface/dialogs/IPageChangingListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/dialogs/IPageChangingListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,32 @@ >+/******************************************************************************* >+ * 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; >+ >+/** >+ * A listener which is notified when the current page of the multi-page dialog >+ * is changing. >+ * >+ * @see IPageChangingProvider >+ * @see PageChangingEvent >+ * >+ * @since 3.2? >+ */ >+public interface IPageChangingListener { >+ >+ /** >+ * Notifies that the selected page is changing. The doit field of the >+ * PageChangingEvent can be set to false to prevent the page from changing. >+ * >+ * @param event >+ * event object describing the change >+ */ >+ public void pageChanging(PageChangingEvent event); >+ >+} >Index: src/org/eclipse/jface/dialogs/IPageChangingProvider.java >=================================================================== >RCS file: src/org/eclipse/jface/dialogs/IPageChangingProvider.java >diff -N src/org/eclipse/jface/dialogs/IPageChangingProvider.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/dialogs/IPageChangingProvider.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,47 @@ >+/******************************************************************************* >+ * 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; >+ >+/** >+ * Minimal interface to a page changing provider. Used for dialogs which can >+ * switch between multiple pages. >+ * >+ * @since 3.2? >+ */ >+public interface IPageChangingProvider { >+ /** >+ * 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 JFace provided dialogs 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 changing listener >+ */ >+ void addPageChangingListener(IPageChangingListener 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 changing listener >+ */ >+ void removePageChangingdListener(IPageChangingListener listener); >+ >+} >Index: src/org/eclipse/jface/dialogs/PageChangingEvent.java >=================================================================== >RCS file: src/org/eclipse/jface/dialogs/PageChangingEvent.java >diff -N src/org/eclipse/jface/dialogs/PageChangingEvent.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/dialogs/PageChangingEvent.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,106 @@ >+/******************************************************************************* >+ * 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.jface.util.Assert; >+ >+/** >+ * Event object describing a page selection being changed. The source of these events >+ * is a page changing provider. >+ * >+ * @see IPageChangingProvider >+ * @see IPageChangingListener >+ * >+ * @since 3.2? >+ */ >+public class PageChangingEvent extends EventObject { >+ >+ >+ private static final long serialVersionUID = 1L; >+ >+ /** >+ * The selected page. >+ */ >+ protected Object selectedPage; >+ >+ /** >+ * One of the directional constants below >+ */ >+ protected int direction; >+ >+ /** >+ * Constant describing a backward page navigation >+ */ >+ public static final int DIRECTION_BACK = 1; >+ /** >+ * Constant describing a forward page navigation >+ */ >+ public static final int DIRECTION_NEXT = 2; >+ /** >+ * Constant describing a finish page navigation >+ */ >+ public static final int DIRECTION_FINISH = 3; >+ >+ /** >+ * Public field, 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 direction DIRECTION_BACK,DIRECTION_NEXT,DIRECTION_FINISH >+ */ >+ public PageChangingEvent(IPageChangingProvider source, >+ Object selectedPage,int direction) { >+ super(source); >+ Assert.isNotNull(selectedPage); >+ Assert.isTrue(direction == DIRECTION_BACK || direction == DIRECTION_NEXT || direction == DIRECTION_FINISH); >+ this.direction = direction; >+ 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 IPageChangingProvider getPageChangingProvider() { >+ return (IPageChangingProvider) getSource(); >+ } >+ >+ /** >+ * Returns a integer constant describing the direction of the page >+ * change request. >+ * >+ * @return DIRECTION_BACK,DIRECTION_NEXT,DIRECTION_FINISH >+ */ >+ public int getDirection() { >+ return direction; >+ } >+ >+}
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