NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

MultiViewCloneableEditor save hook

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Developers
View previous topic :: View next topic  
Author Message
Yann Dameron



Joined: 12 Mar 2010
Posts: 11

PostPosted: Wed Sep 28, 2016 10:32 am    Post subject: MultiViewCloneableEditor save hook Reply with quote

Hi guys,

Looking at the source code of the MultiViewCloneableEditor.canCloseElement(), I found a potential bug for which I'd like to get your inputs.

Current source code:
Code:
        Savable sav = getLookup().lookup(Savable.class);
        if (sav != null) {
            AbstractAction save = new AbstractAction() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        sup.saveDocument();
                    } catch (IOException ex) {
                        Exceptions.printStackTrace(ex);
                    }
                }
            };


We retrieve the Savable object from the Lookup but we don't use it to perform the save. This looks weird and could lead to some unexpected behaviour.
In my application, the Savable object retrieved by the lookup is performing more checks than the saveDocument but it is not triggered when the User close the editor with pending changes.

I'd like to submit the following patch but I'd like to be sure I understood correctly.

Code:
        final Savable sav = getLookup().lookup(Savable.class);
        if (sav != null) {
            AbstractAction save = new AbstractAction() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    try {
                        sav.sav();
                    } catch (IOException ex) {
                        Exceptions.printStackTrace(ex);
                    }
                }
            };


Regards,
Yann
Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Developers All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo