added null check for attachment entry and move button state management to the auto preview method.
This commit is contained in:
parent
4aef583e4f
commit
8675e83423
|
|
@ -314,6 +314,8 @@ public class WAttachment extends Window implements EventListener
|
||||||
private boolean autoPreview(int index, boolean immediate)
|
private boolean autoPreview(int index, boolean immediate)
|
||||||
{
|
{
|
||||||
MAttachmentEntry entry = m_attachment.getEntry(index);
|
MAttachmentEntry entry = m_attachment.getEntry(index);
|
||||||
|
if (entry != null)
|
||||||
|
{
|
||||||
String mimeType = entry.getContentType();
|
String mimeType = entry.getContentType();
|
||||||
byte[] data = entry.getData();
|
byte[] data = entry.getData();
|
||||||
String unit = " KB";
|
String unit = " KB";
|
||||||
|
|
@ -326,6 +328,10 @@ public class WAttachment extends Window implements EventListener
|
||||||
}
|
}
|
||||||
size = size.setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
size = size.setScale(2, BigDecimal.ROUND_HALF_EVEN);
|
||||||
sizeLabel.setText(size.toPlainString() + unit);
|
sizeLabel.setText(size.toPlainString() + unit);
|
||||||
|
|
||||||
|
bSave.setEnabled(true);
|
||||||
|
bDelete.setEnabled(true);
|
||||||
|
|
||||||
if (autoPreviewList.contains(mimeType))
|
if (autoPreviewList.contains(mimeType))
|
||||||
{
|
{
|
||||||
displayData(index, immediate);
|
displayData(index, immediate);
|
||||||
|
|
@ -336,6 +342,13 @@ public class WAttachment extends Window implements EventListener
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bSave.setEnabled(false);
|
||||||
|
bDelete.setEnabled(false);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display gif or jpg in gifPanel
|
* Display gif or jpg in gifPanel
|
||||||
|
|
@ -347,9 +360,6 @@ public class WAttachment extends Window implements EventListener
|
||||||
// Reset UI
|
// Reset UI
|
||||||
preview.setSrc(null);
|
preview.setSrc(null);
|
||||||
|
|
||||||
bDelete.setEnabled(false);
|
|
||||||
bSave.setEnabled(false);
|
|
||||||
|
|
||||||
displayIndex = index;
|
displayIndex = index;
|
||||||
|
|
||||||
if (immediate)
|
if (immediate)
|
||||||
|
|
@ -372,9 +382,6 @@ public class WAttachment extends Window implements EventListener
|
||||||
log.config("Index=" + displayIndex + " - " + entry);
|
log.config("Index=" + displayIndex + " - " + entry);
|
||||||
if (entry != null && entry.getData() != null)
|
if (entry != null && entry.getData() != null)
|
||||||
{
|
{
|
||||||
bSave.setEnabled(true);
|
|
||||||
bDelete.setEnabled(true);
|
|
||||||
|
|
||||||
log.config(entry.toStringX());
|
log.config(entry.toStringX());
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue