[ 2435685 ] FR: Pluggable desktop presentation
This commit is contained in:
parent
61adf07b17
commit
3c95eafdf4
|
@ -21,8 +21,12 @@ import java.util.Properties;
|
|||
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.adempiere.webui.desktop.DefaultDesktop;
|
||||
import org.adempiere.webui.desktop.IDesktop;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.compiere.model.MSession;
|
||||
import org.compiere.model.MSysConfig;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Language;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
|
@ -43,6 +47,8 @@ import org.zkoss.zul.Window;
|
|||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||
* @date Feb 25, 2007
|
||||
* @version $Revision: 0.10 $
|
||||
*
|
||||
* @author hengsin
|
||||
*/
|
||||
public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
||||
{
|
||||
|
@ -50,15 +56,17 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
|||
|
||||
public static final String APP_NAME = "Adempiere ZK webUI";
|
||||
|
||||
public static final String UID = "0.2";
|
||||
public static final String UID = "1.0";
|
||||
|
||||
private WLogin loginDesktop;
|
||||
|
||||
private Desktop appDesktop;
|
||||
private IDesktop appDesktop;
|
||||
|
||||
private ClientInfo clientInfo;
|
||||
|
||||
private String langSession;
|
||||
|
||||
private static final CLogger logger = CLogger.getCLogger(AdempiereWebUI.class);
|
||||
|
||||
public AdempiereWebUI()
|
||||
{
|
||||
|
@ -128,12 +136,12 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
|||
Env.setContext(ctx, "#ShowAdvanced", true);
|
||||
|
||||
IDesktop d = (IDesktop) currSess.getAttribute("application.desktop");
|
||||
if (d != null && d instanceof Desktop)
|
||||
if (d != null && d instanceof IDesktop)
|
||||
{
|
||||
ExecutionCarryOver eco = (ExecutionCarryOver) currSess.getAttribute("execution.carryover");
|
||||
if (eco != null) {
|
||||
//try restore
|
||||
appDesktop = (Desktop) d;
|
||||
appDesktop = (IDesktop) d;
|
||||
|
||||
ExecutionCarryOver current = new ExecutionCarryOver(this.getPage().getDesktop());
|
||||
ExecutionCtrl ctrl = ExecutionsCtrl.getCurrentCtrl();
|
||||
|
@ -162,7 +170,7 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
|||
if (appDesktop == null)
|
||||
{
|
||||
//create new desktop
|
||||
appDesktop = new Desktop();
|
||||
createDesktop();
|
||||
appDesktop.setClientInfo(clientInfo);
|
||||
appDesktop.createPart(this.getPage());
|
||||
currSess.setAttribute("application.desktop", appDesktop);
|
||||
|
@ -171,7 +179,28 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
private void createDesktop()
|
||||
{
|
||||
appDesktop = null;
|
||||
String className = MSysConfig.getValue(IDesktop.CLASS_NAME_KEY);
|
||||
if ( className != null && className.trim().length() > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
Class<?> clazz = this.getClass().getClassLoader().loadClass(className);
|
||||
appDesktop = (IDesktop) clazz.newInstance();
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
logger.warning("Failed to instantiate desktop. Class=" + className);
|
||||
}
|
||||
}
|
||||
//fallback to default
|
||||
if (appDesktop == null)
|
||||
appDesktop = new DefaultDesktop();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.adempiere.webui.IWebClient#logout()
|
||||
*/
|
||||
public void logout()
|
||||
|
@ -190,7 +219,7 @@ public class AdempiereWebUI extends Window implements EventListener, IWebClient
|
|||
Executions.sendRedirect("index.zul");
|
||||
}
|
||||
|
||||
public Desktop getAppDeskop()
|
||||
public IDesktop getAppDeskop()
|
||||
{
|
||||
return appDesktop;
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,7 +0,0 @@
|
|||
package org.adempiere.webui;
|
||||
|
||||
public interface IDashboardPanel {
|
||||
|
||||
public void updateInfo();
|
||||
|
||||
}
|
|
@ -1,125 +0,0 @@
|
|||
package org.adempiere.webui;
|
||||
|
||||
import org.adempiere.webui.apps.ProcessDialog;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.panel.ADForm;
|
||||
import org.adempiere.webui.window.ADWindow;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.util.WebDoc;
|
||||
|
||||
public interface IDesktop {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return ClientInfo
|
||||
*/
|
||||
public ClientInfo getClientInfo();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nodeId
|
||||
*/
|
||||
public void onMenuSelected(int nodeId);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param window
|
||||
* @return windowNo
|
||||
*/
|
||||
public int registerWindow(Object window);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param WindowNo
|
||||
* @return Object
|
||||
*/
|
||||
public Object findWindow(int WindowNo);
|
||||
|
||||
/**
|
||||
* close active window
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean closeActiveWindow();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param windowNo
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean closeWindow(int windowNo);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param url
|
||||
* @param closeable
|
||||
*/
|
||||
public void showURL(String url, boolean closeable);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param doc
|
||||
* @param string
|
||||
* @param closeable
|
||||
*/
|
||||
public void showURL(WebDoc doc, String string, boolean closeable);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param win
|
||||
*/
|
||||
public void showWindow(Window win);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param win
|
||||
* @param position
|
||||
*/
|
||||
public void showWindow(Window win, String position);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param window_ID
|
||||
* @param query
|
||||
*/
|
||||
public void showZoomWindow(int window_ID, MQuery query);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param windowNo
|
||||
*/
|
||||
public void unregisterWindow(int windowNo);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param processId
|
||||
* @param soTrx
|
||||
* @return ProcessDialog
|
||||
*/
|
||||
public ProcessDialog openProcessDialog(int processId, boolean soTrx);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param formId
|
||||
* @return ADWindow
|
||||
*/
|
||||
public ADForm openForm(int formId);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param windowId
|
||||
* @return ADWindow
|
||||
*/
|
||||
public ADWindow openWindow(int windowId);
|
||||
|
||||
/**
|
||||
* Open operating system task window
|
||||
* @param task_ID
|
||||
*/
|
||||
public void openTask(int task_ID);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param workflow_ID
|
||||
*/
|
||||
public void openWorkflow(int workflow_ID);
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package org.adempiere.webui;
|
||||
|
||||
import org.adempiere.webui.desktop.IDesktop;
|
||||
|
||||
public interface IWebClient {
|
||||
|
||||
public void loginCompleted();
|
||||
|
|
|
@ -11,11 +11,11 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.Desktop;
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.Panel;
|
||||
import org.adempiere.webui.component.VerticalBox;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.desktop.IDesktop;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
import org.adempiere.webui.window.SimplePDFViewer;
|
||||
|
@ -94,7 +94,7 @@ public class ProcessDialog extends Window implements EventListener//, ASyncProce
|
|||
log.info("Process=" + AD_Process_ID );
|
||||
m_ctx = Env.getCtx();;
|
||||
m_WindowNo = SessionManager.getAppDesktop().registerWindow(this);
|
||||
this.setAttribute(Desktop.WINDOWNO_ATTRIBUTE, m_WindowNo);
|
||||
this.setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, m_WindowNo);
|
||||
m_AD_Process_ID = AD_Process_ID;
|
||||
Env.setContext(Env.getCtx(), m_WindowNo, "IsSOTrx", isSOTrx ? "Y" : "N");
|
||||
try
|
||||
|
|
|
@ -0,0 +1,159 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Low Heng Sin *
|
||||
* Copyright (C) 2008 Idalica Corporation *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.component;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.Div;
|
||||
import org.zkoss.zul.Vbox;
|
||||
|
||||
/**
|
||||
* A custom accoridon implementation using borderlayout
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class Accordion extends Borderlayout implements EventListener {
|
||||
|
||||
private static final long serialVersionUID = 5898232602746332810L;
|
||||
|
||||
private Vbox southBox;
|
||||
private Vbox northBox;
|
||||
|
||||
private List<String> labelList = new ArrayList<String>();
|
||||
private List<ToolBarButton> buttonList = new ArrayList<ToolBarButton>();
|
||||
private List<Component> componentList = new ArrayList<Component>();
|
||||
private int selectedIndex = -1;
|
||||
|
||||
public Accordion() {
|
||||
North north = new North();
|
||||
appendChild(north);
|
||||
northBox = new Vbox();
|
||||
northBox.setWidth("100%");
|
||||
north.appendChild(northBox);
|
||||
north.setSplittable(false);
|
||||
north.setCollapsible(false);
|
||||
|
||||
Center center = new Center();
|
||||
center.setFlex(true);
|
||||
appendChild(new Center());
|
||||
|
||||
South south = new South();
|
||||
appendChild(south);
|
||||
southBox = new Vbox();
|
||||
southBox.setWidth("100%");
|
||||
south.appendChild(southBox);
|
||||
south.setSplittable(false);
|
||||
south.setCollapsible(false);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param component
|
||||
* @param label
|
||||
*/
|
||||
public void add(Component component, String label) {
|
||||
ToolBarButton button = new ToolBarButton();
|
||||
button.setLabel(label);
|
||||
button.addEventListener(Events.ON_CLICK, this);
|
||||
button.setWidth("100%");
|
||||
|
||||
Div div = new Div();
|
||||
div.setClass("z-center-header");
|
||||
div.appendChild(button);
|
||||
northBox.appendChild(div);
|
||||
|
||||
labelList.add(label);
|
||||
buttonList.add(button);
|
||||
componentList.add(component);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param index
|
||||
* @param label
|
||||
*/
|
||||
public void setLabel(int index, String label) {
|
||||
labelList.set(index, label);
|
||||
buttonList.get(index).setLabel(label);
|
||||
if (selectedIndex == index) {
|
||||
getCenter().setTitle(label);
|
||||
}
|
||||
}
|
||||
|
||||
public void onEvent(Event event) throws Exception {
|
||||
if (Events.ON_CLICK.equals(event.getName()) && event.getTarget() instanceof ToolBarButton) {
|
||||
ToolBarButton button = (ToolBarButton) event.getTarget();
|
||||
String label = button.getLabel();
|
||||
|
||||
int index = labelList.indexOf(label);
|
||||
if (index >= 0) {
|
||||
setSelectedIndex(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param index
|
||||
*/
|
||||
public void setSelectedIndex(int index) {
|
||||
selectedIndex = index;
|
||||
render(index);
|
||||
}
|
||||
|
||||
private void render(int index) {
|
||||
northBox.getChildren().clear();
|
||||
southBox.getChildren().clear();
|
||||
getCenter().getChildren().clear();
|
||||
|
||||
for (int i = 0; i < index; i++) {
|
||||
Div div = new Div();
|
||||
div.setClass("z-center-header");
|
||||
div.appendChild(buttonList.get(i));
|
||||
div.setWidth("100%");
|
||||
northBox.appendChild(div);
|
||||
}
|
||||
|
||||
getCenter().setTitle(labelList.get(index));
|
||||
getCenter().appendChild(componentList.get(index));
|
||||
|
||||
for (int i = index + 1; i < labelList.size(); i++) {
|
||||
Div div = new Div();
|
||||
div.setClass("z-center-header");
|
||||
div.appendChild(buttonList.get(i));
|
||||
div.setWidth("100%");
|
||||
southBox.appendChild(div);
|
||||
}
|
||||
|
||||
this.invalidate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param index
|
||||
* @param tooltiptext
|
||||
*/
|
||||
public void setTooltiptext(int index, String tooltiptext) {
|
||||
buttonList.get(index).setTooltiptext(tooltiptext);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Elaine Tan *
|
||||
* Copyright (C) 2008 Idalica Corporation *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
|
@ -10,7 +11,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui;
|
||||
package org.adempiere.webui.dashboard;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -161,7 +162,7 @@ public class DPActivities extends DashboardPanel implements EventListener {
|
|||
return count;
|
||||
}
|
||||
|
||||
public void updateInfo()
|
||||
public void refresh()
|
||||
{
|
||||
int noOfNotice = getNoticeCount();
|
||||
int noOfRequest = getRequestCount();
|
|
@ -1,5 +1,6 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Elaine Tan *
|
||||
* Copyright (C) 2008 Idalica Corporation *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
|
@ -10,7 +11,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui;
|
||||
package org.adempiere.webui.dashboard;
|
||||
|
||||
import org.zkoss.zul.Iframe;
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Elaine Tan *
|
||||
* Copyright (C) 2008 Idalica Corporation
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
|
@ -10,7 +11,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui;
|
||||
package org.adempiere.webui.dashboard;
|
||||
|
||||
import java.util.Enumeration;
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Elaine Tan *
|
||||
* Copyright (C) 2008 Idalica Corporation
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
|
@ -10,7 +11,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui;
|
||||
package org.adempiere.webui.dashboard;
|
||||
|
||||
import org.adempiere.webui.apps.graph.WPAPanel;
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Elaine Tan *
|
||||
* Copyright (C) 2008 Idalica Corporation
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
|
@ -10,7 +11,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui;
|
||||
package org.adempiere.webui.dashboard;
|
||||
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.component.ToolBarButton;
|
|
@ -1,5 +1,6 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Elaine Tan *
|
||||
* Copyright (C) 2008 Idalica Corporation *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
|
@ -10,7 +11,7 @@
|
|||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui;
|
||||
package org.adempiere.webui.dashboard;
|
||||
|
||||
import org.adempiere.webui.component.Window;
|
||||
|
||||
|
@ -30,7 +31,7 @@ public abstract class DashboardPanel extends Window implements IDashboardPanel {
|
|||
* Desktop.UpdateInfoRunnable will call this method at a certain interval.
|
||||
* Subclass should overwrite this method to support server push.
|
||||
*/
|
||||
public void updateInfo() {
|
||||
public void refresh() {
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,83 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Low Heng Sin *
|
||||
* Copyright (C) 2008 Idalica Corporation *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.dashboard;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.webui.desktop.IDesktop;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.zkoss.zk.ui.Desktop;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
|
||||
public class DashboardRunnable implements Runnable {
|
||||
private Desktop desktop;
|
||||
private boolean stop = false;
|
||||
private List<DashboardPanel> dashboardPanels;
|
||||
private IDesktop appDesktop;
|
||||
|
||||
private static final CLogger logger = CLogger.getCLogger(DashboardRunnable.class);
|
||||
|
||||
public DashboardRunnable(Desktop desktop, IDesktop appDesktop) {
|
||||
this.desktop = desktop;
|
||||
this.appDesktop = appDesktop;
|
||||
|
||||
dashboardPanels = new ArrayList<DashboardPanel>();
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
while(!stop) {
|
||||
try {
|
||||
Thread.sleep(60000); // Update every one minutes
|
||||
} catch (InterruptedException e1) {
|
||||
if (stop) break;
|
||||
}
|
||||
|
||||
try {
|
||||
// get full control of desktop
|
||||
Executions.activate(desktop);
|
||||
try {
|
||||
refreshDashboard();
|
||||
} catch (Error ex) {
|
||||
logger.log(Level.WARNING, "UpdateInfo Thread error="+ex.getLocalizedMessage(), ex);
|
||||
break;
|
||||
} finally {
|
||||
// release full control of desktop
|
||||
Executions.deactivate(desktop);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
logger.log(Level.WARNING, "UpdateInfo Thread error="+e.getLocalizedMessage(), e);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void refreshDashboard()
|
||||
{
|
||||
for(int i = 0; i < dashboardPanels.size(); i++)
|
||||
dashboardPanels.get(i).refresh();
|
||||
|
||||
appDesktop.onServerPush();
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
stop = true;
|
||||
}
|
||||
|
||||
public void add(DashboardPanel dashboardPanel) {
|
||||
dashboardPanels.add(dashboardPanel);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Elaine Tan *
|
||||
* Copyright (C) 2008 Idalica Corporation
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.dashboard;
|
||||
|
||||
/**
|
||||
* Interface for dashboard panel
|
||||
* @author Elaine
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public interface IDashboardPanel {
|
||||
|
||||
/**
|
||||
* Refresh content of panel
|
||||
*/
|
||||
public void refresh();
|
||||
|
||||
}
|
|
@ -0,0 +1,393 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Low Heng Sin *
|
||||
* Copyright (C) 2008 Idalica Corporation *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.desktop;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.apps.graph.BarGraphColumn;
|
||||
import org.adempiere.webui.ClientInfo;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.apps.graph.WBarGraph;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.exception.ApplicationException;
|
||||
import org.adempiere.webui.part.AbstractUIPart;
|
||||
import org.compiere.model.MAchievement;
|
||||
import org.compiere.model.MGoal;
|
||||
import org.compiere.model.MMeasureCalc;
|
||||
import org.compiere.model.MMenu;
|
||||
import org.compiere.model.MProjectType;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.MRequestType;
|
||||
import org.compiere.model.MRole;
|
||||
import org.compiere.util.CLogger;
|
||||
import org.compiere.util.Env;
|
||||
import org.zkoss.zhtml.Button;
|
||||
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.zul.Panelchildren;
|
||||
|
||||
/**
|
||||
* Base class for desktop implementation
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractDesktop extends AbstractUIPart implements IDesktop {
|
||||
|
||||
private transient ClientInfo clientInfo;
|
||||
|
||||
private List<Object> windows = null;
|
||||
|
||||
private MGoal[] m_goals = null;
|
||||
|
||||
private List<MQuery> queryZoom = null;
|
||||
|
||||
private static final CLogger logger = CLogger.getCLogger(AbstractDesktop.class);
|
||||
|
||||
private static final String ZOOM_KEY = "queryZoom";
|
||||
|
||||
public AbstractDesktop() {
|
||||
m_goals = MGoal.getUserGoals(Env.getCtx(), Env.getAD_User_ID(Env.getCtx()));
|
||||
windows = new ArrayList<Object>();
|
||||
queryZoom = new ArrayList<MQuery>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Event listener for menu item selection.
|
||||
* Identifies the action associated with the selected
|
||||
* menu item and acts accordingly.
|
||||
*
|
||||
* @param menuId Identifier for the selected menu item
|
||||
*
|
||||
* @throws ApplicationException If the selected menu action has yet
|
||||
* to be implemented
|
||||
*/
|
||||
public void onMenuSelected(int menuId)
|
||||
{
|
||||
MMenu menu = new MMenu(Env.getCtx(), menuId, null);
|
||||
if(menu == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(menu.getAction().equals(MMenu.ACTION_Window))
|
||||
{
|
||||
openWindow(menu.getAD_Window_ID());
|
||||
}
|
||||
else if(menu.getAction().equals(MMenu.ACTION_Process) ||
|
||||
menu.getAction().equals(MMenu.ACTION_Report))
|
||||
{
|
||||
openProcessDialog(menu.getAD_Process_ID(), menu.isSOTrx());
|
||||
}
|
||||
else if(menu.getAction().equals(MMenu.ACTION_Form))
|
||||
{
|
||||
openForm(menu.getAD_Form_ID());
|
||||
}
|
||||
else if(menu.getAction().equals(MMenu.ACTION_WorkFlow))
|
||||
{
|
||||
openWorkflow(menu.getAD_Workflow_ID());
|
||||
}
|
||||
else if(menu.getAction().equals(MMenu.ACTION_Task))
|
||||
{
|
||||
openTask(menu.getAD_Task_ID());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ApplicationException("Menu Action not yet implemented: " + menu.getAction());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return clientInfo
|
||||
*/
|
||||
public ClientInfo getClientInfo() {
|
||||
return clientInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param clientInfo
|
||||
*/
|
||||
public void setClientInfo(ClientInfo clientInfo) {
|
||||
this.clientInfo = clientInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param win
|
||||
*/
|
||||
public int registerWindow(Object win) {
|
||||
int retValue = windows.size();
|
||||
windows.add(win);
|
||||
return retValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param WindowNo
|
||||
*/
|
||||
public void unregisterWindow(int WindowNo) {
|
||||
if (WindowNo < windows.size())
|
||||
windows.set(WindowNo, null);
|
||||
Env.clearWinContext(WindowNo);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param WindowNo
|
||||
* @return Object
|
||||
*/
|
||||
public Object findWindow(int WindowNo) {
|
||||
if (WindowNo < windows.size())
|
||||
return windows.get(WindowNo);
|
||||
else
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param win
|
||||
*/
|
||||
public void showWindow(Window win)
|
||||
{
|
||||
String pos = win.getPosition();
|
||||
this.showWindow(win, pos);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param win
|
||||
* @param pos
|
||||
*/
|
||||
public void showWindow(Window win, String pos)
|
||||
{
|
||||
win.setPage(page);
|
||||
Object objMode = win.getAttribute(Window.MODE_KEY);
|
||||
|
||||
String mode = Window.MODE_MODAL;
|
||||
|
||||
if (objMode != null)
|
||||
{
|
||||
mode = objMode.toString();
|
||||
}
|
||||
|
||||
if (Window.MODE_MODAL.equals(mode))
|
||||
{
|
||||
showModal(win);
|
||||
}
|
||||
else if (Window.MODE_POPUP.equals(mode))
|
||||
{
|
||||
showPopup(win, pos);
|
||||
}
|
||||
else if (Window.MODE_OVERLAPPED.equals(mode))
|
||||
{
|
||||
showOverlapped(win, pos);
|
||||
}
|
||||
else if (Window.MODE_EMBEDDED.equals(mode))
|
||||
{
|
||||
showEmbedded(win);
|
||||
}
|
||||
else if (Window.MODE_HIGHLIGHTED.equals(mode))
|
||||
{
|
||||
showHighlighted(win, pos);
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void showEmbedded(Window win);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param win
|
||||
*/
|
||||
protected void showModal(Window win)
|
||||
{
|
||||
try
|
||||
{
|
||||
win.doModal();
|
||||
}
|
||||
catch(InterruptedException e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param win
|
||||
* @param position
|
||||
*/
|
||||
protected void showPopup(Window win, String position)
|
||||
{
|
||||
if (position == null)
|
||||
win.setPosition("center");
|
||||
else
|
||||
win.setPosition(position);
|
||||
|
||||
win.doPopup();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param win
|
||||
* @param position
|
||||
*/
|
||||
protected void showOverlapped(Window win, String position)
|
||||
{
|
||||
if (position == null)
|
||||
win.setPosition("center");
|
||||
else
|
||||
win.setPosition(position);
|
||||
|
||||
win.doOverlapped();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param win
|
||||
* @param position
|
||||
*/
|
||||
protected void showHighlighted(Window win, String position)
|
||||
{
|
||||
if (position == null)
|
||||
win.setPosition("center");
|
||||
else
|
||||
win.setPosition(position);
|
||||
|
||||
win.doHighlighted();
|
||||
}
|
||||
|
||||
protected String renderGoals(int AD_Table_ID, Panelchildren panel)
|
||||
{
|
||||
String output = "";
|
||||
if (m_goals == null)
|
||||
return output;
|
||||
|
||||
for (int i = 0; i < m_goals.length; i++)
|
||||
{
|
||||
MMeasureCalc mc = MMeasureCalc.get(Env.getCtx(), m_goals[i].getMeasure().getPA_MeasureCalc_ID());
|
||||
|
||||
if (AD_Table_ID == m_goals[i].getPA_Goal_ID())
|
||||
{
|
||||
output += "<table class=\"dataGrid\"><tr>\n<th colspan=\"3\" class=\"label\"><b>"
|
||||
+ m_goals[i].getName() + "</b></th></tr>\n";
|
||||
output += "<tr><td class=\"label\">Target</td><td colspan=\"2\" class=\"tdcontent\">"
|
||||
+ m_goals[i].getMeasureTarget() + "</td></tr>\n";
|
||||
output += "<tr><td class=\"label\">Actual</td><td colspan=\"2\" class=\"tdcontent\">"
|
||||
+ m_goals[i].getMeasureActual() + "</td></tr>\n";
|
||||
|
||||
WBarGraph barPanel = new WBarGraph(m_goals[i]);
|
||||
BarGraphColumn[] bList = barPanel.getBarGraphColumnList();
|
||||
MQuery query = null;
|
||||
output += "<tr><td rowspan=\"" + bList.length
|
||||
+ "\" class=\"label\" valign=\"top\">"
|
||||
+ m_goals[i].getXAxisText() + "</td>\n";
|
||||
|
||||
for (int k = 0; k < bList.length; k++)
|
||||
{
|
||||
BarGraphColumn bgc = bList[k];
|
||||
if (k > 0)
|
||||
output += "<tr>";
|
||||
if (bgc.getAchievement() != null) // Single Achievement
|
||||
{
|
||||
MAchievement a = bgc.getAchievement();
|
||||
query = MQuery.getEqualQuery("PA_Measure_ID", a.getPA_Measure_ID());
|
||||
}
|
||||
else if (bgc.getGoal() != null) // Multiple Achievements
|
||||
{
|
||||
MGoal goal = bgc.getGoal();
|
||||
query = MQuery.getEqualQuery("PA_Measure_ID", goal.getPA_Measure_ID());
|
||||
}
|
||||
else if (bgc.getMeasureCalc() != null) // Document
|
||||
{
|
||||
mc = bgc.getMeasureCalc();
|
||||
query = mc.getQuery(m_goals[i].getRestrictions(false), bgc.getMeasureDisplay(),
|
||||
bgc.getDate(), MRole.getDefault()); // logged in role
|
||||
}
|
||||
else if (bgc.getProjectType() != null) // Document
|
||||
{
|
||||
MProjectType pt = bgc.getProjectType();
|
||||
query = pt.getQuery(m_goals[i].getRestrictions(false), bgc.getMeasureDisplay(),
|
||||
bgc.getDate(), bgc.getID(), MRole.getDefault()); // logged in role
|
||||
}
|
||||
else if (bgc.getRequestType() != null) // Document
|
||||
{
|
||||
MRequestType rt = bgc.getRequestType();
|
||||
query = rt.getQuery(m_goals[i].getRestrictions(false), bgc.getMeasureDisplay(),
|
||||
bgc.getDate(), bgc.getID(), MRole.getDefault()); // logged in role
|
||||
}
|
||||
output += "<td class=\"tdcontent\">" + bgc.getLabel()
|
||||
+ "</td><td class=\"tdcontent\">";
|
||||
if (query != null) {
|
||||
Button btn = new Button();
|
||||
btn.setId(String.valueOf(ZOOM_KEY + queryZoom.size()));
|
||||
btn.addEventListener(Events.ON_CLICK, new EventListener() {
|
||||
public void onEvent(Event event) throws Exception {
|
||||
Component comp = event.getTarget();
|
||||
String id = comp.getId();
|
||||
if(id.startsWith(ZOOM_KEY))
|
||||
{
|
||||
String ss = id.substring(ZOOM_KEY.length());
|
||||
int index = Integer.parseInt(String.valueOf(ss));
|
||||
if ((index >= 0) && (index < queryZoom.size()))
|
||||
AEnv.zoom(queryZoom.get(index));
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
btn.setVisible(false);
|
||||
panel.appendChild(btn);
|
||||
|
||||
output += "<a class=\"hrefZoom\" id=\"" + ZOOM_KEY +
|
||||
+ queryZoom.size()
|
||||
+ "\" href=\"javascript:;\" onclick=\"$('" + btn.getUuid() + "').click()\">"
|
||||
+ bgc.getValue()
|
||||
+ "</a><br>\n";
|
||||
|
||||
queryZoom.add(query);
|
||||
} else {
|
||||
logger.info("Nothing to zoom to - " + bgc);
|
||||
output += bgc.getValue();
|
||||
}
|
||||
output += "</td></tr>";
|
||||
}
|
||||
output += "</tr>"
|
||||
+ "<tr><td colspan=\"3\">"
|
||||
+ m_goals[i].getDescription()
|
||||
+ "<br>"
|
||||
+ stripHtml(m_goals[i].getColorSchema()
|
||||
.getDescription(), true) + "</td></tr>"
|
||||
+ "</table>\n";
|
||||
bList = null;
|
||||
barPanel = null;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
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(">", ">")
|
||||
.replace("<", "<");
|
||||
return htmlString;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,385 @@
|
|||
/******************************************************************************
|
||||
* Product: Posterita Ajax UI *
|
||||
* Copyright (C) 2007 Posterita Ltd. All Rights Reserved. *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
* For the text or an alternative of this public license, you may reach us *
|
||||
* Posterita Ltd., 3, Draper Avenue, Quatre Bornes, Mauritius *
|
||||
* or via info@posterita.org or http://www.posterita.org/ *
|
||||
*****************************************************************************/
|
||||
|
||||
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.logging.Level;
|
||||
|
||||
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;
|
||||
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.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.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;
|
||||
|
||||
/**
|
||||
*
|
||||
* Default desktop implementation.
|
||||
* @author <a href="mailto:agramdass@gmail.com">Ashley G Ramdass</a>
|
||||
* @author <a href="mailto:hengsin@gmail.com">Low Heng Sin</a>
|
||||
* @date Mar 2, 2007
|
||||
* @version $Revision: 0.10 $
|
||||
*/
|
||||
public class DefaultDesktop extends TabbedDesktop implements MenuListener, Serializable, EventListener
|
||||
{
|
||||
|
||||
private static final long serialVersionUID = 9056511175189603883L;
|
||||
|
||||
private static final CLogger logger = CLogger.getCLogger(DefaultDesktop.class);
|
||||
|
||||
private Center windowArea;
|
||||
|
||||
private Borderlayout layout;
|
||||
|
||||
private Thread dashboardThread;
|
||||
|
||||
private DashboardRunnable dashboardRunnable;
|
||||
|
||||
public DefaultDesktop()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
protected Component doCreatePart(Component parent)
|
||||
{
|
||||
SidePanel pnlSide = new SidePanel();
|
||||
HeaderPanel pnlHead = new HeaderPanel();
|
||||
|
||||
pnlSide.getMenuPanel().addMenuListener(this);
|
||||
|
||||
layout = new Borderlayout();
|
||||
if (parent != null)
|
||||
{
|
||||
layout.setParent(parent);
|
||||
layout.setWidth("100%");
|
||||
layout.setHeight("100%");
|
||||
layout.setStyle("position: absolute");
|
||||
}
|
||||
else
|
||||
layout.setPage(page);
|
||||
|
||||
dashboardRunnable = new DashboardRunnable(layout.getDesktop(), this);
|
||||
|
||||
North n = new North();
|
||||
layout.appendChild(n);
|
||||
n.setCollapsible(false);
|
||||
pnlHead.setParent(n);
|
||||
|
||||
West w = new West();
|
||||
layout.appendChild(w);
|
||||
w.setWidth("300px");
|
||||
w.setCollapsible(true);
|
||||
w.setSplittable(true);
|
||||
w.setTitle("Menu");
|
||||
w.setFlex(true);
|
||||
pnlSide.setParent(w);
|
||||
|
||||
windowArea = new Center();
|
||||
windowArea.setParent(layout);
|
||||
windowArea.setFlex(true);
|
||||
|
||||
windowContainer.createPart(windowArea);
|
||||
|
||||
createHomeTab();
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
private void createHomeTab()
|
||||
{
|
||||
Tabpanel homeTab = new Tabpanel();
|
||||
windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false);
|
||||
|
||||
Portallayout portalLayout = new Portallayout();
|
||||
portalLayout.setWidth("100%");
|
||||
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' "
|
||||
+ "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()));
|
||||
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)
|
||||
{
|
||||
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");
|
||||
result.append(renderGoals(PA_Goal_ID, content));
|
||||
result.append("</div>\n</body>\n</html>\n</html>");
|
||||
|
||||
Html html = new Html();
|
||||
html.setContent(result.toString());
|
||||
content.appendChild(html);
|
||||
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();
|
||||
}
|
||||
|
||||
public void onEvent(Event event)
|
||||
{
|
||||
Component comp = event.getTarget();
|
||||
String eventName = event.getName();
|
||||
|
||||
if(eventName.equals(Events.ON_CLICK))
|
||||
{
|
||||
if(comp instanceof ToolBarButton)
|
||||
{
|
||||
ToolBarButton btn = (ToolBarButton) comp;
|
||||
|
||||
int menuId = 0;
|
||||
try
|
||||
{
|
||||
menuId = Integer.valueOf(btn.getName());
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
if(menuId > 0) onMenuSelected(menuId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onServerPush()
|
||||
{
|
||||
int noOfNotice = DPActivities.getNoticeCount();
|
||||
int noOfRequest = DPActivities.getRequestCount();
|
||||
int noOfWorkflow = DPActivities.getWorkflowCount();
|
||||
int total = noOfNotice + noOfRequest + noOfWorkflow;
|
||||
|
||||
windowContainer.setTabTitle(0, "Home (" + total + ")",
|
||||
"Notice : " + noOfNotice + ", Request : " + noOfRequest + ", Workflow Activities : " + noOfWorkflow);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param page
|
||||
*/
|
||||
public void setPage(Page page) {
|
||||
if (this.page != page) {
|
||||
layout.setPage(page);
|
||||
this.page = page;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the root component
|
||||
* @return Component
|
||||
*/
|
||||
public Component getComponent() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
public void logout() {
|
||||
if (dashboardThread != null && dashboardThread.isAlive()) {
|
||||
dashboardRunnable.stop();
|
||||
dashboardThread.interrupt();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,177 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Low Heng Sin *
|
||||
* Copyright (C) 2008 Idalica Corporation *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.desktop;
|
||||
|
||||
import org.adempiere.webui.ClientInfo;
|
||||
import org.adempiere.webui.apps.ProcessDialog;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.panel.ADForm;
|
||||
import org.adempiere.webui.part.UIPart;
|
||||
import org.adempiere.webui.window.ADWindow;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.util.WebDoc;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Page;
|
||||
|
||||
/**
|
||||
* Desktop interface
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public interface IDesktop extends UIPart {
|
||||
|
||||
public static final String WINDOWNO_ATTRIBUTE = "desktop.windowno";
|
||||
public static final String CLASS_NAME_KEY = "ZK_DESKTOP_CLASS";
|
||||
|
||||
/**
|
||||
*
|
||||
* @return ClientInfo
|
||||
*/
|
||||
public ClientInfo getClientInfo();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param nodeId
|
||||
*/
|
||||
public void onMenuSelected(int nodeId);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param window
|
||||
* @return windowNo
|
||||
*/
|
||||
public int registerWindow(Object window);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param WindowNo
|
||||
* @return Object
|
||||
*/
|
||||
public Object findWindow(int WindowNo);
|
||||
|
||||
/**
|
||||
* close active window
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean closeActiveWindow();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param windowNo
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean closeWindow(int windowNo);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param url
|
||||
* @param closeable
|
||||
*/
|
||||
public void showURL(String url, boolean closeable);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param doc
|
||||
* @param string
|
||||
* @param closeable
|
||||
*/
|
||||
public void showURL(WebDoc doc, String string, boolean closeable);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param win
|
||||
*/
|
||||
public void showWindow(Window win);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param win
|
||||
* @param position
|
||||
*/
|
||||
public void showWindow(Window win, String position);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param window_ID
|
||||
* @param query
|
||||
*/
|
||||
public void showZoomWindow(int window_ID, MQuery query);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param windowNo
|
||||
*/
|
||||
public void unregisterWindow(int windowNo);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param processId
|
||||
* @param soTrx
|
||||
* @return ProcessDialog
|
||||
*/
|
||||
public ProcessDialog openProcessDialog(int processId, boolean soTrx);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param formId
|
||||
* @return ADWindow
|
||||
*/
|
||||
public ADForm openForm(int formId);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param windowId
|
||||
* @return ADWindow
|
||||
*/
|
||||
public ADWindow openWindow(int windowId);
|
||||
|
||||
/**
|
||||
* Open operating system task window
|
||||
* @param task_ID
|
||||
*/
|
||||
public void openTask(int task_ID);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param workflow_ID
|
||||
*/
|
||||
public void openWorkflow(int workflow_ID);
|
||||
|
||||
/**
|
||||
* Get the root component of the desktop
|
||||
* @return Component
|
||||
*/
|
||||
public Component getComponent();
|
||||
|
||||
/**
|
||||
* Attached to page
|
||||
* @param page
|
||||
*/
|
||||
public void setPage(Page page);
|
||||
|
||||
/**
|
||||
* @param clientInfo
|
||||
*/
|
||||
public void setClientInfo(ClientInfo clientInfo);
|
||||
|
||||
/**
|
||||
* User logout from desktop, do clean up
|
||||
*/
|
||||
public void logout();
|
||||
|
||||
/**
|
||||
* Invoke by the server push thread.
|
||||
*/
|
||||
public void onServerPush();
|
||||
}
|
|
@ -0,0 +1,425 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Low Heng Sin *
|
||||
* Copyright (C) 2008 Idalica Corporation *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
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.logging.Level;
|
||||
|
||||
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.HeaderPanel;
|
||||
import org.adempiere.webui.panel.SidePanel;
|
||||
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.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.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.Div;
|
||||
import org.zkoss.zul.Html;
|
||||
import org.zkoss.zul.Panel;
|
||||
import org.zkoss.zul.Panelchildren;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
*/
|
||||
public class LeftBar2Desktop extends TabbedDesktop implements MenuListener, Serializable, EventListener
|
||||
{
|
||||
|
||||
private static final String FAVOURITES_PATH = "/zul/favourites.zul";
|
||||
|
||||
private static final String ACTIVITIES_PATH = "/zul/activities.zul";
|
||||
|
||||
private static final long serialVersionUID = 9056511175189603883L;
|
||||
|
||||
private static final CLogger logger = CLogger.getCLogger(DefaultDesktop.class);
|
||||
|
||||
private Center windowArea;
|
||||
|
||||
private Borderlayout layout;
|
||||
|
||||
private Thread dashboardThread;
|
||||
|
||||
private DashboardRunnable dashboardRunnable;
|
||||
|
||||
private Accordion shortcutPanel;
|
||||
|
||||
public LeftBar2Desktop()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
protected Component doCreatePart(Component parent)
|
||||
{
|
||||
SidePanel pnlSide = new SidePanel();
|
||||
HeaderPanel pnlHead = new HeaderPanel();
|
||||
|
||||
pnlSide.getMenuPanel().addMenuListener(this);
|
||||
|
||||
layout = new Borderlayout();
|
||||
if (parent != null)
|
||||
{
|
||||
layout.setParent(parent);
|
||||
layout.setWidth("100%");
|
||||
layout.setHeight("100%");
|
||||
layout.setStyle("position: absolute");
|
||||
}
|
||||
else
|
||||
layout.setPage(page);
|
||||
|
||||
dashboardRunnable = new DashboardRunnable(layout.getDesktop(), this);
|
||||
|
||||
North n = new North();
|
||||
layout.appendChild(n);
|
||||
n.setCollapsible(false);
|
||||
pnlHead.setParent(n);
|
||||
|
||||
West w = new West();
|
||||
layout.appendChild(w);
|
||||
w.setWidth("300px");
|
||||
w.setCollapsible(true);
|
||||
w.setSplittable(true);
|
||||
w.setTitle("Menu");
|
||||
w.setFlex(true);
|
||||
pnlSide.setParent(w);
|
||||
w.setOpen(false);
|
||||
|
||||
Center center = new Center();
|
||||
center.setParent(layout);
|
||||
center.setFlex(true);
|
||||
|
||||
Borderlayout innerLayout = new Borderlayout();
|
||||
innerLayout.setHeight("100%");
|
||||
innerLayout.setWidth("100%");
|
||||
innerLayout.setParent(center);
|
||||
|
||||
West innerW = new West();
|
||||
innerW.setWidth("200px");
|
||||
innerW.setCollapsible(true);
|
||||
innerW.setTitle("Navigation");
|
||||
innerW.setSplittable(true);
|
||||
innerW.setCollapsible(true);
|
||||
innerW.setParent(innerLayout);
|
||||
|
||||
shortcutPanel = new Accordion();
|
||||
shortcutPanel.setWidth("100%");
|
||||
shortcutPanel.setHeight("100%");
|
||||
innerW.appendChild(shortcutPanel);
|
||||
|
||||
Div div = new Div();
|
||||
Executions.createComponents(FAVOURITES_PATH, div, null);
|
||||
shortcutPanel.add(div, "Favourites");
|
||||
|
||||
div = new Div();
|
||||
Component component = Executions.createComponents(ACTIVITIES_PATH, div, null);
|
||||
if (component instanceof DashboardPanel)
|
||||
{
|
||||
DashboardPanel dashboardPanel = (DashboardPanel) component;
|
||||
dashboardRunnable.add(dashboardPanel);
|
||||
}
|
||||
shortcutPanel.add(div, "Activities");
|
||||
|
||||
shortcutPanel.setSelectedIndex(0);
|
||||
|
||||
windowArea = new Center();
|
||||
windowArea.setParent(innerLayout);
|
||||
windowArea.setFlex(true);
|
||||
|
||||
windowContainer.createPart(windowArea);
|
||||
|
||||
createHomeTab();
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
private void createHomeTab()
|
||||
{
|
||||
Tabpanel homeTab = new Tabpanel();
|
||||
windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false);
|
||||
|
||||
Portallayout portalLayout = new Portallayout();
|
||||
portalLayout.setWidth("100%");
|
||||
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)
|
||||
{
|
||||
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");
|
||||
result.append(renderGoals(PA_Goal_ID, content));
|
||||
result.append("</div>\n</body>\n</html>\n</html>");
|
||||
|
||||
Html html = new Html();
|
||||
html.setContent(result.toString());
|
||||
content.appendChild(html);
|
||||
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();
|
||||
}
|
||||
|
||||
public void onEvent(Event event)
|
||||
{
|
||||
Component comp = event.getTarget();
|
||||
String eventName = event.getName();
|
||||
|
||||
if(eventName.equals(Events.ON_CLICK))
|
||||
{
|
||||
if(comp instanceof ToolBarButton)
|
||||
{
|
||||
ToolBarButton btn = (ToolBarButton) comp;
|
||||
|
||||
int menuId = 0;
|
||||
try
|
||||
{
|
||||
menuId = Integer.valueOf(btn.getName());
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
if(menuId > 0) onMenuSelected(menuId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onServerPush()
|
||||
{
|
||||
int noOfNotice = DPActivities.getNoticeCount();
|
||||
int noOfRequest = DPActivities.getRequestCount();
|
||||
int noOfWorkflow = DPActivities.getWorkflowCount();
|
||||
int total = noOfNotice + noOfRequest + noOfWorkflow;
|
||||
|
||||
shortcutPanel.setLabel(1, "Activities (" + total + ")");
|
||||
shortcutPanel.setTooltiptext(1, "Notice : " + noOfNotice + ", Request : " + noOfRequest + ", Workflow Activities : " + noOfWorkflow);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param page
|
||||
*/
|
||||
public void setPage(Page page) {
|
||||
if (this.page != page) {
|
||||
layout.setPage(page);
|
||||
this.page = page;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the root component
|
||||
* @return Component
|
||||
*/
|
||||
public Component getComponent() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
public void logout() {
|
||||
if (dashboardThread != null && dashboardThread.isAlive()) {
|
||||
dashboardRunnable.stop();
|
||||
dashboardThread.interrupt();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,417 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Low Heng Sin *
|
||||
* Copyright (C) 2008 Idalica Corporation *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
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.logging.Level;
|
||||
|
||||
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.HeaderPanel;
|
||||
import org.adempiere.webui.panel.SidePanel;
|
||||
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.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.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.Div;
|
||||
import org.zkoss.zul.Html;
|
||||
import org.zkoss.zul.Panel;
|
||||
import org.zkoss.zul.Panelchildren;
|
||||
|
||||
/**
|
||||
* @author hengsin
|
||||
*/
|
||||
public class LeftBarDesktop extends TabbedDesktop implements MenuListener, Serializable, EventListener
|
||||
{
|
||||
|
||||
private static final String FAVOURITES_PATH = "/zul/favourites.zul";
|
||||
|
||||
private static final String ACTIVITIES_PATH = "/zul/activities.zul";
|
||||
|
||||
private static final String VIEWS_PATH = "/zul/views.zul";
|
||||
|
||||
private static final long serialVersionUID = 9056511175189603883L;
|
||||
|
||||
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;
|
||||
|
||||
public LeftBarDesktop()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
protected Component doCreatePart(Component parent)
|
||||
{
|
||||
SidePanel pnlSide = new SidePanel();
|
||||
HeaderPanel pnlHead = new HeaderPanel();
|
||||
|
||||
pnlSide.getMenuPanel().addMenuListener(this);
|
||||
|
||||
layout = new Borderlayout();
|
||||
if (parent != null)
|
||||
{
|
||||
layout.setParent(parent);
|
||||
layout.setWidth("100%");
|
||||
layout.setHeight("100%");
|
||||
layout.setStyle("position: absolute");
|
||||
}
|
||||
else
|
||||
layout.setPage(page);
|
||||
|
||||
dashboardRunnable = new DashboardRunnable(layout.getDesktop(), this);
|
||||
|
||||
North n = new North();
|
||||
layout.appendChild(n);
|
||||
n.setCollapsible(false);
|
||||
pnlHead.setParent(n);
|
||||
|
||||
leftRegion = new West();
|
||||
layout.appendChild(leftRegion);
|
||||
leftRegion.setWidth("300px");
|
||||
leftRegion.setCollapsible(true);
|
||||
leftRegion.setSplittable(true);
|
||||
leftRegion.setTitle("Navigation");
|
||||
leftRegion.setFlex(true);
|
||||
navigationPanel = new Accordion();
|
||||
navigationPanel.setParent(leftRegion);
|
||||
leftRegion.setOpen(true);
|
||||
|
||||
navigationPanel.setWidth("100%");
|
||||
navigationPanel.setHeight("100%");
|
||||
navigationPanel.add(pnlSide, "Application Menu");
|
||||
|
||||
Div div = new Div();
|
||||
Executions.createComponents(FAVOURITES_PATH, div, null);
|
||||
navigationPanel.add(div, "Favourites");
|
||||
|
||||
div = new Div();
|
||||
Component component = Executions.createComponents(ACTIVITIES_PATH, div, null);
|
||||
if (component instanceof DashboardPanel)
|
||||
{
|
||||
DashboardPanel dashboardPanel = (DashboardPanel) component;
|
||||
dashboardRunnable.add(dashboardPanel);
|
||||
}
|
||||
navigationPanel.add(div, "Activities");
|
||||
|
||||
div = new Div();
|
||||
Executions.createComponents(VIEWS_PATH, div, null);
|
||||
navigationPanel.add(div, "Views");
|
||||
|
||||
navigationPanel.setSelectedIndex(0);
|
||||
|
||||
windowArea = new Center();
|
||||
windowArea.setParent(layout);
|
||||
windowArea.setFlex(true);
|
||||
|
||||
windowContainer.createPart(windowArea);
|
||||
|
||||
createHomeTab();
|
||||
|
||||
return layout;
|
||||
}
|
||||
|
||||
private void createHomeTab()
|
||||
{
|
||||
Tabpanel homeTab = new Tabpanel();
|
||||
windowContainer.addWindow(homeTab, Msg.getMsg(Env.getCtx(), "Home").replaceAll("&", ""), false);
|
||||
|
||||
Portallayout portalLayout = new Portallayout();
|
||||
portalLayout.setWidth("100%");
|
||||
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)
|
||||
{
|
||||
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");
|
||||
result.append(renderGoals(PA_Goal_ID, content));
|
||||
result.append("</div>\n</body>\n</html>\n</html>");
|
||||
|
||||
Html html = new Html();
|
||||
html.setContent(result.toString());
|
||||
content.appendChild(html);
|
||||
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();
|
||||
}
|
||||
|
||||
public void onEvent(Event event)
|
||||
{
|
||||
Component comp = event.getTarget();
|
||||
String eventName = event.getName();
|
||||
|
||||
if(eventName.equals(Events.ON_CLICK))
|
||||
{
|
||||
if(comp instanceof ToolBarButton)
|
||||
{
|
||||
ToolBarButton btn = (ToolBarButton) comp;
|
||||
|
||||
int menuId = 0;
|
||||
try
|
||||
{
|
||||
menuId = Integer.valueOf(btn.getName());
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
}
|
||||
|
||||
if(menuId > 0) onMenuSelected(menuId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onServerPush()
|
||||
{
|
||||
int noOfNotice = DPActivities.getNoticeCount();
|
||||
int noOfRequest = DPActivities.getRequestCount();
|
||||
int noOfWorkflow = DPActivities.getWorkflowCount();
|
||||
int total = noOfNotice + noOfRequest + noOfWorkflow;
|
||||
|
||||
navigationPanel.setLabel(2, "Activities (" + total + ")");
|
||||
navigationPanel.setTooltiptext(2, "Notice : " + noOfNotice + ", Request : " + noOfRequest + ", Workflow Activities : " + noOfWorkflow);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param page
|
||||
*/
|
||||
public void setPage(Page page) {
|
||||
if (this.page != page) {
|
||||
layout.setPage(page);
|
||||
this.page = page;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the root component
|
||||
* @return Component
|
||||
*/
|
||||
public Component getComponent() {
|
||||
return layout;
|
||||
}
|
||||
|
||||
public void logout() {
|
||||
if (dashboardThread != null && dashboardThread.isAlive()) {
|
||||
dashboardRunnable.stop();
|
||||
dashboardThread.interrupt();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,285 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2008 Low Heng Sin *
|
||||
* Copyright (C) 2008 Idalica Corporation *
|
||||
* This program is free software; you can redistribute it and/or modify it *
|
||||
* under the terms version 2 of the GNU General Public License as published *
|
||||
* by the Free Software Foundation. This program is distributed in the hope *
|
||||
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
|
||||
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
|
||||
* See the GNU General Public License for more details. *
|
||||
* You should have received a copy of the GNU General Public License along *
|
||||
* with this program; if not, write to the Free Software Foundation, Inc., *
|
||||
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
|
||||
*****************************************************************************/
|
||||
package org.adempiere.webui.desktop;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.webui.apps.ProcessDialog;
|
||||
import org.adempiere.webui.apps.wf.WFPanel;
|
||||
import org.adempiere.webui.component.DesktopTabpanel;
|
||||
import org.adempiere.webui.component.Tabbox;
|
||||
import org.adempiere.webui.component.Tabpanel;
|
||||
import org.adempiere.webui.component.Window;
|
||||
import org.adempiere.webui.panel.ADForm;
|
||||
import org.adempiere.webui.part.WindowContainer;
|
||||
import org.adempiere.webui.window.ADWindow;
|
||||
import org.adempiere.webui.window.WTask;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.model.MTask;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.WebDoc;
|
||||
import org.zkoss.util.media.AMedia;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zul.Iframe;
|
||||
import org.zkoss.zul.Tab;
|
||||
import org.zkoss.zul.Tabpanels;
|
||||
|
||||
/**
|
||||
* A Tabbed MDI implementation
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public abstract class TabbedDesktop extends AbstractDesktop {
|
||||
|
||||
protected WindowContainer windowContainer;
|
||||
|
||||
public TabbedDesktop() {
|
||||
super();
|
||||
windowContainer = new WindowContainer();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param processId
|
||||
* @param soTrx
|
||||
* @return ProcessDialog
|
||||
*/
|
||||
public ProcessDialog openProcessDialog(int processId, boolean soTrx) {
|
||||
ProcessDialog pd = new ProcessDialog (processId, soTrx);
|
||||
if (pd.isValid()) {
|
||||
DesktopTabpanel tabPanel = new DesktopTabpanel();
|
||||
pd.setParent(tabPanel);
|
||||
String title = pd.getTitle();
|
||||
pd.setTitle(null);
|
||||
windowContainer.addWindow(tabPanel, title, true);
|
||||
}
|
||||
return pd;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param formId
|
||||
* @return ADWindow
|
||||
*/
|
||||
public ADForm openForm(int formId) {
|
||||
ADForm form = ADForm.openForm(formId);
|
||||
|
||||
DesktopTabpanel tabPanel = new DesktopTabpanel();
|
||||
form.setParent(tabPanel);
|
||||
//do not show window title when open as tab
|
||||
form.setTitle(null);
|
||||
windowContainer.addWindow(tabPanel, form.getFormName(), true);
|
||||
|
||||
return form;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param workflow_ID
|
||||
*/
|
||||
public void openWorkflow(int workflow_ID) {
|
||||
WFPanel p = new WFPanel();
|
||||
p.load(workflow_ID);
|
||||
|
||||
DesktopTabpanel tabPanel = new DesktopTabpanel();
|
||||
p.setParent(tabPanel);
|
||||
windowContainer.addWindow(tabPanel, p.getWorkflow().getName(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param windowId
|
||||
* @return ADWindow
|
||||
*/
|
||||
public ADWindow openWindow(int windowId) {
|
||||
ADWindow adWindow = new ADWindow(Env.getCtx(), windowId);
|
||||
|
||||
DesktopTabpanel tabPanel = new DesktopTabpanel();
|
||||
if (adWindow.createPart(tabPanel) != null) {
|
||||
windowContainer.addWindow(tabPanel, adWindow.getTitle(), true);
|
||||
return adWindow;
|
||||
} else {
|
||||
//user cancel
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param taskId
|
||||
*/
|
||||
public void openTask(int taskId) {
|
||||
MTask task = new MTask(Env.getCtx(), taskId, null);
|
||||
new WTask(task.getName(), task);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param url
|
||||
*/
|
||||
public void showURL(String url, boolean closeable)
|
||||
{
|
||||
showURL(url, url, closeable);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param url
|
||||
* @param title
|
||||
* @param closeable
|
||||
*/
|
||||
public void showURL(String url, String title, boolean closeable)
|
||||
{
|
||||
Iframe iframe = new Iframe(url);
|
||||
addWin(iframe, title, closeable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param webDoc
|
||||
* @param title
|
||||
* @param closeable
|
||||
*/
|
||||
public void showURL(WebDoc webDoc, String title, boolean closeable)
|
||||
{
|
||||
Iframe iframe = new Iframe();
|
||||
|
||||
AMedia media = new AMedia(title, "html", "text/html", webDoc.toString().getBytes());
|
||||
iframe.setContent(media);
|
||||
|
||||
addWin(iframe, title, closeable);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param fr
|
||||
* @param title
|
||||
* @param closeable
|
||||
*/
|
||||
private void addWin(Iframe fr, String title, boolean closeable)
|
||||
{
|
||||
fr.setWidth("100%");
|
||||
fr.setHeight("100%");
|
||||
fr.setStyle("padding: 0; margin: 0; border: none; position: absolute");
|
||||
Window window = new Window();
|
||||
window.setWidth("100%");
|
||||
window.setHeight("100%");
|
||||
window.setStyle("padding: 0; margin: 0; border: none");
|
||||
window.appendChild(fr);
|
||||
window.setStyle("position: absolute");
|
||||
|
||||
Tabpanel tabPanel = new Tabpanel();
|
||||
window.setParent(tabPanel);
|
||||
windowContainer.addWindow(tabPanel, title, closeable);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param AD_Window_ID
|
||||
* @param query
|
||||
*/
|
||||
public void showZoomWindow(int AD_Window_ID, MQuery query)
|
||||
{
|
||||
ADWindow wnd = new ADWindow(Env.getCtx(), AD_Window_ID, query);
|
||||
|
||||
DesktopTabpanel tabPanel = new DesktopTabpanel();
|
||||
wnd.createPart(tabPanel);
|
||||
windowContainer.insertAfter(windowContainer.getSelectedTab(), tabPanel, wnd.getTitle(), true, true);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param window
|
||||
*/
|
||||
protected void showEmbedded(Window window)
|
||||
{
|
||||
Tabpanel tabPanel = new Tabpanel();
|
||||
window.setParent(tabPanel);
|
||||
String title = window.getTitle();
|
||||
window.setTitle(null);
|
||||
if (Window.INSERT_NEXT.equals(window.getAttribute(Window.INSERT_POSITION_KEY)))
|
||||
windowContainer.insertAfter(windowContainer.getSelectedTab(), tabPanel, title, true, true);
|
||||
else
|
||||
windowContainer.addWindow(tabPanel, title, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Close active tab
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean closeActiveWindow()
|
||||
{
|
||||
if (windowContainer.getSelectedTab() != null)
|
||||
{
|
||||
Tabpanel panel = (Tabpanel) windowContainer.getSelectedTab().getLinkedPanel();
|
||||
Component component = panel.getFirstChild();
|
||||
Object att = component.getAttribute(WINDOWNO_ATTRIBUTE);
|
||||
|
||||
if ( windowContainer.closeActiveWindow() )
|
||||
{
|
||||
if (att != null && (att instanceof Integer))
|
||||
{
|
||||
unregisterWindow((Integer) att);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Component
|
||||
*/
|
||||
public Component getActiveWindow()
|
||||
{
|
||||
return windowContainer.getSelectedTab().getLinkedPanel().getFirstChild();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param windowNo
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean closeWindow(int windowNo)
|
||||
{
|
||||
Tabbox tabbox = windowContainer.getComponent();
|
||||
Tabpanels panels = tabbox.getTabpanels();
|
||||
List<?> childrens = panels.getChildren();
|
||||
for (Object child : childrens)
|
||||
{
|
||||
Tabpanel panel = (Tabpanel) child;
|
||||
Component component = panel.getFirstChild();
|
||||
Object att = component.getAttribute(WINDOWNO_ATTRIBUTE);
|
||||
if (att != null && (att instanceof Integer))
|
||||
{
|
||||
if (windowNo == (Integer)att)
|
||||
{
|
||||
Tab tab = panel.getLinkedTab();
|
||||
panel.getLinkedTab().onClose();
|
||||
if (tab.getParent() == null)
|
||||
{
|
||||
unregisterWindow(windowNo);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -19,8 +19,8 @@ package org.adempiere.webui.session;
|
|||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.webui.IDesktop;
|
||||
import org.adempiere.webui.IWebClient;
|
||||
import org.adempiere.webui.desktop.IDesktop;
|
||||
import org.compiere.util.Env;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
import org.zkoss.zk.ui.Session;
|
||||
|
|
|
@ -19,7 +19,7 @@ package org.adempiere.webui.window;
|
|||
|
||||
import java.util.Properties;
|
||||
|
||||
import org.adempiere.webui.Desktop;
|
||||
import org.adempiere.webui.desktop.IDesktop;
|
||||
import org.adempiere.webui.panel.ADWindowPanel;
|
||||
import org.adempiere.webui.part.AbstractUIPart;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
|
@ -77,7 +77,7 @@ public class ADWindow extends AbstractUIPart
|
|||
{
|
||||
windowPanelComponent = windowPanel.createPart(parent);
|
||||
windowPanelComponent.setAttribute("ADWindow", this);
|
||||
windowPanelComponent.setAttribute(Desktop.WINDOWNO_ATTRIBUTE, windowNo);
|
||||
windowPanelComponent.setAttribute(IDesktop.WINDOWNO_ATTRIBUTE, windowNo);
|
||||
if (windowPanel.initPanel(adWindowId, query))
|
||||
{
|
||||
_title = windowPanel.getTitle();
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<window use="org.adempiere.webui.DPActivities"/>
|
||||
<window use="org.adempiere.webui.dashboard.DPActivities"/>
|
|
@ -1,2 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<window use="org.adempiere.webui.DPCalendar"/>
|
||||
<window use="org.adempiere.webui.dashboard.DPCalendar"/>
|
|
@ -1,2 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<window use="org.adempiere.webui.DPFavourites"/>
|
||||
<window use="org.adempiere.webui.dashboard.DPFavourites"/>
|
|
@ -1,2 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<window use="org.adempiere.webui.DPPerformance"/>
|
||||
<window use="org.adempiere.webui.dashboard.DPPerformance"/>
|
|
@ -1,2 +1,2 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<window use="org.adempiere.webui.DPViews"/>
|
||||
<window use="org.adempiere.webui.dashboard.DPViews"/>
|
Loading…
Reference in New Issue