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 105654 Details for
Bug 237856
[Wizards] [DataBinding] WizardPageSupport class should track the staleness state of relevant observables
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 for the WizardPageSupport part
patch_237856.txt (text/plain), 9.35 KB, created by
Ovidio Mallo
on 2008-06-23 13:58:19 EDT
(
hide
)
Description:
proposed patch for the WizardPageSupport part
Filename:
MIME Type:
Creator:
Ovidio Mallo
Created:
2008-06-23 13:58:19 EDT
Size:
9.35 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface.databinding >Index: src/org/eclipse/jface/databinding/wizard/WizardPageSupport.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/databinding/wizard/WizardPageSupport.java,v >retrieving revision 1.5 >diff -u -r1.5 WizardPageSupport.java >--- src/org/eclipse/jface/databinding/wizard/WizardPageSupport.java 15 May 2008 23:19:43 -0000 1.5 >+++ src/org/eclipse/jface/databinding/wizard/WizardPageSupport.java 23 Jun 2008 17:54:20 -0000 >@@ -10,6 +10,7 @@ > * Boris Bokowski - bug 218269 > * Matthew Hall - bug 218269 > * Ashley Cambrell - bug 199179 >+ * Ovidio Mallo - bug 237856 > *******************************************************************************/ > package org.eclipse.jface.databinding.wizard; > >@@ -21,6 +22,8 @@ > import org.eclipse.core.databinding.observable.ChangeEvent; > import org.eclipse.core.databinding.observable.IChangeListener; > import org.eclipse.core.databinding.observable.IObservable; >+import org.eclipse.core.databinding.observable.IStaleListener; >+import org.eclipse.core.databinding.observable.StaleEvent; > import org.eclipse.core.databinding.observable.list.IListChangeListener; > import org.eclipse.core.databinding.observable.list.IObservableList; > import org.eclipse.core.databinding.observable.list.ListChangeEvent; >@@ -41,6 +44,17 @@ > * given wizard page, updating the wizard page's completion state and its error > * message accordingly. > * >+ * <p> >+ * The completion state of the wizard page will only be set to <code>true</code> >+ * if <i>all</i> of the following conditions are met: >+ * <ul> >+ * <li>The validation result from the data binding context has none of the >+ * severities {@link IStatus#ERROR} or {@link IStatus#CANCEL}.</li> >+ * <li>None of the validation status observables of the data binding context is >+ * stale.</li> >+ * </ul> >+ * </p> >+ * > * @noextend This class is not intended to be subclassed by clients. > * > * @since 1.1 >@@ -137,6 +151,11 @@ > handleStatusChanged(); > } > }); >+ aggregateStatus.addStaleListener(new IStaleListener() { >+ public void handleStale(StaleEvent staleEvent) { >+ handleStatusChanged(); >+ } >+ }); > currentStatus = (IStatus) aggregateStatus.getValue(); > handleStatusChanged(); > dbc.getValidationStatusProviders().addListChangeListener( >@@ -188,7 +207,8 @@ > } else if (currentStatus != null > && currentStatus.getSeverity() != IStatus.OK) { > int severity = currentStatus.getSeverity(); >- wizardPage.setPageComplete((severity & IStatus.CANCEL) != 0); >+ wizardPage.setPageComplete(((severity & IStatus.CANCEL) != 0) >+ && !aggregateStatus.isStale()); > int type; > switch (severity) { > case IStatus.OK: >@@ -213,7 +233,7 @@ > wizardPage.setErrorMessage(null); > wizardPage.setMessage(currentStatus.getMessage(), type); > } else { >- wizardPage.setPageComplete(true); >+ wizardPage.setPageComplete(!aggregateStatus.isStale()); > wizardPage.setMessage(null); > wizardPage.setErrorMessage(null); > } >#P org.eclipse.jface.tests.databinding >Index: src/org/eclipse/jface/tests/databinding/BindingTestSuite.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.tests.databinding/src/org/eclipse/jface/tests/databinding/BindingTestSuite.java,v >retrieving revision 1.84 >diff -u -r1.84 BindingTestSuite.java >--- src/org/eclipse/jface/tests/databinding/BindingTestSuite.java 25 Apr 2008 23:16:36 -0000 1.84 >+++ src/org/eclipse/jface/tests/databinding/BindingTestSuite.java 23 Jun 2008 17:54:22 -0000 >@@ -132,6 +132,7 @@ > import org.eclipse.jface.tests.databinding.viewers.ObservableSetContentProviderTest; > import org.eclipse.jface.tests.databinding.viewers.ObservableSetTreeContentProviderTest; > import org.eclipse.jface.tests.databinding.viewers.ViewersObservablesTest; >+import org.eclipse.jface.tests.databinding.wizard.WizardPageSupportTest; > import org.eclipse.jface.tests.examples.databinding.mask.internal.EditMaskLexerAndTokenTest; > import org.eclipse.jface.tests.examples.databinding.mask.internal.EditMaskParserTest; > import org.eclipse.jface.tests.internal.databinding.swt.ButtonObservableValueTest; >@@ -332,7 +333,10 @@ > addTestSuite(ObservableSetContentProviderTest.class); > addTestSuite(ObservableSetTreeContentProviderTest.class); > addTestSuite(ViewersObservablesTest.class); >- >+ >+ // org.eclipse.jface.tests.databinding.wizard >+ addTestSuite(WizardPageSupportTest.class); >+ > //org.eclipse.jface.tests.example.databinding.mask.internal > addTestSuite(EditMaskLexerAndTokenTest.class); > addTestSuite(EditMaskParserTest.class); >Index: src/org/eclipse/jface/tests/databinding/wizard/WizardPageSupportTest.java >=================================================================== >RCS file: src/org/eclipse/jface/tests/databinding/wizard/WizardPageSupportTest.java >diff -N src/org/eclipse/jface/tests/databinding/wizard/WizardPageSupportTest.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/jface/tests/databinding/wizard/WizardPageSupportTest.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,140 @@ >+/******************************************************************************* >+ * Copyright (c) 2008 Ovidio Mallo 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: >+ * Ovidio Mallo - initial API and implementation (bug 237856) >+ ******************************************************************************/ >+ >+package org.eclipse.jface.tests.databinding.wizard; >+ >+import org.eclipse.core.databinding.DataBindingContext; >+import org.eclipse.core.databinding.ValidationStatusProvider; >+import org.eclipse.core.databinding.observable.Diffs; >+import org.eclipse.core.databinding.observable.ObservableTracker; >+import org.eclipse.core.databinding.observable.Observables; >+import org.eclipse.core.databinding.observable.Realm; >+import org.eclipse.core.databinding.observable.list.IObservableList; >+import org.eclipse.core.databinding.observable.value.AbstractObservableValue; >+import org.eclipse.core.databinding.observable.value.IObservableValue; >+import org.eclipse.core.databinding.validation.ValidationStatus; >+import org.eclipse.core.internal.commands.util.Util; >+import org.eclipse.core.runtime.IStatus; >+import org.eclipse.jface.databinding.wizard.WizardPageSupport; >+import org.eclipse.jface.tests.databinding.AbstractSWTTestCase; >+import org.eclipse.jface.wizard.IWizardPage; >+import org.eclipse.jface.wizard.Wizard; >+import org.eclipse.jface.wizard.WizardDialog; >+import org.eclipse.jface.wizard.WizardPage; >+import org.eclipse.swt.widgets.Composite; >+ >+/** >+ * @since 1.2 >+ */ >+public class WizardPageSupportTest extends AbstractSWTTestCase { >+ >+ public void testPageCompleteOnValidationStaleness() { >+ IWizardPage page = new WizardPage("Page") { >+ public void createControl(Composite parent) { >+ setControl(parent); >+ >+ ValidationObservable validation = new ValidationObservable(); >+ >+ DataBindingContext dbc = new DataBindingContext(); >+ dbc.addValidationStatusProvider(new ValidationProvider( >+ validation)); >+ >+ WizardPageSupport.create(this, dbc); >+ >+ assertTrue(isPageComplete()); >+ >+ validation.setStale(true); >+ assertFalse(isPageComplete()); >+ >+ validation.setStale(false); >+ assertTrue(isPageComplete()); >+ } >+ }; >+ >+ loadWizardPage(page); >+ } >+ >+ private void loadWizardPage(IWizardPage page) { >+ Wizard wizard = new Wizard() { >+ public boolean performFinish() { >+ return true; >+ } >+ }; >+ wizard.addPage(page); >+ >+ WizardDialog dialog = new WizardDialog(getShell(), wizard); >+ dialog.create(); >+ } >+ >+ private static class ValidationObservable extends AbstractObservableValue { >+ >+ private Object value = ValidationStatus.ok(); >+ >+ private boolean stale = false; >+ >+ public ValidationObservable() { >+ super(Realm.getDefault()); >+ } >+ >+ protected Object doGetValue() { >+ return value; >+ } >+ >+ protected void doSetValue(Object value) { >+ Object oldValue = this.value; >+ this.value = value; >+ if (!Util.equals(oldValue, value)) { >+ fireValueChange(Diffs.createValueDiff(oldValue, value)); >+ } >+ } >+ >+ public boolean isStale() { >+ ObservableTracker.getterCalled(this); >+ return stale; >+ } >+ >+ public void setStale(boolean stale) { >+ if (this.stale != stale) { >+ this.stale = stale; >+ if (stale) { >+ fireStale(); >+ } else { >+ fireValueChange(Diffs.createValueDiff(value, value)); >+ } >+ } >+ } >+ >+ public Object getValueType() { >+ return IStatus.class; >+ } >+ } >+ >+ private static class ValidationProvider extends ValidationStatusProvider { >+ >+ private final IObservableValue validation; >+ >+ public ValidationProvider(IObservableValue validation) { >+ this.validation = validation; >+ } >+ >+ public IObservableValue getValidationStatus() { >+ return validation; >+ } >+ >+ public IObservableList getTargets() { >+ return Observables.emptyObservableList(); >+ } >+ >+ public IObservableList getModels() { >+ return Observables.emptyObservableList(); >+ } >+ } >+}
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
Flags:
qualidafial
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 237856
: 105654 |
115962