Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 304624

Summary: Text change commands executed without actual edit
Product: [Modeling] EEF Reporter: Miles Parker <milesparker>
Component: GeneralAssignee: EEF Inbox <emft.eef-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: goulwen.lefur, laurent.redor, sbouchet
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Mac OS X   
Whiteboard:
Bug Depends on: 300795    
Bug Blocks: 304768    

Description Miles Parker CLA 2010-03-04 00:53:13 EST
When editing a live generated form, a command is generated on focus lost from Text box. This causes editor to be marked as dirty and for undo not to function correctly. 

I think the reason this is happening is simply that property edition events are being fired when not appropriate. See example code is below. Shouldn't we be checking to see if the label has actually been changed? If possible can you confirm as soon as you get a chance if this looks like its the issue? I might be making an assumption about how this is supposed to be working that isn't correct. Perhaps we're assuming that the command will have no effect if the text hasn't changed? This assumption wouldn't work in my case because the commands have side effects and in any case we still end up with a spurious command on the stack.


        label.addModifyListener(new ModifyListener() {

            /**
             * {@inheritDoc}
             * 
             * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
             */
            public void modifyText(ModifyEvent e) {
                if (propertiesEditionComponent != null) {
                    propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(
                                                                                                SContextPropertiesEditionPartForm.this, MetaabmViewsRepository.SContext.label,
                                                                                                PropertiesEditionEvent.CHANGE, PropertiesEditionEvent.SET, null, label.getText()));
                }
            }

        });
        label.addFocusListener(new FocusAdapter() {

            /**
             * {@inheritDoc}
             * 
             * @see org.eclipse.swt.events.FocusAdapter#focusLost(org.eclipse.swt.events.FocusEvent)
             */
            public void focusLost(FocusEvent e) {
                if (propertiesEditionComponent != null) {
                    propertiesEditionComponent.firePropertiesChanged(new PropertiesEditionEvent(
                                                                                                SContextPropertiesEditionPartForm.this, MetaabmViewsRepository.SContext.label,
                                                                                                PropertiesEditionEvent.COMMIT, PropertiesEditionEvent.SET, null, label.getText()));
                }
            }

        });
Comment 1 Bouchet Stéphane CLA 2010-03-04 11:56:29 EST
You are right, we may check if the contents are actually modified on focusLost before commiting any commansds from this event.
Comment 2 Laurent Redor CLA 2010-06-11 03:40:06 EDT
Another use case for this bug : 
 - Use the Worldcupforecast Application : http://eef-modeling.blogspot.com/2010/06/share-worldcup-experience-with-eclipse.html
 - Go to a forecast field
 - Type 3
 - Type Ctrl+S (to save the file)
 - The editor stays in dirty mode (with an *)
 - Select another match
 - Go to a forecast field (and type nothing) 
 - Type Ctrl+S (to save the file)
 - The editor stays in dirty mode (with an *)

The only way to exit the "dirty mode" is to select a match and type Ctrl+S. We should not be in a field.

Laurent
Comment 3 Goulwen Le Fur CLA 2013-05-24 04:08:04 EDT
FIXED: in EEF 1.2 with CDO compatibility works