- binary field editor not working
This commit is contained in:
Heng Sin Low 2009-08-10 05:05:32 +00:00
parent 62bcdf7b62
commit 0880878b70
2 changed files with 20 additions and 10 deletions

View File

@ -15,6 +15,7 @@ package org.adempiere.webui.editor;
import org.adempiere.webui.component.Button; import org.adempiere.webui.component.Button;
import org.adempiere.webui.event.ValueChangeEvent;
import org.adempiere.webui.window.WMediaDialog; import org.adempiere.webui.window.WMediaDialog;
import org.compiere.model.GridField; import org.compiere.model.GridField;
import org.compiere.util.CLogger; import org.compiere.util.CLogger;
@ -125,7 +126,19 @@ public class WBinaryEditor extends WEditor
{ {
WMediaDialog dialog = new WMediaDialog(gridField.getHeader(), m_data); WMediaDialog dialog = new WMediaDialog(gridField.getHeader(), m_data);
if (!dialog.isCancel() && dialog.isChange()) if (!dialog.isCancel() && dialog.isChange())
m_data = dialog.getData(); {
Object oldValue = m_data;
Object newValue = dialog.getData();
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
return;
}
if (oldValue == null && newValue == null) {
return;
}
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newValue);
super.fireValueChange(changeEvent);
setValue(newValue);
}
} }
} }
} }

View File

@ -16,7 +16,6 @@
package org.adempiere.webui.window; package org.adempiere.webui.window;
import java.awt.Dimension;
import java.sql.Blob; import java.sql.Blob;
import java.sql.Clob; import java.sql.Clob;
import java.sql.SQLException; import java.sql.SQLException;
@ -95,6 +94,8 @@ public class WMediaDialog extends Window implements EventListener
try try
{ {
staticInit(); staticInit();
m_data = data;
displayData();
} }
catch (Exception ex) catch (Exception ex)
{ {
@ -150,15 +151,15 @@ public class WMediaDialog extends Window implements EventListener
bSave.setEnabled(false); bSave.setEnabled(false);
bSave.setSrc("/images/Export24.png"); bSave.setImage("/images/Export24.png");
bSave.setTooltiptext(Msg.getMsg(Env.getCtx(), "AttachmentSave")); bSave.setTooltiptext(Msg.getMsg(Env.getCtx(), "AttachmentSave"));
bSave.addEventListener(Events.ON_CLICK, this); bSave.addEventListener(Events.ON_CLICK, this);
bLoad.setSrc("/images/Import24.png"); bLoad.setImage("/images/Import24.png");
bLoad.setTooltiptext(Msg.getMsg(Env.getCtx(), "Load")); bLoad.setTooltiptext(Msg.getMsg(Env.getCtx(), "Load"));
bLoad.addEventListener(Events.ON_CLICK, this); bLoad.addEventListener(Events.ON_CLICK, this);
bDelete.setSrc("/images/Delete24.png"); bDelete.setImage("/images/Delete24.png");
bDelete.setTooltiptext(Msg.getMsg(Env.getCtx(), "Delete")); bDelete.setTooltiptext(Msg.getMsg(Env.getCtx(), "Delete"));
bDelete.addEventListener(Events.ON_CLICK, this); bDelete.addEventListener(Events.ON_CLICK, this);
@ -210,8 +211,6 @@ public class WMediaDialog extends Window implements EventListener
bDelete.setEnabled(false); bDelete.setEnabled(false);
bSave.setEnabled(false); bSave.setEnabled(false);
Dimension size = null;
if (m_data != null) if (m_data != null)
{ {
bSave.setEnabled(true); bSave.setEnabled(true);
@ -236,12 +235,10 @@ public class WMediaDialog extends Window implements EventListener
String contentType = null; String contentType = null;
if (m_data instanceof byte[]) if (m_data instanceof byte[])
{ {
contentType = "application/octet-stream";
media = new AMedia(this.getTitle(), null, contentType, (byte[])m_data); media = new AMedia(this.getTitle(), null, contentType, (byte[])m_data);
} }
else if (m_data instanceof Blob) else if (m_data instanceof Blob)
{ {
contentType = "application/octet-stream";
media = new AMedia(this.getTitle(), null, contentType, ((Blob)m_data).getBinaryStream()); media = new AMedia(this.getTitle(), null, contentType, ((Blob)m_data).getBinaryStream());
} }
else if (m_data instanceof Clob) else if (m_data instanceof Clob)
@ -331,7 +328,6 @@ public class WMediaDialog extends Window implements EventListener
} }
catch (InterruptedException e) catch (InterruptedException e)
{ {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
@ -340,6 +336,7 @@ public class WMediaDialog extends Window implements EventListener
//update //update
m_change = true; m_change = true;
m_data = media.getByteData(); m_data = media.getByteData();
displayData();
} // getFileName } // getFileName