|
From: Peter De B. (JIRA) <no...@at...> - 2005-10-18 06:45:08
|
[ http://opensource.atlassian.com/projects/spring/browse/RCP-215?page=all ] Peter De Bruycker updated RCP-215: ---------------------------------- Attachment: rcp-215.patch.txt I investigated the problem, and I propose another fix: if the component passed to the ColorChanger is disabled, first enable it, get the background color, then disable it again. Another thing that changes is that if a field is disabled, it no longer gets it background painted in the error color private class ColorChanger implements Guarded { private Color normalColor; private JComponent component; private Guarded componentGuard; public ColorChanger(JComponent component) { componentGuard = GuardedGroup.createGuardedAdapter(component); if (!componentGuard.isEnabled()) { componentGuard.setEnabled(true); this.normalColor = component.getBackground(); componentGuard.setEnabled(false); } else { this.normalColor = component.getBackground(); } this.component = component; } public boolean isEnabled() { return false; } public void setEnabled(boolean enabled) { if (componentGuard.isEnabled()) { component.setBackground(enabled ? normalColor : errorColor); } } } > ColorValidationInterceptorFactory.ColorChanger does not respond to changing component background > ------------------------------------------------------------------------------------------------ > > Key: RCP-215 > URL: http://opensource.atlassian.com/projects/spring/browse/RCP-215 > Project: Spring Framework Rich Client Project > Type: Bug > Components: Binding System > Versions: PR1 > Reporter: Scott Russell > Assignee: Peter De Bruycker > Priority: Minor > Attachments: ColorValidationInterceptorFactory.patch, rcp-215.patch.txt > > ColorValidationInterceptorFactory.ColorChanger stores the JComponent background color upon creation, then uses this color to reset component background to if no errors exist. However, in some circumstances the component might change its background color during form interaction (eg. a JTextField starts off non-editable (bg: grey) when first bound, then changes to editable (bg: white) upon a button click). > a suitable fix would be to replace ColorChanger as follows: > private class ColorChanger implements Guarded { > private Color normalColor; > private boolean enabled = false; > private JComponent component; > public ColorChanger(JComponent component) { > this.component = component; > normalColor = component.getBackground(); > } > public boolean isEnabled() { > return enabled; > } > public void setEnabled(boolean enabled) { > if (enabled == this.enabled) > return; > > this.enabled = enabled; > > if (enabled){ > component.setBackground(normalColor); > } > else { > normalColor = component.getBackground(); > component.setBackground(errorColor); > } > } > } > -Scott -- This message is automatically generated by JIRA. - If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/spring/secure/Administrators.jspa - For more information on JIRA, see: http://www.atlassian.com/software/jira |