IDEMPIERE-144 Performance: Remove the use of zk event thread. Drop the use of FileUpload, remove use of Mode_MODAL that have been overlook in previous commit.
This commit is contained in:
parent
7ddd707502
commit
a9ca3fbf24
|
@ -87,7 +87,7 @@ public class WProcessCtl extends AbstractProcessCtl {
|
|||
para.setWidth("500px");
|
||||
para.setVisible(true);
|
||||
para.setPosition("center");
|
||||
para.setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
|
||||
para.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
|
||||
AEnv.showWindow(para);
|
||||
}
|
||||
} // execute
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.compiere.util.Env;
|
|||
import org.compiere.util.Ini;
|
||||
import org.compiere.util.Msg;
|
||||
import org.zkoss.util.media.Media;
|
||||
import org.zkoss.zk.ui.IdSpace;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
|
@ -60,7 +61,6 @@ import org.zkoss.zul.Center;
|
|||
import org.zkoss.zul.North;
|
||||
import org.zkoss.zul.South;
|
||||
import org.zkoss.zul.Div;
|
||||
import org.zkoss.zul.Fileupload;
|
||||
import org.zkoss.zul.Hbox;
|
||||
import org.zkoss.zul.Separator;
|
||||
|
||||
|
@ -118,7 +118,6 @@ public class WFileImport extends ADForm implements EventListener
|
|||
|
||||
public WFileImport()
|
||||
{
|
||||
this.addEventListener(Events.ON_UPLOAD, this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -173,7 +172,8 @@ public class WFileImport extends ADForm implements EventListener
|
|||
|
||||
bFile.setLabel(Msg.getMsg(Env.getCtx(), "FileImportFile"));
|
||||
bFile.setTooltiptext(Msg.getMsg(Env.getCtx(), "FileImportFileInfo"));
|
||||
bFile.addEventListener(Events.ON_CLICK, this);
|
||||
bFile.setUpload("true");
|
||||
bFile.addEventListener(Events.ON_UPLOAD, this);
|
||||
|
||||
fCharset.setMold("select");
|
||||
fCharset.setRows(0);
|
||||
|
@ -275,9 +275,10 @@ public class WFileImport extends ADForm implements EventListener
|
|||
|
||||
public void onEvent(Event e) throws Exception
|
||||
{
|
||||
if (e.getTarget() == bFile)
|
||||
if (e instanceof UploadEvent)
|
||||
{
|
||||
cmd_loadFile();
|
||||
UploadEvent ue = (UploadEvent) e;
|
||||
processUploadMedia(ue.getMedia());
|
||||
invalidate();
|
||||
}
|
||||
else if (e.getTarget() == fCharset)
|
||||
|
@ -308,11 +309,6 @@ public class WFileImport extends ADForm implements EventListener
|
|||
SessionManager.getAppDesktop().closeActiveWindow();
|
||||
return;
|
||||
}
|
||||
else if (e instanceof UploadEvent)
|
||||
{
|
||||
UploadEvent ue = (UploadEvent) e;
|
||||
processUploadMedia(ue.getMedia());
|
||||
}
|
||||
|
||||
if (m_data != null && m_data.size() > 0 // file loaded
|
||||
&& m_format != null && m_format.getRowCount() > 0) // format loaded
|
||||
|
@ -321,17 +317,6 @@ public class WFileImport extends ADForm implements EventListener
|
|||
confirmPanel.getButton("Ok").setEnabled(false);
|
||||
}
|
||||
|
||||
/**************************************************************************
|
||||
* Load File
|
||||
*/
|
||||
|
||||
private void cmd_loadFile()
|
||||
{
|
||||
Media media = Fileupload.get();
|
||||
if (AdempiereWebUI.isEventThreadEnabled())
|
||||
processUploadMedia(media);
|
||||
}
|
||||
|
||||
private void processUploadMedia(Media media) {
|
||||
if (media == null)
|
||||
return;
|
||||
|
|
|
@ -12,6 +12,9 @@
|
|||
*****************************************************************************/
|
||||
package org.adempiere.webui.component;
|
||||
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Low Heng Sin
|
||||
|
@ -27,6 +30,7 @@ public class FilenameBox extends EditorBox
|
|||
public FilenameBox()
|
||||
{
|
||||
super();
|
||||
btn.setUpload("true");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,5 +40,18 @@ public class FilenameBox extends EditorBox
|
|||
{
|
||||
super();
|
||||
setText(fileName);
|
||||
btn.setUpload("true");
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.adempiere.webui.component.EditorBox#addEventListener(java.lang.String, org.zkoss.zk.ui.event.EventListener)
|
||||
*/
|
||||
@Override
|
||||
public boolean addEventListener(String evtnm, EventListener listener) {
|
||||
if (Events.ON_UPLOAD.equals(evtnm)) {
|
||||
return btn.addEventListener(evtnm, listener);
|
||||
} else {
|
||||
return super.addEventListener(evtnm, listener);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -76,7 +76,7 @@ public class RequestWindow extends Window implements EventListener<Event> {
|
|||
this.parent = parent;
|
||||
|
||||
setTitle("Event");
|
||||
setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
|
||||
setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
|
||||
setWidth("400px");
|
||||
setHeight("500px");
|
||||
this.setBorder("normal");
|
||||
|
|
|
@ -41,6 +41,7 @@ public class WFileDirectoryEditor extends WEditor
|
|||
super(new FilenameBox(), gridField);
|
||||
getComponent().setButtonImage("/images/Open16.png");
|
||||
getComponent().addEventListener(Events.ON_CLICK, this);
|
||||
getComponent().getButton().setUpload("false");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -21,17 +21,14 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.AdempiereWebUI;
|
||||
import org.adempiere.webui.component.FilenameBox;
|
||||
import org.adempiere.webui.event.ValueChangeEvent;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.zkoss.util.media.Media;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
import org.zkoss.zk.ui.event.UploadEvent;
|
||||
import org.zkoss.zul.Fileupload;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -50,7 +47,8 @@ public class WFilenameEditor extends WEditor
|
|||
{
|
||||
super(new FilenameBox(), gridField);
|
||||
getComponent().setButtonImage("/images/Open16.png");
|
||||
getComponent().addEventListener(Events.ON_CLICK, this);
|
||||
getComponent().addEventListener(Events.ON_UPLOAD, this);
|
||||
getComponent().getButton().setUpload("true,native");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -105,11 +103,6 @@ public class WFilenameEditor extends WEditor
|
|||
newValue = getComponent().getText();
|
||||
|
||||
}
|
||||
else if (Events.ON_CLICK.equals(event.getName()))
|
||||
{
|
||||
cmd_file();
|
||||
newValue = getComponent().getText();
|
||||
}
|
||||
else if (event instanceof UploadEvent)
|
||||
{
|
||||
UploadEvent ue = (UploadEvent) event;
|
||||
|
@ -121,6 +114,10 @@ public class WFilenameEditor extends WEditor
|
|||
return;
|
||||
}
|
||||
|
||||
processNewValue(newValue);
|
||||
}
|
||||
|
||||
protected void processNewValue(String newValue) {
|
||||
if (oldValue != null && newValue != null && oldValue.equals(newValue)) {
|
||||
return;
|
||||
}
|
||||
|
@ -131,29 +128,6 @@ public class WFilenameEditor extends WEditor
|
|||
fireValueChange(changeEvent);
|
||||
}
|
||||
|
||||
private Component parent = null;
|
||||
|
||||
/**
|
||||
* Load file
|
||||
*/
|
||||
private void cmd_file()
|
||||
{
|
||||
if (parent == null || getComponent().getParent() != parent)
|
||||
{
|
||||
if (parent != null)
|
||||
{
|
||||
parent.removeEventListener(Events.ON_UPLOAD, this);
|
||||
}
|
||||
parent = getComponent().getParent();
|
||||
parent.addEventListener(Events.ON_UPLOAD, this);
|
||||
}
|
||||
|
||||
// Show File Open Dialog
|
||||
Media media = Fileupload.get(true);
|
||||
if (AdempiereWebUI.isEventThreadEnabled())
|
||||
processUploadMedia(media);
|
||||
} // cmd_file
|
||||
|
||||
private void processUploadMedia(Media file) {
|
||||
if (file == null)
|
||||
return;
|
||||
|
@ -196,6 +170,8 @@ public class WFilenameEditor extends WEditor
|
|||
}
|
||||
|
||||
getComponent().setText(fileName);
|
||||
|
||||
processNewValue(getComponent().getText());
|
||||
}
|
||||
|
||||
public String[] getEvents()
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.adempiere.webui.component.Textbox;
|
|||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.event.ContextMenuEvent;
|
||||
import org.adempiere.webui.event.ContextMenuListener;
|
||||
import org.adempiere.webui.event.DialogEvents;
|
||||
import org.adempiere.webui.event.ValueChangeEvent;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.window.WFieldRecordInfo;
|
||||
|
@ -32,6 +33,7 @@ import org.adempiere.webui.window.WTextEditorDialog;
|
|||
import org.compiere.model.GridField;
|
||||
import org.compiere.util.DisplayType;
|
||||
import org.zkoss.zk.ui.event.Event;
|
||||
import org.zkoss.zk.ui.event.EventListener;
|
||||
import org.zkoss.zk.ui.event.Events;
|
||||
|
||||
/**
|
||||
|
@ -221,17 +223,23 @@ public class WStringEditor extends WEditor implements ContextMenuListener
|
|||
}
|
||||
else if (WEditorPopupMenu.EDITOR_EVENT.equals(evt.getContextEvent()))
|
||||
{
|
||||
WTextEditorDialog dialog = new WTextEditorDialog(this.getColumnName(), getDisplay(),
|
||||
final WTextEditorDialog dialog = new WTextEditorDialog(this.getColumnName(), getDisplay(),
|
||||
isReadWrite(), gridField.getFieldLength());
|
||||
dialog.setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
|
||||
dialog.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
|
||||
dialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
if (!dialog.isCancelled()) {
|
||||
getComponent().setText(dialog.getText());
|
||||
String newText = getComponent().getValue();
|
||||
ValueChangeEvent changeEvent = new ValueChangeEvent(WStringEditor.this, WStringEditor.this.getColumnName(), oldValue, newText);
|
||||
WStringEditor.super.fireValueChange(changeEvent);
|
||||
oldValue = newText;
|
||||
}
|
||||
}
|
||||
});
|
||||
SessionManager.getAppDesktop().showWindow(dialog);
|
||||
if (!dialog.isCancelled()) {
|
||||
getComponent().setText(dialog.getText());
|
||||
String newText = getComponent().getValue();
|
||||
ValueChangeEvent changeEvent = new ValueChangeEvent(this, this.getColumnName(), oldValue, newText);
|
||||
super.fireValueChange(changeEvent);
|
||||
oldValue = newText;
|
||||
}
|
||||
|
||||
}
|
||||
else if (WEditorPopupMenu.CHANGE_LOG_EVENT.equals(evt.getContextEvent()))
|
||||
{
|
||||
|
|
|
@ -1877,19 +1877,10 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
}
|
||||
|
||||
//show table with deletion rows -> value, name...
|
||||
final Window messagePanel = new Window() {
|
||||
private static final long serialVersionUID = 3954976581821972619L;
|
||||
|
||||
@Override
|
||||
public void detach() {
|
||||
super.detach();
|
||||
focusToActivePanel();
|
||||
}
|
||||
};
|
||||
final Window messagePanel = new Window();
|
||||
messagePanel.setBorder("normal");
|
||||
messagePanel.setWidth("600px");
|
||||
messagePanel.setTitle(Msg.getMsg(Env.getCtx(), "Find").replaceAll("&", "") + ": " + title);
|
||||
messagePanel.setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
|
||||
messagePanel.setClosable(true);
|
||||
messagePanel.setSizable(true);
|
||||
|
||||
|
@ -2062,6 +2053,12 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
|
|||
hbox.setHflex("1");
|
||||
|
||||
messagePanel.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
|
||||
messagePanel.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
focusToActivePanel();
|
||||
}
|
||||
});
|
||||
AEnv.showWindow(messagePanel);
|
||||
}
|
||||
//
|
||||
|
|
|
@ -254,7 +254,8 @@ public class WAttachment extends Window implements EventListener<Event>
|
|||
|
||||
bLoad.setImage("/images/Import24.png");
|
||||
bLoad.setTooltiptext(Msg.getMsg(Env.getCtx(), "Load"));
|
||||
bLoad.addEventListener(Events.ON_CLICK, this);
|
||||
bLoad.setUpload("true");
|
||||
bLoad.addEventListener(Events.ON_UPLOAD, this);
|
||||
|
||||
bDelete.setImage("/images/Delete24.png");
|
||||
bDelete.setTooltiptext(Msg.getMsg(Env.getCtx(), "Delete"));
|
||||
|
@ -455,7 +456,13 @@ public class WAttachment extends Window implements EventListener<Event>
|
|||
{
|
||||
// Save and Close
|
||||
|
||||
if (e.getTarget() == bOk)
|
||||
if (e instanceof UploadEvent)
|
||||
{
|
||||
preview.setVisible(false);
|
||||
UploadEvent ue = (UploadEvent) e;
|
||||
processUploadMedia(ue.getMedia());
|
||||
}
|
||||
else if (e.getTarget() == bOk)
|
||||
{
|
||||
String newText = text.getText();
|
||||
|
||||
|
@ -513,11 +520,6 @@ public class WAttachment extends Window implements EventListener<Event>
|
|||
autoPreview (cbContent.getSelectedIndex(), false);
|
||||
}
|
||||
|
||||
// Load Attachment
|
||||
|
||||
else if (e.getTarget() == bLoad)
|
||||
loadFile();
|
||||
|
||||
// Open Attachment
|
||||
|
||||
else if (e.getTarget() == bSave)
|
||||
|
@ -533,21 +535,6 @@ public class WAttachment extends Window implements EventListener<Event>
|
|||
|
||||
} // onEvent
|
||||
|
||||
/**************************************************************************
|
||||
* Load file for attachment
|
||||
*/
|
||||
|
||||
private void loadFile()
|
||||
{
|
||||
log.info("");
|
||||
|
||||
preview.setVisible(false);
|
||||
|
||||
Media media = Fileupload.get(true);
|
||||
if (AdempiereWebUI.isEventThreadEnabled())
|
||||
processUploadMedia(media);
|
||||
}
|
||||
|
||||
private void processUploadMedia(Media media) {
|
||||
if (media != null)
|
||||
{
|
||||
|
|
|
@ -85,7 +85,6 @@ public class WChat extends Window implements EventListener<Event>, DialogEvents
|
|||
{
|
||||
super();
|
||||
setTitle(Msg.getMsg(Env.getCtx(), "Chat") + " " + Description);
|
||||
setAttribute(Window.MODE_KEY, Window.MODE_MODAL);
|
||||
log.config("ID=" + CM_Chat_ID
|
||||
+ ", Table=" + AD_Table_ID + ", Record=" + Record_ID);
|
||||
//
|
||||
|
|
Loading…
Reference in New Issue