MultiViewCloneableEditor save hook
"Yann Dameron" <[email protected]> Wed, 28 Sep 2016 10:32:31 +0000
| Newsgroups | gmane.comp.java.netbeans.devel |
|---|---|
| Message-ID | <[email protected]> |
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