IDEMPIERE-2596 Lost changes when attachment window is closed / avoid NPE and duplicated process of changes

This commit is contained in:
Carlos Ruiz 2015-05-13 18:47:50 -05:00
parent ffd2288dfd
commit 15a7173e64
1 changed files with 21 additions and 18 deletions

View File

@ -478,6 +478,7 @@ public class WAttachment extends Window implements EventListener<Event>
UploadEvent ue = (UploadEvent) e;
processUploadMedia(ue.getMedia());
} else if (e.getTarget() == bOk || DialogEvents.ON_WINDOW_CLOSE.equals(e.getName())) {
if (m_attachment != null) {
String newText = text.getText();
if (newText == null)
newText = "";
@ -493,6 +494,7 @@ public class WAttachment extends Window implements EventListener<Event>
m_attachment.setBinaryData(new byte[0]); // ATTENTION! HEAVY HACK HERE... Else it will not save :(
m_attachment.setTextMsg(text.getText());
m_attachment.saveEx();
m_change = false;
}
} else {
m_attachment.delete(true);
@ -500,6 +502,7 @@ public class WAttachment extends Window implements EventListener<Event>
}
dispose();
}
} else if (e.getTarget() == bCancel) {
// Cancel
dispose();