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 161226 Details for
Bug 304890
[Forms] FormEditor.getCurrentPage() doesn't work as explained in JavaDoc
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Proposed patch that returns the IPageChangeProvider implementation in FormEditor
Bug-304890.patch (text/plain), 9.32 KB, created by
Ivan Furnadjiev
on 2010-03-06 13:04:33 EST
(
hide
)
Description:
Proposed patch that returns the IPageChangeProvider implementation in FormEditor
Filename:
MIME Type:
Creator:
Ivan Furnadjiev
Created:
2010-03-06 13:04:33 EST
Size:
9.32 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rap.ui.forms >Index: src/org/eclipse/ui/forms/editor/FormEditor.java >=================================================================== >RCS file: /cvsroot/rt/org.eclipse.rap/runtime.ui/org.eclipse.rap.ui.forms/src/org/eclipse/ui/forms/editor/FormEditor.java,v >retrieving revision 1.2 >diff -u -r1.2 FormEditor.java >--- src/org/eclipse/ui/forms/editor/FormEditor.java 28 Feb 2010 11:19:44 -0000 1.2 >+++ src/org/eclipse/ui/forms/editor/FormEditor.java 6 Mar 2010 17:59:24 -0000 >@@ -12,6 +12,12 @@ > > import java.util.Vector; > >+import org.eclipse.core.runtime.ListenerList; >+import org.eclipse.jface.dialogs.IPageChangeProvider; >+import org.eclipse.jface.dialogs.IPageChangedListener; >+import org.eclipse.jface.dialogs.PageChangedEvent; >+import org.eclipse.jface.util.SafeRunnable; >+ > import org.eclipse.jface.viewers.ISelection; > import org.eclipse.jface.viewers.ISelectionProvider; > import org.eclipse.jface.viewers.SelectionChangedEvent; >@@ -50,10 +56,15 @@ > * FormEditor is a page change provider. It allows listeners to attach to it and > * get notified when pages are changed. This new API in JFace allows dynamic > * help to update on page changes. >- * >+ * > * @since 1.0 > */ >-public abstract class FormEditor extends MultiPageEditorPart { >+// RAP [if] As RAP is still using workbench 3.4 the implementation of >+// IPageChangeProvider is missing from MultiPageEditorPart. Remove this code >+// with the adoption of workbench > 3.5 >+//public abstract class FormEditor extends MultiPageEditorPart { >+public abstract class FormEditor extends MultiPageEditorPart implements >+ IPageChangeProvider { > > /** > * An array of pages currently in the editor. Page objects are not limited >@@ -131,7 +142,7 @@ > > /** > * Creates the common toolkit for this editor and adds pages to the editor. >- * >+ * > * @see #addPages > */ > protected void createPages() { >@@ -153,7 +164,7 @@ > * use of this method would be to create the form toolkit using one shared > * <code>FormColors</code> object to share resources across the multiple > * editor instances. >- * >+ * > * @param display > * the display to use when creating the toolkit > * @return the newly created toolkit instance >@@ -170,7 +181,7 @@ > > /* > * (non-Javadoc) >- * >+ * > * @see org.eclipse.jface.dialogs.IPageChangeProvider#getSelectedPage() > */ > public Object getSelectedPage() { >@@ -181,7 +192,7 @@ > * Adds the form page to this editor. Form page will be loaded lazily. Its > * part control will not be created until it is activated for the first > * time. >- * >+ * > * @param page > * the form page to add > */ >@@ -195,7 +206,7 @@ > * Adds the form page to this editor at the specified index (0-based). Form > * page will be loaded lazily. Its part control will not be created until it > * is activated for the first time. >- * >+ * > * @param index > * the position to add the page at (0-based) > * @param page >@@ -210,7 +221,7 @@ > /** > * Adds a simple SWT control as a page. Overrides superclass implementation > * to keep track of pages. >- * >+ * > * @param control > * the page control to add > * @return the 0-based index of the newly added page >@@ -228,7 +239,7 @@ > /** > * Adds a simple SWT control as a page. Overrides superclass implementation > * to keep track of pages. >- * >+ * > * @param control > * the page control to add > * @param index >@@ -248,7 +259,7 @@ > * Tests whether the editor is dirty by checking all the pages that > * implement <code>IFormPage</code>. If none of them is dirty, the method > * delegates further processing to <code>super.isDirty()</code>. >- * >+ * > * @return <code>true</code> if any of the pages in the editor are dirty, > * <code>false</code> otherwise. > */ >@@ -261,18 +272,18 @@ > IFormPage fpage = (IFormPage) page; > if (fpage.isDirty()) > return true; >- >+ > } else if (page instanceof IEditorPart) { > IEditorPart editor = (IEditorPart) page; > if (editor.isDirty()) { > return true; >- } >+ } > } > } > } > return super.isDirty(); > } >- >+ > /** > * Commits all dirty pages in the editor. This method should > * be called as a first step of a 'save' operation. >@@ -291,12 +302,12 @@ > mform.commit(onSave); > } > } >- } >+ } > } > > /** > * Adds a complete editor part to the multi-page editor. >- * >+ * > * @see MultiPageEditorPart#addPage(IEditorPart, IEditorInput) > */ > public int addPage(IEditorPart editor, IEditorInput input) >@@ -312,7 +323,7 @@ > /** > * Adds a complete editor part to the multi-page editor at the specified > * position. >- * >+ * > * @see MultiPageEditorPart#addPage(int, IEditorPart, IEditorInput) > */ > public void addPage(int index, IEditorPart editor, IEditorInput input) >@@ -322,12 +333,12 @@ > configurePage(index, (IFormPage) editor); > else > registerPage(index, editor); >- updatePageIndices(index+1); >+ updatePageIndices(index+1); > } > > /** > * Configures the form page. >- * >+ * > * @param index > * the page index > * @param page >@@ -345,7 +356,7 @@ > > /** > * Overrides the superclass to remove the page from the page table. >- * >+ * > * @param pageIndex > * the 0-based index of the page in the editor > */ >@@ -409,7 +420,7 @@ > > /** > * Returns the toolkit owned by this editor. >- * >+ * > * @return the toolkit object > */ > public FormToolkit getToolkit() { >@@ -418,7 +429,7 @@ > > /** > * Widens the visibility of the method in the superclass. >- * >+ * > * @return the active nested editor > */ > public IEditorPart getActiveEditor() { >@@ -433,7 +444,7 @@ > * Another important difference is during the editor closing. When the tab > * folder is disposed, 'getActivePage()' will return -1, while this method > * will still return the last active page. >- * >+ * > * @see #getActivePage > * @return the currently selected page or -1 if no page is currently > * selected >@@ -480,17 +491,24 @@ > && pages.get(newPageIndex) instanceof IFormPage) > ((IFormPage) pages.get(newPageIndex)).setActive(true); > if (oldPageIndex != -1 && pages.size() > oldPageIndex >- && newPageIndex != oldPageIndex && >+ && newPageIndex != oldPageIndex && > pages.get(oldPageIndex) instanceof IFormPage) > ((IFormPage) pages.get(oldPageIndex)).setActive(false); > // Call super - this will cause pages to switch > super.pageChange(newPageIndex); >+// RAP [if] As RAP is still using workbench 3.4 the implementation of >+// IPageChangeProvider is missing from MultiPageEditorPart. Remove this code >+// with the adoption of workbench > 3.5 >+ IFormPage newPage = getActivePageInstance(); >+ if (newPage != null) >+ firePageChanged(new PageChangedEvent(this, newPage)); >+// RAPEND [if] > this.currentPage = newPageIndex; > } > > /** > * Sets the active page using the unique page identifier. >- * >+ * > * @param pageId > * the id of the page to switch to > * @return page that was set active or <samp>null </samp> if not found. >@@ -511,7 +529,7 @@ > > /** > * Finds the page instance that has the provided id. >- * >+ * > * @param pageId > * the id of the page to find > * @return page with the matching id or <code>null</code> if not found. >@@ -531,7 +549,7 @@ > /** > * Sets the active page using the unique page identifier and sets its input > * to the provided object. >- * >+ * > * @param pageId > * the id of the page to switch to > * @param pageInput >@@ -551,7 +569,7 @@ > /** > * Iterates through the pages calling similar method until a page is found > * that contains the desired page input. >- * >+ * > * @param pageInput > * the object to select and reveal > * @return the page that accepted the request or <code>null</code> if no >@@ -573,7 +591,7 @@ > /** > * Returns active page instance if the currently selected page index is not > * -1, or <code>null</code> if it is. >- * >+ * > * @return active page instance if selected, or <code>null</code> if no > * page is currently active. > */ >@@ -605,7 +623,7 @@ > > /** > * Notifies action bar contributor about page change. >- * >+ * > * @param pageIndex > * the index of the new page > */ >@@ -623,7 +641,7 @@ > > /** > * Closes the editor programmatically. >- * >+ * > * @param save > * if <code>true</code>, the content should be saved before > * closing. >@@ -652,4 +670,30 @@ > fpage.init(getEditorSite(), getEditorInput()); > } > } >+ >+// RAP [if] As RAP is still using workbench 3.4 the implementation of >+// IPageChangeProvider is missing from MultiPageEditorPart. Remove this code >+// with the adoption of workbench > 3.5 >+ private ListenerList pageListeners = new ListenerList(); >+ >+ public void addPageChangedListener(IPageChangedListener listener) { >+ pageListeners.add(listener); >+ } >+ >+ public void removePageChangedListener(IPageChangedListener listener) { >+ pageListeners.remove(listener); >+ } >+ >+ private void firePageChanged(final PageChangedEvent event) { >+ Object[] listeners = pageListeners.getListeners(); >+ for (int i = 0; i < listeners.length; ++i) { >+ final IPageChangedListener l = (IPageChangedListener) listeners[i]; >+ SafeRunnable.run(new SafeRunnable() { >+ public void run() { >+ l.pageChanged(event); >+ } >+ }); >+ } >+ } >+// RAPEND [if] > }
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 304890
: 161226