- image field editor dialog throw npe when user want to reset
This commit is contained in:
Heng Sin Low 2009-08-10 06:01:38 +00:00
parent 0880878b70
commit c1b8fd3f32
1 changed files with 12 additions and 6 deletions

View File

@ -90,7 +90,6 @@ public class WImageDialog extends Window implements EventListener
} }
fileButton.setLabel(m_mImage.getName()); fileButton.setLabel(m_mImage.getName());
// imageLabel.setIcon(m_mImage.getIcon());
AEnv.showCenterScreen(this); AEnv.showCenterScreen(this);
} // WImageDialog } // WImageDialog
@ -157,10 +156,16 @@ public class WImageDialog extends Window implements EventListener
else if (e.getTarget().getId().equals(ConfirmPanel.A_OK)) else if (e.getTarget().getId().equals(ConfirmPanel.A_OK))
{ {
if (m_mImage.save()) if (image.getContent() != null)
{
m_mImage.saveEx();
}
else if (m_mImage != null && m_mImage.getAD_Image_ID() > 0)
{
m_mImage.deleteEx(true);
m_mImage = null;
}
detach(); detach();
else
FDialog.error(-1, "Failed to save image");
} }
else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL)) else if (e.getTarget().getId().equals(ConfirmPanel.A_CANCEL))
{ {
@ -169,7 +174,6 @@ public class WImageDialog extends Window implements EventListener
} }
else if (e.getTarget().getId().equals(ConfirmPanel.A_RESET)) else if (e.getTarget().getId().equals(ConfirmPanel.A_RESET))
{ {
m_mImage = null;
AImage img = null; AImage img = null;
image.setContent(img); image.setContent(img);
} }
@ -226,6 +230,8 @@ public class WImageDialog extends Window implements EventListener
invalidate(); invalidate();
// Save info // Save info
if (m_mImage == null)
m_mImage = MImage.get (Env.getCtx(), 0);
m_mImage.setName(fileName); m_mImage.setName(fileName);
m_mImage.setImageURL(fileName); m_mImage.setImageURL(fileName);
if (image.getContent() != null) if (image.getContent() != null)