IDEMPIERE-1196 Create a service to manage Home Widgets. Based on contribution from Antonio Cañaveral.
This commit is contained in:
parent
f2f0580161
commit
b173f3889b
|
@ -0,0 +1,41 @@
|
|||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
-- Oct 4, 2013 2:48:55 PM MYT
|
||||
-- IDEMPIERE-1196 Create a service to manage Home Widgets.
|
||||
UPDATE AD_Element SET Help='URI for Dashboard Gadget. This can be absolute path to a zul file or an unique gadget id which is instantiated through OSGi factory services.', Name='Gadget URI', Description='URI for Dashboard Gadget', PrintName='Gadget URI',Updated=TO_DATE('2013-10-04 14:48:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=53710
|
||||
;
|
||||
|
||||
-- Oct 4, 2013 2:48:56 PM MYT
|
||||
-- IDEMPIERE-1196 Create a service to manage Home Widgets.
|
||||
UPDATE AD_Column SET ColumnName='ZulFilePath', Name='Gadget URI', Description='URI for Dashboard Gadget', Help='URI for Dashboard Gadget. This can be absolute path to a zul file or an unique gadget id which is instantiated through OSGi factory services.' WHERE AD_Element_ID=53710
|
||||
;
|
||||
|
||||
-- Oct 4, 2013 2:48:56 PM MYT
|
||||
-- IDEMPIERE-1196 Create a service to manage Home Widgets.
|
||||
UPDATE AD_Process_Para SET ColumnName='ZulFilePath', Name='Gadget URI', Description='URI for Dashboard Gadget', Help='URI for Dashboard Gadget. This can be absolute path to a zul file or an unique gadget id which is instantiated through OSGi factory services.', AD_Element_ID=53710 WHERE UPPER(ColumnName)='ZULFILEPATH' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL
|
||||
;
|
||||
|
||||
-- Oct 4, 2013 2:48:56 PM MYT
|
||||
-- IDEMPIERE-1196 Create a service to manage Home Widgets.
|
||||
UPDATE AD_Process_Para SET ColumnName='ZulFilePath', Name='Gadget URI', Description='URI for Dashboard Gadget', Help='URI for Dashboard Gadget. This can be absolute path to a zul file or an unique gadget id which is instantiated through OSGi factory services.' WHERE AD_Element_ID=53710 AND IsCentrallyMaintained='Y'
|
||||
;
|
||||
|
||||
-- Oct 4, 2013 2:48:56 PM MYT
|
||||
-- IDEMPIERE-1196 Create a service to manage Home Widgets.
|
||||
UPDATE AD_InfoColumn SET ColumnName='ZulFilePath', Name='Gadget URI', Description='URI for Dashboard Gadget', Help='URI for Dashboard Gadget. This can be absolute path to a zul file or an unique gadget id which is instantiated through OSGi factory services.' WHERE AD_Element_ID=53710 AND IsCentrallyMaintained='Y'
|
||||
;
|
||||
|
||||
-- Oct 4, 2013 2:48:56 PM MYT
|
||||
-- IDEMPIERE-1196 Create a service to manage Home Widgets.
|
||||
UPDATE AD_Field SET Name='Gadget URI', Description='URI for Dashboard Gadget', Help='URI for Dashboard Gadget. This can be absolute path to a zul file or an unique gadget id which is instantiated through OSGi factory services.' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=53710) AND IsCentrallyMaintained='Y'
|
||||
;
|
||||
|
||||
-- Oct 4, 2013 2:48:56 PM MYT
|
||||
-- IDEMPIERE-1196 Create a service to manage Home Widgets.
|
||||
UPDATE AD_PrintFormatItem SET PrintName='Gadget URI', Name='Gadget URI' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=53710)
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201310040650_IDEMPIERE-1196.sql') FROM dual
|
||||
;
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
-- Oct 4, 2013 2:48:55 PM MYT
|
||||
-- IDEMPIERE-1196 Create a service to manage Home Widgets.
|
||||
UPDATE AD_Element SET Help='URI for Dashboard Gadget. This can be absolute path to a zul file or an unique gadget id which is instantiated through OSGi factory services.', Name='Gadget URI', Description='URI for Dashboard Gadget', PrintName='Gadget URI',Updated=TO_TIMESTAMP('2013-10-04 14:48:55','YYYY-MM-DD HH24:MI:SS'),UpdatedBy=100 WHERE AD_Element_ID=53710
|
||||
;
|
||||
|
||||
-- Oct 4, 2013 2:48:56 PM MYT
|
||||
-- IDEMPIERE-1196 Create a service to manage Home Widgets.
|
||||
UPDATE AD_Column SET ColumnName='ZulFilePath', Name='Gadget URI', Description='URI for Dashboard Gadget', Help='URI for Dashboard Gadget. This can be absolute path to a zul file or an unique gadget id which is instantiated through OSGi factory services.' WHERE AD_Element_ID=53710
|
||||
;
|
||||
|
||||
-- Oct 4, 2013 2:48:56 PM MYT
|
||||
-- IDEMPIERE-1196 Create a service to manage Home Widgets.
|
||||
UPDATE AD_Process_Para SET ColumnName='ZulFilePath', Name='Gadget URI', Description='URI for Dashboard Gadget', Help='URI for Dashboard Gadget. This can be absolute path to a zul file or an unique gadget id which is instantiated through OSGi factory services.', AD_Element_ID=53710 WHERE UPPER(ColumnName)='ZULFILEPATH' AND IsCentrallyMaintained='Y' AND AD_Element_ID IS NULL
|
||||
;
|
||||
|
||||
-- Oct 4, 2013 2:48:56 PM MYT
|
||||
-- IDEMPIERE-1196 Create a service to manage Home Widgets.
|
||||
UPDATE AD_Process_Para SET ColumnName='ZulFilePath', Name='Gadget URI', Description='URI for Dashboard Gadget', Help='URI for Dashboard Gadget. This can be absolute path to a zul file or an unique gadget id which is instantiated through OSGi factory services.' WHERE AD_Element_ID=53710 AND IsCentrallyMaintained='Y'
|
||||
;
|
||||
|
||||
-- Oct 4, 2013 2:48:56 PM MYT
|
||||
-- IDEMPIERE-1196 Create a service to manage Home Widgets.
|
||||
UPDATE AD_InfoColumn SET ColumnName='ZulFilePath', Name='Gadget URI', Description='URI for Dashboard Gadget', Help='URI for Dashboard Gadget. This can be absolute path to a zul file or an unique gadget id which is instantiated through OSGi factory services.' WHERE AD_Element_ID=53710 AND IsCentrallyMaintained='Y'
|
||||
;
|
||||
|
||||
-- Oct 4, 2013 2:48:56 PM MYT
|
||||
-- IDEMPIERE-1196 Create a service to manage Home Widgets.
|
||||
UPDATE AD_Field SET Name='Gadget URI', Description='URI for Dashboard Gadget', Help='URI for Dashboard Gadget. This can be absolute path to a zul file or an unique gadget id which is instantiated through OSGi factory services.' WHERE AD_Column_ID IN (SELECT AD_Column_ID FROM AD_Column WHERE AD_Element_ID=53710) AND IsCentrallyMaintained='Y'
|
||||
;
|
||||
|
||||
-- Oct 4, 2013 2:48:56 PM MYT
|
||||
-- IDEMPIERE-1196 Create a service to manage Home Widgets.
|
||||
UPDATE AD_PrintFormatItem SET PrintName='Gadget URI', Name='Gadget URI' WHERE IsCentrallyMaintained='Y' AND EXISTS (SELECT * FROM AD_Column c WHERE c.AD_Column_ID=AD_PrintFormatItem.AD_Column_ID AND c.AD_Element_ID=53710)
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201310040650_IDEMPIERE-1196.sql') FROM dual
|
||||
;
|
||||
|
|
@ -85,4 +85,4 @@ Bundle-Activator: org.adempiere.webui.WebUIActivator
|
|||
Eclipse-ExtensibleAPI: true
|
||||
Eclipse-RegisterBuddy: org.zkoss.zk.library
|
||||
Web-ContextPath: webui
|
||||
Service-Component: OSGI-INF/reportviewerprovider.xml, OSGI-INF/defaultinfofactory.xml, OSGI-INF/defaulteditorfactory.xml, OSGI-INF/jrviewerprovider.xml, OSGI-INF/resourcefinder.xml, OSGI-INF/defaultpaymentformfactory.xml, OSGI-INF/processfactory.xml, OSGI-INF/defaultprintshippinglabel.xml, OSGI-INF/defaultcreatefromfactory.xml, OSGI-INF/defaultformfactory.xml, OSGI-INF/feedbackservice.xml
|
||||
Service-Component: OSGI-INF/reportviewerprovider.xml, OSGI-INF/defaultinfofactory.xml, OSGI-INF/defaulteditorfactory.xml, OSGI-INF/jrviewerprovider.xml, OSGI-INF/resourcefinder.xml, OSGI-INF/defaultpaymentformfactory.xml, OSGI-INF/processfactory.xml, OSGI-INF/defaultprintshippinglabel.xml, OSGI-INF/defaultcreatefromfactory.xml, OSGI-INF/defaultformfactory.xml, OSGI-INF/feedbackservice.xml, OSGI-INF/zulgadgetfactory.xml
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" name="org.adempiere.webui.factory.ZulDashboardGadgetFactory">
|
||||
<implementation class="org.adempiere.webui.factory.ZulDashboardGadgetFactory"/>
|
||||
<service>
|
||||
<provide interface="org.adempiere.webui.factory.IDashboardGadgetFactory"/>
|
||||
</service>
|
||||
<property name="service.ranking" type="Integer" value="0"/>
|
||||
</scr:component>
|
|
@ -26,6 +26,7 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.base.Service;
|
||||
import org.adempiere.exceptions.AdempiereException;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.apps.graph.WGraph;
|
||||
|
@ -33,6 +34,7 @@ import org.adempiere.webui.apps.graph.WPerformanceDetail;
|
|||
import org.adempiere.webui.component.ToolBarButton;
|
||||
import org.adempiere.webui.dashboard.DashboardPanel;
|
||||
import org.adempiere.webui.dashboard.DashboardRunnable;
|
||||
import org.adempiere.webui.factory.IDashboardGadgetFactory;
|
||||
import org.adempiere.webui.report.HTMLExtension;
|
||||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.theme.ThemeManager;
|
||||
|
@ -66,6 +68,7 @@ import org.zkoss.zk.ui.event.MaximizeEvent;
|
|||
import org.zkoss.zul.Anchorchildren;
|
||||
import org.zkoss.zul.Anchorlayout;
|
||||
import org.zkoss.zul.Caption;
|
||||
import org.zkoss.zul.Div;
|
||||
import org.zkoss.zul.Html;
|
||||
import org.zkoss.zul.Iframe;
|
||||
import org.zkoss.zul.Include;
|
||||
|
@ -249,12 +252,14 @@ public class DashboardController implements EventListener<Event> {
|
|||
if(AD_Window_ID > 0)
|
||||
{
|
||||
int AD_Menu_ID = dc.getAD_Menu_ID();
|
||||
Div div = new Div();
|
||||
ToolBarButton btn = new ToolBarButton(String.valueOf(AD_Menu_ID));
|
||||
I_AD_Menu menu = dc.getAD_Menu();
|
||||
btn.setLabel(menu.getName());
|
||||
btn.setAttribute("AD_Menu_ID", AD_Menu_ID);
|
||||
btn.addEventListener(Events.ON_CLICK, this);
|
||||
content.appendChild(btn);
|
||||
div.appendChild(btn);
|
||||
content.appendChild(div);
|
||||
panelEmpty = false;
|
||||
}
|
||||
|
||||
|
@ -300,6 +305,7 @@ public class DashboardController implements EventListener<Event> {
|
|||
if(PA_Goal_ID > 0)
|
||||
{
|
||||
//link to open performance detail
|
||||
Div div = new Div();
|
||||
Toolbarbutton link = new Toolbarbutton();
|
||||
link.setImage(ThemeManager.getThemeResource("images/Zoom16.png"));
|
||||
link.setAttribute("PA_Goal_ID", PA_Goal_ID);
|
||||
|
@ -310,7 +316,8 @@ public class DashboardController implements EventListener<Event> {
|
|||
new WPerformanceDetail(goal);
|
||||
}
|
||||
});
|
||||
content.appendChild(link);
|
||||
div.appendChild(link);
|
||||
content.appendChild(div);
|
||||
|
||||
String goalDisplay = dc.getGoalDisplay();
|
||||
MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null);
|
||||
|
@ -326,7 +333,15 @@ public class DashboardController implements EventListener<Event> {
|
|||
if(url != null)
|
||||
{
|
||||
try {
|
||||
Component component = Executions.createComponents(url, content, null);
|
||||
|
||||
Component component = null;
|
||||
List<IDashboardGadgetFactory> f = Service.locator().list(IDashboardGadgetFactory.class).getServices();
|
||||
for (IDashboardGadgetFactory factory : f) {
|
||||
component = factory.getGadget(url.toString(),content);
|
||||
if(component != null)
|
||||
break;
|
||||
}
|
||||
|
||||
if(component != null)
|
||||
{
|
||||
if (component instanceof Include)
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2013 Antonio Cañaveral *
|
||||
* Copyright (C) 2013 Trek Global *
|
||||
* 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.factory;
|
||||
|
||||
import org.zkoss.zk.ui.Component;
|
||||
|
||||
/**
|
||||
* @author Antonio Cañaveral
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public interface IDashboardGadgetFactory {
|
||||
/**
|
||||
*
|
||||
* @param uri
|
||||
* @param parent
|
||||
* @return Component instance of DashboardPanel or null
|
||||
*/
|
||||
public Component getGadget(String uri, Component parent);
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
/******************************************************************************
|
||||
* Copyright (C) 2013 Antonio Cañaveral *
|
||||
* Copyright (C) 2013 Trek Global *
|
||||
* 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.factory;
|
||||
|
||||
import java.net.URL;
|
||||
|
||||
import org.adempiere.base.Core;
|
||||
import org.adempiere.base.IResourceFinder;
|
||||
import org.zkoss.zk.ui.Component;
|
||||
import org.zkoss.zk.ui.Executions;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Antonio Cañaveral
|
||||
* @author hengsin
|
||||
*
|
||||
*/
|
||||
public class ZulDashboardGadgetFactory implements IDashboardGadgetFactory {
|
||||
@Override
|
||||
public Component getGadget(String uri, Component parent) {
|
||||
if (uri != null && uri.toLowerCase().endsWith(".zul")) {
|
||||
IResourceFinder rf = Core.getResourceFinder();
|
||||
URL url = rf.getResource(uri);
|
||||
if(url!=null)
|
||||
return Executions.createComponents(url.toString(), parent, null);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue