diff options
author | Matthew Hall | 2009-05-09 05:20:15 +0000 |
---|---|---|
committer | Matthew Hall | 2009-05-09 05:20:15 +0000 |
commit | 1f51825eb86ef843be1b3acb1b7e84e6dbd58e73 (patch) | |
tree | b28ee39bd9232c21387322aa055bf12eae85db54 | |
parent | b8815dd8dcadfa39dc7782385f47607e190f4f40 (diff) | |
download | org.eclipse.e4.databinding-1f51825eb86ef843be1b3acb1b7e84e6dbd58e73.tar.gz org.eclipse.e4.databinding-1f51825eb86ef843be1b3acb1b7e84e6dbd58e73.tar.xz org.eclipse.e4.databinding-1f51825eb86ef843be1b3acb1b7e84e6dbd58e73.zip |
FIXED - bug 275058: [DataBinding] TitleAreaDialogSupport results in a NPE when a TabFolder is included in the dialog
https://bugs.eclipse.org/bugs/show_bug.cgi?id=275058
2 files changed, 27 insertions, 8 deletions
diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/dialog/DialogPageSupport.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/dialog/DialogPageSupport.java index e7e35e9f..56d5b4db 100644 --- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/dialog/DialogPageSupport.java +++ b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/dialog/DialogPageSupport.java @@ -9,7 +9,7 @@ * IBM Corporation - initial API and implementation * (through WizardPageSupport.java) * Matthew Hall - initial API and implementation (bug 239900) - * Matthew Hall - bug 237856 + * Matthew Hall - bugs 237856, 275058 * Ovidio Mallo - bug 237856 ******************************************************************************/ @@ -40,6 +40,9 @@ import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.DialogPage; import org.eclipse.jface.dialogs.IMessageProvider; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; /** * Connects the validation result from the given data binding context to the @@ -55,13 +58,13 @@ public class DialogPageSupport { * away. Upon any validation result change, the dialog page's error message * will be updated according to the current validation result. * - * @param wizardPage + * @param dialogPage * @param dbc * @return an instance of WizardPageSupport */ - public static DialogPageSupport create(DialogPage wizardPage, + public static DialogPageSupport create(DialogPage dialogPage, DataBindingContext dbc) { - return new DialogPageSupport(wizardPage, dbc); + return new DialogPageSupport(dialogPage, dbc); } private DialogPage dialogPage; @@ -152,6 +155,11 @@ public class DialogPageSupport { handleStatusChanged(); } }); + dialogPage.getShell().addListener(SWT.Dispose, new Listener() { + public void handleEvent(Event event) { + dispose(); + } + }); aggregateStatus.addStaleListener(new IStaleListener() { public void handleStale(StaleEvent staleEvent) { currentStatusStale = true; @@ -296,8 +304,9 @@ public class DialogPageSupport { * may have attached. */ public void dispose() { - aggregateStatus.dispose(); - if (!uiChanged) { + if (aggregateStatus != null) + aggregateStatus.dispose(); + if (dbc != null && !uiChanged) { for (Iterator it = dbc.getValidationStatusProviders().iterator(); it .hasNext();) { ValidationStatusProvider validationStatusProvider = (ValidationStatusProvider) it diff --git a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/dialog/TitleAreaDialogSupport.java b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/dialog/TitleAreaDialogSupport.java index bfa77c01..3bdb34c0 100644 --- a/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/dialog/TitleAreaDialogSupport.java +++ b/bundles/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/dialog/TitleAreaDialogSupport.java @@ -10,6 +10,8 @@ * (through WizardPageSupport.java) * Matthew Hall - initial API and implementation (bug 239900) * Ben Vitale <bvitale3002@yahoo.com> - bug 263100 + * Kai Schlamp - bug 275058 + * Matthew Hall - bug 275058 ******************************************************************************/ package org.eclipse.jface.databinding.dialog; @@ -37,6 +39,8 @@ import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.dialogs.IMessageProvider; import org.eclipse.jface.dialogs.TitleAreaDialog; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; /** * Connects the validation result from the given data binding context to the @@ -134,6 +138,11 @@ public class TitleAreaDialogSupport { handleStatusChanged(); } }); + dialog.getShell().addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent e) { + dispose(); + } + }); currentStatus = (IStatus) aggregateStatus.getValue(); handleStatusChanged(); dbc.getValidationStatusProviders().addListChangeListener( @@ -268,8 +277,9 @@ public class TitleAreaDialogSupport { * it may have attached. */ public void dispose() { - aggregateStatus.dispose(); - if (!uiChanged) { + if (aggregateStatus != null) + aggregateStatus.dispose(); + if (dbc != null && !uiChanged) { for (Iterator it = dbc.getValidationStatusProviders().iterator(); it .hasNext();) { ValidationStatusProvider validationStatusProvider = (ValidationStatusProvider) it |