Summary: | [DataBinding] ControlDecorationSupport should hide validation errors initially | ||||||
---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] Platform | Reporter: | Philipp Kursawe <phil.kursawe> | ||||
Component: | UI | Assignee: | Platform UI Triaged <platform-ui-triaged> | ||||
Status: | NEW --- | QA Contact: | |||||
Severity: | enhancement | ||||||
Priority: | P3 | CC: | bokowski, contact, fg, qualidafial | ||||
Version: | 3.5 | ||||||
Target Milestone: | --- | ||||||
Hardware: | PC | ||||||
OS: | All | ||||||
Whiteboard: | |||||||
Attachments: |
|
Description
Philipp Kursawe
2009-07-23 04:46:54 EDT
Created attachment 142429 [details]
Patch
Philipp, would you apply this patch and try it out? Try using ControlDecorationUpdater.required() for your updater and tell me how it works for you.
Matthew
Thats for the quick reaction Matthew. However I am not sure how to use the ControlDecoratorUpdater. I have never used it. The problem I described in that bug is a little different I guess. I am creating the "required" control decorations myself. label = toolkit.createLabel(parent, "Name" + ":"); //$NON-NLS-2$ GridDataFactory.swtDefaults().align(SWT.END, SWT.CENTER).applyTo(label); this.nameText = toolkit.createText(parent, null, SWT.NULL); GridDataFactory.swtDefaults().hint(200, SWT.DEFAULT).applyTo(this.nameText); decoration = new ControlDecoration(this.nameText, SWT.TOP | SWT.RIGHT); decoration.setImage(FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_REQUIRED).getImage()); decoration.show(); Then I have a managed form with its IMessageManager that I use to update the validation status. My Databinding validator calls the this.messageManager.addMessage(this, status.getMessage(), value, IMessageProvider.ERROR, this.control); in case of an error. This happens right after opening the dialog (when the model is written to the target, which it should not really do). My databinding goes like this: observeValue = BeansObservables.observeValue(input, "name"); //$NON-NLS-1$ observeValue.addChangeListener(new IChangeListener() { public void handleChange(final ChangeEvent arg0) { markDirty(); } }); observeText = SWTObservables.observeText(this.nameText, SWT.Modify); getDataBindingContext().bindValue( observeText, observeValue, new UpdateValueStrategy().setBeforeSetValidator(new RegexStringValidator( "^([^ ]+) ([^ ]+( [^ ]+)*)", "Please enter first and last name.", new FormWizardPageValidationHandler(this.page, this.nameText))), null); The class FormWizardPageValidationHandler updates the IMessageManager as described above. So I have successfully applied your patch but do not know how to use it in my situation. Any further instructions? Adapting your example above: ControlDecorationUpdater updater = ControlDecorationUpdater.required(); Binding binding = getDataBindingContext().bindValue( observeText, observeValue, new UpdateValueStrategy().setBeforeSetValidator(new RegexStringValidator( "^([^ ]+) ([^ ]+( [^ ]+)*)", "Please enter first and last name.", new FormWizardPageValidationHandler(this.page, this.nameText))), null); ControlDecorationSupport.create(binding, SWT.LEFT | SWT.TOP, null, updater); ControlDecorationSupport is intended to completely manage the creation, updating and disposal of ControlDecorations for your widgets. See Snippet033CrossValidationControlDecoration.java in the examples project for an example. Thanks for the patch. It is working as expected! I will now re-model my IManagedForm based validation framework too. How would I use the required decoration and have it not track any errors, as I am doing that already in the IManagedForms message manager, and it decorates controls too. So that would then be 2 decorations for one control in case of an error. Removed from 3.6. Owners can re-assess. PW This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant. |