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 142429 Details for
Bug 284384
[DataBinding] ControlDecorationSupport should hide validation errors initially
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch
clipboard.txt (text/plain), 8.81 KB, created by
Matthew Hall
on 2009-07-23 13:49:28 EDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Matthew Hall
Created:
2009-07-23 13:49:28 EDT
Size:
8.81 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jface.examples.databinding >Index: src/org/eclipse/jface/examples/databinding/snippets/Snippet033CrossValidationControlDecoration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet033CrossValidationControlDecoration.java,v >retrieving revision 1.1 >diff -u -r1.1 Snippet033CrossValidationControlDecoration.java >--- src/org/eclipse/jface/examples/databinding/snippets/Snippet033CrossValidationControlDecoration.java 31 Mar 2009 14:58:51 -0000 1.1 >+++ src/org/eclipse/jface/examples/databinding/snippets/Snippet033CrossValidationControlDecoration.java 23 Jul 2009 17:49:57 -0000 >@@ -113,13 +113,13 @@ > > // Customize the decoration's description text and image > ControlDecorationUpdater decorationUpdater = new ControlDecorationUpdater() { >- protected String getDescriptionText(IStatus status) { >- return "ERROR: " + super.getDescriptionText(status); >+ protected String getDescriptionText(IStatus status, boolean init) { >+ return "ERROR: " + super.getDescriptionText(status, init); > } > >- protected Image getImage(IStatus status) { >- return status.isOK() ? null : Display.getCurrent() >- .getSystemImage(SWT.ICON_ERROR); >+ protected Image getImage(IStatus status, boolean init) { >+ return init ? null : status.isOK() ? null : Display >+ .getCurrent().getSystemImage(SWT.ICON_ERROR); > } > }; > ControlDecorationSupport.create(new DateRangeValidator(Observables >#P org.eclipse.jface.databinding >Index: src/org/eclipse/jface/internal/databinding/provisional/fieldassist/ControlDecorationSupport.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/fieldassist/ControlDecorationSupport.java,v >retrieving revision 1.1 >diff -u -r1.1 ControlDecorationSupport.java >--- src/org/eclipse/jface/internal/databinding/provisional/fieldassist/ControlDecorationSupport.java 31 Mar 2009 14:58:53 -0000 1.1 >+++ src/org/eclipse/jface/internal/databinding/provisional/fieldassist/ControlDecorationSupport.java 23 Jul 2009 17:49:58 -0000 >@@ -116,7 +116,7 @@ > > private IValueChangeListener statusChangeListener = new IValueChangeListener() { > public void handleValueChange(ValueChangeEvent event) { >- statusChanged((IStatus) validationStatus.getValue()); >+ statusChanged((IStatus) validationStatus.getValue(), false); > } > }; > >@@ -131,7 +131,7 @@ > targetRemoved((IObservable) element); > } > }); >- statusChanged((IStatus) validationStatus.getValue()); >+ statusChanged((IStatus) validationStatus.getValue(), false); > } > }; > >@@ -171,7 +171,7 @@ > for (Iterator it = targets.iterator(); it.hasNext();) > targetAdded((IObservable) it.next()); > >- statusChanged((IStatus) validationStatus.getValue()); >+ statusChanged((IStatus) validationStatus.getValue(), true); > } > > private void targetAdded(IObservable target) { >@@ -220,11 +220,11 @@ > return null; > } > >- private void statusChanged(IStatus status) { >+ private void statusChanged(IStatus status, boolean init) { > for (Iterator it = targetDecorations.iterator(); it.hasNext();) { > TargetDecoration targetDecoration = (TargetDecoration) it.next(); > ControlDecoration decoration = targetDecoration.decoration; >- updater.update(decoration, status); >+ updater.update(decoration, status, init); > } > } > >Index: src/org/eclipse/jface/internal/databinding/provisional/fieldassist/ControlDecorationUpdater.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jface.databinding/src/org/eclipse/jface/internal/databinding/provisional/fieldassist/ControlDecorationUpdater.java,v >retrieving revision 1.1 >diff -u -r1.1 ControlDecorationUpdater.java >--- src/org/eclipse/jface/internal/databinding/provisional/fieldassist/ControlDecorationUpdater.java 31 Mar 2009 14:58:53 -0000 1.1 >+++ src/org/eclipse/jface/internal/databinding/provisional/fieldassist/ControlDecorationUpdater.java 23 Jul 2009 17:49:58 -0000 >@@ -30,6 +30,24 @@ > public class ControlDecorationUpdater { > /** > * <b>EXPERIMENTAL</b>: This method is not API. It is experimental and >+ * subject to arbitrary change, including removals. Please provide feedback >+ * if you would like to see this become API. >+ * >+ * @return . >+ */ >+ public static ControlDecorationUpdater required() { >+ return new ControlDecorationUpdater() { >+ protected String getFieldDecorationId(IStatus status, boolean init) { >+ String decorationId = super.getFieldDecorationId(status, init); >+ if (decorationId == null || init) >+ return FieldDecorationRegistry.DEC_REQUIRED; >+ return decorationId; >+ } >+ }; >+ } >+ >+ /** >+ * <b>EXPERIMENTAL</b>: This method is not API. It is experimental and > * subject to arbitrary change, including removal. Please provide feedback > * if you would like to see this become API. > * <p> >@@ -40,13 +58,16 @@ > * the ControlDecoration to update > * @param status > * the status to be displayed by the decoration >+ * @param init >+ * whether the decoration is being updated for the first time > */ >- protected void update(ControlDecoration decoration, IStatus status) { >+ protected void update(ControlDecoration decoration, IStatus status, >+ boolean init) { > if (status == null || status.isOK()) { > decoration.hide(); > } else { >- decoration.setImage(getImage(status)); >- decoration.setDescriptionText(getDescriptionText(status)); >+ decoration.setImage(getImage(status, init)); >+ decoration.setDescriptionText(getDescriptionText(status, init)); > decoration.show(); > } > } >@@ -62,10 +83,12 @@ > * > * @param status > * the status object. >+ * @param init >+ * whether the decoration is being updated for the first time > * @return the description text to show in a ControlDecoration for the given > * status. > */ >- protected String getDescriptionText(IStatus status) { >+ protected String getDescriptionText(IStatus status, boolean init) { > return status == null ? "" : status.getMessage(); //$NON-NLS-1$ > } > >@@ -76,25 +99,45 @@ > * <p> > * Returns an image to display in a ControlDecoration which is appropriate > * for the given status. The default implementation of this method returns >- * an image according to <code>status.getSeverity()</code>: >+ * an image according to <code>status.getSeverity()</code> and/or the >+ * <code>init</code> parameter: > * <ul> >- * <li>IStatus.OK => No image >- * <li>IStatus.INFO => FieldDecorationRegistry.DEC_INFORMATION >- * <li>IStatus.WARNING => FieldDecorationRegistry.DEC_WARNING >- * <li>IStatus.ERROR => FieldDecorationRegistry.DEC_ERROR >- * <li>IStatus.CANCEL => FieldDecorationRegistry.DEC_ERROR >+ * <li>severity == IStatus.OK => No image >+ * <li>severity == IStatus.INFO => FieldDecorationRegistry.DEC_INFORMATION >+ * <li>severity == IStatus.WARNING => FieldDecorationRegistry.DEC_WARNING >+ * <li>init == true => No image >+ * <li>severity == IStatus.ERROR => FieldDecorationRegistry.DEC_ERROR >+ * <li>severity == IStatus.CANCEL => FieldDecorationRegistry.DEC_ERROR > * <li>Other => No image > * </ul> > * > * @param status >- * the status object. >+ * the status object (may be null) >+ * @param init >+ * whether the decoration is being updated for the first time > * @return an image to display in a ControlDecoration which is appropriate > * for the given status. > */ >- protected Image getImage(IStatus status) { >+ protected Image getImage(IStatus status, boolean init) { >+ FieldDecoration decoration = FieldDecorationRegistry.getDefault() >+ .getFieldDecoration(getFieldDecorationId(status, init)); >+ return decoration == null ? null : decoration.getImage(); >+ } >+ >+ /** >+ * <b>EXPERIMENTAL</b>: This method is not API. It is experimental and >+ * subject to arbitrary change, including removal. Please provide feedback >+ * if you would like to see this become API. >+ * >+ * @param status >+ * the status object (may be null) >+ * @param init >+ * whether the decoration is being updated for the first time >+ * @return . >+ */ >+ protected String getFieldDecorationId(IStatus status, boolean init) { > if (status == null) > return null; >- > String fieldDecorationID = null; > switch (status.getSeverity()) { > case IStatus.INFO: >@@ -105,12 +148,10 @@ > break; > case IStatus.ERROR: > case IStatus.CANCEL: >- fieldDecorationID = FieldDecorationRegistry.DEC_ERROR; >+ if (!init) >+ fieldDecorationID = FieldDecorationRegistry.DEC_ERROR; > break; > } >- >- FieldDecoration fieldDecoration = FieldDecorationRegistry.getDefault() >- .getFieldDecoration(fieldDecorationID); >- return fieldDecoration == null ? null : fieldDecoration.getImage(); >+ return fieldDecorationID; > } > }
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 284384
: 142429