From 36ca94788a4f1211bdd174b78d27edef7f710bba Mon Sep 17 00:00:00 2001 From: Heng Sin Low Date: Mon, 20 Jul 2009 03:57:51 +0000 Subject: [PATCH] https://sourceforge.net/tracker/?func=detail&aid=2819356&group_id=176962&atid=879335 - Added GoalDisplay column to PA_Goal. - The new field allow user to select to render performance goal as table or chart at dashboard. --- migration/353a-trunk/oracle/506_FR2819356.sql | 68 +++ .../353a-trunk/postgresql/506_FR2819356.sql | 66 +++ .../adempiere/webui/apps/graph/WGraph.java | 552 +++++++++++------- .../webui/apps/graph/WPerformanceDetail.java | 2 +- .../webui/desktop/DefaultDesktop.java | 5 +- .../webui/desktop/NavBar2Desktop.java | 7 +- .../webui/desktop/NavBarDesktop.java | 7 +- zkwebui/css/PAPanel.css | 7 +- 8 files changed, 488 insertions(+), 226 deletions(-) create mode 100644 migration/353a-trunk/oracle/506_FR2819356.sql create mode 100644 migration/353a-trunk/postgresql/506_FR2819356.sql diff --git a/migration/353a-trunk/oracle/506_FR2819356.sql b/migration/353a-trunk/oracle/506_FR2819356.sql new file mode 100644 index 0000000000..2b822a08b4 --- /dev/null +++ b/migration/353a-trunk/oracle/506_FR2819356.sql @@ -0,0 +1,68 @@ +-- Jul 17, 2009 6:29:53 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Org_ID,ColumnName,Created,CreatedBy,Description,EntityType,Help,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,53895,0,'GoalDisplay',TO_DATE('2009-07-17 18:29:50','YYYY-MM-DD HH24:MI:SS'),100,'Type of goal display on dashboard','D','Display goal on dashboard as html table or graph.','Y','Goal Display','Goal Display',TO_DATE('2009-07-17 18:29:50','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Jul 17, 2009 6:29:53 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=53895 AND EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Element_ID!=t.AD_Element_ID) +; + +-- Jul 17, 2009 6:31:10 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Reference (AD_Client_ID,AD_Org_ID,AD_Reference_ID,Created,CreatedBy,Description,EntityType,IsActive,IsOrderByValue,Name,Updated,UpdatedBy,ValidationType) VALUES (0,0,53316,TO_DATE('2009-07-17 18:31:09','YYYY-MM-DD HH24:MI:SS'),100,'Type of goal display on dashboard','D','Y','N','PA_DashboardContent GoalDisplay',TO_DATE('2009-07-17 18:31:09','YYYY-MM-DD HH24:MI:SS'),100,'L') +; + +-- Jul 17, 2009 6:31:10 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Reference_Trl (AD_Language,AD_Reference_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Reference_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Reference t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Reference_ID=53316 AND EXISTS (SELECT * FROM AD_Reference_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Reference_ID!=t.AD_Reference_ID) +; + +-- Jul 17, 2009 6:31:36 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,53501,53316,TO_DATE('2009-07-17 18:31:35','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','HTML Table',TO_DATE('2009-07-17 18:31:35','YYYY-MM-DD HH24:MI:SS'),100,'T') +; + +-- Jul 17, 2009 6:31:36 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=53501 AND EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Ref_List_ID!=t.AD_Ref_List_ID) +; + +-- Jul 17, 2009 6:32:00 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,53502,53316,TO_DATE('2009-07-17 18:31:59','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','Chart',TO_DATE('2009-07-17 18:31:59','YYYY-MM-DD HH24:MI:SS'),100,'C') +; + +-- Jul 17, 2009 6:32:00 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=53502 AND EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Ref_List_ID!=t.AD_Ref_List_ID) +; + +-- Jul 17, 2009 6:33:02 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Reference_Value_ID,AD_Table_ID,ColumnName,Created,CreatedBy,DefaultValue,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,57922,53895,0,17,53316,50010,'GoalDisplay',TO_DATE('2009-07-17 18:33:01','YYYY-MM-DD HH24:MI:SS'),100,'T','Type of goal display on dashboard','D',1,'Display goal on dashboard as html table or graph.','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Goal Display',0,TO_DATE('2009-07-17 18:33:01','YYYY-MM-DD HH24:MI:SS'),100,1.000000000000) +; + +-- Jul 17, 2009 6:33:02 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=57922 AND EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Column_ID!=t.AD_Column_ID) +; + +-- Jul 17, 2009 6:33:18 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +ALTER TABLE PA_DashboardContent ADD GoalDisplay CHAR(1) DEFAULT 'T' +; + +-- Jul 17, 2009 6:35:13 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,DisplayLogic,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,SortNo,Updated,UpdatedBy) VALUES (0,57922,57344,0,50010,TO_DATE('2009-07-17 18:35:11','YYYY-MM-DD HH24:MI:SS'),100,'Type of goal display on dashboard',14,'@PA_Goal_ID@!0','D','Display goal on dashboard as html table or graph.','Y','Y','Y','N','N','N','N','N','Goal Display',120,0,TO_DATE('2009-07-17 18:35:11','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Jul 17, 2009 6:35:13 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=57344 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID) +; + +COMMIT; + + diff --git a/migration/353a-trunk/postgresql/506_FR2819356.sql b/migration/353a-trunk/postgresql/506_FR2819356.sql new file mode 100644 index 0000000000..d619c81c26 --- /dev/null +++ b/migration/353a-trunk/postgresql/506_FR2819356.sql @@ -0,0 +1,66 @@ +-- Jul 17, 2009 6:29:53 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Element (AD_Client_ID,AD_Element_ID,AD_Org_ID,ColumnName,Created,CreatedBy,Description,EntityType,Help,IsActive,Name,PrintName,Updated,UpdatedBy) VALUES (0,53895,0,'GoalDisplay',TO_TIMESTAMP('2009-07-17 18:29:50','YYYY-MM-DD HH24:MI:SS'),100,'Type of goal display on dashboard','D','Display goal on dashboard as html table or graph.','Y','Goal Display','Goal Display',TO_TIMESTAMP('2009-07-17 18:29:50','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Jul 17, 2009 6:29:53 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Element_Trl (AD_Language,AD_Element_ID, Description,Help,Name,PO_Description,PO_Help,PO_Name,PO_PrintName,PrintName, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Element_ID, t.Description,t.Help,t.Name,t.PO_Description,t.PO_Help,t.PO_Name,t.PO_PrintName,t.PrintName, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Element t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Element_ID=53895 AND EXISTS (SELECT * FROM AD_Element_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Element_ID!=t.AD_Element_ID) +; + +-- Jul 17, 2009 6:31:10 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Reference (AD_Client_ID,AD_Org_ID,AD_Reference_ID,Created,CreatedBy,Description,EntityType,IsActive,IsOrderByValue,Name,Updated,UpdatedBy,ValidationType) VALUES (0,0,53316,TO_TIMESTAMP('2009-07-17 18:31:09','YYYY-MM-DD HH24:MI:SS'),100,'Type of goal display on dashboard','D','Y','N','PA_DashboardContent GoalDisplay',TO_TIMESTAMP('2009-07-17 18:31:09','YYYY-MM-DD HH24:MI:SS'),100,'L') +; + +-- Jul 17, 2009 6:31:10 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Reference_Trl (AD_Language,AD_Reference_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Reference_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Reference t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Reference_ID=53316 AND EXISTS (SELECT * FROM AD_Reference_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Reference_ID!=t.AD_Reference_ID) +; + +-- Jul 17, 2009 6:31:36 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,53501,53316,TO_TIMESTAMP('2009-07-17 18:31:35','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','HTML Table',TO_TIMESTAMP('2009-07-17 18:31:35','YYYY-MM-DD HH24:MI:SS'),100,'T') +; + +-- Jul 17, 2009 6:31:36 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=53501 AND EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Ref_List_ID!=t.AD_Ref_List_ID) +; + +-- Jul 17, 2009 6:32:00 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Ref_List (AD_Client_ID,AD_Org_ID,AD_Ref_List_ID,AD_Reference_ID,Created,CreatedBy,EntityType,IsActive,Name,Updated,UpdatedBy,Value) VALUES (0,0,53502,53316,TO_TIMESTAMP('2009-07-17 18:31:59','YYYY-MM-DD HH24:MI:SS'),100,'D','Y','Chart',TO_TIMESTAMP('2009-07-17 18:31:59','YYYY-MM-DD HH24:MI:SS'),100,'C') +; + +-- Jul 17, 2009 6:32:00 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Ref_List_Trl (AD_Language,AD_Ref_List_ID, Description,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Ref_List_ID, t.Description,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Ref_List t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Ref_List_ID=53502 AND EXISTS (SELECT * FROM AD_Ref_List_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Ref_List_ID!=t.AD_Ref_List_ID) +; + +-- Jul 17, 2009 6:33:02 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Column (AD_Client_ID,AD_Column_ID,AD_Element_ID,AD_Org_ID,AD_Reference_ID,AD_Reference_Value_ID,AD_Table_ID,ColumnName,Created,CreatedBy,DefaultValue,Description,EntityType,FieldLength,Help,IsActive,IsAllowLogging,IsAlwaysUpdateable,IsAutocomplete,IsEncrypted,IsIdentifier,IsKey,IsMandatory,IsParent,IsSelectionColumn,IsSyncDatabase,IsTranslated,IsUpdateable,Name,SeqNo,Updated,UpdatedBy,Version) VALUES (0,57922,53895,0,17,53316,50010,'GoalDisplay',TO_TIMESTAMP('2009-07-17 18:33:01','YYYY-MM-DD HH24:MI:SS'),100,'T','Type of goal display on dashboard','D',1,'Display goal on dashboard as html table or graph.','Y','Y','N','N','N','N','N','N','N','N','N','N','Y','Goal Display',0,TO_TIMESTAMP('2009-07-17 18:33:01','YYYY-MM-DD HH24:MI:SS'),100,1.000000000000) +; + +-- Jul 17, 2009 6:33:02 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Column_Trl (AD_Language,AD_Column_ID, Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Column_ID, t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Column t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Column_ID=57922 AND EXISTS (SELECT * FROM AD_Column_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Column_ID!=t.AD_Column_ID) +; + +-- Jul 17, 2009 6:33:18 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +ALTER TABLE PA_DashboardContent ADD COLUMN GoalDisplay CHAR(1) DEFAULT 'T' +; + +-- Jul 17, 2009 6:35:13 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Field (AD_Client_ID,AD_Column_ID,AD_Field_ID,AD_Org_ID,AD_Tab_ID,Created,CreatedBy,Description,DisplayLength,DisplayLogic,EntityType,Help,IsActive,IsCentrallyMaintained,IsDisplayed,IsEncrypted,IsFieldOnly,IsHeading,IsReadOnly,IsSameLine,Name,SeqNo,SortNo,Updated,UpdatedBy) VALUES (0,57922,57344,0,50010,TO_TIMESTAMP('2009-07-17 18:35:11','YYYY-MM-DD HH24:MI:SS'),100,'Type of goal display on dashboard',14,'@PA_Goal_ID@!0','D','Display goal on dashboard as html table or graph.','Y','Y','Y','N','N','N','N','N','Goal Display',120,0,TO_TIMESTAMP('2009-07-17 18:35:11','YYYY-MM-DD HH24:MI:SS'),100) +; + +-- Jul 17, 2009 6:35:13 PM MYT +-- Add more chart type support to Performance indicator - ID: 2819356 +INSERT INTO AD_Field_Trl (AD_Language,AD_Field_ID, Description,Help,Name, IsTranslated,AD_Client_ID,AD_Org_ID,Created,Createdby,Updated,UpdatedBy) SELECT l.AD_Language,t.AD_Field_ID, t.Description,t.Help,t.Name, 'N',t.AD_Client_ID,t.AD_Org_ID,t.Created,t.Createdby,t.Updated,t.UpdatedBy FROM AD_Language l, AD_Field t WHERE l.IsActive='Y' AND l.IsSystemLanguage='Y' AND l.IsBaseLanguage='N' AND t.AD_Field_ID=57344 AND EXISTS (SELECT * FROM AD_Field_Trl tt WHERE tt.AD_Language!=l.AD_Language OR tt.AD_Field_ID!=t.AD_Field_ID) +; + +COMMIT; diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WGraph.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WGraph.java index b4c519bfd2..04102bcad2 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WGraph.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WGraph.java @@ -43,6 +43,12 @@ import org.jfree.chart.entity.CategoryItemEntity; import org.jfree.chart.entity.ChartEntity; import org.jfree.chart.entity.PieSectionEntity; import org.zkoss.image.AImage; +import org.zkoss.zhtml.A; +import org.zkoss.zhtml.Br; +import org.zkoss.zhtml.Table; +import org.zkoss.zhtml.Td; +import org.zkoss.zhtml.Text; +import org.zkoss.zhtml.Tr; import org.zkoss.zk.ui.Component; import org.zkoss.zk.ui.IdSpace; import org.zkoss.zk.ui.event.Event; @@ -53,21 +59,18 @@ import org.zkoss.zkex.zul.Borderlayout; import org.zkoss.zkex.zul.Center; import org.zkoss.zkex.zul.East; import org.zkoss.zul.Area; -import org.zkoss.zul.Button; import org.zkoss.zul.Div; -import org.zkoss.zul.Html; import org.zkoss.zul.Imagemap; import org.zkoss.zul.Panel; import org.zkoss.zul.Panelchildren; import org.zkoss.zul.Toolbar; /** - * Bar Graph - * - * @author hengsin + * Performance Graph + * + * @author hengsin */ -public class WGraph extends Div implements IdSpace -{ +public class WGraph extends Div implements IdSpace { /** * */ @@ -79,105 +82,163 @@ public class WGraph extends Div implements IdSpace private Panel panel; - private boolean m_showDetail; + private boolean m_renderTable = false; + + private boolean m_renderChart = true; + + /** Zero/Zero Coordibate point */ + private Point m_point0_0 = null; + + /** Logger */ + private static CLogger log = CLogger.getCLogger(WGraph.class); + + /** Y Axis Target Line Label */ + private String m_Y_TargetLabel = null; /** - * Constructor + * Load Performance Data */ - public WGraph() - { + ArrayList list = new ArrayList(); + + private GraphBuilder builder; + + private boolean m_chartSelection; + + private int zoomFactor = 0; + + /** + * Constructor + */ + public WGraph() { super(); - builder = new GraphBuilder(); - } // BarGraph + builder = new GraphBuilder(); + panel = new Panel(); + } // BarGraph /** - * Constructor - * @param goal goal + * Constructor + * + * @param goal */ - public WGraph(MGoal goal) - { - this(goal, 0, false, false, false); + public WGraph(MGoal goal) { + this(goal, 0, false, false, false, true); } /** - * Constructor - * @param goal goal + * Constructor + * + * @param goal + * @param zoom + * @param userSelection + * @param hideTitle + * @param showTable + * @param showChart */ - public WGraph(MGoal goal, int zoom, boolean userSelection, boolean hideTitle, boolean showDetail) - { + public WGraph(MGoal goal, int zoom, boolean chartSelection, + boolean hideTitle, boolean renderTable, boolean renderChart) { this(); + setGoal(goal); + m_chartSelection = chartSelection; + zoomFactor = zoom; + m_hideTitle = hideTitle; + m_renderTable = renderTable; + m_renderChart = renderChart; + + loadData(); + + render(); + } // WGraph + + /** + * @param goal + */ + public void setGoal(MGoal goal) + { builder.setMGoal(goal); builder.setYAxisLabel(goal.getName()); builder.setXAxisLabel(goal.getXAxisText()); - m_userSelection = userSelection; - zoomFactor = zoom; - m_hideTitle = hideTitle; - m_showDetail = showDetail; - panel = new Panel(); - Borderlayout layout = new Borderlayout(); - if (m_showDetail) - { + } + + /** + * @return true if the chart type selection control is available + */ + public boolean isChartSelection() { + return m_chartSelection; + } + + /** + * show/hide the chart type selection control + * @param chartSelection + */ + public void setChartSelection(boolean chartSelection) { + m_chartSelection = chartSelection; + } + + /** + * render chart and/or table + */ + public void render() { + Borderlayout layout = null; + + this.getChildren().clear(); + + if (m_renderTable && m_renderChart) { layout = new Borderlayout(); appendChild(layout); layout.setStyle("height: 100%; width: 100%; position: absolute;"); Center center = new Center(); layout.appendChild(center); center.appendChild(panel); - } - else - { + } else { appendChild(panel); } - loadData(); - if (m_showDetail) - { - Html html = new Html(); - html.setContent(renderGoal()); - East east = new East(); - layout.appendChild(east); - east.appendChild(html); + + if (m_renderChart) { + JFreeChart chart = builder.createChart(builder.getMGoal() + .getChartType()); + + render(chart); } - } // BarGraph - - /** Zero/Zero Coordibate point */ - private Point m_point0_0 = null; - - /** Logger */ - private static CLogger log = CLogger.getCLogger (WGraph.class); - - /** Y Axis Target Line Label */ - private String m_Y_TargetLabel = null; - - /** - * Load Performance Data - */ - ArrayList list = new ArrayList(); - - private GraphBuilder builder; - - private boolean m_userSelection; - - private int zoomFactor = 0; - - private void loadData() - { + if (m_renderTable) { + if (m_renderChart) { + East east = new East(); + layout.appendChild(east); + renderTable(east); + } else { + Panelchildren pc = panel.getPanelchildren(); + if (pc == null) { + pc = new Panelchildren(); + panel.appendChild(pc); + } else { + pc.getChildren().clear(); + } + renderTable(pc); + } + } + } + + private void loadData() { list = builder.loadData(); - if (m_userSelection) - { + if (m_renderChart && m_chartSelection) { Toolbar toolbar = new Toolbar(); panel.appendChild(toolbar); - int AD_Reference_Value_ID = DB.getSQLValue(null, "SELECT AD_Reference_ID FROM AD_Reference WHERE Name = ?", "PA_Goal ChartType"); - MLookupInfo info = MLookupFactory.getLookup_List(Env.getLanguage(Env.getCtx()), AD_Reference_Value_ID); + int AD_Reference_Value_ID = DB.getSQLValue(null, + "SELECT AD_Reference_ID FROM AD_Reference WHERE Name = ?", + "PA_Goal ChartType"); + MLookupInfo info = MLookupFactory.getLookup_List(Env + .getLanguage(Env.getCtx()), AD_Reference_Value_ID); MLookup mLookup = new MLookup(info, 0); - WTableDirEditor editor = new WTableDirEditor("ChartType", false, false, true, mLookup); + WTableDirEditor editor = new WTableDirEditor("ChartType", false, + false, true, mLookup); toolbar.appendChild(editor.getComponent()); editor.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent evt) { Object value = evt.getNewValue(); - if (value == null || value.toString().trim().length() == 0) return; + if (value == null || value.toString().trim().length() == 0) + return; JFreeChart chart = null; chart = builder.createChart(value.toString()); if (chart != null) @@ -186,25 +247,21 @@ public class WGraph extends Div implements IdSpace }); } - JFreeChart chart = builder.createChart(builder.getMGoal().getChartType()); - - render(chart); - } // loadData + } // loadData private void render(JFreeChart chart) { ChartRenderingInfo info = new ChartRenderingInfo(); int width = 560; int height = 400; - if (zoomFactor > 0) - { + if (zoomFactor > 0) { width = width * zoomFactor / 100; height = height * zoomFactor / 100; } - if (m_hideTitle) - { + if (m_hideTitle) { chart.setTitle(""); } - BufferedImage bi = chart.createBufferedImage(width, height, BufferedImage.TRANSLUCENT, info); + BufferedImage bi = chart.createBufferedImage(width, height, + BufferedImage.TRANSLUCENT, info); try { byte[] bytes = EncoderUtil.encode(bi, ImageFormat.PNG, true); @@ -222,29 +279,25 @@ public class WGraph extends Div implements IdSpace } int count = 0; - for(Iterator it = info.getEntityCollection().getEntities().iterator(); it.hasNext(); ) - { - ChartEntity entity = ( ChartEntity ) it.next(); + for (Iterator it = info.getEntityCollection().getEntities() + .iterator(); it.hasNext();) { + ChartEntity entity = (ChartEntity) it.next(); String key = null; - if (entity instanceof CategoryItemEntity) - { - Comparable colKey = ((CategoryItemEntity)entity).getColumnKey(); - if (colKey != null) - { + if (entity instanceof CategoryItemEntity) { + Comparable colKey = ((CategoryItemEntity) entity) + .getColumnKey(); + if (colKey != null) { key = colKey.toString(); } - } - else if (entity instanceof PieSectionEntity) - { - Comparable sectionKey = ((PieSectionEntity)entity).getSectionKey(); - if (sectionKey != null) - { + } else if (entity instanceof PieSectionEntity) { + Comparable sectionKey = ((PieSectionEntity) entity) + .getSectionKey(); + if (sectionKey != null) { key = sectionKey.toString(); } } - if (key == null) - { + if (key == null) { continue; } @@ -253,23 +306,18 @@ public class WGraph extends Div implements IdSpace area.setCoords(entity.getShapeCoords()); area.setShape(entity.getShapeType()); area.setTooltiptext(entity.getToolTipText()); - area.setId("WG_"+key); + area.setId("WG_" + key); count++; } - myImage.addEventListener(Events.ON_CLICK, new EventListener() - { - public void onEvent(Event event) throws Exception - { + myImage.addEventListener(Events.ON_CLICK, new EventListener() { + public void onEvent(Event event) throws Exception { MouseEvent me = (MouseEvent) event; String areaId = me.getArea(); - if(areaId != null) - { - for(int i = 0; i < list.size(); i++) - { + if (areaId != null) { + for (int i = 0; i < list.size(); i++) { String s = "WG_" + list.get(i).getLabel(); - if(areaId.equals(s)) - { + if (areaId.equals(s)) { chartMouseClicked(i); return; } @@ -277,79 +325,120 @@ public class WGraph extends Div implements IdSpace } } }); - } - catch (Exception e) { - log.log (Level.SEVERE, "", e); + } catch (Exception e) { + log.log(Level.SEVERE, "", e); } } + /** * Get Point 0_0 - * + * * @return point */ - public Point getPoint0_0() - { + public Point getPoint0_0() { return m_point0_0; - } // getPoint0_0 - + } // getPoint0_0 /** * @return Returns the x_AxisLabel. */ - public String getX_AxisLabel () - { + public String getX_AxisLabel() { return builder.getXAxisLabel(); - } // getX_AxisLabel + } // getX_AxisLabel /** - * @param axisLabel The x_AxisLabel to set. + * @param axisLabel + * The x_AxisLabel to set. */ - public void setX_AxisLabel (String axisLabel) - { + public void setX_AxisLabel(String axisLabel) { builder.setXAxisLabel(axisLabel); - } // setX_AxisLabel + } // setX_AxisLabel /** * @return Returns the y_AxisLabel. */ - public String getY_AxisLabel () - { + public String getY_AxisLabel() { return builder.getYAxisLabel(); - } // getY_AxisLabel + } // getY_AxisLabel /** - * @param axisLabel The y_AxisLabel to set. + * @param axisLabel + * The y_AxisLabel to set. */ - public void setY_AxisLabel (String axisLabel) - { + public void setY_AxisLabel(String axisLabel) { builder.setYAxisLabel(axisLabel); - } // setY_AxisLabel + } // setY_AxisLabel /** * @return Returns the y_TargetLabel. */ - public String getY_TargetLabel () - { + public String getY_TargetLabel() { return m_Y_TargetLabel; - } // getY_TargetLabel + } // getY_TargetLabel /** - * @param targetLabel The y_TargetLabel to set. + * @param targetLabel + * The y_TargetLabel to set. */ - public void setY_TargetLabel (String targetLabel, double target) - { + public void setY_TargetLabel(String targetLabel, double target) { m_Y_TargetLabel = targetLabel; -// m_Y_Target = target; - } // setY_TargetLabel + // m_Y_Target = target; + } // setY_TargetLabel + /** + * @return zoom in factor + */ + public int getZoomFactor() { + return zoomFactor; + } + + /** + * set zoom in factor + * + * @param zoomFactor + */ + public void setZoomFactor(int zoomFactor) { + this.zoomFactor = zoomFactor; + } + + /** + * @return true if the summary table for performance goal is render on screen + */ + public boolean isRenderTable() { + return m_renderTable; + } + + /** + * hide/show the summary table for performance goal + * @param mRenderTable + */ + public void setRenderTable(boolean mRenderTable) { + m_renderTable = mRenderTable; + } + + /** + * @return true if chart is render on screen + */ + public boolean isRenderChart() { + return m_renderChart; + } + + /** + * hide/show chart for performance goal + * @param mRenderChart + */ + public void setRenderChart(boolean mRenderChart) { + m_renderChart = mRenderChart; + } /************************************************************************** - * Paint Component - * @param g graphics + * Paint Component + * + * @param g + * graphics */ - public void chartMouseClicked(int index) - { + public void chartMouseClicked(int index) { GraphColumn bgc = list.get(index); if (null == bgc) return; @@ -360,110 +449,137 @@ public class WGraph extends Div implements IdSpace log.warning("Nothing to zoom to - " + bgc); } - public void chartMouseMoved(ChartMouseEvent event) {} + public void chartMouseMoved(ChartMouseEvent event) { + } - public GraphColumn[] getGraphColumnList() - { + /** + * + * @return GraphColumn[] + */ + public GraphColumn[] getGraphColumnList() { GraphColumn[] array = new GraphColumn[list.size()]; - for (int i = 0; i < list.size(); i++){ + for (int i = 0; i < list.size(); i++) { array[i] = list.get(i); } return array; } - public int getZoomFactor() { - return zoomFactor; - } + private void renderTable(Component parent) { + Div div = new Div(); + appendChild(div); + div.setSclass("pa-content"); + parent.appendChild(div); - public void setZoomFactor(int zoomFactor) { - this.zoomFactor = zoomFactor; - } + Table table = new Table(); + table.setSclass("pa-dataGrid"); + div.appendChild(table); + Tr tr = new Tr(); + table.appendChild(tr); + Td td = new Td(); + td.setSclass("pa-label"); + tr.appendChild(td); + Text text = new Text("Target"); + td.appendChild(text); + td = new Td(); + td.setDynamicProperty("colspan", "2"); + td.setSclass("pa-tdcontent"); + tr.appendChild(td); + text = new Text(builder.getMGoal().getMeasureTarget().setScale(2, + BigDecimal.ROUND_HALF_UP).toPlainString()); + td.appendChild(text); - protected String renderGoal() - { - String output = "
"; - - output += "\n"; - output += "\n"; - output += "\n"; + tr = new Tr(); + table.appendChild(tr); + td = new Td(); + td.setSclass("pa-label"); + tr.appendChild(td); + text = new Text("Actual"); + td.appendChild(text); + td = new Td(); + td.setDynamicProperty("colspan", "2"); + td.setSclass("pa-tdcontent"); + tr.appendChild(td); + text = new Text(builder.getMGoal().getMeasureActual().setScale(2, + BigDecimal.ROUND_HALF_UP).toPlainString()); + td.appendChild(text); GraphColumn[] bList = getGraphColumnList(); - output += "\n"; - for (int k = 0; k < bList.length; k++) - { + tr = new Tr(); + table.appendChild(tr); + td = new Td(); + tr.appendChild(td); + td.setDynamicProperty("rowspan", bList.length); + td.setSclass("pa-label"); + td.setDynamicProperty("valign", "top"); + text = new Text(builder.getMGoal().getXAxisText()); + td.appendChild(text); + + for (int k = 0; k < bList.length; k++) { GraphColumn bgc = bList[k]; - if (k > 0) - output += ""; + if (k > 0) { + tr = new Tr(); + table.appendChild(tr); + } - output += ""; } - output += "" - + "" - + "
Target" - + builder.getMGoal().getMeasureTarget().setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() - + "
Actual" - + builder.getMGoal().getMeasureActual().setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() - + "
" - + builder.getMGoal().getXAxisText() + "
" + bgc.getLabel() - + ""; - if (bgc.getMQuery(builder.getMGoal()) != null) { - Button btn = new Button(); - btn.setId(String.valueOf(ZOOM_KEY + k)); - btn.addEventListener(Events.ON_CLICK, new EventListener() { + td = new Td(); + td.setSclass("pa-tdlabel"); + tr.appendChild(td); + text = new Text(bgc.getLabel()); + td.appendChild(text); + td = new Td(); + td.setSclass("pa-tdvalue"); + tr.appendChild(td); + BigDecimal value = new BigDecimal(bgc.getValue()); + if (bgc.getMQuery(builder.getMGoal()) != null) { + A a = new A(); + a.setSclass("pa-hrefNode"); + td.appendChild(a); + a.setId(ZOOM_KEY + k); + a.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)); - GraphColumn[] colList = getGraphColumnList(); - if ((index >= 0) && (index < colList.length)) - AEnv.zoom(colList[index].getMQuery(builder.getMGoal())); - } + if (id.startsWith(ZOOM_KEY)) { + String ss = id.substring(ZOOM_KEY.length()); + int index = Integer.parseInt(String.valueOf(ss)); + GraphColumn[] colList = getGraphColumnList(); + if ((index >= 0) && (index < colList.length)) + AEnv.zoom(colList[index].getMQuery(builder + .getMGoal())); + } } }); - btn.setVisible(false); - appendChild(btn); - - BigDecimal value = new BigDecimal(bgc.getValue()); - output += "" - + value.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() - + "\n"; + a.setDynamicProperty("href", "javascript:;"); + text = new Text(value.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString()); + a.appendChild(text); } else { - output += bgc.getValue(); + text = new Text(value.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString()); } - output += "
" - + builder.getMGoal().getDescription() - + "
" - + stripHtml(builder.getMGoal().getColorSchema() - .getDescription(), true) + "
\n"; - - output += "
"; - bList = null; - - return output; + tr = new Tr(); + table.appendChild(tr); + td = new Td(); + td.setDynamicProperty("colspan", "3"); + tr.appendChild(td); + text = new Text(builder.getMGoal().getDescription()); + td.appendChild(text); + Br br = new Br(); + td.appendChild(br); + text = new Text(stripHtml(builder.getMGoal().getColorSchema() + .getDescription(), true)); + td.appendChild(text); } - protected String stripHtml(String htmlString, boolean all) { - htmlString = htmlString - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", "") - .replace("", ""); + private String stripHtml(String htmlString, boolean all) { + htmlString = htmlString.replace("", "").replace("", "") + .replace("", "").replace("", "").replace("", + "").replace("", ""); if (all) - htmlString = htmlString - .replace(">", ">") - .replace("<", "<"); + htmlString = htmlString.replace(">", ">").replace("<", "<"); return htmlString; } -} // BarGraph +} // BarGraph diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WPerformanceDetail.java b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WPerformanceDetail.java index 4b456f81c6..c327e9ede2 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WPerformanceDetail.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/apps/graph/WPerformanceDetail.java @@ -28,7 +28,7 @@ public class WPerformanceDetail extends Window super(); setTitle(goal.getName()); - WGraph barPanel = new WGraph(goal, 0, true, false, true); + WGraph barPanel = new WGraph(goal, 0, true, false, true, true); appendChild(barPanel); this.setAttribute(Window.MODE_KEY, Window.MODE_EMBEDDED); diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java b/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java index 75ee5e945f..c20aef117e 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/DefaultDesktop.java @@ -274,8 +274,11 @@ public class DefaultDesktop extends TabbedDesktop implements MenuListener, Seria }); content.appendChild(link); + String goalDisplay = rs.getString(X_PA_DashboardContent.COLUMNNAME_GoalDisplay); MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null); - WGraph graph = new WGraph(goal, 55, false, true, false); + WGraph graph = new WGraph(goal, 55, false, true, + !(X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)), + X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)); content.appendChild(graph); panelEmpty = false; } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBar2Desktop.java b/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBar2Desktop.java index 580f42a3ce..981ae97871 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBar2Desktop.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBar2Desktop.java @@ -297,8 +297,11 @@ public class NavBar2Desktop extends TabbedDesktop implements MenuListener, Seria int PA_Goal_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_PA_Goal_ID); if(PA_Goal_ID > 0) { - MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null); - WGraph graph = new WGraph(goal, 55, false, true, false); + String goalDisplay = rs.getString(X_PA_DashboardContent.COLUMNNAME_GoalDisplay); + MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null); + WGraph graph = new WGraph(goal, 55, false, true, + !(X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)), + X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)); content.appendChild(graph); panelEmpty = false; } diff --git a/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBarDesktop.java b/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBarDesktop.java index 6c12c86096..3e23b5663c 100644 --- a/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBarDesktop.java +++ b/zkwebui/WEB-INF/src/org/adempiere/webui/desktop/NavBarDesktop.java @@ -300,8 +300,11 @@ public class NavBarDesktop extends TabbedDesktop implements MenuListener, Serial int PA_Goal_ID = rs.getInt(X_PA_DashboardContent.COLUMNNAME_PA_Goal_ID); if(PA_Goal_ID > 0) { - MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null); - WGraph graph = new WGraph(goal, 55, false, true, false); + String goalDisplay = rs.getString(X_PA_DashboardContent.COLUMNNAME_GoalDisplay); + MGoal goal = new MGoal(Env.getCtx(), PA_Goal_ID, null); + WGraph graph = new WGraph(goal, 55, false, true, + !(X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)), + X_PA_DashboardContent.GOALDISPLAY_Chart.equals(goalDisplay)); content.appendChild(graph); panelEmpty = false; } diff --git a/zkwebui/css/PAPanel.css b/zkwebui/css/PAPanel.css index 0713e69e00..a79bb96238 100755 --- a/zkwebui/css/PAPanel.css +++ b/zkwebui/css/PAPanel.css @@ -15,8 +15,8 @@ border-color: #BBBBBB; border-style: solid; border-collapse: collapse; - width: 60%; - background-color: #EBF1EF; + width: 90%; + background-color: #EBF1EF; } .pa-dataGrid th { text-align: center; @@ -32,14 +32,17 @@ border-width: 1px; border-color: #BBBBBB; border-style: solid; + padding: 3px; } .pa-label { background-color: #C6D1CD; } .pa-tdlabel { background-color: #D6E1DD; + padding: 3px; } .pa-tdvalue { background-color: #EBF1EF; text-align: right; + padding: 3px; } \ No newline at end of file