IDEMPIERE-144 Performance: Remove the use of zk event thread. Fixed InfoSchedule not showing up and misc. timeline related javascript bugs. Fixed popup dialog sometime is position off screen.

This commit is contained in:
Heng Sin Low 2012-08-22 17:45:31 +08:00
parent 0050af3c3a
commit 2f1aa8ac91
12 changed files with 141 additions and 57 deletions

View File

@ -19,6 +19,7 @@ import org.zkoss.zk.ui.HtmlBasedComponent;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Div;
import org.zkoss.zul.Window;
/**
*
@ -72,4 +73,34 @@ public final class LayoutUtils {
return div;
}
/**
* open popup window overlapping the ref component
* @param ref
* @param window
*/
public static void openPopupWindow(Component ref, Window window) {
openPopupWindow(ref, window, "overlap");
}
/**
* open popup window relative to the ref component
* @param ref
* @param window
* @param position
*/
public static void openPopupWindow(Component ref, Window window, String position) {
if (window.getPage() == null)
window.setPage(ref.getPage());
StringBuilder script = new StringBuilder();
script.append("_idempiere_popup_window('#")
.append(ref.getUuid())
.append("','#")
.append(window.getUuid())
.append("','")
.append(position)
.append("');");
window.doPopup();
Clients.response("_openPopupWindow_", new AuScript(window, script.toString()));
}
}

View File

@ -123,11 +123,13 @@ public class TimelineEventFeed extends HttpServlet {
}
if (slot.getMAssignment() != null) {
//encode assignment id as coordinate x
String link = "<a href=\"javascript:void(0)\" onclick=\""
+ "ad_closeBuble('" + timeLineId + "');"
+ "zkau.send({uuid: '" + uuid + "', cmd: 'onClick', data: "
+ "[" + slot.getMAssignment().getS_ResourceAssignment_ID() + ", 0]"
+ ", ctl: true})\">Edit</a>";
String link = "<a href=\"javascript:void(0)\" onclick=\""
+ "_ad_closeBuble(jq(this));"
+ "var widget = zk.Widget.$('" + uuid+"');"
+ "var event = new zk.Event(widget, 'onClick', {x:"
+ slot.getMAssignment().getS_ResourceAssignment_ID() + ",y: 0}, {toServer: true});"
+ "zAu.send(event);"
+ "\">Edit</a>";
xml.append("\r\n").append(XMLs.encodeText(link));
}
xml.append("\r\n").append("</event>").append("\r\n");

View File

@ -7,6 +7,7 @@ import java.text.NumberFormat;
import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.EditorBox;
import org.adempiere.webui.event.ContextMenuEvent;
@ -162,7 +163,8 @@ public class WAssignmentEditor extends WEditor implements ContextMenuListener {
processNewValue(oldValue, ma);
}
});
AEnv.showWindow(vad);
vad.setTitle(null);
LayoutUtils.openPopupWindow(this.getComponent().getTextbox(), vad);
}
// Start InfoSchedule directly
else

View File

@ -20,6 +20,7 @@ package org.adempiere.webui.editor;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.ValuePreference;
import org.adempiere.webui.component.Locationbox;
import org.adempiere.webui.event.ContextMenuEvent;
@ -189,10 +190,8 @@ public class WLocationEditor extends WEditor implements EventListener<Event>, Pr
setValue(ii);
}
});
getComponent().appendChild(ld);
ld.setPosition("parent");
ld.setTitle(null);
ld.doPopup();
LayoutUtils.openPopupWindow(getComponent(), ld);
}
}

View File

@ -24,6 +24,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.logging.Level;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.ValuePreference;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.EditorBox;
@ -249,10 +250,8 @@ public class WLocatorEditor extends WEditor implements EventListener<Event>, Pro
}
});
// display
getComponent().appendChild(ld);
ld.setPosition("parent");
ld.setTitle(null);
ld.doPopup();
LayoutUtils.openPopupWindow(getComponent(), ld);
}
}

View File

@ -18,13 +18,13 @@ package org.adempiere.webui.panel;
import java.text.DateFormat;
import java.util.Date;
import java.util.TimeZone;
import java.util.logging.Level;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.component.Panel;
import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.event.DialogEvents;
import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.window.InfoSchedule;
import org.adempiere.webui.window.WAssignmentDialog;
import org.compiere.model.MResourceAssignment;
@ -127,7 +127,8 @@ public class WSchedule extends Panel implements EventListener
hourBand.setIntervalUnit("hour");
hourBand.setWidth("40%");
hourBand.setIntervalPixels(40);
hourBand.setTimeZone(TimeZone.getDefault());
hourBand.setTimeZone(SessionManager.getAppDesktop().getClientInfo().timeZone);
hourBand.setId("WScheduleHourBand");
if (dayBand != null)
dayBand.detach();
@ -137,9 +138,10 @@ public class WSchedule extends Panel implements EventListener
dayBand.setWidth("35%");
dayBand.setIntervalPixels(100);
dayBand.setSyncWith(hourBand.getId());
dayBand.setTimeZone(TimeZone.getDefault());
dayBand.setTimeZone(SessionManager.getAppDesktop().getClientInfo().timeZone);
// listening band scroll event
dayBand.addEventListener("onBandScroll", this);
dayBand.setId("WScheduleDayBand");
if (mthBand != null)
mthBand.detach();
@ -149,7 +151,7 @@ public class WSchedule extends Panel implements EventListener
mthBand.setWidth("25%");
mthBand.setIntervalPixels(150);
mthBand.setSyncWith(dayBand.getId());
mthBand.setTimeZone(TimeZone.getDefault());
mthBand.setTimeZone(SessionManager.getAppDesktop().getClientInfo().timeZone);
}
/**
@ -166,7 +168,7 @@ public class WSchedule extends Panel implements EventListener
// if (m_center == null || date.getTime() != m_center.getTime())
// hourBand.scrollToCenter(date);
//
String feedUrl = "timeline?S_Resource_ID=" + S_Resource_ID + "&date=" + DateFormat.getInstance().format(date)
+ "&uuid=" + button.getUuid() + "&tlid=" + timeLine.getUuid();
hourBand.setEventSourceUrl(feedUrl);
@ -184,17 +186,19 @@ public class WSchedule extends Panel implements EventListener
MouseEvent me = (MouseEvent) event;
if (me.getX() > 0) {
MResourceAssignment assignment = new MResourceAssignment(Env.getCtx(), me.getX(), null);
final WAssignmentDialog wad = new WAssignmentDialog(assignment, false, infoSchedule.isCreateNew());
wad.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
final WAssignmentDialog assignmentDialog = new WAssignmentDialog(assignment, false, infoSchedule.isCreateNew());
assignmentDialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
if (!wad.isCancelled()) {
_assignmentDialogResult = wad.getMResourceAssignment();
if (!assignmentDialog.isCancelled()) {
_assignmentDialogResult = assignmentDialog.getMResourceAssignment();
Events.echoEvent("onAssignmentCallback", WSchedule.this, null);
}
}
});
AEnv.showWindow(wad);
assignmentDialog.setTitle(null);
LayoutUtils.openPopupWindow(this, assignmentDialog, "at_pointer");
Events.postEvent(new Event(Events.ON_CLICK, assignmentDialog.getDateFrom()));
}
} else if (event instanceof BandScrollEvent){
BandScrollEvent e = (BandScrollEvent) event;
@ -207,5 +211,4 @@ public class WSchedule extends Panel implements EventListener
}
}
}
} // WSchedule

View File

@ -27,6 +27,7 @@ import java.util.GregorianCalendar;
import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel;
@ -52,6 +53,7 @@ import org.compiere.util.Env;
import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
import org.compiere.util.TimeUtil;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
@ -103,10 +105,17 @@ public class InfoSchedule extends Window implements EventListener
super();
setTitle(Msg.getMsg(Env.getCtx(), "InfoSchedule"));
if (createNew)
setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
{
setAttribute(Window.MODE_KEY, Window.MODE_POPUP);
this.setWidth("600px");
}
else
setAttribute(Window.MODE_KEY, Window.MODE_OVERLAPPED);
this.setWidth("600px");
{
setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED);
this.setWidth("100%");
this.setHeight("100%");
}
// this.setHeight("600px");
this.setClosable(true);
this.setBorder("normal");
@ -138,7 +147,9 @@ public class InfoSchedule extends Window implements EventListener
catch(Exception ex)
{
log.log(Level.SEVERE, "InfoSchedule", ex);
}
}
AEnv.showWindow(this);
displayCalendar();
} // InfoSchedule
/**
@ -174,7 +185,8 @@ public class InfoSchedule extends Window implements EventListener
//
private WSchedule schedulePane = new WSchedule(this);
private StatusBarPanel statusBar = new StatusBarPanel();
private ConfirmPanel confirmPanel = new ConfirmPanel(true);
private ConfirmPanel confirmPanel = null;
private Button btnNew;
/**
* Static Layout
@ -226,7 +238,11 @@ public class InfoSchedule extends Window implements EventListener
schedulePane.setWidth("100%");
schedulePane.setHeight("400px");
Div div = new Div();
div.appendChild(confirmPanel);
if (m_createNew)
{
confirmPanel = new ConfirmPanel(true);
div.appendChild(confirmPanel);
}
div.appendChild(statusBar);
mainLayout.appendChild(div);
@ -255,18 +271,17 @@ public class InfoSchedule extends Window implements EventListener
bNext.addEventListener(Events.ON_CLICK, this);
//
//
confirmPanel.addActionListener(Events.ON_CLICK, this);
//
if (createNew) {
Button btnNew = new Button();
confirmPanel.addActionListener(Events.ON_CLICK, this);
btnNew = new Button();
btnNew.setName("btnNew");
btnNew.setId("New");
btnNew.setSrc("/images/New24.png");
confirmPanel.addComponentsLeft(btnNew);
btnNew.addEventListener(Events.ON_CLICK, this);
}
displayCalendar();
}
} // dynInit
/**
@ -569,7 +584,8 @@ public class InfoSchedule extends Window implements EventListener
mAssignmentCallback(vad.getMResourceAssignment());
}
});
AEnv.showWindow(vad);
vad.setTitle(null);
LayoutUtils.openPopupWindow(btnNew, vad, "before_start");
} else {
FDialog.error(0, this, "No available time slot for the selected day.");
}
@ -587,6 +603,17 @@ public class InfoSchedule extends Window implements EventListener
m_dateFrom = new Timestamp(date.getTime());
fieldDate.setValue(m_dateFrom); // Elaine 2008/12/15
}
/* (non-Javadoc)
* @see org.zkoss.zk.ui.AbstractComponent#onPageAttached(org.zkoss.zk.ui.Page, org.zkoss.zk.ui.Page)
*/
@Override
public void onPageAttached(Page newpage, Page oldpage) {
super.onPageAttached(newpage, oldpage);
if (newpage != null) {
displayCalendar();
}
}
/**

View File

@ -30,7 +30,6 @@ import java.util.logging.Level;
import org.adempiere.util.Callback;
import org.adempiere.webui.LayoutUtils;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.component.Button;
import org.adempiere.webui.component.ConfirmPanel;
import org.adempiere.webui.component.Datebox;
@ -114,6 +113,8 @@ public class WAssignmentDialog extends Window implements EventListener
log.log(Level.SEVERE, "", e);
}
setDisplay(); // from mAssignment
setWidth("600px");
setSizable(true);
//
} // VAssignmentDialog
@ -377,17 +378,8 @@ public class WAssignmentDialog extends Window implements EventListener
// Zoom - InfoResource
else if (e.getTarget().getId().equals("Zoom"))
{
InfoSchedule is = new InfoSchedule (m_mAssignment, true, new Callback<MResourceAssignment>() {
@Override
public void onCallback(MResourceAssignment result) {
if (result != null)
{
m_mAssignment = result;
// setDisplay();
detach();
}
}
});
setVisible(false);
Events.echoEvent("onShowSchedule", this, null);
}
// cancel - return
@ -417,17 +409,40 @@ public class WAssignmentDialog extends Window implements EventListener
}
}
public void onShowSchedule()
{
InfoSchedule is = new InfoSchedule (m_mAssignment, true, new Callback<MResourceAssignment>() {
@Override
public void onCallback(MResourceAssignment result) {
if (result != null)
{
m_mAssignment = result;
// setDisplay();
detach();
}
else
{
setVisible(true);
}
}
});
}
private void getDateAndTimeFrom(Calendar date) {
Date dateFrom = fDateFrom.getValue();
Date timeFrom = fTimeFrom.getValue();
date.setTime(dateFrom);
Calendar time = new GregorianCalendar();
time.setTime(timeFrom);
date.set(Calendar.HOUR, time.get(Calendar.HOUR));
date.set(Calendar.HOUR_OF_DAY, time.get(Calendar.HOUR_OF_DAY));
date.set(Calendar.MINUTE, time.get(Calendar.MINUTE));
}
public boolean isCancelled() {
return m_cancel;
}
public Datebox getDateFrom() {
return fDateFrom;
}
} // VAssignmentDialog

View File

@ -10,13 +10,10 @@ function _ad_deferBDL(uuid) {
if (cmp) { cmp.resize(); }
}
function ad_closeBuble(uuid) {
var cmp = zk.Widget.$(uuid);
if (cmp) {
for(var i=0;i<cmp.bandInfos.length;i++){
cmp.instance.getBand(i).closeBubble();
}
}
function _ad_closeBuble(link) {
var parent = link.parentsUntil("simileAjax-bubble-contentContainer");
var btn = parent.next();
btn.click();
}
function scrollToRow(uuid){
@ -26,4 +23,3 @@ function scrollToRow(uuid){
cmp.focus();
}
}

View File

@ -0,0 +1,5 @@
function _idempiere_popup_window(refid, windowid, position) {
var ref = zk.Widget.$(refid);
var window = zk(windowid);
window.position(ref.$n(), position);
}

View File

@ -37,6 +37,7 @@ Copyright (C) 2007 Ashley G Ramdass (ADempiere WebUI).
<javascript src="/js/report.js" charset="UTF-8"/>
<javascript src="/js/persist-min.js" charset="UTF-8"/>
<javascript src="/js/token.js" charset="UTF-8"/>
<javascript src="/js/window.js" charset="UTF-8"/>
<javascript package="jawwa.atmosphere" merge="false" />

View File

@ -596,4 +596,8 @@ div.z-vfiletree-body td.menu-tree-cell {
<%-- dashlet --%>
.z-panel-hl .z-panel-header {
padding: 0 0 2px 0;
}
div.simileAjax-bubble-container {
z-index: 2800 !important;
}