Merge update from idempiere

This commit is contained in:
Heng Sin Low 2012-03-05 13:02:52 +08:00
commit 98a016016f
134 changed files with 2081 additions and 2126 deletions

View File

@ -98,3 +98,9 @@ syntax: regexp
syntax: regexp
swingclient.product .*
syntax: regexp
^org\.zkoss\.zk\.library/bin$
syntax: regexp
\.class$
syntax: regexp
\.class$

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="lib" path="WEB-INF/classes/"/>
<classpathentry exported="true" kind="lib" path="WEB-INF/classes/" sourcepath="WEB-INF/src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="WEB-INF/src"/>

View File

@ -32,7 +32,7 @@ Require-Bundle: org.adempiere.report.jasper;bundle-version="1.0.0",
org.adempiere.base;bundle-version="1.0.0",
org.adempiere.report.jasper.library;bundle-version="1.0.0",
org.adempiere.ui;bundle-version="1.0.0",
org.zkoss.zk.library;bundle-version="3.6.3"
org.zkoss.zk.library;bundle-version="6.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Eclipse-ExtensibleAPI: true
Import-Package: javax.servlet,

View File

@ -43,7 +43,6 @@ import org.compiere.model.MUser;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Language;
import org.zkoss.zk.au.Command;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.Page;
@ -122,6 +121,10 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
{
loginCompleted();
}
Executions.getCurrent().getDesktop().addListener(new DrillCommand());
Executions.getCurrent().getDesktop().addListener(new TokenCommand());
Executions.getCurrent().getDesktop().addListener(new ZoomCommand());
}
public void onOk()
@ -362,12 +365,4 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
public UserPreference getUserPreference() {
return userPreference;
}
//global command
static {
new ZoomCommand("onZoom", Command.IGNORE_OLD_EQUIV);
new DrillCommand("onDrillAcross", Command.IGNORE_OLD_EQUIV);
new DrillCommand("onDrillDown", Command.IGNORE_OLD_EQUIV);
new TokenCommand(TokenEvent.ON_USER_TOKEN, Command.IGNORE_OLD_EQUIV);
}
}

View File

@ -16,6 +16,7 @@
*****************************************************************************/
package org.adempiere.webui;
import java.io.Serializable;
import java.util.TimeZone;
/**
@ -23,7 +24,12 @@ import java.util.TimeZone;
* @author Low Heng Sin
*
*/
public class ClientInfo {
public class ClientInfo implements Serializable {
/**
*
*/
private static final long serialVersionUID = -713195891415378500L;
public int colorDepth;
public int desktopWidth;
public int desktopHeight;

View File

@ -17,7 +17,7 @@ import org.zkoss.zk.au.out.AuScript;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.HtmlBasedComponent;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Div;
/**

View File

@ -24,12 +24,12 @@ import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.UiException;
import org.zkoss.zk.ui.metainfo.PageDefinition;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.East;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zkex.zul.West;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.East;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.West;
import org.zkoss.zul.Div;
import org.zkoss.zul.Vbox;
import org.zkoss.zul.Window;

View File

@ -61,9 +61,9 @@ import org.compiere.util.ValueNamePair;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.South;
import org.zkoss.zul.Caption;
import org.zkoss.zul.Filedownload;
import org.zkoss.zul.Groupbox;
@ -520,7 +520,7 @@ public class WAcctViewer extends Window implements EventListener
southPanel.setWidths("80%, 20%");
Grid southLeftGrid = new Grid();
southLeftGrid.setInnerWidth("");
southLeftGrid.setInnerHeight("");
southLeftGrid.setHeight("");
southLeftGrid.makeNoStrip();
southLeftGrid.setStyle("border: none; margin: none");
southPanel.appendChild(southLeftGrid);

View File

@ -39,10 +39,10 @@ import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Html;

View File

@ -309,7 +309,7 @@ public class ProcessModalDialog extends Window implements EventListener, IProces
if (m_processMonitor != null) {
m_processMonitor.lockUI(m_pi);
Clients.showBusy(null, false);
Clients.clearBusy();
}
lockUI(m_pi);

View File

@ -53,10 +53,10 @@ import org.compiere.util.Msg;
import org.compiere.util.Trx;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Separator;
import org.zkoss.zul.Space;

View File

@ -49,10 +49,10 @@ import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Separator;
/**

View File

@ -44,8 +44,8 @@ import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.Space;
public class WCreateFromInvoiceUI extends CreateFromInvoice implements EventListener, ValueChangeListener

View File

@ -36,8 +36,8 @@ import org.compiere.util.CLogger;
import org.compiere.util.DisplayType;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
public class WCreateFromRMAUI extends CreateFromRMA implements ValueChangeListener
{

View File

@ -53,8 +53,8 @@ import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.Space;
public class WCreateFromShipmentUI extends CreateFromShipment implements EventListener, ValueChangeListener

View File

@ -51,8 +51,8 @@ import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.Hbox;
public class WCreateFromStatementUI extends CreateFromStatement implements EventListener

View File

@ -30,10 +30,10 @@ import org.compiere.util.Trx;
import org.compiere.util.TrxRunnable;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Separator;
public class WCreateFromWindow extends Window implements EventListener, WTableModelListener

View File

@ -53,10 +53,10 @@ import org.zkoss.util.media.Media;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
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;
@ -321,14 +321,7 @@ public class WFileImport extends ADForm implements EventListener
{
Media media = null;
try
{
media = Fileupload.get();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
if (media == null)
return;

View File

@ -57,10 +57,10 @@ import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Html;
@ -206,7 +206,7 @@ public class WGenForm extends ADForm implements EventListener, WTableModelListen
public void postQueryEvent()
{
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Processing"), true);
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Processing"));
Events.echoEvent("onExecuteQuery", this, null);
}
@ -221,7 +221,7 @@ public class WGenForm extends ADForm implements EventListener, WTableModelListen
}
finally
{
Clients.showBusy(null, false);
Clients.clearBusy();
}
}
@ -341,7 +341,7 @@ public class WGenForm extends ADForm implements EventListener, WTableModelListen
// OK to print
if (FDialog.ask(getWindowNo(), this, genForm.getAskPrintMsg()))
{
Clients.showBusy("Processing...", true);
Clients.showBusy("Processing...");
Clients.response(new AuEcho(this, "onPrint", null));
} // OK to print
}
@ -378,14 +378,14 @@ public class WGenForm extends ADForm implements EventListener, WTableModelListen
File outFile = File.createTempFile(genForm.getClass().getName(), ".pdf");
AEnv.mergePdf(pdfList, outFile);
Clients.showBusy(null, false);
Clients.clearBusy();
Window win = new SimplePDFViewer(getFormName(), new FileInputStream(outFile));
SessionManager.getAppDesktop().showWindow(win, "center");
} catch (Exception e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
} else if (pdfList.size() > 0) {
Clients.showBusy(null, false);
Clients.clearBusy();
try {
Window win = new SimplePDFViewer(getFormName(), new FileInputStream(pdfList.get(0)));
SessionManager.getAppDesktop().showWindow(win, "center");

View File

@ -56,10 +56,10 @@ import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Separator;
import org.zkoss.zul.Space;

View File

@ -43,9 +43,9 @@ import org.zkoss.zk.au.out.AuEcho;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.South;
/**
* Merge Dialog.
@ -265,7 +265,7 @@ public class WMerge extends Merge implements IFormController, EventListener
m_success = merge (columnName, from_ID, to_ID);
postMerge(columnName, to_ID);
} finally{
Clients.showBusy(null, false);
Clients.clearBusy();
Clients.response(new AuEcho(form, "onAfterProcess", null));
}
}

View File

@ -58,9 +58,9 @@ import org.compiere.util.PaymentExport;
import org.compiere.util.ValueNamePair;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.South;
import org.zkoss.zul.Filedownload;
/**

View File

@ -56,10 +56,10 @@ import org.zkoss.zk.ui.SuspendNotAllowedException;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Separator;
import org.zkoss.zul.Space;
@ -388,8 +388,6 @@ public class WPaySelect extends PaySelect
dialog.doModal();
} catch (SuspendNotAllowedException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
} catch (InterruptedException e) {
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
}
} // generatePaySelect
@ -402,7 +400,7 @@ public class WPaySelect extends PaySelect
{
if (m_isLock) return;
m_isLock = true;
Clients.showBusy(null, true);
Clients.showBusy(null);
} // lockUI
/**
@ -414,7 +412,7 @@ public class WPaySelect extends PaySelect
if (!m_isLock) return;
m_isLock = false;
m_pi = pi;
Clients.showBusy(null, false);
Clients.clearBusy();
//TODO: The response returned is always Cancel
// if (!FDialog.ask(0, form, "VPaySelectPrint?", "(" + m_pi.getSummary() + ")"))

View File

@ -72,10 +72,10 @@ import org.zkoss.zk.au.out.AuEcho;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Space;
/**

View File

@ -41,12 +41,12 @@ import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.East;
import org.zkoss.zkex.zul.North;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.East;
import org.zkoss.zul.North;
import org.zkoss.zul.ListModel;
import org.zkoss.zul.SimpleTreeNode;
import org.zkoss.zul.DefaultTreeNode;
import org.zkoss.zul.Space;
import org.zkoss.zul.Splitter;
import org.zkoss.zul.Tree;
@ -300,9 +300,9 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
if (selected != null) // allow add if not in tree
{
SimpleTreeModel tm = (SimpleTreeModel) centerTree.getModel();
SimpleTreeNode stn = tm.find(tm.getRoot(), selected.id);
DefaultTreeNode stn = tm.find(tm.getRoot(), selected.id);
if (stn != null) {
int[] path = tm.getPath(tm.getRoot(), stn);
int[] path = tm.getPath(stn);
Treeitem ti = centerTree.renderItemByPath(path);
ti.setSelected(true);
}
@ -317,7 +317,7 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
private void onTreeSelection (Event e)
{
Treeitem ti = centerTree.getSelectedItem();
SimpleTreeNode stn = (SimpleTreeNode) ti.getValue();
DefaultTreeNode stn = (DefaultTreeNode) ti.getValue();
MTreeNode tn = (MTreeNode)stn.getData();
log.info(tn.toString());
if (tn == null)
@ -344,17 +344,17 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
if (item != null)
{
SimpleTreeModel model = (SimpleTreeModel) centerTree.getModel();
SimpleTreeNode stn = model.find(model.getRoot(), item.id);
DefaultTreeNode stn = model.find(model.getRoot(), item.id);
if (stn != null) {
MTreeNode tNode = (MTreeNode) stn.getData();
tNode.setName(item.name);
tNode.setAllowsChildren(item.isSummary);
tNode.setImageIndicator(item.imageIndicator);
model.nodeUpdated(stn);
Treeitem ti = centerTree.renderItemByPath(model.getPath(model.getRoot(), stn));
Treeitem ti = centerTree.renderItemByPath(model.getPath(stn));
ti.setTooltiptext(item.description);
} else {
stn = new SimpleTreeNode(new MTreeNode(item.id, 0, item.name, item.description, 0, item.isSummary,
stn = new DefaultTreeNode(new MTreeNode(item.id, 0, item.name, item.description, 0, item.isSummary,
item.imageIndicator, false, null), new ArrayList<Object>());
model.addNode(stn);
}
@ -373,7 +373,7 @@ public class WTreeMaintenance extends TreeMaintenance implements IFormController
if (item != null)
{
SimpleTreeModel model = (SimpleTreeModel) centerTree.getModel();
SimpleTreeNode stn = model.find(model.getRoot(), item.id);
DefaultTreeNode stn = model.find(model.getRoot(), item.id);
if (stn != null)
model.removeNode(stn);

View File

@ -50,10 +50,10 @@ import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Separator;
/**

View File

@ -55,9 +55,9 @@ import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.MouseEvent;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.East;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.East;
import org.zkoss.zul.Area;
import org.zkoss.zul.Div;
import org.zkoss.zul.Imagemap;

View File

@ -50,10 +50,10 @@ import org.zkoss.zk.ui.event.DropEvent;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Label;
@ -215,8 +215,6 @@ public class WFEditor extends ADForm {
w.doModal();
} catch (SuspendNotAllowedException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
String name = text.getText();

View File

@ -33,9 +33,9 @@ import org.zkoss.zhtml.Tr;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Html;

View File

@ -59,10 +59,10 @@ import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Html;
@ -275,7 +275,7 @@ public class WWFActivity extends ADForm implements EventListener
cmd_zoom();
else if (comp == bOK)
{
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Processing"), true);
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Processing"));
Events.echoEvent("onOK", this, null);
}
else if (comp == fAnswerButton)
@ -595,7 +595,7 @@ public class WWFActivity extends ADForm implements EventListener
log.config("Activity=" + m_activity);
if (m_activity == null)
{
Clients.showBusy(null, false);
Clients.clearBusy();
return;
}
int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
@ -689,7 +689,7 @@ public class WWFActivity extends ADForm implements EventListener
}
finally
{
Clients.showBusy(null, false);
Clients.clearBusy();
if (trx != null)
trx.close();
}

View File

@ -68,7 +68,8 @@ public class ADTabListModel extends AbstractListModel implements ListitemRendere
}
}
public void render(Listitem item, Object data) throws Exception {
@Override
public void render(Listitem item, Object data, int index) throws Exception {
ADTabLabel tabLabel = (ADTabLabel)data;
Listcell cell = new Listcell(tabLabel.label, null);
if (tabLabel.tabLevel > 0) {

View File

@ -24,7 +24,7 @@ import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Menuitem;
import org.zkoss.zul.Menupopup;
import org.zkoss.zul.SimpleTreeNode;
import org.zkoss.zul.DefaultTreeNode;
import org.zkoss.zul.Tree;
import org.zkoss.zul.Treeitem;
import org.zkoss.zul.Treerow;
@ -67,7 +67,7 @@ public class ADTreeOnDropListener implements EventListener {
if (de.getDragged() != de.getTarget()) {
Treeitem src = (Treeitem) ((Treerow) de.getDragged()).getParent();
Treeitem target = (Treeitem) ((Treerow) de.getTarget()).getParent();
moveNode((SimpleTreeNode)src.getValue(), (SimpleTreeNode)target.getValue());
moveNode((DefaultTreeNode)src.getValue(), (DefaultTreeNode)target.getValue());
}
}
}
@ -77,7 +77,7 @@ public class ADTreeOnDropListener implements EventListener {
* @param movingNode The node to be moved
* @param toNode The target node
*/
private void moveNode(SimpleTreeNode movingNode, SimpleTreeNode toNode)
private void moveNode(DefaultTreeNode movingNode, DefaultTreeNode toNode)
{
log.info(movingNode.toString() + " to " + toNode.toString());
@ -86,7 +86,7 @@ public class ADTreeOnDropListener implements EventListener {
MTreeNode toMNode = (MTreeNode) toNode.getData();
SimpleTreeNode newParent;
DefaultTreeNode newParent;
int index;
if (!toMNode.isSummary()) // drop on a child node
{
@ -95,7 +95,7 @@ public class ADTreeOnDropListener implements EventListener {
else // drop on a summary node
{
//prompt user to select insert after or drop into the summary node
int path[] = treeModel.getPath(treeModel.getRoot(), toNode);
int path[] = treeModel.getPath(toNode);
Treeitem toItem = tree.renderItemByPath(path);
tree.setSelectedItem(toItem);
@ -121,13 +121,13 @@ public class ADTreeOnDropListener implements EventListener {
} // moveNode
private void moveNode(SimpleTreeNode movingNode, SimpleTreeNode toNode, boolean moveInto)
private void moveNode(DefaultTreeNode movingNode, DefaultTreeNode toNode, boolean moveInto)
{
SimpleTreeNode newParent;
DefaultTreeNode newParent;
int index;
// remove
SimpleTreeNode oldParent = treeModel.getParent(movingNode);
DefaultTreeNode oldParent = treeModel.getParent(movingNode);
treeModel.removeNode(movingNode);
//get new index
@ -145,7 +145,7 @@ public class ADTreeOnDropListener implements EventListener {
// insert
treeModel.addNode(newParent, movingNode, index);
int path[] = treeModel.getPath(treeModel.getRoot(), movingNode);
int path[] = treeModel.getPath(movingNode);
Treeitem movingItem = tree.renderItemByPath(path);
tree.setSelectedItem(movingItem);
Events.sendEvent(tree, new Event(Events.ON_SELECT, tree));
@ -158,7 +158,7 @@ public class ADTreeOnDropListener implements EventListener {
MTreeNode oldMParent = (MTreeNode) oldParent.getData();
for (int i = 0; i < oldParent.getChildCount(); i++)
{
SimpleTreeNode nd = (SimpleTreeNode)oldParent.getChildAt(i);
DefaultTreeNode nd = (DefaultTreeNode)oldParent.getChildAt(i);
MTreeNode md = (MTreeNode) nd.getData();
StringBuffer sql = new StringBuffer("UPDATE ");
sql.append(mTree.getNodeTableName())
@ -175,7 +175,7 @@ public class ADTreeOnDropListener implements EventListener {
MTreeNode newMParent = (MTreeNode) newParent.getData();
for (int i = 0; i < newParent.getChildCount(); i++)
{
SimpleTreeNode nd = (SimpleTreeNode)newParent.getChildAt(i);
DefaultTreeNode nd = (DefaultTreeNode)newParent.getChildAt(i);
MTreeNode md = (MTreeNode) nd.getData();
StringBuffer sql = new StringBuffer("UPDATE ");
sql.append(mTree.getNodeTableName())
@ -201,9 +201,9 @@ public class ADTreeOnDropListener implements EventListener {
}
class MenuListener implements EventListener {
private SimpleTreeNode movingNode;
private SimpleTreeNode toNode;
MenuListener(SimpleTreeNode movingNode, SimpleTreeNode toNode) {
private DefaultTreeNode movingNode;
private DefaultTreeNode toNode;
MenuListener(DefaultTreeNode movingNode, DefaultTreeNode toNode) {
this.movingNode = movingNode;
this.toNode = toNode;
}

View File

@ -20,10 +20,10 @@ import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Vbox;

View File

@ -4,17 +4,17 @@
package org.adempiere.webui.component;
import org.zkoss.zk.ui.Component;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.East;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zkex.zul.West;
import org.zkoss.zul.Center;
import org.zkoss.zul.East;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.West;
/**
* @author teo_sarca
*
*/
public class Borderlayout extends org.zkoss.zkex.zul.Borderlayout
public class Borderlayout extends org.zkoss.zul.Borderlayout
{
/**
*

View File

@ -119,9 +119,12 @@ public class Combobox extends org.zkoss.zul.Combobox
return item.getValue().equals(value);
}
//TODO: Find zk6 replacement
/** Returns RS_NO_WIDTH|RS_NO_HEIGHT.
*/
/*
protected int getRealStyleFlags() {
return super.getRealStyleFlags() & 0x0006;
}
*/
}

View File

@ -13,11 +13,13 @@
*****************************************************************************/
package org.adempiere.webui.component;
import java.util.Map;
import org.adempiere.webui.event.DrillEvent;
import org.compiere.model.MQuery;
import org.zkoss.lang.Objects;
import org.zkoss.zk.au.AuRequest;
import org.zkoss.zk.au.Command;
import org.zkoss.zk.au.AuService;
import org.zkoss.zk.mesg.MZk;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.UiException;
@ -28,15 +30,18 @@ import org.zkoss.zk.ui.event.Events;
* @author hengsin
*
*/
public class DrillCommand extends Command {
public class DrillCommand implements AuService {
public DrillCommand(String id, int flags) {
super(id, flags);
public DrillCommand() {
}
@Override
protected void process(AuRequest request) {
final String[] data = request.getData();
public boolean service(AuRequest request, boolean everError) {
if (!DrillEvent.ON_DRILL_ACROSS.equals(request.getCommand())
&& !DrillEvent.ON_DRILL_DOWN.equals(request.getCommand()))
return false;
final Map<?, ?> map = request.getData();
String[] data = (String[]) map.get("");
final Component comp = request.getComponent();
if (comp == null)
@ -53,6 +58,8 @@ public class DrillCommand extends Command {
MQuery query = new MQuery(tableName);
query.addRestriction(columnName, MQuery.EQUAL, code);
Events.postEvent(new DrillEvent(getId(), comp, query));
Events.postEvent(new DrillEvent(request.getCommand(), comp, query));
return true;
}
}

View File

@ -24,10 +24,10 @@ import org.compiere.util.ValueNamePair;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
/**
* Directory and File Browser

View File

@ -37,9 +37,10 @@ import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.Frozen;
import org.zkoss.zul.South;
import org.zkoss.zul.Column;
import org.zkoss.zul.Div;
import org.zkoss.zul.Paging;
@ -89,12 +90,14 @@ public class GridPanel extends Borderlayout implements EventListener
private South south;
private boolean modeless;
private boolean modeless = true;
private String columnOnClick;
private AbstractADWindowPanel windowPanel;
private boolean refreshing;
public static final String PAGE_SIZE_KEY = "ZK_PAGING_SIZE";
public static final String MODE_LESS_KEY = "ZK_GRID_EDIT_MODELESS";
@ -118,8 +121,8 @@ public class GridPanel extends Borderlayout implements EventListener
//default paging size
pageSize = MSysConfig.getIntValue(PAGE_SIZE_KEY, 100);
//default false for better performance
modeless = MSysConfig.getBooleanValue(MODE_LESS_KEY, false);
//default true for better UI experience
modeless = MSysConfig.getBooleanValue(MODE_LESS_KEY, true);
}
/**
@ -175,11 +178,17 @@ public class GridPanel extends Borderlayout implements EventListener
}
else
{
refreshing = true;
listbox.setModel(listModel);
updateListIndex();
refreshing = false;
}
}
public boolean isRefreshing() {
return refreshing;
}
/**
* Update current row from model
*/
@ -253,6 +262,14 @@ public class GridPanel extends Borderlayout implements EventListener
if (init) return;
Columns columns = new Columns();
Frozen frozen = new Frozen();
frozen.setColumns(1);
listbox.appendChild(frozen);
org.zkoss.zul.Column indicator = new Column();
indicator.setWidth("30px");
columns.appendChild(indicator);
listbox.appendChild(columns);
columns.setSizable(true);
columns.setMenupopup("auto");
@ -307,8 +324,8 @@ public class GridPanel extends Borderlayout implements EventListener
LayoutUtils.addSclass("adtab-grid-panel", this);
listbox.setVflex(true);
//true is faster but render badly on some browser
listbox.setFixedLayout(false);
//true might looks better, false for better performance
listbox.setSizedByContent(false);
listbox.addEventListener(Events.ON_CLICK, this);
updateModel();
@ -401,6 +418,7 @@ public class GridPanel extends Borderlayout implements EventListener
}
}
}
event.stopPropagation();
}
else if (event.getTarget() == paging)
{

View File

@ -76,7 +76,8 @@ public class GridTabListItemRenderer implements ListitemRenderer, ListitemRender
* @param data
* @see ListitemRenderer#render(Listitem, Object)
*/
public void render(Listitem listitem, Object data) throws Exception {
@Override
public void render(Listitem listitem, Object data, int index) throws Exception {
//don't render if not visible
for(Component c = listitem.getParent(); c != null; c = c.getParent()) {
if (!c.isVisible())

View File

@ -54,7 +54,6 @@ import org.zkoss.zul.RendererCtrl;
import org.zkoss.zul.Row;
import org.zkoss.zul.RowRenderer;
import org.zkoss.zul.RowRendererExt;
import org.zkoss.zhtml.Input;
import org.zkoss.zhtml.Label;
import org.zkoss.zhtml.Text;
@ -66,9 +65,8 @@ import org.zkoss.zhtml.Text;
* <li>BF [ 2996608 ] GridPanel is not displaying time
* https://sourceforge.net/tracker/?func=detail&aid=2996608&group_id=176962&atid=955896
*/
public class GridTabRowRenderer implements RowRenderer, RowRendererExt, RendererCtrl {
public class GridTabRowRenderer implements RowRenderer<Object[]>, RowRendererExt, RendererCtrl {
private static final String CURRENT_ROW_STYLE = "border-top: 2px solid #6f97d2; border-bottom: 2px solid #6f97d2";
private static final int MAX_TEXT_LENGTH = 60;
private GridTab gridTab;
private int windowNo;
@ -98,9 +96,19 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
this.dataBinder = new GridTabDataBinder(gridTab);
}
private WEditor getEditorCell(GridField gridField, Object object, int i) {
private WEditor getEditorCell(GridField gridField) {
WEditor editor = editors.get(gridField);
if (editor != null) {
prepareFieldEditor(gridField, editor);
}
editor.addValueChangeListener(dataBinder);
gridField.removePropertyChangeListener(editor);
gridField.addPropertyChangeListener(editor);
editor.setValue(gridField.getValue());
return editor;
}
private void prepareFieldEditor(GridField gridField, WEditor editor) {
if (editor instanceof WButtonEditor)
{
if (m_windowPanel != null)
@ -117,21 +125,11 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
}
}
}
else
{
editor.addValueChangeListener(dataBinder);
}
gridField.removePropertyChangeListener(editor);
gridField.addPropertyChangeListener(editor);
editor.setValue(gridField.getValue());
//streach component to fill grid cell
if (editor.getComponent() instanceof Textbox)
((HtmlBasedComponent)editor.getComponent()).setWidth("98%");
else
if (editor.getComponent() instanceof HtmlBasedComponent) {
editor.fillHorizontal();
}
return editor;
}
private int getColumnIndex(GridField field) {
@ -309,7 +307,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
else
child = parent;
}
Component component = div.getFirstChild();
Component component = (Component) div.getAttribute("display.component");
if (updateCellLabel) {
if (component instanceof Label) {
Label label = (Label)component;
@ -325,13 +323,14 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
checkBox.setChecked(false);
}
}
component.setVisible(true);
if (row == null)
row = ((Row)div.getParent());
entry.getValue().getComponent().detach();
entry.getKey().removePropertyChangeListener(entry.getValue());
entry.getValue().removeValuechangeListener(dataBinder);
div.appendChild(component);
}
}
@ -344,7 +343,8 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
* @param data
* @see RowRenderer#render(Row, Object)
*/
public void render(Row row, Object data) throws Exception {
@Override
public void render(Row row, Object[] data, int index) throws Exception {
//don't render if not visible
if (gridPanel != null && !gridPanel.isVisible()) {
return;
@ -356,7 +356,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
if (rowListener == null)
rowListener = new RowListener((Grid)row.getParent().getParent());
currentValues = (Object[])data;
currentValues = data;
int columnCount = gridTab.getTableModel().getColumnCount();
GridField[] gridField = gridTab.getFields();
Grid grid = (Grid) row.getParent().getParent();
@ -367,9 +367,18 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
rowIndex = (paging.getActivePage() * paging.getPageSize()) + rowIndex;
}
Div indicatorDiv = new Div();
indicatorDiv.setStyle("text-align: center; border: none; width: 100%; height: 100%;");
indicatorDiv.appendChild(new Label());
//TODO: checkbox for selection and batch action ( delete, export, complete, etc )
// indicatorDiv.appendChild(new Checkbox());
row.appendChild(indicatorDiv);
int colIndex = -1;
int compCount = 0;
for (int i = 0; i < columnCount; i++) {
if (editors.get(gridField[i]) == null)
editors.put(gridField[i], WebEditorFactory.getEditor(gridField[i], true));
if (!gridField[i].isDisplayed()) {
continue;
}
@ -379,13 +388,9 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
String divStyle = "border: none; width: 100%; height: 100%;";
org.zkoss.zul.Column column = (org.zkoss.zul.Column) columns.getChildren().get(colIndex);
if (column.isVisible()) {
compCount++;
Component component = getDisplayComponent(rowIndex, currentValues[i], gridField[i]);
div.appendChild(component);
// if (compCount == 1) {
//add hidden input component to help focusing to row
div.appendChild(createAnchorInput());
// }
div.setAttribute("display.component", component);
if (DisplayType.YesNo == gridField[i].getDisplayType() || DisplayType.Image == gridField[i].getDisplayType()) {
divStyle += "text-align:center; ";
@ -398,6 +403,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
div.setAttribute("columnName", gridField[i].getColumnName());
div.addEventListener(Events.ON_CLICK, rowListener);
div.addEventListener(Events.ON_DOUBLE_CLICK, rowListener);
row.addEventListener(Events.ON_CLICK, rowListener);
row.appendChild(div);
}
@ -407,28 +413,27 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
row.addEventListener(Events.ON_OK, rowListener);
}
/**
* @param component
* @return
*/
private Input createAnchorInput() {
Input input = new Input();
input.setDynamicProperty("type", "text");
input.setValue("");
input.setDynamicProperty("readonly", "readonly");
input.setStyle("border: none; display: none; width: 3px;");
return input;
}
/**
* @param row
*/
public void setCurrentRow(Row row) {
if (currentRow != null && currentRow.getParent() != null && currentRow != row) {
currentRow.setStyle(null);
Div div = (Div) currentRow.getFirstChild();
if (div != null) {
Label label = (Label) div.getFirstChild();
label.getChildren().clear();
}
}
currentRow = row;
currentRow.setStyle(CURRENT_ROW_STYLE);
Div div = (Div) currentRow.getFirstChild();
if (div != null) {
Label label = (Label) div.getFirstChild();
label.getChildren().clear();
label.appendChild(new Text(">>"));
label.setStyle("color: darkblue; font-weight: bold; text-align: center");
}
currentRowIndex = gridTab.getCurrentRow();
if (currentRowIndex == gridTab.getCurrentRow()) {
if (editing) {
stopEditing(false);
@ -465,19 +470,19 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
int columnCount = gridTab.getTableModel().getColumnCount();
GridField[] gridField = gridTab.getFields();
org.zkoss.zul.Columns columns = grid.getColumns();
int colIndex = -1;
//skip indicator column
int colIndex = 0;
for (int i = 0; i < columnCount; i++) {
if (!gridField[i].isDisplayed()) {
continue;
}
colIndex ++;
if (editors.get(gridField[i]) == null)
editors.put(gridField[i], WebEditorFactory.getEditor(gridField[i], true));
org.zkoss.zul.Column column = (org.zkoss.zul.Column) columns.getChildren().get(colIndex);
if (column.isVisible()) {
Div div = (Div) currentRow.getChildren().get(colIndex);
WEditor editor = getEditorCell(gridField[i], currentValues[i], i);
div.getFirstChild().detach();
WEditor editor = getEditorCell(gridField[i]);
div.appendChild(editor.getComponent());
WEditorPopupMenu popupMenu = editor.getPopupMenu();
@ -486,7 +491,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
popupMenu.addMenuListener((ContextMenuListener)editor);
div.appendChild(popupMenu);
}
div.getFirstChild().setVisible(false);
//check context
if (!gridField[i].isDisplayed(true))
{
@ -594,7 +599,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
this.gridPanel = gridPanel;
}
class RowListener implements EventListener {
class RowListener implements EventListener<Event> {
private Grid _grid;
@ -606,6 +611,7 @@ public class GridTabRowRenderer implements RowRenderer, RowRendererExt, Renderer
if (Events.ON_CLICK.equals(event.getName())) {
Event evt = new Event(Events.ON_CLICK, _grid, event.getTarget());
Events.sendEvent(_grid, evt);
evt.stopPropagation();
}
else if (Events.ON_DOUBLE_CLICK.equals(event.getName())) {
Event evt = new Event(Events.ON_DOUBLE_CLICK, _grid, _grid);

View File

@ -224,4 +224,9 @@ public class GridTableListModel extends AbstractListModel implements TableModelL
editing = b;
}
@Override
public String getSortDirection(Comparator cmpr) {
return "natural";
}
}

View File

@ -29,9 +29,9 @@ 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;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.South;
import org.zkoss.zul.Paging;
import org.zkoss.zul.event.ZulEvents;

View File

@ -99,12 +99,6 @@ public class Listbox extends org.zkoss.zul.Listbox implements EventListener
return (ListItem)super.getSelectedItem();
}
@SuppressWarnings("unchecked")
public List<ListItem> getItems()
{
return (List<ListItem>)super.getItems();
}
/**
* Set selected item for the list box based on the value of list item
* set selected to none if no item found matching the value given or
@ -120,8 +114,8 @@ public class Listbox extends org.zkoss.zul.Listbox implements EventListener
return ;
}
List<ListItem> items = getItems();
for (ListItem item : items)
List<Listitem> items = getItems();
for (Listitem item : items)
{
if (value.getClass() != item.getValue().getClass()) {
// if the classes of value and item are different convert both to String
@ -331,7 +325,7 @@ public class Listbox extends org.zkoss.zul.Listbox implements EventListener
@Override
public String toString() {
StringBuffer items = new StringBuffer("[");
for (ListItem item : getItems()) {
for (Listitem item : getItems()) {
if (items.length() > 1)
items.append(", ");
items.append(item.toString());

View File

@ -132,7 +132,7 @@ public class NumberBox extends Div
public void setValue(Object value)
{
if (value == null)
decimalBox.setValue(null);
decimalBox.setValue((BigDecimal) null);
else if (value instanceof BigDecimal)
decimalBox.setValue((BigDecimal) value);
else if (value instanceof Number)
@ -199,7 +199,7 @@ public class NumberBox extends Div
char separatorChar = DisplayType.getNumberFormat(DisplayType.Number, Env.getLanguage(Env.getCtx())).getDecimalFormatSymbols().getDecimalSeparator();
txtCalc = new Textbox();
txtCalc.setAction("onKeyPress : return calc.validate('" +
txtCalc.setWidgetListener("onKeyPress", "return calc.validate('" +
decimalBox.getId() + "','" + txtCalc.getId()
+ "'," + integral + "," + (int)separatorChar + ", event);");
txtCalc.setMaxlength(250);
@ -213,27 +213,27 @@ public class NumberBox extends Div
Button btnAC = new Button();
btnAC.setWidth("40px");
btnAC.setLabel("AC");
btnAC.setAction("onClick : calc.clearAll('" + txtCalcId + "')");
btnAC.setWidgetListener("onClick", "calc.clearAll('" + txtCalcId + "')");
Button btn7 = new Button();
btn7.setWidth("30px");
btn7.setLabel("7");
btn7.setAction("onClick : calc.append('" + txtCalcId + "', '7')");
btn7.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', '7')");
Button btn8 = new Button();
btn8.setWidth("30px");
btn8.setLabel("8");
btn8.setAction("onClick : calc.append('" + txtCalcId + "', '8')");
btn8.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', '8')");
Button btn9 = new Button();
btn9.setWidth("30px");
btn9.setLabel("9");
btn9.setAction("onClick : calc.append('" + txtCalcId + "', '9')");
btn9.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', '9')");
Button btnMultiply = new Button();
btnMultiply.setWidth("30px");
btnMultiply.setLabel("*");
btnMultiply.setAction("onClick : calc.append('" + txtCalcId + "', ' * ')");
btnMultiply.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', ' * ')");
row1.appendChild(btnAC);
row1.appendChild(btn7);
@ -246,27 +246,27 @@ public class NumberBox extends Div
Button btnC = new Button();
btnC.setWidth("40px");
btnC.setLabel("C");
btnC.setAction("onClick : calc.clear('" + txtCalcId + "')");
btnC.setWidgetListener("onClick", "calc.clear('" + txtCalcId + "')");
Button btn4 = new Button();
btn4.setWidth("30px");
btn4.setLabel("4");
btn4.setAction("onClick : calc.append('" + txtCalcId + "', '4')");
btn4.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', '4')");
Button btn5 = new Button();
btn5.setWidth("30px");
btn5.setLabel("5");
btn5.setAction("onClick : calc.append('" + txtCalcId + "', '5')");
btn5.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', '5')");
Button btn6 = new Button();
btn6.setWidth("30px");
btn6.setLabel("6");
btn6.setAction("onClick : calc.append('" + txtCalcId + "', '6')");
btn6.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', '6')");
Button btnDivide = new Button();
btnDivide.setWidth("30px");
btnDivide.setLabel("/");
btnDivide.setAction("onClick : calc.append('" + txtCalcId + "', ' / ')");
btnDivide.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', ' / ')");
row2.appendChild(btnC);
row2.appendChild(btn4);
@ -279,27 +279,27 @@ public class NumberBox extends Div
Button btnModulo = new Button();
btnModulo.setWidth("40px");
btnModulo.setLabel("%");
btnModulo.setAction("onClick : calc.append('" + txtCalcId + "', ' % ')");
btnModulo.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', ' % ')");
Button btn1 = new Button();
btn1.setWidth("30px");
btn1.setLabel("1");
btn1.setAction("onClick : calc.append('" + txtCalcId + "', '1')");
btn1.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', '1')");
Button btn2 = new Button();
btn2.setWidth("30px");
btn2.setLabel("2");
btn2.setAction("onClick : calc.append('" + txtCalcId + "', '2')");
btn2.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', '2')");
Button btn3 = new Button();
btn3.setWidth("30px");
btn3.setLabel("3");
btn3.setAction("onClick : calc.append('" + txtCalcId + "', '3')");
btn3.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', '3')");
Button btnSubstract = new Button();
btnSubstract.setWidth("30px");
btnSubstract.setLabel("-");
btnSubstract.setAction("onClick : calc.append('" + txtCalcId + "', ' - ')");
btnSubstract.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', ' - ')");
row3.appendChild(btnModulo);
row3.appendChild(btn1);
@ -317,25 +317,25 @@ public class NumberBox extends Div
Button btn0 = new Button();
btn0.setWidth("30px");
btn0.setLabel("0");
btn0.setAction("onClick : calc.append('" + txtCalcId + "', '0')");
btn0.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', '0')");
String separator = Character.toString(separatorChar);
Button btnDot = new Button();
btnDot.setWidth("30px");
btnDot.setLabel(separator);
btnDot.setDisabled(integral);
btnDot.setAction("onClick : calc.append('" + txtCalcId + "', '" + separator + "')");
btnDot.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', '" + separator + "')");
Button btnEqual = new Button();
btnEqual.setWidth("30px");
btnEqual.setLabel("=");
btnEqual.setAction("onClick : calc.evaluate('" + decimalBox.getId() + "','"
btnEqual.setWidgetListener("onClick", "calc.evaluate('" + decimalBox.getId() + "','"
+ txtCalcId + "','" + separator + "')");
Button btnAdd = new Button();
btnAdd.setWidth("30px");
btnAdd.setLabel("+");
btnAdd.setAction("onClick : calc.append('" + txtCalcId + "', ' + ')");
btnAdd.setWidgetListener("onClick", "calc.append('" + txtCalcId + "', ' + ')");
row4.appendChild(btnCurrency);
row4.appendChild(btnDot);

View File

@ -68,7 +68,8 @@ public class SimpleListModel extends AbstractListModel implements ListitemRender
.append(src.substring(0, j)).append("...");
}
public void render(Listitem item, Object data) throws Exception {
@Override
public void render(Listitem item, Object data, int index) throws Exception {
if (data instanceof Object[]) {
renderArray(item, (Object[])data);
} else if (data instanceof Collection) {

View File

@ -25,8 +25,9 @@ import org.zkoss.lang.Objects;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.SimpleTreeNode;
import org.zkoss.zul.DefaultTreeNode;
import org.zkoss.zul.Tree;
import org.zkoss.zul.TreeNode;
import org.zkoss.zul.Treecell;
import org.zkoss.zul.Treecol;
import org.zkoss.zul.Treecols;
@ -40,7 +41,7 @@ import org.zkoss.zul.event.TreeDataEvent;
* @author Low Heng Sin
*
*/
public class SimpleTreeModel extends org.zkoss.zul.SimpleTreeModel implements TreeitemRenderer, EventListener {
public class SimpleTreeModel extends org.zkoss.zul.DefaultTreeModel implements TreeitemRenderer, EventListener {
/**
*
@ -52,7 +53,7 @@ public class SimpleTreeModel extends org.zkoss.zul.SimpleTreeModel implements Tr
private boolean itemDraggable;
private List<EventListener> onDropListners = new ArrayList<EventListener>();
public SimpleTreeModel(SimpleTreeNode root) {
public SimpleTreeModel(DefaultTreeNode root) {
super(root);
}
@ -105,10 +106,10 @@ public class SimpleTreeModel extends org.zkoss.zul.SimpleTreeModel implements Tr
SimpleTreeModel model = null;
Enumeration nodeEnum = root.children();
SimpleTreeNode stRoot = new SimpleTreeNode(root, new ArrayList());
DefaultTreeNode stRoot = new DefaultTreeNode(root, new ArrayList());
while(nodeEnum.hasMoreElements()) {
MTreeNode childNode = (MTreeNode)nodeEnum.nextElement();
SimpleTreeNode stNode = new SimpleTreeNode(childNode, new ArrayList());
DefaultTreeNode stNode = new DefaultTreeNode(childNode, new ArrayList());
stRoot.getChildren().add(stNode);
if (childNode.getChildCount() > 0) {
populate(stNode, childNode);
@ -118,11 +119,11 @@ public class SimpleTreeModel extends org.zkoss.zul.SimpleTreeModel implements Tr
return model;
}
private static void populate(SimpleTreeNode stNode, MTreeNode root) {
private static void populate(DefaultTreeNode stNode, MTreeNode root) {
Enumeration nodeEnum = root.children();
while(nodeEnum.hasMoreElements()) {
MTreeNode childNode = (MTreeNode)nodeEnum.nextElement();
SimpleTreeNode stChildNode = new SimpleTreeNode(childNode, new ArrayList());
DefaultTreeNode stChildNode = new DefaultTreeNode(childNode, new ArrayList());
stNode.getChildren().add(stChildNode);
if (childNode.getChildCount() > 0) {
populate(stChildNode, childNode);
@ -160,33 +161,33 @@ public class SimpleTreeModel extends org.zkoss.zul.SimpleTreeModel implements Tr
* Add to root
* @param newNode
*/
public void addNode(SimpleTreeNode newNode) {
SimpleTreeNode root = (SimpleTreeNode) getRoot();
public void addNode(DefaultTreeNode newNode) {
DefaultTreeNode root = (DefaultTreeNode) getRoot();
root.getChildren().add(newNode);
fireEvent(root, root.getChildCount() - 1, root.getChildCount() - 1, TreeDataEvent.INTERVAL_ADDED);
}
@Override
public SimpleTreeNode getRoot() {
return (SimpleTreeNode) super.getRoot();
public DefaultTreeNode getRoot() {
return (DefaultTreeNode) super.getRoot();
}
@Override
public SimpleTreeNode getChild(Object parent, int index) {
return (SimpleTreeNode) super.getChild(parent, index);
public DefaultTreeNode getChild(Object parent, int index) {
return (DefaultTreeNode) super.getChild((TreeNode)parent, index);
}
/**
* @param treeNode
*/
public void removeNode(SimpleTreeNode treeNode) {
int path[] = this.getPath(getRoot(), treeNode);
public void removeNode(DefaultTreeNode treeNode) {
int path[] = this.getPath(treeNode);
if (path != null && path.length > 0) {
SimpleTreeNode parentNode = getRoot();
DefaultTreeNode parentNode = getRoot();
int index = path.length - 1;
for (int i = 0; i < index; i++) {
parentNode = getChild(parentNode, path[i]);
parentNode = (DefaultTreeNode) getChild((TreeNode)parentNode, path[i]);
}
@ -230,16 +231,16 @@ public class SimpleTreeModel extends org.zkoss.zul.SimpleTreeModel implements Tr
/**
* @param treeNode
* @return SimpleTreeNode
* @return DefaultTreeNode
*/
public SimpleTreeNode getParent(SimpleTreeNode treeNode) {
int path[] = this.getPath(getRoot(), treeNode);
public DefaultTreeNode getParent(DefaultTreeNode treeNode) {
int path[] = this.getPath(treeNode);
if (path != null && path.length > 0) {
SimpleTreeNode parentNode = getRoot();
DefaultTreeNode parentNode = getRoot();
int index = path.length - 1;
for (int i = 0; i < index; i++) {
parentNode = getChild(parentNode, path[i]);
parentNode = (DefaultTreeNode) getChild((TreeNode)parentNode, path[i]);
}
return parentNode;
@ -253,7 +254,7 @@ public class SimpleTreeModel extends org.zkoss.zul.SimpleTreeModel implements Tr
* @param newNode
* @param index
*/
public void addNode(SimpleTreeNode newParent, SimpleTreeNode newNode,
public void addNode(DefaultTreeNode newParent, DefaultTreeNode newNode,
int index) {
newParent.getChildren().add(index, newNode);
fireEvent(newParent, index, index, TreeDataEvent.INTERVAL_ADDED);
@ -262,9 +263,9 @@ public class SimpleTreeModel extends org.zkoss.zul.SimpleTreeModel implements Tr
/**
* @param fromNode
* @param recordId
* @return SimpleTreeNode
* @return DefaultTreeNode
*/
public SimpleTreeNode find(SimpleTreeNode fromNode, int recordId) {
public DefaultTreeNode find(DefaultTreeNode fromNode, int recordId) {
if (fromNode == null)
fromNode = getRoot();
MTreeNode data = (MTreeNode) fromNode.getData();
@ -274,8 +275,8 @@ public class SimpleTreeModel extends org.zkoss.zul.SimpleTreeModel implements Tr
return null;
int cnt = getChildCount(fromNode);
for(int i = 0; i < cnt; i++ ) {
SimpleTreeNode child = getChild(fromNode, i);
SimpleTreeNode treeNode = find(child, recordId);
DefaultTreeNode child = (DefaultTreeNode) getChild(fromNode, i);
DefaultTreeNode treeNode = find(child, recordId);
if (treeNode != null)
return treeNode;
}
@ -285,11 +286,17 @@ public class SimpleTreeModel extends org.zkoss.zul.SimpleTreeModel implements Tr
/**
* @param node
*/
public void nodeUpdated(SimpleTreeNode node) {
SimpleTreeNode parent = getParent(node);
public void nodeUpdated(DefaultTreeNode node) {
DefaultTreeNode parent = getParent(node);
if (parent != null) {
int i = parent.getChildren().indexOf(node);
fireEvent(parent, i, i, TreeDataEvent.CONTENTS_CHANGED);
}
}
@Override
public void render(Treeitem arg0, Object arg1, int arg2) throws Exception {
// TODO Auto-generated method stub
}
}

View File

@ -13,10 +13,12 @@
*****************************************************************************/
package org.adempiere.webui.component;
import java.util.Map;
import org.adempiere.webui.event.TokenEvent;
import org.zkoss.lang.Objects;
import org.zkoss.zk.au.AuRequest;
import org.zkoss.zk.au.Command;
import org.zkoss.zk.au.AuService;
import org.zkoss.zk.mesg.MZk;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.UiException;
@ -27,15 +29,19 @@ import org.zkoss.zk.ui.event.Events;
* @author hengsin
*
*/
public class TokenCommand extends Command {
public class TokenCommand implements AuService {
public TokenCommand(String id, int flags) {
super(id, flags);
public TokenCommand() {
}
@Override
protected void process(AuRequest request) {
final String[] data = request.getData();
public boolean service(AuRequest request, boolean everError) {
if (!TokenEvent.ON_USER_TOKEN.equals(request.getCommand()))
return false;
Map<?, ?> map = request.getData();
String sid = (String) map.get("sid");
String hash = (String) map.get("hash");
final String[] data = new String[] {sid, hash};
final Component comp = request.getComponent();
if (comp == null)
@ -45,6 +51,8 @@ public class TokenCommand extends Command {
throw new UiException(MZk.ILLEGAL_REQUEST_WRONG_DATA, new Object[] {
Objects.toString(data), this });
Events.postEvent(new TokenEvent(getId(), comp, data));
Events.postEvent(new TokenEvent(request.getCommand(), comp, data));
return true;
}
}

View File

@ -128,9 +128,10 @@ public class WListItemRenderer implements ListitemRenderer, EventListener, Listi
/* (non-Javadoc)
* @see org.zkoss.zul.ListitemRenderer#render(org.zkoss.zul.Listitem, java.lang.Object)
*/
public void render(Listitem item, Object data) throws Exception
@Override
public void render(Listitem item, Object data, int index) throws Exception
{
render((ListItem)item, data);
render((ListItem)item, data, index);
}
/**
@ -143,7 +144,7 @@ public class WListItemRenderer implements ListitemRenderer, EventListener, Listi
* @throws Exception
* @see {@link #render(Listitem, Object)}
*/
private void render(ListItem item, Object data)
private void render(ListItem item, Object data, int index)
{
Listcell listcell = null;
int colIndex = 0;

View File

@ -13,11 +13,13 @@
*****************************************************************************/
package org.adempiere.webui.component;
import java.util.Map;
import org.adempiere.webui.event.ZoomEvent;
import org.compiere.model.MQuery;
import org.zkoss.lang.Objects;
import org.zkoss.zk.au.AuRequest;
import org.zkoss.zk.au.Command;
import org.zkoss.zk.au.AuService;
import org.zkoss.zk.mesg.MZk;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.UiException;
@ -28,15 +30,17 @@ import org.zkoss.zk.ui.event.Events;
* @author hengsin
*
*/
public class ZoomCommand extends Command {
public class ZoomCommand implements AuService {
public ZoomCommand(String id, int flags) {
super(id, flags);
public ZoomCommand() {
}
@Override
protected void process(AuRequest request) {
final String[] data = request.getData();
public boolean service(AuRequest request, boolean everError) {
if (!ZoomEvent.EVENT_NAME.equals(request.getCommand()))
return false;
Map<?, ?> map = request.getData();
final String[] data = (String[]) map.get("");
final Component comp = request.getComponent();
if (comp == null)
@ -67,6 +71,8 @@ public class ZoomCommand extends Command {
query.setRecordCount(1);
Events.postEvent(new ZoomEvent(comp, query));
return true;
}
}

View File

@ -56,10 +56,6 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
public void onMenuSelected(int menuId)
{
MMenu menu = new MMenu(Env.getCtx(), menuId, null);
if(menu == null)
{
return;
}
if(menu.getAction().equals(MMenu.ACTION_Window))
{
@ -192,16 +188,9 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
{
//fall back to highlighted if can't execute doModal
if (Events.inEventListener())
{
try
{
win.doModal();
}
catch(InterruptedException e)
{
}
}
else
{
showHighlighted(win, null);
@ -253,20 +242,4 @@ public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop
win.doHighlighted();
}
protected String stripHtml(String htmlString, boolean all) {
htmlString = htmlString
.replace("<html>", "")
.replace("</html>", "")
.replace("<body>", "")
.replace("</body>", "")
.replace("<head>", "")
.replace("</head>", "");
if (all)
htmlString = htmlString
.replace(">", "&gt;")
.replace("<", "&lt;");
return htmlString;
}
}

View File

@ -0,0 +1,324 @@
/**
*
*/
package org.adempiere.webui.desktop;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import org.adempiere.webui.apps.graph.WGraph;
import org.adempiere.webui.apps.graph.WPerformanceDetail;
import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.dashboard.DashboardPanel;
import org.adempiere.webui.dashboard.DashboardRunnable;
import org.compiere.model.I_AD_Menu;
import org.compiere.model.MDashboardContent;
import org.compiere.model.MGoal;
import org.compiere.model.X_PA_DashboardContent;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Desktop;
import org.zkoss.zk.ui.Executions;
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;
import org.zkoss.zk.ui.event.MaximizeEvent;
import org.zkoss.zul.Anchorchildren;
import org.zkoss.zul.Anchorlayout;
import org.zkoss.zul.Html;
import org.zkoss.zul.Panel;
import org.zkoss.zul.Panelchildren;
import org.zkoss.zul.Style;
import org.zkoss.zul.Toolbarbutton;
import org.zkoss.zul.Vlayout;
/**
* @author hengsin
*
*/
public class DashboardController implements EventListener<MaximizeEvent> {
private final static CLogger logger = CLogger.getCLogger(DashboardController.class);
private Component prevParent;
private Component prevNext;
private List<Panel> panelList = new ArrayList<Panel>();
private List<Anchorchildren> columnList = new ArrayList<Anchorchildren>();
private Anchorlayout dashboardLayout;
private Anchorchildren maximizedHolder;
private Thread dashboardThread;
private DashboardRunnable dashboardRunnable;
public DashboardController() {
dashboardLayout = new Anchorlayout();
dashboardLayout.setWidth("99%");
dashboardLayout.setHeight("99%");
dashboardLayout.setStyle("position: absolute;");
dashboardLayout.setVflex("true");
maximizedHolder = new Anchorchildren();
maximizedHolder.setAnchor("99% 99%");
}
public void render(Component parent, IDesktop desktopImpl) {
Style style = new Style();
//, .z-anchorchildren
style.setContent(".z-anchorlayout-body { overflow:auto } .z-anchorchildren { overflow:visible } ");
style.setPage(parent.getPage());
parent.appendChild(dashboardLayout);
if (!dashboardLayout.getDesktop().isServerPushEnabled())
dashboardLayout.getDesktop().enableServerPush(true);
dashboardRunnable = new DashboardRunnable(parent.getDesktop(), desktopImpl);
// Dashboard content
Vlayout dashboardColumnLayout = null;
int currentColumnNo = 0;
int noOfCols = 0;
int width = 0;
try
{
noOfCols = MDashboardContent.getForSessionColumnCount();
width = noOfCols <= 0 ? 100 : 100 / noOfCols;
for (final MDashboardContent dp : MDashboardContent.getForSession())
{
int columnNo = dp.getColumnNo();
if(dashboardColumnLayout == null || currentColumnNo != columnNo)
{
dashboardColumnLayout = new Vlayout();
Anchorchildren dashboardColumn = new Anchorchildren();
dashboardColumn.setAnchor((width-2) + "%" + " 100%");
dashboardColumn.appendChild(dashboardColumnLayout);
columnList.add(dashboardColumn);
dashboardLayout.appendChild(dashboardColumn);
dashboardColumnLayout.setWidth("100%");
currentColumnNo = columnNo;
}
Panel panel = new Panel();
panelList.add(panel);
panel.addEventListener(Events.ON_MAXIMIZE, this);
panel.setStyle("margin: 2px; position: relative;");
panel.setTitle(dp.get_Translation(MDashboardContent.COLUMNNAME_Name));
panel.setMaximizable(true);
String description = dp.get_Translation(MDashboardContent.COLUMNNAME_Description);
if(description != null)
panel.setTooltiptext(description);
panel.setCollapsible(dp.isCollapsible());
panel.setBorder("normal");
dashboardColumnLayout.appendChild(panel);
Panelchildren content = new Panelchildren();
panel.appendChild(content);
boolean panelEmpty = true;
// HTML content
String htmlContent = dp.getHTML();
if(htmlContent != null)
{
StringBuffer result = new StringBuffer("<html><head>");
URL url = getClass().getClassLoader().getResource("org/compiere/images/PAPanel.css");
InputStreamReader ins;
try {
ins = new InputStreamReader(url.openStream());
BufferedReader bufferedReader = new BufferedReader( ins );
String cssLine;
while ((cssLine = bufferedReader.readLine()) != null)
result.append(cssLine + "\n");
} catch (IOException e1) {
logger.log(Level.SEVERE, e1.getLocalizedMessage(), e1);
}
result.append("</head><body><div class=\"content\">\n");
// if(description != null)
// result.append("<h2>" + description + "</h2>\n");
result.append(stripHtml(htmlContent, false) + "<br>\n");
result.append("</div>\n</body>\n</html>\n</html>");
Html html = new Html();
html.setContent(result.toString());
content.appendChild(html);
panelEmpty = false;
}
// Window
int AD_Window_ID = dp.getAD_Window_ID();
if(AD_Window_ID > 0)
{
int AD_Menu_ID = dp.getAD_Menu_ID();
ToolBarButton btn = new ToolBarButton(String.valueOf(AD_Menu_ID));
I_AD_Menu menu = dp.getAD_Menu();
btn.setLabel(menu.getName());
btn.setAttribute("AD_Menu_ID", AD_Menu_ID);
btn.addEventListener(Events.ON_CLICK, this);
content.appendChild(btn);
panelEmpty = false;
}
// Goal
int PA_Goal_ID = dp.getPA_Goal_ID();
if(PA_Goal_ID > 0)
{
//link to open performance detail
Toolbarbutton link = new Toolbarbutton();
link.setImage("/images/Zoom16.png");
link.setAttribute("PA_Goal_ID", PA_Goal_ID);
link.addEventListener(Events.ON_CLICK, new EventListener<Event>() {
public void onEvent(Event event) throws Exception {
int PA_Goal_ID = (Integer)event.getTarget().getAttribute("PA_Goal_ID");
MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null);
new WPerformanceDetail(goal);
}
});
content.appendChild(link);
String goalDisplay = dp.getGoalDisplay();
MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null);
WGraph graph = new WGraph(goal, 55, false, true,
!(X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)),
X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay));
content.appendChild(graph);
panelEmpty = false;
}
// ZUL file url
String url = dp.getZulFilePath();
if(url != null)
{
try {
Component component = Executions.createComponents(url, content, null);
if(component != null)
{
if (component instanceof DashboardPanel)
{
DashboardPanel dashboardPanel = (DashboardPanel) component;
if (!dashboardPanel.getChildren().isEmpty()) {
content.appendChild(dashboardPanel);
dashboardRunnable.add(dashboardPanel);
panelEmpty = false;
}
}
else
{
content.appendChild(component);
panelEmpty = false;
}
}
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to create components. zul="+url, e);
}
}
if (panelEmpty)
panel.detach();
}
}
catch (Exception e)
{
logger.log(Level.WARNING, "Failed to create dashboard content", e);
}
//
if (!dashboardRunnable.isEmpty())
{
dashboardRunnable.refreshDashboard();
dashboardThread = new Thread(dashboardRunnable, "UpdateInfo");
dashboardThread.setDaemon(true);
dashboardThread.start();
}
}
@Override
public void onEvent(MaximizeEvent event) throws Exception {
Panel panel = (Panel) event.getTarget();
if (event.isMaximized()) {
prevParent = panel.getParent();
prevNext = panel.getNextSibling();
panel.detach();
for (Anchorchildren anchorChildren : columnList) {
anchorChildren.detach();
}
dashboardLayout.appendChild(maximizedHolder);
maximizedHolder.appendChild(panel);
} else {
maximizedHolder.detach();
panel.detach();
prevParent.insertBefore(panel, prevNext);
for (Anchorchildren anchorChildren : columnList) {
dashboardLayout.appendChild(anchorChildren);
}
//following 2 line needed for restore to size the panel correctly
panel.setWidth(null);
panel.setHeight(null);
}
}
/**
*
* @param page
* @param desktop
* @param appDesktop
*/
public void onSetPage(Page page, Desktop desktop, IDesktop appDesktop) {
if (dashboardThread != null && dashboardThread.isAlive()) {
dashboardRunnable.stop();
dashboardThread.interrupt();
DashboardRunnable tmp = dashboardRunnable;
dashboardRunnable = new DashboardRunnable(tmp, desktop, appDesktop);
dashboardThread = new Thread(dashboardRunnable, "UpdateInfo");
dashboardThread.setDaemon(true);
dashboardThread.start();
}
}
/**
* clean up for logout
*/
public void onLogOut() {
if (dashboardThread != null && dashboardThread.isAlive()) {
dashboardRunnable.stop();
dashboardThread.interrupt();
}
}
public void addDashboardPanel(DashboardPanel dashboardPanel) {
if (dashboardRunnable != null) {
dashboardRunnable.add(dashboardPanel);
}
}
private String stripHtml(String htmlString, boolean all) {
htmlString = htmlString
.replace("<html>", "")
.replace("</html>", "")
.replace("<body>", "")
.replace("</body>", "")
.replace("<head>", "")
.replace("</head>", "");
if (all)
htmlString = htmlString
.replace(">", "&gt;")
.replace("<", "&lt;");
return htmlString;
}
}

View File

@ -17,23 +17,14 @@
package org.adempiere.webui.desktop;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.net.URL;
import java.util.Properties;
import java.util.logging.Level;
import org.adempiere.util.ServerContext;
import org.adempiere.webui.apps.BusyDialog;
import org.adempiere.webui.apps.graph.WGraph;
import org.adempiere.webui.apps.graph.WPerformanceDetail;
import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.dashboard.DPActivities;
import org.adempiere.webui.dashboard.DashboardPanel;
import org.adempiere.webui.dashboard.DashboardRunnable;
import org.adempiere.webui.event.MenuListener;
import org.adempiere.webui.panel.HeaderPanel;
import org.adempiere.webui.panel.SidePanel;
@ -42,33 +33,22 @@ import org.adempiere.webui.session.SessionManager;
import org.adempiere.webui.util.IServerPushCallback;
import org.adempiere.webui.util.ServerPushTemplate;
import org.adempiere.webui.util.UserPreference;
import org.compiere.model.I_AD_Menu;
import org.compiere.model.MDashboardContent;
import org.compiere.model.MGoal;
import org.compiere.model.X_PA_DashboardContent;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.zk.au.out.AuScript;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.Executions;
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;
import org.zkoss.zk.ui.event.OpenEvent;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.West;
import org.zkoss.zkmax.zul.Portalchildren;
import org.zkoss.zkmax.zul.Portallayout;
import org.zkoss.zul.Html;
import org.zkoss.zul.Panel;
import org.zkoss.zul.Panelchildren;
import org.zkoss.zul.Toolbarbutton;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.West;
/**
*
@ -78,23 +58,20 @@ import org.zkoss.zul.Toolbarbutton;
* @date Mar 2, 2007
* @version $Revision: 0.10 $
*/
public class DefaultDesktop extends TabbedDesktop implements MenuListener, Serializable, EventListener, IServerPushCallback
public class DefaultDesktop extends TabbedDesktop implements MenuListener, Serializable, EventListener<Event>, IServerPushCallback
{
/**
* generated serial version ID
*/
private static final long serialVersionUID = -8203958978173990301L;
@SuppressWarnings("unused")
private static final CLogger logger = CLogger.getCLogger(DefaultDesktop.class);
private Center windowArea;
private Borderlayout layout;
private Thread dashboardThread;
private DashboardRunnable dashboardRunnable;
private int noOfNotice;
private int noOfRequest;
@ -103,9 +80,12 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
private Tabpanel homeTab;
private DashboardController dashboardController;
public DefaultDesktop()
{
super();
dashboardController = new DashboardController();
}
protected Component doCreatePart(Component parent)
@ -126,8 +106,6 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
else
layout.setPage(page);
dashboardRunnable = new DashboardRunnable(layout.getDesktop(), this);
North n = new North();
layout.appendChild(n);
n.setCollapsible(false);
@ -140,7 +118,7 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
w.setSplittable(true);
w.setTitle(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Menu")));
w.setFlex(true);
w.addEventListener(Events.ON_OPEN, new EventListener() {
w.addEventListener(Events.ON_OPEN, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
OpenEvent oe = (OpenEvent) event;
@ -201,180 +179,13 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
private void renderHomeTab()
{
homeTab.getChildren().clear();
Portallayout portalLayout = new Portallayout();
portalLayout.setWidth("100%");
portalLayout.setHeight("100%");
portalLayout.setStyle("position: absolute; overflow: auto");
homeTab.appendChild(portalLayout);
// Dashboard content
Portalchildren portalchildren = null;
int currentColumnNo = 0;
int noOfCols = 0;
int width = 0;
try
{
noOfCols = MDashboardContent.getForSessionColumnCount();
width = noOfCols <= 0 ? 100 : 100 / noOfCols;
for (final MDashboardContent dp : MDashboardContent.getForSession())
{
int columnNo = dp.getColumnNo();
if(portalchildren == null || currentColumnNo != columnNo)
{
portalchildren = new Portalchildren();
portalLayout.appendChild(portalchildren);
portalchildren.setWidth(width + "%");
portalchildren.setStyle("padding: 5px");
currentColumnNo = columnNo;
}
Panel panel = new Panel();
panel.setStyle("margin-bottom:10px");
panel.setTitle(dp.get_Translation(MDashboardContent.COLUMNNAME_Name));
String description = dp.get_Translation(MDashboardContent.COLUMNNAME_Description);
if(description != null)
panel.setTooltiptext(description);
panel.setCollapsible(dp.isCollapsible());
panel.setBorder("normal");
portalchildren.appendChild(panel);
Panelchildren content = new Panelchildren();
panel.appendChild(content);
boolean panelEmpty = true;
// HTML content
String htmlContent = dp.getHTML();
if(htmlContent != null)
{
StringBuffer result = new StringBuffer("<html><head>");
URL url = getClass().getClassLoader().getResource("org/compiere/images/PAPanel.css");
InputStreamReader ins;
try {
ins = new InputStreamReader(url.openStream());
BufferedReader bufferedReader = new BufferedReader( ins );
String cssLine;
while ((cssLine = bufferedReader.readLine()) != null)
result.append(cssLine + "\n");
} catch (IOException e1) {
logger.log(Level.SEVERE, e1.getLocalizedMessage(), e1);
}
result.append("</head><body><div class=\"content\">\n");
// if(description != null)
// result.append("<h2>" + description + "</h2>\n");
result.append(stripHtml(htmlContent, false) + "<br>\n");
result.append("</div>\n</body>\n</html>\n</html>");
Html html = new Html();
html.setContent(result.toString());
content.appendChild(html);
panelEmpty = false;
}
// Window
int AD_Window_ID = dp.getAD_Window_ID();
if(AD_Window_ID > 0)
{
int AD_Menu_ID = dp.getAD_Menu_ID();
ToolBarButton btn = new ToolBarButton(String.valueOf(AD_Menu_ID));
I_AD_Menu menu = dp.getAD_Menu();
btn.setLabel(menu.getName());
btn.setAttribute("AD_Menu_ID", AD_Menu_ID);
btn.addEventListener(Events.ON_CLICK, this);
content.appendChild(btn);
panelEmpty = false;
}
// Goal
int PA_Goal_ID = dp.getPA_Goal_ID();
if(PA_Goal_ID > 0)
{
//link to open performance detail
Toolbarbutton link = new Toolbarbutton();
link.setImage("/images/Zoom16.png");
link.setAttribute("PA_Goal_ID", PA_Goal_ID);
link.addEventListener(Events.ON_CLICK, new EventListener() {
public void onEvent(Event event) throws Exception {
int PA_Goal_ID = (Integer)event.getTarget().getAttribute("PA_Goal_ID");
MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null);
new WPerformanceDetail(goal);
}
});
content.appendChild(link);
String goalDisplay = dp.getGoalDisplay();
MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null);
WGraph graph = new WGraph(goal, 55, false, true,
!(X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)),
X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay));
content.appendChild(graph);
panelEmpty = false;
}
// ZUL file url
String url = dp.getZulFilePath();
if(url != null)
{
try {
Component component = Executions.createComponents(url, content, null);
if(component != null)
{
if (component instanceof DashboardPanel)
{
DashboardPanel dashboardPanel = (DashboardPanel) component;
if (!dashboardPanel.getChildren().isEmpty()) {
content.appendChild(dashboardPanel);
dashboardRunnable.add(dashboardPanel);
panelEmpty = false;
}
}
else
{
content.appendChild(component);
panelEmpty = false;
}
}
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to create components. zul="+url, e);
}
}
if (panelEmpty)
panel.detach();
}
}
catch (Exception e)
{
logger.log(Level.WARNING, "Failed to create dashboard content", e);
}
//
//register as 0
registerWindow(homeTab);
if (!portalLayout.getDesktop().isServerPushEnabled())
portalLayout.getDesktop().enableServerPush(true);
if (!dashboardRunnable.isEmpty())
{
dashboardRunnable.refreshDashboard();
dashboardThread = new Thread(dashboardRunnable, "UpdateInfo");
dashboardThread.setDaemon(true);
dashboardThread.start();
}
dashboardController.render(homeTab, this);
}
public void onEvent(Event event)
@ -414,15 +225,9 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
if (this.page != page) {
layout.setPage(page);
this.page = page;
if (dashboardThread != null && dashboardThread.isAlive()) {
dashboardRunnable.stop();
dashboardThread.interrupt();
DashboardRunnable tmp = dashboardRunnable;
dashboardRunnable = new DashboardRunnable(tmp, layout.getDesktop(), this);
dashboardThread = new Thread(dashboardRunnable, "UpdateInfo");
dashboardThread.setDaemon(true);
dashboardThread.start();
if (dashboardController != null) {
dashboardController.onSetPage(page, layout.getDesktop(), this);
}
}
}
@ -436,9 +241,8 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
}
public void logout() {
if (dashboardThread != null && dashboardThread.isAlive()) {
dashboardRunnable.stop();
dashboardThread.interrupt();
if (dashboardController != null) {
dashboardController.onLogOut();
}
}
@ -454,13 +258,9 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria
private void autoHideMenu() {
if (layout.getWest().isCollapsible() && !layout.getWest().isOpen())
{
//using undocumented js api, need to be retested after every version upgrade
String id = layout.getWest().getUuid() + "!real";
String btn = layout.getWest().getUuid() + "!btn";
String script = "zk.show('" + id + "', false);";
script += "$e('"+id+"')._isSlide = false;";
script += "$e('"+id+"')._lastSize = null;";
script += "$e('"+btn+"').style.display = '';";
String id = layout.getWest().getUuid();
//$n('colled') is not documented api so this might break in release after 6.0.0
String script = "jq(zk.Widget.$('"+id+"').$n('colled')).click();";
AuScript aus = new AuScript(layout.getWest(), script);
Clients.response("autoHideWest", aus);
}

View File

@ -13,26 +13,17 @@
*****************************************************************************/
package org.adempiere.webui.desktop;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.net.URL;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;
import java.util.logging.Level;
import org.adempiere.util.ServerContext;
import org.adempiere.webui.apps.BusyDialog;
import org.adempiere.webui.apps.ProcessDialog;
import org.adempiere.webui.apps.graph.WGraph;
import org.adempiere.webui.component.Accordion;
import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.dashboard.DPActivities;
import org.adempiere.webui.dashboard.DashboardPanel;
import org.adempiere.webui.dashboard.DashboardRunnable;
import org.adempiere.webui.event.MenuListener;
import org.adempiere.webui.panel.ADForm;
import org.adempiere.webui.panel.HeaderPanel;
@ -43,12 +34,7 @@ import org.adempiere.webui.util.IServerPushCallback;
import org.adempiere.webui.util.ServerPushTemplate;
import org.adempiere.webui.util.UserPreference;
import org.adempiere.webui.window.ADWindow;
import org.compiere.model.MGoal;
import org.compiere.model.MMenu;
import org.compiere.model.X_AD_Menu;
import org.compiere.model.X_PA_DashboardContent;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
@ -61,21 +47,16 @@ import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.OpenEvent;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.West;
import org.zkoss.zkmax.zul.Portalchildren;
import org.zkoss.zkmax.zul.Portallayout;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.West;
import org.zkoss.zul.Div;
import org.zkoss.zul.Html;
import org.zkoss.zul.Panel;
import org.zkoss.zul.Panelchildren;
/**
* @author hengsin
*/
public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Serializable, EventListener, IServerPushCallback
public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Serializable, EventListener<Event>, IServerPushCallback
{
private static final long serialVersionUID = -7483133591812825441L;
@ -84,16 +65,13 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria
private static final String ACTIVITIES_PATH = "/zul/activities.zul";
@SuppressWarnings("unused")
private static final CLogger logger = CLogger.getCLogger(DefaultDesktop.class);
private Center windowArea;
private Borderlayout layout;
private Thread dashboardThread;
private DashboardRunnable dashboardRunnable;
private Accordion shortcutPanel;
private int noOfNotice;
@ -104,9 +82,12 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria
private Tabpanel homeTab;
private DashboardController dashboardController;
public NavBar2Desktop()
{
super();
dashboardController = new DashboardController();
}
protected Component doCreatePart(Component parent)
@ -127,8 +108,6 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria
else
layout.setPage(page);
dashboardRunnable = new DashboardRunnable(layout.getDesktop(), this);
North n = new North();
layout.appendChild(n);
n.setCollapsible(false);
@ -141,7 +120,7 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria
w.setSplittable(true);
w.setTitle(Util.cleanAmp(Msg.getMsg(Env.getCtx(), "Menu")));
w.setFlex(true);
w.addEventListener(Events.ON_OPEN, new EventListener() {
w.addEventListener(Events.ON_OPEN, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
OpenEvent oe = (OpenEvent) event;
@ -186,7 +165,7 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria
if (component instanceof DashboardPanel)
{
DashboardPanel dashboardPanel = (DashboardPanel) component;
dashboardRunnable.add(dashboardPanel);
dashboardController.addDashboardPanel(dashboardPanel);
}
shortcutPanel.add(div, "Activities");
@ -241,179 +220,10 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria
{
homeTab.getChildren().clear();
Portallayout portalLayout = new Portallayout();
portalLayout.setWidth("100%");
portalLayout.setHeight("100%");
portalLayout.setStyle("position: absolute; overflow: auto");
homeTab.appendChild(portalLayout);
// Dashboard content
Portalchildren portalchildren = null;
int currentColumnNo = 0;
String sql = "SELECT COUNT(DISTINCT COLUMNNO) "
+ "FROM PA_DASHBOARDCONTENT "
+ "WHERE (AD_CLIENT_ID=0 OR AD_CLIENT_ID=?) AND ISACTIVE='Y'";
int noOfCols = DB.getSQLValue(null, sql,
Env.getAD_Client_ID(Env.getCtx()));
int width = noOfCols <= 0 ? 100 : 100/noOfCols;
sql = "SELECT x.*, m.AD_MENU_ID "
+ "FROM PA_DASHBOARDCONTENT x "
+ "LEFT OUTER JOIN AD_MENU m ON x.AD_WINDOW_ID=m.AD_WINDOW_ID "
+ "WHERE (x.AD_CLIENT_ID=0 OR x.AD_CLIENT_ID=?) AND x.ISACTIVE='Y' "
+ "AND x.zulfilepath not in (?, ?) "
+ "ORDER BY x.COLUMNNO, x.AD_CLIENT_ID, x.LINE ";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, Env.getAD_Client_ID(Env.getCtx()));
pstmt.setString(2, ACTIVITIES_PATH);
pstmt.setString(3, FAVOURITES_PATH);
rs = pstmt.executeQuery();
while (rs.next())
{
int columnNo = rs.getInt(X_PA_DashboardContent.COLUMNNAME_ColumnNo);
if(portalchildren == null || currentColumnNo != columnNo)
{
portalchildren = new Portalchildren();
portalLayout.appendChild(portalchildren);
portalchildren.setWidth(width + "%");
portalchildren.setStyle("padding: 5px");
currentColumnNo = columnNo;
}
Panel panel = new Panel();
panel.setStyle("margin-bottom:10px");
panel.setTitle(rs.getString(X_PA_DashboardContent.COLUMNNAME_Name));
String description = rs.getString(X_PA_DashboardContent.COLUMNNAME_Description);
if(description != null)
panel.setTooltiptext(description);
String collapsible = rs.getString(X_PA_DashboardContent.COLUMNNAME_IsCollapsible);
panel.setCollapsible(collapsible.equals("Y"));
panel.setBorder("normal");
portalchildren.appendChild(panel);
Panelchildren content = new Panelchildren();
panel.appendChild(content);
boolean panelEmpty = true;
// HTML content
String htmlContent = rs.getString(X_PA_DashboardContent.COLUMNNAME_HTML);
if(htmlContent != null)
{
StringBuffer result = new StringBuffer("<html><head>");
URL url = getClass().getClassLoader().
getResource("org/compiere/images/PAPanel.css");
InputStreamReader ins;
try {
ins = new InputStreamReader(url.openStream());
BufferedReader bufferedReader = new BufferedReader( ins );
String cssLine;
while ((cssLine = bufferedReader.readLine()) != null)
result.append(cssLine + "\n");
} catch (IOException e1) {
logger.log(Level.SEVERE, e1.getLocalizedMessage(), e1);
}
result.append("</head><body><div class=\"content\">\n");
// if(description != null)
// result.append("<h2>" + description + "</h2>\n");
result.append(stripHtml(htmlContent, false) + "<br>\n");
result.append("</div>\n</body>\n</html>\n</html>");
Html html = new Html();
html.setContent(result.toString());
content.appendChild(html);
panelEmpty = false;
}
// Window
int AD_Window_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_AD_Window_ID);
if(AD_Window_ID > 0)
{
int AD_Menu_ID = rs.getInt(X_AD_Menu.COLUMNNAME_AD_Menu_ID);
ToolBarButton btn = new ToolBarButton(String.valueOf(AD_Menu_ID));
MMenu menu = new MMenu(Env.getCtx(), AD_Menu_ID, null);
btn.setLabel(menu.getName());
btn.addEventListener(Events.ON_CLICK, this);
content.appendChild(btn);
panelEmpty = false;
}
// Goal
int PA_Goal_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_PA_Goal_ID);
if(PA_Goal_ID > 0)
{
String goalDisplay = rs.getString(X_PA_DashboardContent.COLUMNNAME_GoalDisplay);
MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null);
WGraph graph = new WGraph(goal, 55, false, true,
!(X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)),
X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay));
content.appendChild(graph);
panelEmpty = false;
}
// ZUL file url
String url = rs.getString(X_PA_DashboardContent.COLUMNNAME_ZulFilePath);
if(url != null)
{
try {
Component component = Executions.createComponents(url, content, null);
if(component != null)
{
if (component instanceof DashboardPanel)
{
DashboardPanel dashboardPanel = (DashboardPanel) component;
if (!dashboardPanel.getChildren().isEmpty()) {
content.appendChild(dashboardPanel);
dashboardRunnable.add(dashboardPanel);
panelEmpty = false;
}
}
else
{
content.appendChild(component);
panelEmpty = false;
}
}
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to create components. zul="+url, e);
}
}
if (panelEmpty)
panel.detach();
}
} catch(Exception e) {
logger.log(Level.WARNING, "Failed to create dashboard content", e);
} finally {
DB.close(rs, pstmt);
}
//
//register as 0
registerWindow(homeTab);
if (!portalLayout.getDesktop().isServerPushEnabled())
portalLayout.getDesktop().enableServerPush(true);
dashboardRunnable.refreshDashboard();
dashboardThread = new Thread(dashboardRunnable, "UpdateInfo");
dashboardThread.setDaemon(true);
dashboardThread.start();
dashboardController.render(homeTab, this);
}
public void onEvent(Event event)
@ -459,15 +269,8 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria
layout.setPage(page);
this.page = page;
}
if (dashboardThread != null && dashboardThread.isAlive()) {
dashboardRunnable.stop();
dashboardThread.interrupt();
DashboardRunnable tmp = dashboardRunnable;
dashboardRunnable = new DashboardRunnable(tmp, layout.getDesktop(), this);
dashboardThread = new Thread(dashboardRunnable, "UpdateInfo");
dashboardThread.setDaemon(true);
dashboardThread.start();
if (dashboardController != null) {
dashboardController.onSetPage(page, layout.getDesktop(), this);
}
}
@ -480,9 +283,8 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria
}
public void logout() {
if (dashboardThread != null && dashboardThread.isAlive()) {
dashboardRunnable.stop();
dashboardThread.interrupt();
if (dashboardController != null) {
dashboardController.onLogOut();
}
}

View File

@ -13,28 +13,18 @@
*****************************************************************************/
package org.adempiere.webui.desktop;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.Serializable;
import java.net.URL;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Properties;
import java.util.logging.Level;
import org.adempiere.util.ServerContext;
import org.adempiere.webui.apps.AEnv;
import org.adempiere.webui.apps.BusyDialog;
import org.adempiere.webui.apps.ProcessDialog;
import org.adempiere.webui.apps.graph.WGraph;
import org.adempiere.webui.component.Accordion;
import org.adempiere.webui.component.Tabpanel;
import org.adempiere.webui.component.ToolBarButton;
import org.adempiere.webui.dashboard.DPActivities;
import org.adempiere.webui.dashboard.DPFavourites;
import org.adempiere.webui.dashboard.DashboardPanel;
import org.adempiere.webui.dashboard.DashboardRunnable;
import org.adempiere.webui.event.MenuListener;
import org.adempiere.webui.panel.ADForm;
import org.adempiere.webui.panel.HeaderPanel;
@ -45,12 +35,7 @@ import org.adempiere.webui.util.IServerPushCallback;
import org.adempiere.webui.util.ServerPushTemplate;
import org.adempiere.webui.util.UserPreference;
import org.adempiere.webui.window.ADWindow;
import org.compiere.model.MGoal;
import org.compiere.model.MMenu;
import org.compiere.model.X_AD_Menu;
import org.compiere.model.X_PA_DashboardContent;
import org.compiere.util.CLogger;
import org.compiere.util.DB;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.zkoss.zk.au.out.AuScript;
@ -63,23 +48,18 @@ import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.OpenEvent;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.West;
import org.zkoss.zkmax.zul.Portalchildren;
import org.zkoss.zkmax.zul.Portallayout;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.West;
import org.zkoss.zul.Div;
import org.zkoss.zul.Html;
import org.zkoss.zul.Panel;
import org.zkoss.zul.Panelchildren;
import org.zkoss.zul.Treeitem;
import org.zkoss.zul.Treerow;
/**
* @author hengsin
*/
public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serializable, EventListener, IServerPushCallback
public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serializable, EventListener<Event>, IServerPushCallback
{
private static final long serialVersionUID = 4721048271543882164L;
@ -90,16 +70,13 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial
private static final String VIEWS_PATH = "/zul/views.zul";
@SuppressWarnings("unused")
private static final CLogger logger = CLogger.getCLogger(DefaultDesktop.class);
private Center windowArea;
private Borderlayout layout;
private Thread dashboardThread;
private DashboardRunnable dashboardRunnable;
private Accordion navigationPanel;
private West leftRegion;
@ -114,9 +91,12 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial
private Tabpanel homeTab;
private DashboardController dashboardController;
public NavBarDesktop()
{
super();
dashboardController = new DashboardController();
}
protected Component doCreatePart(Component parent)
@ -137,8 +117,6 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial
else
layout.setPage(page);
dashboardRunnable = new DashboardRunnable(layout.getDesktop(), this);
North n = new North();
layout.appendChild(n);
n.setCollapsible(false);
@ -151,7 +129,7 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial
leftRegion.setSplittable(true);
leftRegion.setTitle("Navigation");
leftRegion.setFlex(true);
leftRegion.addEventListener(Events.ON_OPEN, new EventListener() {
leftRegion.addEventListener(Events.ON_OPEN, new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
OpenEvent oe = (OpenEvent) event;
@ -184,7 +162,7 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial
if (component instanceof DashboardPanel)
{
DashboardPanel dashboardPanel = (DashboardPanel) component;
dashboardRunnable.add(dashboardPanel);
dashboardController.addDashboardPanel(dashboardPanel);
}
navigationPanel.add(div, "Activities");
@ -243,180 +221,10 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial
{
homeTab.getChildren().clear();
Portallayout portalLayout = new Portallayout();
portalLayout.setWidth("100%");
portalLayout.setHeight("100%");
portalLayout.setStyle("position: absolute; overflow: auto");
homeTab.appendChild(portalLayout);
// Dashboard content
Portalchildren portalchildren = null;
int currentColumnNo = 0;
String sql = "SELECT COUNT(DISTINCT COLUMNNO) "
+ "FROM PA_DASHBOARDCONTENT "
+ "WHERE (AD_CLIENT_ID=0 OR AD_CLIENT_ID=?) AND ISACTIVE='Y'";
int noOfCols = DB.getSQLValue(null, sql,
Env.getAD_Client_ID(Env.getCtx()));
int width = noOfCols <= 0 ? 100 : 100/noOfCols;
sql = "SELECT x.*, m.AD_MENU_ID "
+ "FROM PA_DASHBOARDCONTENT x "
+ "LEFT OUTER JOIN AD_MENU m ON x.AD_WINDOW_ID=m.AD_WINDOW_ID "
+ "WHERE (x.AD_CLIENT_ID=0 OR x.AD_CLIENT_ID=?) AND x.ISACTIVE='Y' "
+ "AND x.zulfilepath not in (?, ?, ?) "
+ "ORDER BY x.COLUMNNO, x.AD_CLIENT_ID, x.LINE ";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
pstmt = DB.prepareStatement(sql, null);
pstmt.setInt(1, Env.getAD_Client_ID(Env.getCtx()));
pstmt.setString(2, ACTIVITIES_PATH);
pstmt.setString(3, FAVOURITES_PATH);
pstmt.setString(4, VIEWS_PATH);
rs = pstmt.executeQuery();
while (rs.next())
{
int columnNo = rs.getInt(X_PA_DashboardContent.COLUMNNAME_ColumnNo);
if(portalchildren == null || currentColumnNo != columnNo)
{
portalchildren = new Portalchildren();
portalLayout.appendChild(portalchildren);
portalchildren.setWidth(width + "%");
portalchildren.setStyle("padding: 5px");
currentColumnNo = columnNo;
}
Panel panel = new Panel();
panel.setStyle("margin-bottom:10px");
panel.setTitle(rs.getString(X_PA_DashboardContent.COLUMNNAME_Name));
String description = rs.getString(X_PA_DashboardContent.COLUMNNAME_Description);
if(description != null)
panel.setTooltiptext(description);
String collapsible = rs.getString(X_PA_DashboardContent.COLUMNNAME_IsCollapsible);
panel.setCollapsible(collapsible.equals("Y"));
panel.setBorder("normal");
portalchildren.appendChild(panel);
Panelchildren content = new Panelchildren();
panel.appendChild(content);
boolean panelEmpty = true;
// HTML content
String htmlContent = rs.getString(X_PA_DashboardContent.COLUMNNAME_HTML);
if(htmlContent != null)
{
StringBuffer result = new StringBuffer("<html><head>");
URL url = getClass().getClassLoader().
getResource("org/compiere/images/PAPanel.css");
InputStreamReader ins;
try {
ins = new InputStreamReader(url.openStream());
BufferedReader bufferedReader = new BufferedReader( ins );
String cssLine;
while ((cssLine = bufferedReader.readLine()) != null)
result.append(cssLine + "\n");
} catch (IOException e1) {
logger.log(Level.SEVERE, e1.getLocalizedMessage(), e1);
}
result.append("</head><body><div class=\"content\">\n");
// if(description != null)
// result.append("<h2>" + description + "</h2>\n");
result.append(stripHtml(htmlContent, false) + "<br>\n");
result.append("</div>\n</body>\n</html>\n</html>");
Html html = new Html();
html.setContent(result.toString());
content.appendChild(html);
panelEmpty = false;
}
// Window
int AD_Window_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_AD_Window_ID);
if(AD_Window_ID > 0)
{
int AD_Menu_ID = rs.getInt(X_AD_Menu.COLUMNNAME_AD_Menu_ID);
ToolBarButton btn = new ToolBarButton(String.valueOf(AD_Menu_ID));
MMenu menu = new MMenu(Env.getCtx(), AD_Menu_ID, null);
btn.setLabel(menu.getName());
btn.addEventListener(Events.ON_CLICK, this);
content.appendChild(btn);
panelEmpty = false;
}
// Goal
int PA_Goal_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_PA_Goal_ID);
if(PA_Goal_ID > 0)
{
String goalDisplay = rs.getString(X_PA_DashboardContent.COLUMNNAME_GoalDisplay);
MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null);
WGraph graph = new WGraph(goal, 55, false, true,
!(X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)),
X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay));
content.appendChild(graph);
panelEmpty = false;
}
// ZUL file url
String url = rs.getString(X_PA_DashboardContent.COLUMNNAME_ZulFilePath);
if(url != null)
{
try {
Component component = Executions.createComponents(url, content, null);
if(component != null)
{
if (component instanceof DashboardPanel)
{
DashboardPanel dashboardPanel = (DashboardPanel) component;
if (!dashboardPanel.getChildren().isEmpty()) {
content.appendChild(dashboardPanel);
dashboardRunnable.add(dashboardPanel);
panelEmpty = false;
}
}
else
{
content.appendChild(component);
panelEmpty = false;
}
}
} catch (Exception e) {
logger.log(Level.WARNING, "Failed to create components. zul="+url, e);
}
}
if (panelEmpty)
panel.detach();
}
} catch(Exception e) {
logger.log(Level.WARNING, "Failed to create dashboard content", e);
} finally {
DB.close(rs, pstmt);
}
//
//register as 0
registerWindow(homeTab);
if (!portalLayout.getDesktop().isServerPushEnabled())
portalLayout.getDesktop().enableServerPush(true);
dashboardRunnable.refreshDashboard();
dashboardThread = new Thread(dashboardRunnable, "UpdateInfo");
dashboardThread.setDaemon(true);
dashboardThread.start();
dashboardController.render(homeTab, this);
}
public void onEvent(Event event)
@ -475,15 +283,9 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial
layout.setPage(page);
this.page = page;
}
if (dashboardThread != null && dashboardThread.isAlive()) {
dashboardRunnable.stop();
dashboardThread.interrupt();
DashboardRunnable tmp = dashboardRunnable;
dashboardRunnable = new DashboardRunnable(tmp, layout.getDesktop(), this);
dashboardThread = new Thread(dashboardRunnable, "UpdateInfo");
dashboardThread.setDaemon(true);
dashboardThread.start();
if (dashboardController != null) {
dashboardController.onSetPage(page, layout.getDesktop(), this);
}
}
@ -496,9 +298,8 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial
}
public void logout() {
if (dashboardThread != null && dashboardThread.isAlive()) {
dashboardRunnable.stop();
dashboardThread.interrupt();
if (dashboardController != null) {
dashboardController.onLogOut();
}
}

View File

@ -58,7 +58,7 @@ public class WAccountEditor extends WEditor implements ContextMenuListener
popupMenu = new WEditorPopupMenu(false, false, true);
popupMenu.addMenuListener(this);
addChangeLogMenu(popupMenu);
getComponent().setContext(popupMenu.getId());
getComponent().setContext(popupMenu.getUuid());
}
@Override

View File

@ -106,7 +106,7 @@ public class WDateEditor extends WEditor implements ContextMenuListener
popupMenu = new WEditorPopupMenu(false, false, isShowPreference());
popupMenu.addMenuListener(this);
addChangeLogMenu(popupMenu);
getComponent().setContext(popupMenu.getId());
getComponent().setContext(popupMenu.getUuid());
}

View File

@ -100,7 +100,7 @@ public class WDatetimeEditor extends WEditor implements ContextMenuListener
popupMenu = new WEditorPopupMenu(false, false, isShowPreference());
popupMenu.addMenuListener(this);
addChangeLogMenu(popupMenu);
getComponent().setContext(popupMenu.getId());
getComponent().setContext(popupMenu.getUuid());
}
public void onEvent(Event event)

View File

@ -43,6 +43,7 @@ import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zul.Image;
import org.zkoss.zul.Menuitem;
import org.zkoss.zul.impl.InputElement;
/**
*
@ -50,7 +51,7 @@ import org.zkoss.zul.Menuitem;
* @date Mar 11, 2007
* @version $Revision: 0.10 $
*/
public abstract class WEditor implements EventListener, PropertyChangeListener
public abstract class WEditor implements EventListener<Event>, PropertyChangeListener
{
private static final String[] lISTENER_EVENTS = {};
@ -82,6 +83,8 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
protected WEditorPopupMenu popupMenu;
private boolean tableEditor;
public WEditor(Component comp, GridField gridField) {
this(comp, gridField, -1);
}
@ -219,13 +222,13 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
{
component.addEventListener(event, this);
}
component.addEventListener(Events.ON_FOCUS, new EventListener() {
component.addEventListener(Events.ON_FOCUS, new EventListener<Event>() {
public void onEvent(Event event) throws Exception {
hasFocus = true;
}
});
component.addEventListener(Events.ON_BLUR, new EventListener() {
component.addEventListener(Events.ON_BLUR, new EventListener<Event>() {
public void onEvent(Event event) throws Exception {
hasFocus = false;
}
@ -472,7 +475,7 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
//can't stretch bandbox & datebox
if (!(getComponent() instanceof Bandbox) &&
!(getComponent() instanceof Datebox)) {
String width = "100%";
String width = tableEditor ? "98%" : "100%";
if (getComponent() instanceof Button) {
Button btn = (Button) getComponent();
String zclass = btn.getZclass();
@ -485,14 +488,18 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
}
} else if (getComponent() instanceof Image) {
Image image = (Image) getComponent();
image.setWidth("48px");
image.setHeight("48px");
image.setWidth("24px");
image.setHeight("24px");
} else {
if (getComponent() instanceof InputElement && !tableEditor) {
((InputElement)getComponent()).setHflex("1");
} else {
((HtmlBasedComponent)getComponent()).setWidth(width);
}
}
}
}
}
public boolean isHasFocus() {
return hasFocus;
@ -523,6 +530,10 @@ public abstract class WEditor implements EventListener, PropertyChangeListener
}
}
public void setTableEditor(boolean b) {
tableEditor = b;
}
/**
* @return boolean
*/

View File

@ -130,18 +130,10 @@ public class WFilenameEditor extends WEditor
// Show File Open Dialog
Media file = null;
try
{
file = Fileupload.get(true);
if (file == null)
return;
}
catch (InterruptedException e)
{
log.warning(e.getLocalizedMessage());
return;
}
// String fileName = System.getProperty("java.io.tmpdir") + System.getProperty("file.separator") + ;
// File tempFile = new File(fileName);

View File

@ -44,7 +44,7 @@ import org.zkoss.zk.ui.event.Events;
*
* This class is based on VLocation written by Jorg Janke
**/
public class WLocationEditor extends WEditor implements EventListener, PropertyChangeListener, ContextMenuListener
public class WLocationEditor extends WEditor implements EventListener<Event>, PropertyChangeListener, ContextMenuListener
{
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
@ -87,7 +87,7 @@ public class WLocationEditor extends WEditor implements EventListener, PropertyC
popupMenu = new WEditorPopupMenu(false, false, isShowPreference());
popupMenu.addMenuListener(this);
addChangeLogMenu(popupMenu);
getComponent().setContext(popupMenu.getId());
getComponent().setContext(popupMenu.getUuid());
}
@Override

View File

@ -54,7 +54,7 @@ import org.zkoss.zk.ui.event.Events;
* @date Jul 23, 2007
*/
public class WLocatorEditor extends WEditor implements EventListener, PropertyChangeListener, ContextMenuListener, IZoomableEditor
public class WLocatorEditor extends WEditor implements EventListener<Event>, PropertyChangeListener, ContextMenuListener, IZoomableEditor
{
private static final String[] LISTENER_EVENTS = {Events.ON_CLICK};
@ -114,7 +114,7 @@ public class WLocatorEditor extends WEditor implements EventListener, PropertyCh
{
popupMenu = new WEditorPopupMenu(true, true, isShowPreference());
addChangeLogMenu(popupMenu);
getComponent().setContext(popupMenu.getId());
getComponent().setContext(popupMenu.getUuid());
}
}

View File

@ -122,7 +122,7 @@ public class WNumberEditor extends WEditor implements ContextMenuListener
popupMenu = new WEditorPopupMenu(false, false, isShowPreference());
addChangeLogMenu(popupMenu);
getComponent().setContext(popupMenu.getId());
getComponent().setContext(popupMenu.getUuid());
}
/**

View File

@ -73,7 +73,7 @@ public class WPAttributeEditor extends WEditor implements ContextMenuListener
// Popup
popupMenu = new WEditorPopupMenu(true, false, false);
getComponent().getTextbox().setContext(popupMenu.getId());
getComponent().getTextbox().setContext(popupMenu.getUuid());
addChangeLogMenu(popupMenu);
getComponent().getTextbox().setReadonly(true);

View File

@ -162,7 +162,7 @@ public class WSearchEditor extends WEditor implements ContextMenuListener, Value
getComponent().setButtonImage("/images/PickOpen10.png");
}
getComponent().getTextbox().setContext(popupMenu.getId());
getComponent().getTextbox().setContext(popupMenu.getUuid());
addChangeLogMenu(popupMenu);
return;

View File

@ -137,7 +137,7 @@ public class WStringEditor extends WEditor implements ContextMenuListener
addTextEditorMenu(popupMenu);
addChangeLogMenu(popupMenu);
getComponent().setContext(popupMenu.getId());
getComponent().setContext(popupMenu.getUuid());
if (gridField.isAutocomplete()) {
Combobox combo = (Combobox)getComponent();

View File

@ -144,7 +144,7 @@ ContextMenuListener, IZoomableEditor
{
popupMenu = new WEditorPopupMenu(zoom, true, isShowPreference());
addChangeLogMenu(popupMenu);
getComponent().setContext(popupMenu.getId());
getComponent().setContext(popupMenu.getUuid());
}
}

View File

@ -101,7 +101,7 @@ public class WTimeEditor extends WEditor implements ContextMenuListener
popupMenu = new WEditorPopupMenu(false, false, isShowPreference());
popupMenu.addMenuListener(this);
addChangeLogMenu(popupMenu);
getComponent().setContext(popupMenu.getId());
getComponent().setContext(popupMenu.getUuid());
}
public void onEvent(Event event)

View File

@ -42,7 +42,7 @@ public class WUrlEditor extends WEditor implements ContextMenuListener
popupMenu = new WEditorPopupMenu(false, false, isShowPreference());
popupMenu.addMenuListener(this);
addChangeLogMenu(popupMenu);
getComponent().setContext(popupMenu.getId());
getComponent().setContext(popupMenu.getUuid());
}

View File

@ -76,7 +76,7 @@ public class WYesNoEditor extends WEditor implements ContextMenuListener
popupMenu = new WEditorPopupMenu(false, false, isShowPreference());
popupMenu.addMenuListener(this);
addChangeLogMenu(popupMenu);
getComponent().setContext(popupMenu.getId());
getComponent().setContext(popupMenu.getUuid());
}
public void onEvent(Event event)

View File

@ -20,10 +20,13 @@ package org.adempiere.webui.editor;
import java.util.List;
import org.adempiere.base.Service;
import org.adempiere.webui.component.EditorBox;
import org.adempiere.webui.component.NumberBox;
import org.adempiere.webui.factory.IEditorFactory;
import org.compiere.model.GridField;
import org.compiere.model.GridTab;
import org.compiere.util.CLogger;
import org.zkoss.zul.impl.InputElement;
/**
*

View File

@ -23,7 +23,7 @@ import org.zkoss.zk.ui.event.Event;
*/
public class ZoomEvent extends Event {
private static final String EVENT_NAME = "onZoom";
public final static String EVENT_NAME = "onZoom";
public ZoomEvent(Component target, Object data) {
super(EVENT_NAME, target, data);

View File

@ -41,9 +41,9 @@ import org.compiere.util.Msg;
import org.compiere.util.ValueNamePair;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
public class WTranslationDialog extends TranslationController implements IFormController, EventListener {

View File

@ -68,16 +68,17 @@ import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.West;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.West;
import org.zkoss.zul.Div;
import org.zkoss.zul.Group;
import org.zkoss.zul.Groupfoot;
import org.zkoss.zul.Separator;
import org.zkoss.zul.SimpleTreeNode;
import org.zkoss.zul.DefaultTreeNode;
import org.zkoss.zul.Space;
import org.zkoss.zul.Treeitem;
import org.zkoss.zul.impl.InputElement;
/**
*
@ -92,7 +93,7 @@ import org.zkoss.zul.Treeitem;
*
* @author Low Heng Sin
*/
public class ADTabpanel extends Div implements Evaluatee, EventListener,
public class ADTabpanel extends Div implements Evaluatee, EventListener<Event>,
DataStatusListener, IADTabpanel, VetoableChangeListener
{
/**
@ -487,7 +488,7 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
label.addEventListener(Events.ON_CLICK, new ZoomListener((IZoomableEditor) editor));
}
label.setContext(popupMenu.getId());
label.setContext(popupMenu.getUuid());
}
}
}
@ -813,11 +814,11 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
}
else if (event.getTarget() == treePanel.getTree()) {
Treeitem item = treePanel.getTree().getSelectedItem();
navigateTo((SimpleTreeNode)item.getValue());
navigateTo((DefaultTreeNode)item.getValue());
}
}
private void navigateTo(SimpleTreeNode value) {
private void navigateTo(DefaultTreeNode value) {
MTreeNode treeNode = (MTreeNode) value.getData();
// We Have a TreeNode
int nodeID = treeNode.getNode_ID();
@ -940,7 +941,7 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
SimpleTreeModel model = (SimpleTreeModel) treePanel.getTree().getModel();
if (treePanel.getTree().getSelectedItem() != null) {
SimpleTreeNode treeNode = (SimpleTreeNode) treePanel.getTree().getSelectedItem().getValue();
DefaultTreeNode treeNode = (DefaultTreeNode) treePanel.getTree().getSelectedItem().getValue();
MTreeNode data = (MTreeNode) treeNode.getData();
if (data.getNode_ID() == recordId) {
model.removeNode(treeNode);
@ -948,7 +949,7 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
}
}
SimpleTreeNode treeNode = model.find(null, recordId);
DefaultTreeNode treeNode = model.find(null, recordId);
if (treeNode != null) {
model.removeNode(treeNode);
}
@ -962,13 +963,13 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
String imageIndicator = (String)gridTab.getValue("Action"); // Menu - Action
//
SimpleTreeModel model = (SimpleTreeModel) treePanel.getTree().getModel();
SimpleTreeNode treeNode = model.getRoot();
DefaultTreeNode treeNode = model.getRoot();
MTreeNode root = (MTreeNode) treeNode.getData();
MTreeNode node = new MTreeNode (gridTab.getRecord_ID(), 0, name, description,
root.getNode_ID(), summary, imageIndicator, false, null);
SimpleTreeNode newNode = new SimpleTreeNode(node, new ArrayList<Object>());
DefaultTreeNode newNode = new DefaultTreeNode(node, new ArrayList<Object>());
model.addNode(newNode);
int[] path = model.getPath(model.getRoot(), newNode);
int[] path = model.getPath(newNode);
Treeitem ti = treePanel.getTree().renderItemByPath(path);
treePanel.getTree().setSelectedItem(ti);
}
@ -978,15 +979,15 @@ DataStatusListener, IADTabpanel, VetoableChangeListener
if (recordId <= 0) return;
if (treePanel.getTree().getSelectedItem() != null) {
SimpleTreeNode treeNode = (SimpleTreeNode) treePanel.getTree().getSelectedItem().getValue();
DefaultTreeNode treeNode = (DefaultTreeNode) treePanel.getTree().getSelectedItem().getValue();
MTreeNode data = (MTreeNode) treeNode.getData();
if (data.getNode_ID() == recordId) return;
}
SimpleTreeModel model = (SimpleTreeModel) treePanel.getTree().getModel();
SimpleTreeNode treeNode = model.find(null, recordId);
DefaultTreeNode treeNode = model.find(null, recordId);
if (treeNode != null) {
int[] path = model.getPath(model.getRoot(), treeNode);
int[] path = model.getPath(treeNode);
Treeitem ti = treePanel.getTree().renderItemByPath(path);
treePanel.getTree().setSelectedItem(ti);
} else {

View File

@ -40,19 +40,19 @@ import org.compiere.model.MQuery;
import org.compiere.util.CLogger;
import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.zkforge.keylistener.Keylistener;
//import org.zkforge.keylistener.Keylistener;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.HtmlBasedComponent;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.event.KeyEvent;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.East;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zkex.zul.West;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.East;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.West;
import org.zkoss.zul.Tab;
/**
@ -78,7 +78,7 @@ public class ADWindowPanel extends AbstractADWindowPanel
private East east;
private Keylistener keyListener;
// private Keylistener keyListener;
public ADWindowPanel(Properties ctx, int windowNo)
{
@ -186,14 +186,19 @@ public class ADWindowPanel extends AbstractADWindowPanel
}
if (!isEmbedded()) {
if (keyListener != null)
keyListener.detach();
keyListener = new Keylistener();
statusBar.appendChild(keyListener);
keyListener.setCtrlKeys("#f1#f2#f3#f4#f5#f6#f7#f8#f9#f10#f11#f12^f^i^n^s^d@#left@#right@#up@#down@#pgup@#pgdn@p^p@z@x#enter");
keyListener.addEventListener(Events.ON_CTRL_KEY, toolbar);
keyListener.addEventListener(Events.ON_CTRL_KEY, this);
keyListener.setAutoBlur(false);
// if (keyListener != null)
// keyListener.detach();
// keyListener = new Keylistener();
// statusBar.appendChild(keyListener);
// keyListener.setCtrlKeys("#f1#f2#f3#f4#f5#f6#f7#f8#f9#f10#f11#f12^f^i^n^s^d@#left@#right@#up@#down@#pgup@#pgdn@p^p@z@x#enter");
// keyListener.addEventListener(Events.ON_CTRL_KEY, toolbar);
// keyListener.addEventListener(Events.ON_OK, this);
// keyListener.setAutoBlur(false);
//FIXME: only work when focus is at input element
contentArea.setCtrlKeys("#f1#f2#f3#f4#f5#f6#f7#f8#f9#f10#f11#f12^f^i^n^s^d@#left@#right@#up@#down@#pgup@#pgdn@p^p@z@x");
contentArea.addEventListener(Events.ON_CTRL_KEY, toolbar);
contentArea.addEventListener(Events.ON_OK, this);
}
layout.setAttribute(ITabOnSelectHandler.ATTRIBUTE_KEY, new ITabOnSelectHandler() {
@ -244,6 +249,7 @@ public class ADWindowPanel extends AbstractADWindowPanel
* @see EventListener#onEvent(Event)
*/
public void onEvent(Event event) {
//FIXME: not working for zk6
if (Events.ON_CTRL_KEY.equals(event.getName())) {
KeyEvent keyEvent = (KeyEvent) event;
//enter == 13
@ -255,6 +261,13 @@ public class ADWindowPanel extends AbstractADWindowPanel
}
}
}
} else if (Events.ON_OK.equals(event.getName())) {
IADTabpanel panel = adTab.getSelectedTabpanel();
if (panel != null) {
if (panel.onEnterKey()) {
event.stopPropagation();
}
}
} else {
super.onEvent(event);
}

View File

@ -1850,13 +1850,9 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
AD_Process_ID,table_ID, record_ID, true);
if (dialog.isValid()) {
dialog.setPosition("center");
try {
dialog.setPage(this.getComponent().getPage());
dialog.doModal();
}
catch (InterruptedException e) {
}
}
}
/**
@ -2325,14 +2321,14 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
m_uiLocked = true;
if (Executions.getCurrent() != null)
Clients.showBusy(null, true);
Clients.showBusy(null);
else
{
try {
//acquire desktop, 2 second timeout
Executions.activate(getComponent().getDesktop(), 2000);
try {
Clients.showBusy(null, true);
Clients.showBusy(null);
} catch(Error ex){
throw ex;
} finally{
@ -2364,7 +2360,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{
updateUI(pi);
}
Clients.showBusy(null, false);
Clients.clearBusy(null);
}
else
{
@ -2376,7 +2372,7 @@ public abstract class AbstractADWindowPanel extends AbstractUIPart implements To
{
updateUI(pi);
}
Clients.showBusy(null, false);
Clients.clearBusy(null);
} catch(Error ex){
throw ex;
} finally{

View File

@ -24,9 +24,9 @@ import org.adempiere.webui.window.AboutWindow;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.West;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.West;
import org.zkoss.zul.Image;
import org.zkoss.zul.Vbox;
@ -39,11 +39,11 @@ import org.zkoss.zul.Vbox;
* @version $Revision: 0.20 $
*/
public class HeaderPanel extends Panel implements EventListener
public class HeaderPanel extends Panel implements EventListener<Event>
{
private static final long serialVersionUID = -2351317624519209484L;
private Image image = new Image();
private Image image;
public HeaderPanel()
{
@ -57,7 +57,7 @@ public class HeaderPanel extends Panel implements EventListener
UserPanel userPanel = new UserPanel();
image.setSrc(ThemeManager.getSmallLogo());
image = new Image(ThemeManager.getSmallLogo());
image.addEventListener(Events.ON_CLICK, this);
image.setStyle("cursor: pointer;");
@ -98,7 +98,7 @@ public class HeaderPanel extends Panel implements EventListener
{
AboutWindow w = new AboutWindow();
w.setPage(this.getPage());
w.doModal();
w.doHighlighted();
}
}

View File

@ -42,10 +42,10 @@ import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Separator;
import org.zkoss.zul.Vbox;

View File

@ -47,10 +47,10 @@ import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Separator;
import org.zkoss.zul.Vbox;

View File

@ -42,10 +42,10 @@ import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Separator;
import org.zkoss.zul.Vbox;

View File

@ -46,10 +46,10 @@ import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Separator;

View File

@ -41,10 +41,10 @@ import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Separator;
import org.zkoss.zul.Vbox;

View File

@ -46,10 +46,10 @@ import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Separator;

View File

@ -48,10 +48,10 @@ import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Separator;

View File

@ -47,10 +47,10 @@ import org.compiere.util.Env;
import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.zk.ui.WrongValueException;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Separator;

View File

@ -33,10 +33,10 @@ import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
/**

View File

@ -1290,4 +1290,10 @@ public abstract class InfoPanel extends Window implements EventListener, WTableM
}
}
}
@Override
public String getSortDirection(Comparator cmpr) {
return "natural";
}
} // Info

View File

@ -47,10 +47,10 @@ import org.compiere.util.Msg;
import org.compiere.util.Util;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Hbox;
import org.zkoss.zul.Separator;

View File

@ -39,6 +39,7 @@ import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Vector;
import java.util.logging.Level;
@ -77,10 +78,10 @@ import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
/**
* Search Product and return selection
@ -1422,5 +1423,4 @@ public class InfoProductPanel extends InfoPanel implements EventListener
return M_AttributeSet_ID;
}
} // InfoProduct

View File

@ -45,10 +45,10 @@ import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
/**
* Price History for BPartner/Product

View File

@ -23,6 +23,7 @@
package org.adempiere.webui.panel;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Locale;
@ -60,6 +61,7 @@ import org.compiere.util.Login;
import org.compiere.util.Msg;
import org.zkoss.lang.Strings;
import org.zkoss.util.Locales;
import org.zkoss.web.Attributes;
import org.zkoss.zhtml.Div;
import org.zkoss.zhtml.Table;
import org.zkoss.zhtml.Td;
@ -89,6 +91,7 @@ import org.zkoss.zul.Image;
*/
public class LoginPanel extends Window implements EventListener
{
private static final String ON_LOAD_TOKEN = "onLoadToken";
/**
*
*/
@ -115,10 +118,11 @@ public class LoginPanel extends Window implements EventListener
init();
this.setId("loginPanel");
AuFocus auf = new AuFocus(txtUserId);
Clients.response(auf);
BrowserToken.load(this.getUuid());
txtUserId.setEnabled(false);
txtPassword.setEnabled(false);
lstLanguage.setEnabled(false);
Events.echoEvent(ON_LOAD_TOKEN, this, null);
this.addEventListener(ON_LOAD_TOKEN, this);
}
private void init()
@ -208,7 +212,7 @@ public class LoginPanel extends Window implements EventListener
div.appendChild(pnlButtons);
this.appendChild(div);
this.addEventListener(TokenEvent.ON_USER_TOKEN, new EventListener() {
txtUserId.addEventListener(TokenEvent.ON_USER_TOKEN, new EventListener() {
@Override
public void onEvent(Event event) throws Exception {
@ -323,7 +327,7 @@ public class LoginPanel extends Window implements EventListener
{
validateLogin();
}
if (event.getName().equals(Events.ON_SELECT))
else if (event.getName().equals(Events.ON_SELECT))
{
if(eventComp.getId().equals(lstLanguage.getId())) {
String langName = (String) lstLanguage.getSelectedItem().getLabel();
@ -331,13 +335,24 @@ public class LoginPanel extends Window implements EventListener
}
}
// Elaine 2009/02/06 - initial language
if (event.getName().equals(Events.ON_CHANGE))
else if (event.getName().equals(Events.ON_CHANGE))
{
if(eventComp.getId().equals(txtUserId.getId()))
{
onUserIdChange();
}
}
else if (event.getName().equals(ON_LOAD_TOKEN))
{
BrowserToken.load(txtUserId);
txtUserId.setEnabled(true);
txtPassword.setEnabled(true);
lstLanguage.setEnabled(true);
AuFocus auf = new AuFocus(txtUserId);
Clients.response(auf);
}
//
}
@ -416,6 +431,8 @@ public class LoginPanel extends Window implements EventListener
}
}
Session currSess = Executions.getCurrent().getDesktop().getSession();
KeyNamePair rolesKNPairs[] = login.getRoles(userId, userPassword);
if(rolesKNPairs == null || rolesKNPairs.length == 0)
throw new WrongValueException("User Id or Password invalid!!!");
@ -432,19 +449,24 @@ public class LoginPanel extends Window implements EventListener
Env.setContext(ctx, UserPreference.LANGUAGE_NAME, language.getName()); // Elaine 2009/02/06
Locales.setThreadLocal(language.getLocale());
Locale locale = language.getLocale();
currSess.setAttribute(Attributes.PREFERRED_LOCALE, locale);
try {
Clients.reloadMessages(locale);
} catch (IOException e) {
logger.log(Level.WARNING, e.getLocalizedMessage(), e);
}
Locales.setThreadLocal(locale);
Clients.response("zkLocaleJavaScript", new AuScript(null, ZkFns.outLocaleJavaScript()));
String timeoutText = getUpdateTimeoutTextScript();
if (!Strings.isEmpty(timeoutText))
Clients.response("zkLocaleJavaScript2", new AuScript(null, timeoutText));
Clients.response("browserTimeoutScript", new AuScript(null, timeoutText));
}
// This temporary validation code is added to check the reported bug
// [ adempiere-ZK Web Client-2832968 ] User context lost?
// https://sourceforge.net/tracker/?func=detail&atid=955896&aid=2832968&group_id=176962
// it's harmless, if there is no bug then this must never fail
Session currSess = Executions.getCurrent().getDesktop().getSession();
currSess.setAttribute("Check_AD_User_ID", Env.getAD_User_ID(ctx));
// End of temporary code for [ adempiere-ZK Web Client-2832968 ] User context lost?

View File

@ -225,7 +225,7 @@ public class StatusBarPanel extends Panel implements EventListener, IStatusBar
showPopup();
//auto hide
String script = "setTimeout('$e(\"" + popup.getUuid() + "\").style.display = \"none\"',";
String script = "setTimeout('zk.Widget.$(\"" + popup.getUuid() + "\").$n().style.display = \"none\"',";
if (error)
script += "3500";
else
@ -258,15 +258,16 @@ public class StatusBarPanel extends Panel implements EventListener, IStatusBar
private void showPopup() {
popup.setVisible(true);
popup.setStyle(popupStyle);
if (getRoot() == null || !getRoot().isVisible() ) return;
String script = "var d = $e('" + popup.getUuid() + "');";
String script = "var d = zk.Widget.$('" + popup.getUuid() + "').$n();";
script += "d.style.display='block';d.style.visibility='hidden';";
script += "var dhs = document.defaultView.getComputedStyle(d, null).getPropertyValue('height');";
script += "var dh = parseInt(dhs, 10);";
script += "var r = $e('" + getRoot().getUuid() + "');";
script += "var r = zk.Widget.$('" + getRoot().getUuid() + "').$n();";
script += "var rhs = document.defaultView.getComputedStyle(r, null).getPropertyValue('height');";
script += "var rh = parseInt(rhs, 10);";
script += "var p = Position.cumulativeOffset(r);";
script += "var p = jq('#"+getRoot().getUuid()+"').zk.cmOffset();";
script += "d.style.top=(rh-dh-5)+'px';";
script += "d.style.left=(p[0]+1)+'px';";
script += "d.style.visibility='visible';";

View File

@ -36,7 +36,7 @@ import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zul.Div;
import org.zkoss.zul.SimpleTreeNode;
import org.zkoss.zul.DefaultTreeNode;
import org.zkoss.zul.Tree;
import org.zkoss.zul.Treeitem;
import org.zkoss.zul.event.TreeDataEvent;
@ -141,7 +141,7 @@ public class TreeSearchPanel extends Panel implements EventListener, TreeDataLis
treeNodeItemMap.put(key, treeItem);
}
private void addTreeItem(SimpleTreeNode node) {
private void addTreeItem(DefaultTreeNode node) {
Object data = node.getData();
if (data instanceof MTreeNode) {
MTreeNode mNode = (MTreeNode) data;
@ -173,7 +173,7 @@ public class TreeSearchPanel extends Panel implements EventListener, TreeDataLis
});
} else {
TreeUtils.traverse(tree.getModel(), new TreeNodeAction() {
public void run(SimpleTreeNode treeNode) {
public void run(DefaultTreeNode treeNode) {
addTreeItem(treeNode);
}
});
@ -193,9 +193,9 @@ public class TreeSearchPanel extends Panel implements EventListener, TreeDataLis
treeValues[i] = treeItem.getLabel();
treeDescription[i] = treeItem.getTooltiptext();
}
else if (value instanceof SimpleTreeNode)
else if (value instanceof DefaultTreeNode)
{
SimpleTreeNode sNode = (SimpleTreeNode) value;
DefaultTreeNode sNode = (DefaultTreeNode) value;
MTreeNode mNode = (MTreeNode) sNode.getData();
treeValues[i] = mNode.getName();
treeDescription[i] = mNode.getDescription();
@ -232,15 +232,15 @@ public class TreeSearchPanel extends Panel implements EventListener, TreeDataLis
} else if (node instanceof Treeitem) {
treeItem = (Treeitem) node;
} else {
SimpleTreeNode sNode = (SimpleTreeNode) node;
int[] path = tree.getModel().getPath(tree.getModel().getRoot(), sNode);
DefaultTreeNode sNode = (DefaultTreeNode) node;
int[] path = tree.getModel().getPath(sNode);
treeItem = tree.renderItemByPath(path);
tree.setSelectedItem(treeItem);
}
if (treeItem != null)
{
select(treeItem);
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Loading"), true);
Clients.showBusy(Msg.getMsg(Env.getCtx(), "Loading"));
Events.echoEvent("onPostSelect", this, null);
}
}
@ -250,7 +250,7 @@ public class TreeSearchPanel extends Panel implements EventListener, TreeDataLis
* don't call this directly, use internally for post selection event
*/
public void onPostSelect() {
Clients.showBusy(null, false);
Clients.clearBusy();
Event event = null;
if (eventToFire.equals(Events.ON_CLICK))
event = new Event(Events.ON_CLICK, tree.getSelectedItem().getTreerow());

View File

@ -46,10 +46,10 @@ import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zk.ui.util.Clients;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zkex.zul.North;
import org.zkoss.zkex.zul.South;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
import org.zkoss.zul.North;
import org.zkoss.zul.South;
import org.zkoss.zul.Div;
import org.zkoss.zul.Filedownload;
import org.zkoss.zul.Fileupload;
@ -159,8 +159,8 @@ public class WAttachment extends Window implements EventListener
AEnv.showWindow(this);
if (autoPreview(0, true))
{
String script = "setTimeout(\"$e('"+ preview.getUuid() + "').src = $e('" +
preview.getUuid() + "').src\", 1000)";
String script = "setTimeout(\"zk.Widget.$('"+ preview.getUuid() + "').$n().src = zk.Widget.$('" +
preview.getUuid() + "').$n().src\", 1000)";
Clients.response(new AuScript(null, script));
}
@ -513,8 +513,6 @@ public class WAttachment extends Window implements EventListener
Media media = null;
try
{
media = Fileupload.get(true);
if (media != null)
@ -528,11 +526,6 @@ public class WAttachment extends Window implements EventListener
preview.invalidate();
return;
}
}
catch (InterruptedException e)
{
log.log(Level.WARNING, e.getLocalizedMessage(), e);
}
String fileName = media.getName();
log.config(fileName);

View File

@ -136,7 +136,6 @@ public class WSchedule extends Panel implements EventListener
dayBand.setIntervalPixels(100);
dayBand.setSyncWith(hourBand.getId());
dayBand.setTimeZone(TimeZone.getDefault());
dayBand.setShowEventText(false);
// listening band scroll event
dayBand.addEventListener("onBandScroll", this);
@ -149,7 +148,6 @@ public class WSchedule extends Panel implements EventListener
mthBand.setIntervalPixels(150);
mthBand.setSyncWith(dayBand.getId());
mthBand.setTimeZone(TimeZone.getDefault());
mthBand.setShowEventText(false);
}
/**

View File

@ -23,8 +23,8 @@ import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events;
import org.zkoss.zkex.zul.Borderlayout;
import org.zkoss.zkex.zul.Center;
import org.zkoss.zul.Borderlayout;
import org.zkoss.zul.Center;
/**
*

View File

@ -359,7 +359,7 @@ public class InvoicePrint extends SvrProcess
File outFile = File.createTempFile("InvoicePrint", ".pdf");
AEnv.mergePdf(pdfList, outFile);
Clients.showBusy(null, false);
Clients.showBusy(null, null);
Window win = new SimplePDFViewer(this.getName(), new FileInputStream(outFile));
win.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);
SessionManager.getAppDesktop().showWindow(win, "center");
@ -367,7 +367,7 @@ public class InvoicePrint extends SvrProcess
log.log(Level.SEVERE, e.getLocalizedMessage(), e);
}
} else if (pdfList.size() > 0) {
Clients.showBusy(null, false);
Clients.clearBusy(null);
try {
Window win = new SimplePDFViewer(this.getName(), new FileInputStream(pdfList.get(0)));
win.setAttribute(Window.MODE_KEY, Window.MODE_HIGHLIGHTED);

View File

@ -26,6 +26,7 @@ import org.compiere.model.MSystem;
import org.compiere.model.MUser;
import org.compiere.util.CLogger;
import org.zkoss.zk.au.out.AuScript;
import org.zkoss.zk.ui.Component;
import org.zkoss.zk.ui.util.Clients;
/**
@ -78,13 +79,13 @@ public final class BrowserToken {
* load stored client side token for auto login
* @param cmpid
*/
public static void load(String cmpid) {
public static void load(Component component) {
//remember me
try
{
String home = getHomeToken();
String script = "adempiere.findUserToken('" + cmpid + "', '" + home + "');";
AuScript aus = new AuScript(null, script);
String script = "adempiere.findUserToken('" + component.getUuid() + "', '" + home + "');";
AuScript aus = new AuScript(component, script);
Clients.response("findUserToken", aus);
}
catch (Exception e)

View File

@ -17,6 +17,8 @@ import org.adempiere.exceptions.AdempiereException;
import org.zkoss.zk.ui.Desktop;
import org.zkoss.zk.ui.DesktopUnavailableException;
import org.zkoss.zk.ui.Executions;
import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener;
/**
* Zk UI update must be done in either UI thread or using server push. This class help to implement
@ -40,28 +42,24 @@ public class ServerPushTemplate {
* Execute callback in UI thread
* @param callback
*/
public void execute(IServerPushCallback callback) {
public void execute(final IServerPushCallback callback) {
boolean inUIThread = Executions.getCurrent() != null;
boolean desktopActivated = false;
try {
if (!inUIThread) {
//10 minutes timeout
if (Executions.activate(desktop, 10 * 60 * 1000)) {
desktopActivated = true;
} else {
throw new DesktopUnavailableException("Timeout activating desktop.");
}
}
EventListener<Event> task = new EventListener<Event>() {
@Override
public void onEvent(Event event) throws Exception {
callback.updateUI();
}
};
Executions.schedule(desktop, task, new Event("onExecute"));
} else {
callback.updateUI();
}
} catch (DesktopUnavailableException de) {
throw de;
} catch (Exception e) {
throw new AdempiereException("Failed to update client in server push worker thread.", e);
} finally {
if (!inUIThread && desktopActivated) {
Executions.deactivate(desktop);
}
}
}

View File

@ -13,7 +13,7 @@
*****************************************************************************/
package org.adempiere.webui.util;
import org.zkoss.zul.SimpleTreeNode;
import org.zkoss.zul.DefaultTreeNode;
/**
*
@ -26,5 +26,5 @@ public interface TreeNodeAction {
*
* @param treeNode
*/
public void run(SimpleTreeNode treeNode);
public void run(DefaultTreeNode treeNode);
}

View File

@ -15,7 +15,7 @@ package org.adempiere.webui.util;
import java.util.List;
import org.zkoss.zul.SimpleTreeNode;
import org.zkoss.zul.DefaultTreeNode;
import org.zkoss.zul.Tree;
import org.zkoss.zul.TreeModel;
import org.zkoss.zul.Treechildren;
@ -120,8 +120,8 @@ public class TreeUtils {
int count = model.getChildCount(parent);
for(int i = 0; i < count; i++) {
Object child = model.getChild(parent, i);
if (child instanceof SimpleTreeNode) {
action.run((SimpleTreeNode) child);
if (child instanceof DefaultTreeNode) {
action.run((DefaultTreeNode) child);
}
traverse(model, child, action);
}

Some files were not shown because too many files have changed in this diff Show More