IDEMPIERE-2596 Lost changes when attachment window is closed / reorganized the if/then/else for readability - helped to discover some dead code
This commit is contained in:
parent
a69b76c40c
commit
d451716524
|
@ -159,6 +159,7 @@ public class WAttachment extends Window implements EventListener<Event>
|
||||||
if (log.isLoggable(Level.CONFIG)) log.config("ID=" + AD_Attachment_ID + ", Table=" + AD_Table_ID + ", Record=" + Record_ID);
|
if (log.isLoggable(Level.CONFIG)) log.config("ID=" + AD_Attachment_ID + ", Table=" + AD_Table_ID + ", Record=" + Record_ID);
|
||||||
|
|
||||||
m_WindowNo = WindowNo;
|
m_WindowNo = WindowNo;
|
||||||
|
this.addEventListener(DialogEvents.ON_WINDOW_CLOSE, this);
|
||||||
if (eventListener != null)
|
if (eventListener != null)
|
||||||
{
|
{
|
||||||
this.addEventListener(DialogEvents.ON_WINDOW_CLOSE, eventListener);
|
this.addEventListener(DialogEvents.ON_WINDOW_CLOSE, eventListener);
|
||||||
|
@ -472,85 +473,52 @@ public class WAttachment extends Window implements EventListener<Event>
|
||||||
public void onEvent(Event e)
|
public void onEvent(Event e)
|
||||||
{
|
{
|
||||||
// Save and Close
|
// Save and Close
|
||||||
|
if (e instanceof UploadEvent) {
|
||||||
if (e instanceof UploadEvent)
|
|
||||||
{
|
|
||||||
preview.setVisible(false);
|
preview.setVisible(false);
|
||||||
UploadEvent ue = (UploadEvent) e;
|
UploadEvent ue = (UploadEvent) e;
|
||||||
processUploadMedia(ue.getMedia());
|
processUploadMedia(ue.getMedia());
|
||||||
}
|
} else if (e.getTarget() == bOk || DialogEvents.ON_WINDOW_CLOSE.equals(e.getName())) {
|
||||||
else if (e.getTarget() == bOk)
|
|
||||||
{
|
|
||||||
String newText = text.getText();
|
String newText = text.getText();
|
||||||
|
|
||||||
if (newText == null)
|
if (newText == null)
|
||||||
newText = "";
|
newText = "";
|
||||||
|
|
||||||
String oldText = m_attachment.getTextMsg();
|
String oldText = m_attachment.getTextMsg();
|
||||||
|
|
||||||
if (oldText == null)
|
if (oldText == null)
|
||||||
oldText = "";
|
oldText = "";
|
||||||
|
|
||||||
if (!m_change)
|
if (!m_change)
|
||||||
m_change = !newText.equals(oldText);
|
m_change = !newText.equals(oldText);
|
||||||
|
|
||||||
if (newText.length() > 0 || m_attachment.getEntryCount() > 0)
|
if (newText.length() > 0 || m_attachment.getEntryCount() > 0) {
|
||||||
{
|
if (m_change) {
|
||||||
if (m_change)
|
|
||||||
{
|
|
||||||
m_attachment.setBinaryData(new byte[0]); // ATTENTION! HEAVY HACK HERE... Else it will not save :(
|
m_attachment.setBinaryData(new byte[0]); // ATTENTION! HEAVY HACK HERE... Else it will not save :(
|
||||||
m_attachment.setTextMsg(text.getText());
|
m_attachment.setTextMsg(text.getText());
|
||||||
m_attachment.saveEx();
|
m_attachment.saveEx();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
m_attachment.delete(true);
|
m_attachment.delete(true);
|
||||||
m_attachment = null;
|
m_attachment = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose();
|
dispose();
|
||||||
}
|
} else if (e.getTarget() == bCancel) {
|
||||||
|
// Cancel
|
||||||
// Cancel
|
|
||||||
|
|
||||||
else if (e.getTarget() == bCancel)
|
|
||||||
{
|
|
||||||
dispose();
|
dispose();
|
||||||
}
|
} else if (e.getTarget() == bDeleteAll) {
|
||||||
|
// Delete Attachment
|
||||||
// Delete Attachment
|
|
||||||
|
|
||||||
else if (e.getTarget() == bDeleteAll)
|
|
||||||
{
|
|
||||||
deleteAttachment();
|
deleteAttachment();
|
||||||
dispose();
|
dispose();
|
||||||
}
|
} else if (e.getTarget() == bDelete) {
|
||||||
|
// Delete individual entry and Return
|
||||||
// Delete individual entry and Return
|
|
||||||
|
|
||||||
else if (e.getTarget() == bDelete)
|
|
||||||
deleteAttachmentEntry();
|
deleteAttachmentEntry();
|
||||||
|
} else if (e.getTarget() == cbContent) {
|
||||||
// Show Data
|
// Show Data
|
||||||
|
|
||||||
else if (e.getTarget() == cbContent)
|
|
||||||
{
|
|
||||||
clearPreview();
|
clearPreview();
|
||||||
autoPreview (cbContent.getSelectedIndex(), false);
|
autoPreview (cbContent.getSelectedIndex(), false);
|
||||||
}
|
} else if (e.getTarget() == bSave) {
|
||||||
|
// Open Attachment
|
||||||
// Open Attachment
|
|
||||||
|
|
||||||
else if (e.getTarget() == bSave)
|
|
||||||
saveAttachmentToFile();
|
saveAttachmentToFile();
|
||||||
|
} else if (e.getTarget() == bRefresh) {
|
||||||
else if (e.getTarget() == bRefresh)
|
|
||||||
displayData(cbContent.getSelectedIndex(), true);
|
displayData(cbContent.getSelectedIndex(), true);
|
||||||
else if (e instanceof UploadEvent)
|
|
||||||
{
|
|
||||||
UploadEvent ue = (UploadEvent) e;
|
|
||||||
processUploadMedia(ue.getMedia());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // onEvent
|
} // onEvent
|
||||||
|
|
Loading…
Reference in New Issue