IDEMPIERE-618 Zk: Binary editor not working.
This commit is contained in:
parent
c0870adfa9
commit
c621ead859
|
@ -14,12 +14,18 @@
|
|||
package org.adempiere.webui.editor;
|
||||
|
||||
|
||||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.adwindow.ADWindow;
|
||||
import org.adempiere.webui.adwindow.ADWindowContent;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.event.DialogEvents;
|
||||
import org.adempiere.webui.event.ValueChangeEvent;
|
||||
import org.adempiere.webui.window.WMediaDialog;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
|
||||
/**
|
||||
|
@ -34,6 +40,8 @@ public class WBinaryEditor extends WEditor
|
|||
|
||||
private boolean m_mandatory;
|
||||
private Object m_data;
|
||||
|
||||
private ADWindow adwindow;
|
||||
|
||||
public WBinaryEditor(GridField gridField)
|
||||
{
|
||||
|
@ -124,20 +132,40 @@ public class WBinaryEditor extends WEditor
|
|||
{
|
||||
if (Events.ON_CLICK.equals(event.getName()))
|
||||
{
|
||||
WMediaDialog dialog = new WMediaDialog(gridField.getHeader(), m_data);
|
||||
if (!dialog.isCancel() && dialog.isChange())
|
||||
{
|
||||
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);
|
||||
final WMediaDialog dialog = new WMediaDialog(gridField.getHeader(), m_data);
|
||||
dialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
if (adwindow != null)
|
||||
{
|
||||
adwindow.getADWindowContent().hideBusyMask();
|
||||
adwindow = null;
|
||||
}
|
||||
if (!dialog.isCancel() && dialog.isChange())
|
||||
{
|
||||
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(WBinaryEditor.this, getColumnName(), oldValue, newValue);
|
||||
fireValueChange(changeEvent);
|
||||
setValue(newValue);
|
||||
}
|
||||
}
|
||||
});
|
||||
adwindow = ADWindow.findADWindow(getComponent());
|
||||
if (adwindow != null) {
|
||||
ADWindowContent content = adwindow.getADWindowContent();
|
||||
content.showBusyMask();
|
||||
content.getComponent().getParent().appendChild(dialog);
|
||||
LayoutUtils.openOverlappedWindow(content.getComponent().getParent(), dialog, "middle_center");
|
||||
} else {
|
||||
AEnv.showWindow(dialog);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,11 +21,10 @@ import java.sql.Clob;
|
|||
import java.sql.SQLException;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.AdempiereWebUI;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.Panel;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.component.ZkCssHelper;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Msg;
|
||||
|
@ -40,7 +39,6 @@ import org.zkoss.zul.Center;
|
|||
import org.zkoss.zul.North;
|
||||
import org.zkoss.zul.South;
|
||||
import org.zkoss.zul.Filedownload;
|
||||
import org.zkoss.zul.Fileupload;
|
||||
import org.zkoss.zul.Hbox;
|
||||
import org.zkoss.zul.Iframe;
|
||||
|
||||
|
@ -102,14 +100,6 @@ public class WMediaDialog extends Window implements EventListener<Event>
|
|||
catch (Exception ex)
|
||||
{
|
||||
log.log(Level.SEVERE, "", ex);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
AEnv.showWindow(this);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
} // WAttachment
|
||||
|
||||
|
@ -132,7 +122,7 @@ public class WMediaDialog extends Window implements EventListener<Event>
|
|||
void staticInit() throws Exception
|
||||
{
|
||||
this.setWidth("500px");
|
||||
this.setHeight("600px");
|
||||
this.setHeight("500px");
|
||||
this.setClosable(true);
|
||||
this.setBorder("normal");
|
||||
this.appendChild(mainPanel);
|
||||
|
@ -159,13 +149,15 @@ public class WMediaDialog extends Window implements EventListener<Event>
|
|||
|
||||
bLoad.setImage("/images/Import24.png");
|
||||
bLoad.setTooltiptext(Msg.getMsg(Env.getCtx(), "Load"));
|
||||
bLoad.addEventListener(Events.ON_CLICK, this);
|
||||
bLoad.addEventListener(Events.ON_UPLOAD, this);
|
||||
bLoad.setUpload("true");
|
||||
|
||||
bDelete.setImage("/images/Delete24.png");
|
||||
bDelete.setTooltiptext(Msg.getMsg(Env.getCtx(), "Delete"));
|
||||
bDelete.addEventListener(Events.ON_CLICK, this);
|
||||
|
||||
previewPanel.appendChild(preview);
|
||||
ZkCssHelper.appendStyle(previewPanel, "margin-top: 10px; margin-bottom: 10px;");
|
||||
preview.setHeight("100%");
|
||||
preview.setWidth("100%");
|
||||
|
||||
|
@ -188,9 +180,7 @@ public class WMediaDialog extends Window implements EventListener<Event>
|
|||
bCancel.addEventListener(Events.ON_CLICK, this);
|
||||
|
||||
confirmPanel.appendChild(bOk);
|
||||
confirmPanel.appendChild(bCancel);
|
||||
|
||||
addEventListener(Events.ON_UPLOAD, this);
|
||||
confirmPanel.appendChild(bCancel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -301,11 +291,6 @@ public class WMediaDialog extends Window implements EventListener<Event>
|
|||
displayData();
|
||||
}
|
||||
|
||||
// Load Attachment
|
||||
|
||||
else if (e.getTarget() == bLoad)
|
||||
loadFile();
|
||||
|
||||
// Open Attachment
|
||||
|
||||
else if (e.getTarget() == bSave)
|
||||
|
@ -319,17 +304,6 @@ public class WMediaDialog extends Window implements EventListener<Event>
|
|||
}
|
||||
} // onEvent
|
||||
|
||||
/**************************************************************************
|
||||
* Load file
|
||||
*/
|
||||
|
||||
private void loadFile()
|
||||
{
|
||||
Media media = Fileupload.get();
|
||||
if (AdempiereWebUI.isEventThreadEnabled())
|
||||
processUploadMedia(media);
|
||||
} // getFileName
|
||||
|
||||
private void processUploadMedia(Media media) {
|
||||
if (media == null)
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue