IDEMPIERE-1157: Adding functionality to add charts on the standard windows / thanks to Adaxa
This commit is contained in:
parent
10488f31ef
commit
c3a14d9547
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1013,6 +1013,16 @@ public class GridField
|
|||
{
|
||||
return m_vo.AD_Window_ID;
|
||||
}
|
||||
|
||||
/** get AD_Chart_ID
|
||||
* @return chart id
|
||||
*/
|
||||
public int getAD_Chart_ID()
|
||||
{
|
||||
return m_vo.AD_Chart_ID;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get Window No
|
||||
* @return window no
|
||||
|
|
|
@ -48,6 +48,8 @@ public class GridFieldVO implements Serializable
|
|||
*/
|
||||
private static final long serialVersionUID = 7595228091613559685L;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return the SQL statement used for the MFieldVO.create
|
||||
* @param ctx context
|
||||
|
@ -223,6 +225,8 @@ public class GridFieldVO implements Serializable
|
|||
vo.NumLines=rs.getInt(i);
|
||||
else if (columnName.equalsIgnoreCase("IsToolbarButton"))
|
||||
vo.IsToolbarButton = "Y".equals(rs.getString(i));
|
||||
else if (columnName.equalsIgnoreCase("AD_Chart_ID"))
|
||||
vo.AD_Chart_ID = rs.getInt (i);
|
||||
}
|
||||
if (vo.Header == null)
|
||||
vo.Header = vo.ColumnName;
|
||||
|
@ -613,6 +617,8 @@ public class GridFieldVO implements Serializable
|
|||
/** Toolbar Button **/
|
||||
public boolean IsToolbarButton = false;
|
||||
|
||||
public int AD_Chart_ID = 0;
|
||||
|
||||
/**
|
||||
* Set Context including contained elements
|
||||
* @param newCtx new context
|
||||
|
@ -713,6 +719,7 @@ public class GridFieldVO implements Serializable
|
|||
clone.DefaultValue = DefaultValue;
|
||||
clone.IsMandatory = IsMandatory;
|
||||
clone.IsReadOnly = IsReadOnly;
|
||||
clone.AD_Chart_ID = AD_Chart_ID;
|
||||
clone.IsUpdateable = IsUpdateable;
|
||||
clone.IsAlwaysUpdateable = IsAlwaysUpdateable;
|
||||
clone.IsHeading = IsHeading;
|
||||
|
|
|
@ -3687,6 +3687,11 @@ public class GridTable extends AbstractTableModel
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
// todo: temporary fix for carlos assumption that all windows have _id column
|
||||
if ( findColumn(m_tableName + "_ID") == -1)
|
||||
return false;
|
||||
|
||||
Timestamp dbUpdated = null;
|
||||
String dbProcessedS = null;
|
||||
PreparedStatement pstmt = null;
|
||||
|
|
|
@ -0,0 +1,257 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2007 ComPiere, Inc. 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 *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
|
||||
/** Generated Interface for AD_Chart
|
||||
* @author Adempiere (generated)
|
||||
* @version Release 3.6.0LTS
|
||||
*/
|
||||
public interface I_AD_Chart
|
||||
{
|
||||
|
||||
/** TableName=AD_Chart */
|
||||
public static final String Table_Name = "AD_Chart";
|
||||
|
||||
/** AD_Table_ID=53284 */
|
||||
public static final int Table_ID = MTable.getTable_ID(Table_Name);
|
||||
|
||||
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
|
||||
|
||||
/** AccessLevel = 4 - System
|
||||
*/
|
||||
BigDecimal accessLevel = BigDecimal.valueOf(4);
|
||||
|
||||
/** Load Meta Data */
|
||||
|
||||
/** Column name AD_Chart_ID */
|
||||
public static final String COLUMNNAME_AD_Chart_ID = "AD_Chart_ID";
|
||||
|
||||
/** Set Chart */
|
||||
public void setAD_Chart_ID (int AD_Chart_ID);
|
||||
|
||||
/** Get Chart */
|
||||
public int getAD_Chart_ID();
|
||||
|
||||
/** Column name AD_Client_ID */
|
||||
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
|
||||
|
||||
/** Get Client.
|
||||
* Client/Tenant for this installation.
|
||||
*/
|
||||
public int getAD_Client_ID();
|
||||
|
||||
/** Column name AD_Org_ID */
|
||||
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
|
||||
|
||||
/** Set Organization.
|
||||
* Organizational entity within client
|
||||
*/
|
||||
public void setAD_Org_ID (int AD_Org_ID);
|
||||
|
||||
/** Get Organization.
|
||||
* Organizational entity within client
|
||||
*/
|
||||
public int getAD_Org_ID();
|
||||
|
||||
/** Column name ChartOrientation */
|
||||
public static final String COLUMNNAME_ChartOrientation = "ChartOrientation";
|
||||
|
||||
/** Set Orientation.
|
||||
* The orientation of the chart.
|
||||
*/
|
||||
public void setChartOrientation (String ChartOrientation);
|
||||
|
||||
/** Get Orientation.
|
||||
* The orientation of the chart.
|
||||
*/
|
||||
public String getChartOrientation();
|
||||
|
||||
/** Column name ChartType */
|
||||
public static final String COLUMNNAME_ChartType = "ChartType";
|
||||
|
||||
/** Set Chart Type.
|
||||
* Type of chart to render
|
||||
*/
|
||||
public void setChartType (String ChartType);
|
||||
|
||||
/** Get Chart Type.
|
||||
* Type of chart to render
|
||||
*/
|
||||
public String getChartType();
|
||||
|
||||
/** Column name Created */
|
||||
public static final String COLUMNNAME_Created = "Created";
|
||||
|
||||
/** Get Created.
|
||||
* Date this record was created
|
||||
*/
|
||||
public Timestamp getCreated();
|
||||
|
||||
/** Column name CreatedBy */
|
||||
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
|
||||
|
||||
/** Get Created By.
|
||||
* User who created this records
|
||||
*/
|
||||
public int getCreatedBy();
|
||||
|
||||
/** Column name Description */
|
||||
public static final String COLUMNNAME_Description = "Description";
|
||||
|
||||
/** Set Description.
|
||||
* Optional short description of the record
|
||||
*/
|
||||
public void setDescription (String Description);
|
||||
|
||||
/** Get Description.
|
||||
* Optional short description of the record
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
/** Column name DomainLabel */
|
||||
public static final String COLUMNNAME_DomainLabel = "DomainLabel";
|
||||
|
||||
/** Set Domain Label.
|
||||
* Label for the domain axis.
|
||||
*/
|
||||
public void setDomainLabel (String DomainLabel);
|
||||
|
||||
/** Get Domain Label.
|
||||
* Label for the domain axis.
|
||||
*/
|
||||
public String getDomainLabel();
|
||||
|
||||
/** Column name IsActive */
|
||||
public static final String COLUMNNAME_IsActive = "IsActive";
|
||||
|
||||
/** Set Active.
|
||||
* The record is active in the system
|
||||
*/
|
||||
public void setIsActive (boolean IsActive);
|
||||
|
||||
/** Get Active.
|
||||
* The record is active in the system
|
||||
*/
|
||||
public boolean isActive();
|
||||
|
||||
/** Column name IsDisplayLegend */
|
||||
public static final String COLUMNNAME_IsDisplayLegend = "IsDisplayLegend";
|
||||
|
||||
/** Set Display Legend.
|
||||
* Display chart legend
|
||||
*/
|
||||
public void setIsDisplayLegend (boolean IsDisplayLegend);
|
||||
|
||||
/** Get Display Legend.
|
||||
* Display chart legend
|
||||
*/
|
||||
public boolean isDisplayLegend();
|
||||
|
||||
/** Column name IsTimeSeries */
|
||||
public static final String COLUMNNAME_IsTimeSeries = "IsTimeSeries";
|
||||
|
||||
/** Set Time Series.
|
||||
* The domain data for the chart is organised by time.
|
||||
*/
|
||||
public void setIsTimeSeries (boolean IsTimeSeries);
|
||||
|
||||
/** Get Time Series.
|
||||
* The domain data for the chart is organised by time.
|
||||
*/
|
||||
public boolean isTimeSeries();
|
||||
|
||||
/** Column name Name */
|
||||
public static final String COLUMNNAME_Name = "Name";
|
||||
|
||||
/** Set Name.
|
||||
* Alphanumeric identifier of the entity
|
||||
*/
|
||||
public void setName (String Name);
|
||||
|
||||
/** Get Name.
|
||||
* Alphanumeric identifier of the entity
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/** Column name RangeLabel */
|
||||
public static final String COLUMNNAME_RangeLabel = "RangeLabel";
|
||||
|
||||
/** Set Range Label.
|
||||
* Label for the range axis.
|
||||
*/
|
||||
public void setRangeLabel (String RangeLabel);
|
||||
|
||||
/** Get Range Label.
|
||||
* Label for the range axis.
|
||||
*/
|
||||
public String getRangeLabel();
|
||||
|
||||
/** Column name TimeScope */
|
||||
public static final String COLUMNNAME_TimeScope = "TimeScope";
|
||||
|
||||
/** Set Time Scope.
|
||||
* The number of time units to include the chart result.
|
||||
*/
|
||||
public void setTimeScope (int TimeScope);
|
||||
|
||||
/** Get Time Scope.
|
||||
* The number of time units to include the chart result.
|
||||
*/
|
||||
public int getTimeScope();
|
||||
|
||||
/** Column name TimeUnit */
|
||||
public static final String COLUMNNAME_TimeUnit = "TimeUnit";
|
||||
|
||||
/** Set Time Unit.
|
||||
* The unit of time for grouping chart data.
|
||||
*/
|
||||
public void setTimeUnit (String TimeUnit);
|
||||
|
||||
/** Get Time Unit.
|
||||
* The unit of time for grouping chart data.
|
||||
*/
|
||||
public String getTimeUnit();
|
||||
|
||||
/** Column name Updated */
|
||||
public static final String COLUMNNAME_Updated = "Updated";
|
||||
|
||||
/** Get Updated.
|
||||
* Date this record was updated
|
||||
*/
|
||||
public Timestamp getUpdated();
|
||||
|
||||
/** Column name UpdatedBy */
|
||||
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
|
||||
|
||||
/** Get Updated By.
|
||||
* User who updated this records
|
||||
*/
|
||||
public int getUpdatedBy();
|
||||
|
||||
/** Column name WinHeight */
|
||||
public static final String COLUMNNAME_WinHeight = "WinHeight";
|
||||
|
||||
/** Set Window Height */
|
||||
public void setWinHeight (int WinHeight);
|
||||
|
||||
/** Get Window Height */
|
||||
public int getWinHeight();
|
||||
}
|
|
@ -0,0 +1,285 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2007 ComPiere, Inc. 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 *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
package org.compiere.model;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
|
||||
/** Generated Interface for AD_ChartDatasource
|
||||
* @author Adempiere (generated)
|
||||
* @version 360LTS.013
|
||||
*/
|
||||
public interface I_AD_ChartDatasource
|
||||
{
|
||||
|
||||
/** TableName=AD_ChartDatasource */
|
||||
public static final String Table_Name = "AD_ChartDatasource";
|
||||
|
||||
/** AD_Table_ID=53282 */
|
||||
public static final int Table_ID = MTable.getTable_ID(Table_Name);
|
||||
|
||||
KeyNamePair Model = new KeyNamePair(Table_ID, Table_Name);
|
||||
|
||||
/** AccessLevel = 4 - System
|
||||
*/
|
||||
BigDecimal accessLevel = BigDecimal.valueOf(4);
|
||||
|
||||
/** Load Meta Data */
|
||||
|
||||
/** Column name AD_ChartDatasource_ID */
|
||||
public static final String COLUMNNAME_AD_ChartDatasource_ID = "AD_ChartDatasource_ID";
|
||||
|
||||
/** Set Chart Datasource */
|
||||
public void setAD_ChartDatasource_ID (int AD_ChartDatasource_ID);
|
||||
|
||||
/** Get Chart Datasource */
|
||||
public int getAD_ChartDatasource_ID();
|
||||
|
||||
/** Column name AD_Chart_ID */
|
||||
public static final String COLUMNNAME_AD_Chart_ID = "AD_Chart_ID";
|
||||
|
||||
/** Set Chart */
|
||||
public void setAD_Chart_ID (int AD_Chart_ID);
|
||||
|
||||
/** Get Chart */
|
||||
public int getAD_Chart_ID();
|
||||
|
||||
public I_AD_Chart getAD_Chart() throws RuntimeException;
|
||||
|
||||
/** Column name AD_Client_ID */
|
||||
public static final String COLUMNNAME_AD_Client_ID = "AD_Client_ID";
|
||||
|
||||
/** Get Client.
|
||||
* Client/Tenant for this installation.
|
||||
*/
|
||||
public int getAD_Client_ID();
|
||||
|
||||
/** Column name AD_Org_ID */
|
||||
public static final String COLUMNNAME_AD_Org_ID = "AD_Org_ID";
|
||||
|
||||
/** Set Organisation.
|
||||
* Organisational entity within client
|
||||
*/
|
||||
public void setAD_Org_ID (int AD_Org_ID);
|
||||
|
||||
/** Get Organisation.
|
||||
* Organisational entity within client
|
||||
*/
|
||||
public int getAD_Org_ID();
|
||||
|
||||
/** Column name AD_Table_ID */
|
||||
public static final String COLUMNNAME_AD_Table_ID = "AD_Table_ID";
|
||||
|
||||
/** Set Table.
|
||||
* Database Table information
|
||||
*/
|
||||
public void setAD_Table_ID (int AD_Table_ID);
|
||||
|
||||
/** Get Table.
|
||||
* Database Table information
|
||||
*/
|
||||
public int getAD_Table_ID();
|
||||
|
||||
public I_AD_Table getAD_Table() throws RuntimeException;
|
||||
|
||||
/** Column name CategoryColumn */
|
||||
public static final String COLUMNNAME_CategoryColumn = "CategoryColumn";
|
||||
|
||||
/** Set Category Column.
|
||||
* Fully qualified data category column
|
||||
*/
|
||||
public void setCategoryColumn (String CategoryColumn);
|
||||
|
||||
/** Get Category Column.
|
||||
* Fully qualified data category column
|
||||
*/
|
||||
public String getCategoryColumn();
|
||||
|
||||
/** Column name Created */
|
||||
public static final String COLUMNNAME_Created = "Created";
|
||||
|
||||
/** Get Created.
|
||||
* Date this record was created
|
||||
*/
|
||||
public Timestamp getCreated();
|
||||
|
||||
/** Column name CreatedBy */
|
||||
public static final String COLUMNNAME_CreatedBy = "CreatedBy";
|
||||
|
||||
/** Get Created By.
|
||||
* User who created this records
|
||||
*/
|
||||
public int getCreatedBy();
|
||||
|
||||
/** Column name DateColumn */
|
||||
public static final String COLUMNNAME_DateColumn = "DateColumn";
|
||||
|
||||
/** Set Date Column.
|
||||
* Fully qualified date column
|
||||
*/
|
||||
public void setDateColumn (String DateColumn);
|
||||
|
||||
/** Get Date Column.
|
||||
* Fully qualified date column
|
||||
*/
|
||||
public String getDateColumn();
|
||||
|
||||
/** Column name Description */
|
||||
public static final String COLUMNNAME_Description = "Description";
|
||||
|
||||
/** Set Description.
|
||||
* Optional short description of the record
|
||||
*/
|
||||
public void setDescription (String Description);
|
||||
|
||||
/** Get Description.
|
||||
* Optional short description of the record
|
||||
*/
|
||||
public String getDescription();
|
||||
|
||||
/** Column name EntityType */
|
||||
public static final String COLUMNNAME_EntityType = "EntityType";
|
||||
|
||||
/** Set Entity Type.
|
||||
* Dictionary Entity Type;
|
||||
Determines ownership and synchronization
|
||||
*/
|
||||
public void setEntityType (String EntityType);
|
||||
|
||||
/** Get Entity Type.
|
||||
* Dictionary Entity Type;
|
||||
Determines ownership and synchronization
|
||||
*/
|
||||
public String getEntityType();
|
||||
|
||||
/** Column name FromClause */
|
||||
public static final String COLUMNNAME_FromClause = "FromClause";
|
||||
|
||||
/** Set Sql FROM.
|
||||
* SQL FROM clause
|
||||
*/
|
||||
public void setFromClause (String FromClause);
|
||||
|
||||
/** Get Sql FROM.
|
||||
* SQL FROM clause
|
||||
*/
|
||||
public String getFromClause();
|
||||
|
||||
/** Column name IsActive */
|
||||
public static final String COLUMNNAME_IsActive = "IsActive";
|
||||
|
||||
/** Set Active.
|
||||
* The record is active in the system
|
||||
*/
|
||||
public void setIsActive (boolean IsActive);
|
||||
|
||||
/** Get Active.
|
||||
* The record is active in the system
|
||||
*/
|
||||
public boolean isActive();
|
||||
|
||||
/** Column name KeyColumn */
|
||||
public static final String COLUMNNAME_KeyColumn = "KeyColumn";
|
||||
|
||||
/** Set Key Column.
|
||||
* Key Column for Table
|
||||
*/
|
||||
public void setKeyColumn (String KeyColumn);
|
||||
|
||||
/** Get Key Column.
|
||||
* Key Column for Table
|
||||
*/
|
||||
public String getKeyColumn();
|
||||
|
||||
/** Column name Name */
|
||||
public static final String COLUMNNAME_Name = "Name";
|
||||
|
||||
/** Set Name.
|
||||
* Alphanumeric identifier of the entity
|
||||
*/
|
||||
public void setName (String Name);
|
||||
|
||||
/** Get Name.
|
||||
* Alphanumeric identifier of the entity
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/** Column name SeriesColumn */
|
||||
public static final String COLUMNNAME_SeriesColumn = "SeriesColumn";
|
||||
|
||||
/** Set Series Column */
|
||||
public void setSeriesColumn (String SeriesColumn);
|
||||
|
||||
/** Get Series Column */
|
||||
public String getSeriesColumn();
|
||||
|
||||
/** Column name TimeOffset */
|
||||
public static final String COLUMNNAME_TimeOffset = "TimeOffset";
|
||||
|
||||
/** Set Time Offset.
|
||||
* Number of time units to offset displayed chart data from the current date.
|
||||
*/
|
||||
public void setTimeOffset (int TimeOffset);
|
||||
|
||||
/** Get Time Offset.
|
||||
* Number of time units to offset displayed chart data from the current date.
|
||||
*/
|
||||
public int getTimeOffset();
|
||||
|
||||
/** Column name Updated */
|
||||
public static final String COLUMNNAME_Updated = "Updated";
|
||||
|
||||
/** Get Updated.
|
||||
* Date this record was updated
|
||||
*/
|
||||
public Timestamp getUpdated();
|
||||
|
||||
/** Column name UpdatedBy */
|
||||
public static final String COLUMNNAME_UpdatedBy = "UpdatedBy";
|
||||
|
||||
/** Get Updated By.
|
||||
* User who updated this records
|
||||
*/
|
||||
public int getUpdatedBy();
|
||||
|
||||
/** Column name ValueColumn */
|
||||
public static final String COLUMNNAME_ValueColumn = "ValueColumn";
|
||||
|
||||
/** Set Value Column.
|
||||
* Fully qualified data value column
|
||||
*/
|
||||
public void setValueColumn (String ValueColumn);
|
||||
|
||||
/** Get Value Column.
|
||||
* Fully qualified data value column
|
||||
*/
|
||||
public String getValueColumn();
|
||||
|
||||
/** Column name WhereClause */
|
||||
public static final String COLUMNNAME_WhereClause = "WhereClause";
|
||||
|
||||
/** Set Sql WHERE.
|
||||
* Fully qualified SQL WHERE clause
|
||||
*/
|
||||
public void setWhereClause (String WhereClause);
|
||||
|
||||
/** Get Sql WHERE.
|
||||
* Fully qualified SQL WHERE clause
|
||||
*/
|
||||
public String getWhereClause();
|
||||
}
|
|
@ -0,0 +1,422 @@
|
|||
package org.compiere.model;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.jfree.chart.ChartFactory;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
import org.jfree.chart.axis.CategoryAxis;
|
||||
import org.jfree.chart.axis.CategoryLabelPositions;
|
||||
import org.jfree.chart.plot.CategoryPlot;
|
||||
import org.jfree.chart.plot.PlotOrientation;
|
||||
import org.jfree.chart.renderer.category.BarRenderer;
|
||||
import org.jfree.chart.renderer.category.CategoryItemRenderer;
|
||||
import org.jfree.chart.renderer.category.StandardBarPainter;
|
||||
import org.jfree.data.category.CategoryDataset;
|
||||
import org.jfree.data.category.DefaultCategoryDataset;
|
||||
import org.jfree.data.general.Dataset;
|
||||
import org.jfree.data.general.DefaultPieDataset;
|
||||
import org.jfree.data.general.PieDataset;
|
||||
import org.jfree.data.time.TimeSeriesCollection;
|
||||
import org.jfree.data.xy.IntervalXYDataset;
|
||||
|
||||
public class MChart extends X_AD_Chart {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -8851465915516536910L;
|
||||
|
||||
private int windowNo=0;
|
||||
private Dataset dataset;
|
||||
private HashMap<String,MQuery> queries;
|
||||
|
||||
public MChart(Properties ctx, int AD_Chart_ID, String trxName) {
|
||||
super(ctx, AD_Chart_ID, trxName);
|
||||
}
|
||||
|
||||
public MChart(Properties ctx, ResultSet rs, String trxName) {
|
||||
super(ctx, rs, trxName);
|
||||
}
|
||||
|
||||
public void loadData() {
|
||||
queries = new HashMap<String,MQuery>();
|
||||
for ( MChartDatasource ds : getDatasources() )
|
||||
{
|
||||
ds.addData(this);
|
||||
}
|
||||
}
|
||||
|
||||
public CategoryDataset getCategoryDataset() {
|
||||
dataset = new DefaultCategoryDataset();
|
||||
loadData();
|
||||
return (CategoryDataset) dataset;
|
||||
}
|
||||
|
||||
public IntervalXYDataset getXYDataset() {
|
||||
dataset = new TimeSeriesCollection();
|
||||
loadData();
|
||||
return (IntervalXYDataset) dataset;
|
||||
}
|
||||
|
||||
public PieDataset getPieDataset() {
|
||||
dataset = new DefaultPieDataset();
|
||||
loadData();
|
||||
return (PieDataset) dataset;
|
||||
}
|
||||
|
||||
public Dataset getDataset() {
|
||||
return dataset;
|
||||
}
|
||||
|
||||
private List<MChartDatasource> getDatasources() {
|
||||
|
||||
return new Query(getCtx(), MChartDatasource.Table_Name, MChart.COLUMNNAME_AD_Chart_ID + "=?", null)
|
||||
.setParameters(getAD_Chart_ID()).setOnlyActiveRecords(true).list();
|
||||
}
|
||||
|
||||
public HashMap<String, MQuery> getQueries() {
|
||||
return queries;
|
||||
}
|
||||
|
||||
public void setWindowNo(int windowNo) {
|
||||
this.windowNo = windowNo;
|
||||
}
|
||||
|
||||
public int getWindowNo() {
|
||||
return windowNo;
|
||||
}
|
||||
|
||||
public MQuery getQuery(String key) {
|
||||
|
||||
|
||||
if ( queries.containsKey(key) )
|
||||
{
|
||||
return queries.get(key);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type
|
||||
* @return JFreeChart
|
||||
*/
|
||||
public JFreeChart createChart() {
|
||||
|
||||
String type = getChartType();
|
||||
|
||||
if(MChart.CHARTTYPE_BarChart.equals(type))
|
||||
{
|
||||
if ( isTimeSeries())
|
||||
{
|
||||
return createXYBarChart();
|
||||
}
|
||||
return createBarChart();
|
||||
}
|
||||
else if (MChart.CHARTTYPE_3DBarChart.equals(type))
|
||||
{
|
||||
return create3DBarChart();
|
||||
}
|
||||
else if (MChart.CHARTTYPE_StackedBarChart.equals(type))
|
||||
{
|
||||
|
||||
if ( isTimeSeries())
|
||||
return createXYBarChart();
|
||||
|
||||
return createStackedBarChart();
|
||||
}
|
||||
else if (MChart.CHARTTYPE_3DStackedBarChart.equals(type))
|
||||
{
|
||||
return create3DStackedBarChart();
|
||||
}
|
||||
else if (MChart.CHARTTYPE_3DPieChart.equals(type))
|
||||
{
|
||||
return create3DPieChart();
|
||||
}
|
||||
else if (MChart.CHARTTYPE_PieChart.equals(type))
|
||||
{
|
||||
return createPieChart();
|
||||
}
|
||||
else if (MChart.CHARTTYPE_3DLineChart.equals(type))
|
||||
{
|
||||
return create3DLineChart();
|
||||
}
|
||||
else if (MChart.CHARTTYPE_AreaChart.equals(type))
|
||||
{
|
||||
return createAreaChart();
|
||||
}
|
||||
else if (MChart.CHARTTYPE_StackedAreaChart.equals(type))
|
||||
{
|
||||
return createStackedAreaChart();
|
||||
}
|
||||
else if (MChart.CHARTTYPE_LineChart.equals(type))
|
||||
{
|
||||
if ( isTimeSeries() )
|
||||
return createTimeSeriesChart();
|
||||
return createLineChart();
|
||||
}
|
||||
else if (MChart.CHARTTYPE_RingChart.equals(type))
|
||||
{
|
||||
return createRingChart();
|
||||
}
|
||||
else if (MChart.CHARTTYPE_WaterfallChart.equals(type))
|
||||
{
|
||||
return createWaterfallChart();
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new IllegalArgumentException("unknown chart type=" + type);
|
||||
}
|
||||
}
|
||||
|
||||
private JFreeChart createXYBarChart() {
|
||||
JFreeChart chart = ChartFactory.createXYBarChart(
|
||||
getName(), // chart title
|
||||
getDomainLabel(), // domain axis label
|
||||
true,
|
||||
getRangeLabel(), // range axis label
|
||||
getXYDataset(), // data
|
||||
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(getChartOrientation())
|
||||
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
|
||||
isDisplayLegend(), // include legend
|
||||
true, // tooltips?
|
||||
true // URLs?
|
||||
);
|
||||
|
||||
|
||||
return chart;
|
||||
}
|
||||
|
||||
private JFreeChart createTimeSeriesChart() {
|
||||
JFreeChart chart = ChartFactory.createTimeSeriesChart(
|
||||
getName(), // chart title
|
||||
getDomainLabel(), // domain axis label
|
||||
getRangeLabel(), // range axis label
|
||||
getXYDataset(), // data
|
||||
isDisplayLegend(), // include legend
|
||||
true, // tooltips?
|
||||
true // URLs?
|
||||
);
|
||||
|
||||
|
||||
return chart;
|
||||
}
|
||||
|
||||
private JFreeChart createWaterfallChart() {
|
||||
JFreeChart chart = ChartFactory.createWaterfallChart(
|
||||
getName(), // chart title
|
||||
getDomainLabel(), // domain axis label
|
||||
getRangeLabel(), // range axis label
|
||||
getCategoryDataset(), // data
|
||||
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(getChartOrientation())
|
||||
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
|
||||
isDisplayLegend(), // include legend
|
||||
true, // tooltips?
|
||||
true // URLs?
|
||||
);
|
||||
|
||||
setupCategoryChart(chart);
|
||||
return chart;
|
||||
}
|
||||
|
||||
private JFreeChart createRingChart() {
|
||||
final JFreeChart chart = ChartFactory.createRingChart(getName(),
|
||||
getPieDataset(), isDisplayLegend(), true, true);
|
||||
|
||||
return chart;
|
||||
}
|
||||
|
||||
private JFreeChart createPieChart() {
|
||||
final JFreeChart chart = ChartFactory.createPieChart(getName(),
|
||||
getPieDataset(), false, true, true);
|
||||
|
||||
return chart;
|
||||
}
|
||||
|
||||
private JFreeChart create3DPieChart() {
|
||||
final JFreeChart chart = ChartFactory.createPieChart3D(getName(),
|
||||
getPieDataset(), false, true, true);
|
||||
|
||||
return chart;
|
||||
}
|
||||
|
||||
private JFreeChart createBarChart() {
|
||||
JFreeChart chart = ChartFactory.createBarChart(
|
||||
getName(), // chart title
|
||||
getDomainLabel(), // domain axis label
|
||||
getRangeLabel(), // range axis label
|
||||
getCategoryDataset(), // data
|
||||
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(getChartOrientation())
|
||||
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
|
||||
isDisplayLegend(), // include legend
|
||||
true, // tooltips?
|
||||
true // URLs?
|
||||
);
|
||||
|
||||
BarRenderer renderer = new BarRenderer();
|
||||
renderer.setBarPainter(new StandardBarPainter());
|
||||
|
||||
CategoryPlot plot = chart.getCategoryPlot();
|
||||
plot.setRenderer(renderer);
|
||||
|
||||
setupCategoryChart(chart);
|
||||
return chart;
|
||||
}
|
||||
|
||||
private JFreeChart create3DBarChart() {
|
||||
JFreeChart chart = ChartFactory.createBarChart3D(
|
||||
getName(), // chart title
|
||||
getDomainLabel(), // domain axis label
|
||||
getRangeLabel(), // range axis label
|
||||
getCategoryDataset(), // data
|
||||
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(getChartOrientation())
|
||||
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
|
||||
isDisplayLegend(), // include legend
|
||||
true, // tooltips?
|
||||
true // URLs?
|
||||
);
|
||||
|
||||
setupCategoryChart(chart);
|
||||
return chart;
|
||||
}
|
||||
|
||||
private JFreeChart createStackedBarChart() {
|
||||
JFreeChart chart = ChartFactory.createStackedBarChart(
|
||||
getName(), // chart title
|
||||
getDomainLabel(), // domain axis label
|
||||
getRangeLabel(), // range axis label
|
||||
getCategoryDataset(), // data
|
||||
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(getChartOrientation())
|
||||
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
|
||||
isDisplayLegend(), // include legend
|
||||
true, // tooltips?
|
||||
true // URLs?
|
||||
);
|
||||
|
||||
|
||||
BarRenderer renderer = new BarRenderer();
|
||||
renderer.setBarPainter(new StandardBarPainter());
|
||||
|
||||
CategoryPlot plot = chart.getCategoryPlot();
|
||||
plot.setRenderer(renderer);
|
||||
|
||||
setupCategoryChart(chart);
|
||||
return chart;
|
||||
}
|
||||
|
||||
private JFreeChart create3DStackedBarChart() {
|
||||
JFreeChart chart = ChartFactory.createStackedBarChart3D(
|
||||
getName(), // chart title
|
||||
getDomainLabel(), // domain axis label
|
||||
getRangeLabel(), // range axis label
|
||||
getCategoryDataset(), // data
|
||||
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(getChartOrientation())
|
||||
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
|
||||
isDisplayLegend(), // include legend
|
||||
true, // tooltips?
|
||||
true // URLs?
|
||||
);
|
||||
|
||||
setupCategoryChart(chart);
|
||||
return chart;
|
||||
}
|
||||
|
||||
private JFreeChart createAreaChart() {
|
||||
// create the chart...
|
||||
JFreeChart chart = ChartFactory.createAreaChart(
|
||||
getName(), // chart title
|
||||
getDomainLabel(), // domain axis label
|
||||
getRangeLabel(), // range axis label
|
||||
getCategoryDataset(), // data
|
||||
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(getChartOrientation())
|
||||
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
|
||||
isDisplayLegend(), // include legend
|
||||
true, // tooltips?
|
||||
true // URLs?
|
||||
);
|
||||
|
||||
setupCategoryChart(chart);
|
||||
return chart;
|
||||
}
|
||||
|
||||
private JFreeChart createStackedAreaChart() {
|
||||
// create the chart...
|
||||
JFreeChart chart = ChartFactory.createStackedAreaChart(
|
||||
getName(), // chart title
|
||||
getDomainLabel(), // domain axis label
|
||||
getRangeLabel(), // range axis label
|
||||
getCategoryDataset(), // data
|
||||
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(getChartOrientation())
|
||||
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
|
||||
isDisplayLegend(), // include legend
|
||||
true, // tooltips?
|
||||
true // URLs?
|
||||
);
|
||||
|
||||
setupCategoryChart(chart);
|
||||
return chart;
|
||||
}
|
||||
|
||||
private JFreeChart createLineChart() {
|
||||
// create the chart...
|
||||
JFreeChart chart = ChartFactory.createLineChart(
|
||||
getName(), // chart title
|
||||
getDomainLabel(), // domain axis label
|
||||
getRangeLabel(), // range axis label
|
||||
getCategoryDataset(), // data
|
||||
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(getChartOrientation())
|
||||
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
|
||||
isDisplayLegend(), // include legend
|
||||
true, // tooltips?
|
||||
true // URLs?
|
||||
);
|
||||
|
||||
|
||||
setupCategoryChart(chart);
|
||||
return chart;
|
||||
}
|
||||
|
||||
private JFreeChart create3DLineChart() {
|
||||
// create the chart...
|
||||
JFreeChart chart = ChartFactory.createLineChart3D(
|
||||
getName(), // chart title
|
||||
getDomainLabel(), // domain axis label
|
||||
getRangeLabel(), // range axis label
|
||||
getCategoryDataset(), // data
|
||||
X_AD_Chart.CHARTORIENTATION_Horizontal.equals(getChartOrientation())
|
||||
? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL, // orientation
|
||||
isDisplayLegend(), // include legend
|
||||
true, // tooltips?
|
||||
true // URLs?
|
||||
);
|
||||
|
||||
|
||||
setupCategoryChart(chart);
|
||||
return chart;
|
||||
}
|
||||
|
||||
private void setupCategoryChart(JFreeChart chart) {
|
||||
CategoryPlot plot = chart.getCategoryPlot();
|
||||
CategoryAxis xAxis = (CategoryAxis)plot.getDomainAxis();
|
||||
xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45);
|
||||
|
||||
CategoryItemRenderer renderer = plot.getRenderer();
|
||||
renderer.setSeriesPaint(0, Color.RED);
|
||||
renderer.setSeriesPaint(1, Color.BLUE);
|
||||
renderer.setSeriesPaint(2, Color.YELLOW);
|
||||
renderer.setSeriesPaint(3, Color.GREEN);
|
||||
renderer.setSeriesPaint(4, Color.ORANGE);
|
||||
renderer.setSeriesPaint(5, Color.CYAN);
|
||||
renderer.setSeriesPaint(6, Color.MAGENTA);
|
||||
renderer.setSeriesPaint(7, Color.GRAY);
|
||||
renderer.setSeriesPaint(8, Color.PINK);
|
||||
|
||||
plot.setRenderer(renderer);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,380 @@
|
|||
package org.compiere.model;
|
||||
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.Timestamp;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Properties;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.adempiere.exceptions.DBException;
|
||||
import org.compiere.util.DB;
|
||||
import org.compiere.util.Env;
|
||||
import org.compiere.util.Util;
|
||||
import org.jfree.data.category.DefaultCategoryDataset;
|
||||
import org.jfree.data.general.Dataset;
|
||||
import org.jfree.data.general.DefaultPieDataset;
|
||||
import org.jfree.data.time.Day;
|
||||
import org.jfree.data.time.Month;
|
||||
import org.jfree.data.time.Quarter;
|
||||
import org.jfree.data.time.RegularTimePeriod;
|
||||
import org.jfree.data.time.TimeSeries;
|
||||
import org.jfree.data.time.TimeSeriesCollection;
|
||||
import org.jfree.data.time.Week;
|
||||
import org.jfree.data.time.Year;
|
||||
|
||||
public class MChartDatasource extends X_AD_ChartDatasource {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 5108909995064477463L;
|
||||
|
||||
public MChartDatasource(Properties ctx, int AD_ChartDatasource_ID,
|
||||
String trxName) {
|
||||
super(ctx, AD_ChartDatasource_ID, trxName);
|
||||
}
|
||||
|
||||
public MChartDatasource(Properties ctx, ResultSet rs, String trxName) {
|
||||
super(ctx, rs, trxName);
|
||||
}
|
||||
|
||||
public void addData(MChart parent) {
|
||||
|
||||
String value = getValueColumn();
|
||||
String category;
|
||||
String unit = "D";
|
||||
|
||||
if ( !parent.isTimeSeries() )
|
||||
category = getCategoryColumn();
|
||||
else
|
||||
{
|
||||
if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Week))
|
||||
{
|
||||
unit = "W";
|
||||
}
|
||||
else if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Month))
|
||||
{
|
||||
unit = "MM";
|
||||
}
|
||||
else if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Quarter))
|
||||
{
|
||||
unit = "Q";
|
||||
}
|
||||
else if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Year))
|
||||
{
|
||||
unit = "Y";
|
||||
}
|
||||
|
||||
category = " TRUNC(" + getDateColumn() + ", '" + unit + "') ";
|
||||
}
|
||||
|
||||
String series = DB.TO_STRING(getName());
|
||||
boolean hasSeries = false;
|
||||
if (getSeriesColumn() != null)
|
||||
{
|
||||
series = getSeriesColumn();
|
||||
hasSeries = true;
|
||||
}
|
||||
|
||||
String where = getWhereClause();
|
||||
if ( !Util.isEmpty(where))
|
||||
{
|
||||
where = Env.parseContext(getCtx(), parent.getWindowNo(), where, true);
|
||||
}
|
||||
|
||||
boolean hasWhere = false;
|
||||
|
||||
String sql = "SELECT " + value + ", " + category + ", " + series
|
||||
+ " FROM " + getFromClause();
|
||||
if ( !Util.isEmpty(where))
|
||||
{
|
||||
sql += " WHERE " + where;
|
||||
hasWhere = true;
|
||||
}
|
||||
|
||||
Date currentDate = Env.getContextAsDate(getCtx(), "#Date");
|
||||
Date startDate = null;
|
||||
Date endDate = null;
|
||||
|
||||
int scope = parent.getTimeScope();
|
||||
int offset = getTimeOffset();
|
||||
|
||||
if ( parent.isTimeSeries() && scope != 0 )
|
||||
{
|
||||
offset += -scope;
|
||||
startDate = increment(currentDate, parent.getTimeUnit(), offset);
|
||||
endDate = increment(startDate, parent.getTimeUnit(), scope);
|
||||
}
|
||||
|
||||
if ( startDate != null && endDate != null )
|
||||
{
|
||||
sql += hasWhere ? " AND " : " WHERE ";
|
||||
sql += category + ">=TRUNC(" + DB.TO_DATE(new Timestamp(startDate.getTime())) + ", '" + unit + "') AND ";
|
||||
sql += category + "<=TRUNC(" + DB.TO_DATE(new Timestamp(endDate.getTime())) + ", '" + unit + "') ";
|
||||
}
|
||||
|
||||
MRole role = MRole.getDefault(getCtx(), false);
|
||||
sql = role.addAccessSQL(sql, null, true, false);
|
||||
|
||||
if (hasSeries)
|
||||
sql += " GROUP BY " + series + ", " + category + " ORDER BY " + series + ", " + category;
|
||||
else
|
||||
sql += " GROUP BY " + category + " ORDER BY " + category;
|
||||
|
||||
log.log(Level.FINE, sql);
|
||||
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
TimeSeries tseries = null;
|
||||
Dataset dataset = parent.getDataset();
|
||||
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement(sql, null);
|
||||
rs = pstmt.executeQuery();
|
||||
while(rs.next())
|
||||
{
|
||||
|
||||
String key = rs.getString(2);
|
||||
String seriesName = rs.getString(3);
|
||||
if (seriesName == null)
|
||||
seriesName = getName();
|
||||
String queryWhere = "";
|
||||
if ( hasWhere )
|
||||
queryWhere += where + " AND ";
|
||||
|
||||
queryWhere += series + " = " + DB.TO_STRING(seriesName) + " AND " + category + " = " ;
|
||||
|
||||
if ( parent.isTimeSeries() && dataset instanceof TimeSeriesCollection )
|
||||
{
|
||||
|
||||
if ( tseries == null || !tseries.getKey().equals(seriesName))
|
||||
{
|
||||
if (tseries != null)
|
||||
((TimeSeriesCollection) dataset).addSeries(tseries);
|
||||
|
||||
tseries = new TimeSeries(seriesName);
|
||||
}
|
||||
|
||||
Date date = rs.getDate(2);
|
||||
RegularTimePeriod period = null;
|
||||
|
||||
if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Day))
|
||||
period = new Day(date);
|
||||
else if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Week))
|
||||
period = new Week(date);
|
||||
else if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Month))
|
||||
period = new Month(date);
|
||||
else if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Quarter))
|
||||
period = new Quarter(date);
|
||||
else if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Year))
|
||||
period = new Year(date);
|
||||
|
||||
tseries.add(period, rs.getBigDecimal(1));
|
||||
key = period.toString();
|
||||
queryWhere += DB.TO_DATE(new Timestamp(date.getTime()));
|
||||
}
|
||||
else {
|
||||
queryWhere += DB.TO_STRING(key);
|
||||
}
|
||||
|
||||
MQuery query = new MQuery(getAD_Table_ID());
|
||||
String keyCol = MTable.get(getCtx(), getAD_Table_ID()).getKeyColumns()[0];
|
||||
String whereClause = keyCol + " IN (SELECT " + getKeyColumn() + " FROM "
|
||||
+ getFromClause() + " WHERE " + queryWhere + " )";
|
||||
query.addRestriction(whereClause.toString());
|
||||
query.setRecordCount(1);
|
||||
|
||||
HashMap<String, MQuery> map = parent.getQueries();
|
||||
|
||||
if ( dataset instanceof DefaultPieDataset) {
|
||||
((DefaultPieDataset) dataset).setValue(key, rs.getBigDecimal(1));
|
||||
map.put(key, query);
|
||||
}
|
||||
else if ( dataset instanceof DefaultCategoryDataset ) {
|
||||
((DefaultCategoryDataset) dataset).addValue(rs.getBigDecimal(1), seriesName, key);
|
||||
map.put(seriesName + "__" + key, query);
|
||||
}
|
||||
else if (dataset instanceof TimeSeriesCollection )
|
||||
{
|
||||
map.put(seriesName + "__" + key, query);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new DBException(e, sql);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
if (tseries != null)
|
||||
((TimeSeriesCollection) dataset).addSeries(tseries);
|
||||
|
||||
}
|
||||
|
||||
private Date increment(Date lastDate, String timeUnit, int qty) {
|
||||
|
||||
if ( lastDate == null )
|
||||
return null;
|
||||
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(lastDate);
|
||||
|
||||
if ( timeUnit.equals(MChart.TIMEUNIT_Day))
|
||||
cal.add(Calendar.DAY_OF_YEAR, qty);
|
||||
else if ( timeUnit.equals(MChart.TIMEUNIT_Week))
|
||||
cal.add(Calendar.WEEK_OF_YEAR, qty);
|
||||
else if ( timeUnit.equals(MChart.TIMEUNIT_Month))
|
||||
cal.add(Calendar.MONTH, qty);
|
||||
else if ( timeUnit.equals(MChart.TIMEUNIT_Quarter))
|
||||
cal.add(Calendar.MONTH, 3*qty);
|
||||
else if ( timeUnit.equals(MChart.TIMEUNIT_Year))
|
||||
cal.add(Calendar.YEAR, qty);
|
||||
|
||||
return cal.getTime();
|
||||
}
|
||||
|
||||
private String formatDate(Date date, String timeUnit)
|
||||
{
|
||||
String key = null;
|
||||
String unitFormat = "yyyy-MM-dd";
|
||||
if ( timeUnit.equals(MChart.TIMEUNIT_Week))
|
||||
unitFormat = "yyyy-w";
|
||||
else if ( timeUnit.equals(MChart.TIMEUNIT_Month))
|
||||
unitFormat = "yyyy-MMM";
|
||||
else if ( timeUnit.equals(MChart.TIMEUNIT_Quarter))
|
||||
unitFormat = "yyyy-MM";
|
||||
else if ( timeUnit.equals(MChart.TIMEUNIT_Year))
|
||||
unitFormat = "yyyy";
|
||||
SimpleDateFormat format = new SimpleDateFormat(unitFormat);
|
||||
key = format.format(date);
|
||||
if ( timeUnit.equals(MChart.TIMEUNIT_Quarter) )
|
||||
key = convertToQuarter(format.format(date));
|
||||
|
||||
return key;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert date formatted as yyyy-MM to yyyy-QQ
|
||||
* @param month
|
||||
* @return
|
||||
*/
|
||||
private String convertToQuarter(String month) {
|
||||
if ( month.length() != 7 )
|
||||
return month;
|
||||
|
||||
String mm = month.substring(5,7);
|
||||
int mon = Integer.parseInt(mm);
|
||||
return month.substring(0,5)+"Q" + ((mon/3) + 1);
|
||||
|
||||
}
|
||||
|
||||
public MQuery getZoomQuery(MChart parent, String value, String category2) {
|
||||
MQuery query = new MQuery(getAD_Table_ID());
|
||||
|
||||
String category;
|
||||
|
||||
if ( !parent.isTimeSeries() )
|
||||
category = getCategoryColumn();
|
||||
else
|
||||
{
|
||||
String unit = "D";
|
||||
if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Week))
|
||||
unit = "W";
|
||||
else if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Month))
|
||||
unit = "MM";
|
||||
else if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Quarter))
|
||||
unit = "Q";
|
||||
else if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Year))
|
||||
unit = "Y";
|
||||
|
||||
category = " TRUNC(" + getDateColumn() + ", '" + unit + "') ";
|
||||
}
|
||||
|
||||
String where = getWhereClause();
|
||||
if ( !Util.isEmpty(where))
|
||||
{
|
||||
where = Env.parseContext(Env.getCtx(), parent.getWindowNo(), where, true);
|
||||
}
|
||||
|
||||
String series = DB.TO_STRING(getName());
|
||||
if (getSeriesColumn() != null)
|
||||
series = getSeriesColumn();
|
||||
|
||||
String sql = "SELECT " + getKeyColumn() + "," + category + "," + series
|
||||
+ " FROM " + getFromClause();
|
||||
|
||||
if ( !Util.isEmpty(where))
|
||||
{
|
||||
sql += " WHERE " + where;
|
||||
}
|
||||
|
||||
|
||||
sql += " GROUP BY " + series + ", " + category + "," + getKeyColumn()
|
||||
+ " ORDER BY " + series + ", " + category + "," + getKeyColumn();
|
||||
|
||||
StringBuffer includedIds = new StringBuffer();
|
||||
// Execute
|
||||
PreparedStatement pstmt = null;
|
||||
ResultSet rs = null;
|
||||
try
|
||||
{
|
||||
pstmt = DB.prepareStatement (sql, null);
|
||||
rs = pstmt.executeQuery ();
|
||||
while (rs.next ())
|
||||
{
|
||||
int id = rs.getInt(1);
|
||||
String key = rs.getString(2);
|
||||
if ( parent.isTimeSeries() )
|
||||
{
|
||||
Date date = rs.getDate(2);
|
||||
String unit = "yyyy-MM-dd";
|
||||
if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Week))
|
||||
unit = "yyyy-w";
|
||||
else if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Month))
|
||||
unit = "yyyy-MMM";
|
||||
else if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Quarter))
|
||||
unit = "yyyy-MM";
|
||||
else if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Year))
|
||||
unit = "yyyy";
|
||||
SimpleDateFormat format = new SimpleDateFormat(unit);
|
||||
key = format.format(date);
|
||||
if ( parent.getTimeUnit().equals(MChart.TIMEUNIT_Quarter) )
|
||||
key = convertToQuarter(format.format(date));
|
||||
}
|
||||
|
||||
if ( value.equals(key) )
|
||||
{
|
||||
if (includedIds.length() > 0)
|
||||
includedIds.append(",");
|
||||
includedIds.append(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (SQLException e)
|
||||
{
|
||||
throw new DBException(e, sql);
|
||||
}
|
||||
finally
|
||||
{
|
||||
DB.close(rs, pstmt);
|
||||
rs = null; pstmt = null;
|
||||
}
|
||||
|
||||
if (includedIds.length() == 0)
|
||||
return MQuery.getNoRecordQuery(query.getTableName(), false);
|
||||
|
||||
|
||||
return query;
|
||||
}
|
||||
|
||||
}
|
|
@ -112,6 +112,7 @@ public class SystemIDs
|
|||
public final static int REFERENCE_DATATYPE_TIME = 24;
|
||||
public final static int REFERENCE_DATATYPE_URL = 40;
|
||||
public final static int REFERENCE_DATATYPE_YES_NO = 20;
|
||||
public final static int REFERENCE_DATATYPE_CHART = 53370;
|
||||
|
||||
public final static int REFERENCE_AD_USER = 110;
|
||||
public final static int REFERENCE_DOCUMENTACTION = 135;
|
||||
|
|
|
@ -0,0 +1,350 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2007 ComPiere, Inc. 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 *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
/** Generated Model - DO NOT CHANGE */
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
|
||||
/** Generated Model for AD_Chart
|
||||
* @author Adempiere (generated)
|
||||
* @version 1.03 - $Id$ */
|
||||
public class X_AD_Chart extends PO implements I_AD_Chart, I_Persistent
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 20120608L;
|
||||
|
||||
/** Standard Constructor */
|
||||
public X_AD_Chart (Properties ctx, int AD_Chart_ID, String trxName)
|
||||
{
|
||||
super (ctx, AD_Chart_ID, trxName);
|
||||
/** if (AD_Chart_ID == 0)
|
||||
{
|
||||
setAD_Chart_ID (0);
|
||||
setChartOrientation (null);
|
||||
// V
|
||||
setChartType (null);
|
||||
setIsDisplayLegend (true);
|
||||
// 'Y'
|
||||
setIsTimeSeries (false);
|
||||
// N
|
||||
setName (null);
|
||||
} */
|
||||
}
|
||||
|
||||
/** Load Constructor */
|
||||
public X_AD_Chart (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
}
|
||||
|
||||
/** AccessLevel
|
||||
* @return 4 - System
|
||||
*/
|
||||
protected int get_AccessLevel()
|
||||
{
|
||||
return accessLevel.intValue();
|
||||
}
|
||||
|
||||
/** Load Meta Data */
|
||||
protected POInfo initPO (Properties ctx)
|
||||
{
|
||||
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
|
||||
return poi;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer ("X_AD_Chart[")
|
||||
.append(get_ID()).append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Set Chart.
|
||||
@param AD_Chart_ID Chart */
|
||||
public void setAD_Chart_ID (int AD_Chart_ID)
|
||||
{
|
||||
if (AD_Chart_ID < 1)
|
||||
set_ValueNoCheck (COLUMNNAME_AD_Chart_ID, null);
|
||||
else
|
||||
set_ValueNoCheck (COLUMNNAME_AD_Chart_ID, Integer.valueOf(AD_Chart_ID));
|
||||
}
|
||||
|
||||
/** Get Chart.
|
||||
@return Chart */
|
||||
public int getAD_Chart_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Chart_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** ChartOrientation AD_Reference_ID=53375 */
|
||||
public static final int CHARTORIENTATION_AD_Reference_ID=53375;
|
||||
/** Horizontal = H */
|
||||
public static final String CHARTORIENTATION_Horizontal = "H";
|
||||
/** Vertical = V */
|
||||
public static final String CHARTORIENTATION_Vertical = "V";
|
||||
/** Set Orientation.
|
||||
@param ChartOrientation
|
||||
The orientation of the chart.
|
||||
*/
|
||||
public void setChartOrientation (String ChartOrientation)
|
||||
{
|
||||
|
||||
set_Value (COLUMNNAME_ChartOrientation, ChartOrientation);
|
||||
}
|
||||
|
||||
/** Get Orientation.
|
||||
@return The orientation of the chart.
|
||||
*/
|
||||
public String getChartOrientation ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_ChartOrientation);
|
||||
}
|
||||
|
||||
/** ChartType AD_Reference_ID=53377 */
|
||||
public static final int CHARTTYPE_AD_Reference_ID=53377;
|
||||
/** Area Chart = AC */
|
||||
public static final String CHARTTYPE_AreaChart = "AC";
|
||||
/** Bar Chart = BC */
|
||||
public static final String CHARTTYPE_BarChart = "BC";
|
||||
/** Stacked Area Chart = AS */
|
||||
public static final String CHARTTYPE_StackedAreaChart = "AS";
|
||||
/** 3D Bar Chart = B3 */
|
||||
public static final String CHARTTYPE_3DBarChart = "B3";
|
||||
/** Stacked Bar Chart = BS */
|
||||
public static final String CHARTTYPE_StackedBarChart = "BS";
|
||||
/** 3D Stacked Bar Chart = B4 */
|
||||
public static final String CHARTTYPE_3DStackedBarChart = "B4";
|
||||
/** Line Chart = LC */
|
||||
public static final String CHARTTYPE_LineChart = "LC";
|
||||
/** 3D Line Chart = L3 */
|
||||
public static final String CHARTTYPE_3DLineChart = "L3";
|
||||
/** Waterfall Chart = WC */
|
||||
public static final String CHARTTYPE_WaterfallChart = "WC";
|
||||
/** Pie Chart = PC */
|
||||
public static final String CHARTTYPE_PieChart = "PC";
|
||||
/** 3D Pie Chart = P3 */
|
||||
public static final String CHARTTYPE_3DPieChart = "P3";
|
||||
/** Ring Chart = RC */
|
||||
public static final String CHARTTYPE_RingChart = "RC";
|
||||
/** Set Chart Type.
|
||||
@param ChartType
|
||||
Type fo chart to render
|
||||
*/
|
||||
public void setChartType (String ChartType)
|
||||
{
|
||||
|
||||
set_Value (COLUMNNAME_ChartType, ChartType);
|
||||
}
|
||||
|
||||
/** Get Chart Type.
|
||||
@return Type fo chart to render
|
||||
*/
|
||||
public String getChartType ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_ChartType);
|
||||
}
|
||||
|
||||
/** Set Description.
|
||||
@param Description
|
||||
Optional short description of the record
|
||||
*/
|
||||
public void setDescription (String Description)
|
||||
{
|
||||
set_Value (COLUMNNAME_Description, Description);
|
||||
}
|
||||
|
||||
/** Get Description.
|
||||
@return Optional short description of the record
|
||||
*/
|
||||
public String getDescription ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_Description);
|
||||
}
|
||||
|
||||
/** Set Domain Label.
|
||||
@param DomainLabel
|
||||
Label for the domain axis.
|
||||
*/
|
||||
public void setDomainLabel (String DomainLabel)
|
||||
{
|
||||
set_Value (COLUMNNAME_DomainLabel, DomainLabel);
|
||||
}
|
||||
|
||||
/** Get Domain Label.
|
||||
@return Label for the domain axis.
|
||||
*/
|
||||
public String getDomainLabel ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_DomainLabel);
|
||||
}
|
||||
|
||||
/** Set Display Legend.
|
||||
@param IsDisplayLegend
|
||||
Display chart legend
|
||||
*/
|
||||
public void setIsDisplayLegend (boolean IsDisplayLegend)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsDisplayLegend, Boolean.valueOf(IsDisplayLegend));
|
||||
}
|
||||
|
||||
/** Get Display Legend.
|
||||
@return Display chart legend
|
||||
*/
|
||||
public boolean isDisplayLegend ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsDisplayLegend);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Time Series.
|
||||
@param IsTimeSeries
|
||||
The domain data for the chart is organised by time.
|
||||
*/
|
||||
public void setIsTimeSeries (boolean IsTimeSeries)
|
||||
{
|
||||
set_Value (COLUMNNAME_IsTimeSeries, Boolean.valueOf(IsTimeSeries));
|
||||
}
|
||||
|
||||
/** Get Time Series.
|
||||
@return The domain data for the chart is organised by time.
|
||||
*/
|
||||
public boolean isTimeSeries ()
|
||||
{
|
||||
Object oo = get_Value(COLUMNNAME_IsTimeSeries);
|
||||
if (oo != null)
|
||||
{
|
||||
if (oo instanceof Boolean)
|
||||
return ((Boolean)oo).booleanValue();
|
||||
return "Y".equals(oo);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Set Name.
|
||||
@param Name
|
||||
Alphanumeric identifier of the entity
|
||||
*/
|
||||
public void setName (String Name)
|
||||
{
|
||||
set_Value (COLUMNNAME_Name, Name);
|
||||
}
|
||||
|
||||
/** Get Name.
|
||||
@return Alphanumeric identifier of the entity
|
||||
*/
|
||||
public String getName ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_Name);
|
||||
}
|
||||
|
||||
/** Set Range Label.
|
||||
@param RangeLabel
|
||||
Label for the range axis.
|
||||
*/
|
||||
public void setRangeLabel (String RangeLabel)
|
||||
{
|
||||
set_Value (COLUMNNAME_RangeLabel, RangeLabel);
|
||||
}
|
||||
|
||||
/** Get Range Label.
|
||||
@return Label for the range axis.
|
||||
*/
|
||||
public String getRangeLabel ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_RangeLabel);
|
||||
}
|
||||
|
||||
/** Set Time Scope.
|
||||
@param TimeScope
|
||||
The number of time units to include the chart result.
|
||||
*/
|
||||
public void setTimeScope (int TimeScope)
|
||||
{
|
||||
set_Value (COLUMNNAME_TimeScope, Integer.valueOf(TimeScope));
|
||||
}
|
||||
|
||||
/** Get Time Scope.
|
||||
@return The number of time units to include the chart result.
|
||||
*/
|
||||
public int getTimeScope ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_TimeScope);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** TimeUnit AD_Reference_ID=53376 */
|
||||
public static final int TIMEUNIT_AD_Reference_ID=53376;
|
||||
/** Day = D */
|
||||
public static final String TIMEUNIT_Day = "D";
|
||||
/** Week = W */
|
||||
public static final String TIMEUNIT_Week = "W";
|
||||
/** Month = M */
|
||||
public static final String TIMEUNIT_Month = "M";
|
||||
/** Quarter = Q */
|
||||
public static final String TIMEUNIT_Quarter = "Q";
|
||||
/** Year = Y */
|
||||
public static final String TIMEUNIT_Year = "Y";
|
||||
/** Set Time Unit.
|
||||
@param TimeUnit
|
||||
The unit of time for grouping chart data.
|
||||
*/
|
||||
public void setTimeUnit (String TimeUnit)
|
||||
{
|
||||
|
||||
set_Value (COLUMNNAME_TimeUnit, TimeUnit);
|
||||
}
|
||||
|
||||
/** Get Time Unit.
|
||||
@return The unit of time for grouping chart data.
|
||||
*/
|
||||
public String getTimeUnit ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_TimeUnit);
|
||||
}
|
||||
|
||||
/** Set Window Height.
|
||||
@param WinHeight Window Height */
|
||||
public void setWinHeight (int WinHeight)
|
||||
{
|
||||
set_Value (COLUMNNAME_WinHeight, Integer.valueOf(WinHeight));
|
||||
}
|
||||
|
||||
/** Get Window Height.
|
||||
@return Window Height */
|
||||
public int getWinHeight ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_WinHeight);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,351 @@
|
|||
/******************************************************************************
|
||||
* Product: Adempiere ERP & CRM Smart Business Solution *
|
||||
* Copyright (C) 1999-2007 ComPiere, Inc. 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 *
|
||||
* ComPiere, Inc., 2620 Augustine Dr. #245, Santa Clara, CA 95054, USA *
|
||||
* or via info@compiere.org or http://www.compiere.org/license.html *
|
||||
*****************************************************************************/
|
||||
/** Generated Model - DO NOT CHANGE */
|
||||
package org.compiere.model;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Properties;
|
||||
import org.compiere.util.KeyNamePair;
|
||||
|
||||
/** Generated Model for AD_ChartDatasource
|
||||
* @author Adempiere (generated)
|
||||
* @version 1.03 - $Id$ */
|
||||
public class X_AD_ChartDatasource extends PO implements I_AD_ChartDatasource, I_Persistent
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 20120608L;
|
||||
|
||||
/** Standard Constructor */
|
||||
public X_AD_ChartDatasource (Properties ctx, int AD_ChartDatasource_ID, String trxName)
|
||||
{
|
||||
super (ctx, AD_ChartDatasource_ID, trxName);
|
||||
/** if (AD_ChartDatasource_ID == 0)
|
||||
{
|
||||
setAD_ChartDatasource_ID (0);
|
||||
setAD_Chart_ID (0);
|
||||
setEntityType (null);
|
||||
// U
|
||||
setFromClause (null);
|
||||
setName (null);
|
||||
setValueColumn (null);
|
||||
setWhereClause (null);
|
||||
// WHERE ...
|
||||
} */
|
||||
}
|
||||
|
||||
/** Load Constructor */
|
||||
public X_AD_ChartDatasource (Properties ctx, ResultSet rs, String trxName)
|
||||
{
|
||||
super (ctx, rs, trxName);
|
||||
}
|
||||
|
||||
/** AccessLevel
|
||||
* @return 4 - System
|
||||
*/
|
||||
protected int get_AccessLevel()
|
||||
{
|
||||
return accessLevel.intValue();
|
||||
}
|
||||
|
||||
/** Load Meta Data */
|
||||
protected POInfo initPO (Properties ctx)
|
||||
{
|
||||
POInfo poi = POInfo.getPOInfo (ctx, Table_ID, get_TrxName());
|
||||
return poi;
|
||||
}
|
||||
|
||||
public String toString()
|
||||
{
|
||||
StringBuffer sb = new StringBuffer ("X_AD_ChartDatasource[")
|
||||
.append(get_ID()).append("]");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/** Set Chart Datasource.
|
||||
@param AD_ChartDatasource_ID Chart Datasource */
|
||||
public void setAD_ChartDatasource_ID (int AD_ChartDatasource_ID)
|
||||
{
|
||||
if (AD_ChartDatasource_ID < 1)
|
||||
set_ValueNoCheck (COLUMNNAME_AD_ChartDatasource_ID, null);
|
||||
else
|
||||
set_ValueNoCheck (COLUMNNAME_AD_ChartDatasource_ID, Integer.valueOf(AD_ChartDatasource_ID));
|
||||
}
|
||||
|
||||
/** Get Chart Datasource.
|
||||
@return Chart Datasource */
|
||||
public int getAD_ChartDatasource_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_AD_ChartDatasource_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
public I_AD_Chart getAD_Chart() throws RuntimeException
|
||||
{
|
||||
return (I_AD_Chart)MTable.get(getCtx(), I_AD_Chart.Table_Name)
|
||||
.getPO(getAD_Chart_ID(), get_TrxName()); }
|
||||
|
||||
/** Set Chart.
|
||||
@param AD_Chart_ID Chart */
|
||||
public void setAD_Chart_ID (int AD_Chart_ID)
|
||||
{
|
||||
if (AD_Chart_ID < 1)
|
||||
set_ValueNoCheck (COLUMNNAME_AD_Chart_ID, null);
|
||||
else
|
||||
set_ValueNoCheck (COLUMNNAME_AD_Chart_ID, Integer.valueOf(AD_Chart_ID));
|
||||
}
|
||||
|
||||
/** Get Chart.
|
||||
@return Chart */
|
||||
public int getAD_Chart_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Chart_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
public I_AD_Table getAD_Table() throws RuntimeException
|
||||
{
|
||||
return (I_AD_Table)MTable.get(getCtx(), I_AD_Table.Table_Name)
|
||||
.getPO(getAD_Table_ID(), get_TrxName()); }
|
||||
|
||||
/** Set Table.
|
||||
@param AD_Table_ID
|
||||
Database Table information
|
||||
*/
|
||||
public void setAD_Table_ID (int AD_Table_ID)
|
||||
{
|
||||
if (AD_Table_ID < 1)
|
||||
set_Value (COLUMNNAME_AD_Table_ID, null);
|
||||
else
|
||||
set_Value (COLUMNNAME_AD_Table_ID, Integer.valueOf(AD_Table_ID));
|
||||
}
|
||||
|
||||
/** Get Table.
|
||||
@return Database Table information
|
||||
*/
|
||||
public int getAD_Table_ID ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_AD_Table_ID);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set Category Column.
|
||||
@param CategoryColumn
|
||||
Fully qualified data category column
|
||||
*/
|
||||
public void setCategoryColumn (String CategoryColumn)
|
||||
{
|
||||
set_Value (COLUMNNAME_CategoryColumn, CategoryColumn);
|
||||
}
|
||||
|
||||
/** Get Category Column.
|
||||
@return Fully qualified data category column
|
||||
*/
|
||||
public String getCategoryColumn ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_CategoryColumn);
|
||||
}
|
||||
|
||||
/** Set Date Column.
|
||||
@param DateColumn
|
||||
Fully qualified date column
|
||||
*/
|
||||
public void setDateColumn (String DateColumn)
|
||||
{
|
||||
set_Value (COLUMNNAME_DateColumn, DateColumn);
|
||||
}
|
||||
|
||||
/** Get Date Column.
|
||||
@return Fully qualified date column
|
||||
*/
|
||||
public String getDateColumn ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_DateColumn);
|
||||
}
|
||||
|
||||
/** Set Description.
|
||||
@param Description
|
||||
Optional short description of the record
|
||||
*/
|
||||
public void setDescription (String Description)
|
||||
{
|
||||
set_Value (COLUMNNAME_Description, Description);
|
||||
}
|
||||
|
||||
/** Get Description.
|
||||
@return Optional short description of the record
|
||||
*/
|
||||
public String getDescription ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_Description);
|
||||
}
|
||||
|
||||
/** EntityType AD_Reference_ID=389 */
|
||||
public static final int ENTITYTYPE_AD_Reference_ID=389;
|
||||
/** Set Entity Type.
|
||||
@param EntityType
|
||||
Dictionary Entity Type; Determines ownership and synchronization
|
||||
*/
|
||||
public void setEntityType (String EntityType)
|
||||
{
|
||||
|
||||
set_Value (COLUMNNAME_EntityType, EntityType);
|
||||
}
|
||||
|
||||
/** Get Entity Type.
|
||||
@return Dictionary Entity Type; Determines ownership and synchronization
|
||||
*/
|
||||
public String getEntityType ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_EntityType);
|
||||
}
|
||||
|
||||
/** Set Sql FROM.
|
||||
@param FromClause
|
||||
SQL FROM clause
|
||||
*/
|
||||
public void setFromClause (String FromClause)
|
||||
{
|
||||
set_Value (COLUMNNAME_FromClause, FromClause);
|
||||
}
|
||||
|
||||
/** Get Sql FROM.
|
||||
@return SQL FROM clause
|
||||
*/
|
||||
public String getFromClause ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_FromClause);
|
||||
}
|
||||
|
||||
/** Set Key Column.
|
||||
@param KeyColumn
|
||||
Key Column for Table
|
||||
*/
|
||||
public void setKeyColumn (String KeyColumn)
|
||||
{
|
||||
set_Value (COLUMNNAME_KeyColumn, KeyColumn);
|
||||
}
|
||||
|
||||
/** Get Key Column.
|
||||
@return Key Column for Table
|
||||
*/
|
||||
public String getKeyColumn ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_KeyColumn);
|
||||
}
|
||||
|
||||
/** Set Name.
|
||||
@param Name
|
||||
Alphanumeric identifier of the entity
|
||||
*/
|
||||
public void setName (String Name)
|
||||
{
|
||||
set_Value (COLUMNNAME_Name, Name);
|
||||
}
|
||||
|
||||
/** Get Name.
|
||||
@return Alphanumeric identifier of the entity
|
||||
*/
|
||||
public String getName ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_Name);
|
||||
}
|
||||
|
||||
/** Get Record ID/ColumnName
|
||||
@return ID/ColumnName pair
|
||||
*/
|
||||
public KeyNamePair getKeyNamePair()
|
||||
{
|
||||
return new KeyNamePair(get_ID(), getName());
|
||||
}
|
||||
|
||||
/** Set Series Column.
|
||||
@param SeriesColumn Series Column */
|
||||
public void setSeriesColumn (String SeriesColumn)
|
||||
{
|
||||
set_Value (COLUMNNAME_SeriesColumn, SeriesColumn);
|
||||
}
|
||||
|
||||
/** Get Series Column.
|
||||
@return Series Column */
|
||||
public String getSeriesColumn ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_SeriesColumn);
|
||||
}
|
||||
|
||||
/** Set Time Offset.
|
||||
@param TimeOffset
|
||||
Number of time units to offset displayed chart data from the current date.
|
||||
*/
|
||||
public void setTimeOffset (int TimeOffset)
|
||||
{
|
||||
set_Value (COLUMNNAME_TimeOffset, Integer.valueOf(TimeOffset));
|
||||
}
|
||||
|
||||
/** Get Time Offset.
|
||||
@return Number of time units to offset displayed chart data from the current date.
|
||||
*/
|
||||
public int getTimeOffset ()
|
||||
{
|
||||
Integer ii = (Integer)get_Value(COLUMNNAME_TimeOffset);
|
||||
if (ii == null)
|
||||
return 0;
|
||||
return ii.intValue();
|
||||
}
|
||||
|
||||
/** Set Value Column.
|
||||
@param ValueColumn
|
||||
Fully qualified data value column
|
||||
*/
|
||||
public void setValueColumn (String ValueColumn)
|
||||
{
|
||||
set_Value (COLUMNNAME_ValueColumn, ValueColumn);
|
||||
}
|
||||
|
||||
/** Get Value Column.
|
||||
@return Fully qualified data value column
|
||||
*/
|
||||
public String getValueColumn ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_ValueColumn);
|
||||
}
|
||||
|
||||
/** Set Sql WHERE.
|
||||
@param WhereClause
|
||||
Fully qualified SQL WHERE clause
|
||||
*/
|
||||
public void setWhereClause (String WhereClause)
|
||||
{
|
||||
set_Value (COLUMNNAME_WhereClause, WhereClause);
|
||||
}
|
||||
|
||||
/** Get Sql WHERE.
|
||||
@return Fully qualified SQL WHERE clause
|
||||
*/
|
||||
public String getWhereClause ()
|
||||
{
|
||||
return (String)get_Value(COLUMNNAME_WhereClause);
|
||||
}
|
||||
}
|
|
@ -49,17 +49,18 @@ import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_TEXTLONG;
|
|||
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_TIME;
|
||||
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_URL;
|
||||
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_YES_NO;
|
||||
|
||||
import org.adempiere.base.IDisplayTypeFactory;
|
||||
import org.adempiere.base.Service;
|
||||
import static org.compiere.model.SystemIDs.REFERENCE_DATATYPE_CHART;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.DecimalFormat;
|
||||
import java.text.NumberFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Level;
|
||||
import java.util.List;
|
||||
|
||||
import org.adempiere.base.IDisplayTypeFactory;
|
||||
import org.adempiere.base.Service;
|
||||
|
||||
/**
|
||||
* System Display Types.
|
||||
|
@ -142,6 +143,8 @@ public final class DisplayType
|
|||
/** Display Type 200012 Payment */
|
||||
public static final int Payment = REFERENCE_DATATYPE_PAYMENT;
|
||||
|
||||
public static final int Chart = REFERENCE_DATATYPE_CHART;
|
||||
|
||||
/**
|
||||
* - New Display Type
|
||||
INSERT INTO AD_REFERENCE
|
||||
|
|
|
@ -18,6 +18,7 @@ import org.compiere.grid.ed.VAccount;
|
|||
import org.compiere.grid.ed.VAssignment;
|
||||
import org.compiere.grid.ed.VBinary;
|
||||
import org.compiere.grid.ed.VButton;
|
||||
import org.compiere.grid.ed.VChart;
|
||||
import org.compiere.grid.ed.VCheckBox;
|
||||
import org.compiere.grid.ed.VColor;
|
||||
import org.compiere.grid.ed.VDate;
|
||||
|
@ -294,6 +295,13 @@ public class DefaultEditorFactory implements IEditorFactory {
|
|||
editor = p;
|
||||
}
|
||||
|
||||
// Chart
|
||||
else if (displayType == DisplayType.Chart )
|
||||
{
|
||||
VChart chart = new VChart(mField.getAD_Chart_ID(), WindowNo);
|
||||
editor = chart;
|
||||
}
|
||||
|
||||
return editor;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,7 @@ import org.compiere.apps.APanel;
|
|||
import org.compiere.apps.AppsAction;
|
||||
import org.compiere.grid.ed.VCellEditor;
|
||||
import org.compiere.grid.ed.VCellRenderer;
|
||||
import org.compiere.grid.ed.VChart;
|
||||
import org.compiere.grid.ed.VEditor;
|
||||
import org.compiere.grid.ed.VEditorFactory;
|
||||
import org.compiere.grid.ed.VHeaderRenderer;
|
||||
|
@ -1021,6 +1022,11 @@ public class GridController extends CPanel
|
|||
Component comp = comps[i];
|
||||
String columnName = comp.getName();
|
||||
|
||||
if ( comp instanceof VChart && isSingleRow())
|
||||
{
|
||||
((VChart) comp).createChart();
|
||||
}
|
||||
|
||||
if (columnName != null && columnName.length() > 0)
|
||||
{
|
||||
GridField mField = m_mTab.getField(columnName);
|
||||
|
|
|
@ -0,0 +1,163 @@
|
|||
package org.compiere.grid.ed;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Cursor;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.beans.PropertyChangeEvent;
|
||||
import java.beans.VetoableChangeListener;
|
||||
|
||||
import org.compiere.apps.AEnv;
|
||||
import org.compiere.model.GridField;
|
||||
import org.compiere.model.MChart;
|
||||
import org.compiere.model.MQuery;
|
||||
import org.compiere.swing.CPanel;
|
||||
import org.compiere.util.Env;
|
||||
import org.jfree.chart.ChartMouseEvent;
|
||||
import org.jfree.chart.ChartMouseListener;
|
||||
import org.jfree.chart.ChartPanel;
|
||||
import org.jfree.chart.JFreeChart;
|
||||
import org.jfree.chart.entity.CategoryItemEntity;
|
||||
import org.jfree.chart.entity.ChartEntity;
|
||||
import org.jfree.chart.entity.PieSectionEntity;
|
||||
|
||||
public class VChart extends CPanel implements ChartMouseListener, VEditor {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
ChartPanel chartPanel;
|
||||
MChart chartModel;
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public VChart()
|
||||
{
|
||||
super();
|
||||
this.setLayout(new BorderLayout());
|
||||
} // Chart
|
||||
|
||||
public VChart(int AD_Chart_ID, int windowNo) {
|
||||
this();
|
||||
chartModel = new MChart(Env.getCtx(), AD_Chart_ID, null);
|
||||
chartModel.setWindowNo(windowNo);
|
||||
//createChart();
|
||||
}
|
||||
|
||||
public void createChart()
|
||||
{
|
||||
JFreeChart chart = chartModel.createChart();
|
||||
if (chartPanel != null)
|
||||
remove(chartPanel);
|
||||
|
||||
chartModel.loadData();
|
||||
chartPanel = new ChartPanel(chart);
|
||||
Dimension size = getSize();
|
||||
size.height= chartModel.getWinHeight();
|
||||
chartPanel.setPreferredSize(size);
|
||||
chartPanel.addChartMouseListener(this);
|
||||
add(chartPanel,BorderLayout.CENTER);
|
||||
|
||||
this.setMinimumSize(size);
|
||||
} // BarGraph
|
||||
|
||||
|
||||
@Override
|
||||
public void addActionListener(ActionListener listener) {}
|
||||
|
||||
@Override
|
||||
public void addVetoableChangeListener(VetoableChangeListener listener) {}
|
||||
|
||||
@Override
|
||||
public void dispose() {}
|
||||
|
||||
@Override
|
||||
public String getName() {return chartModel.getName();}
|
||||
|
||||
@Override
|
||||
public void removeVetoableChangeListener(VetoableChangeListener listener) {}
|
||||
|
||||
@Override
|
||||
public void propertyChange(PropertyChangeEvent arg0) {}
|
||||
|
||||
@Override
|
||||
public void chartMouseClicked(ChartMouseEvent event) {
|
||||
|
||||
if ((event.getEntity()!=null) && (event.getTrigger().getClickCount() > 1))
|
||||
{
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
|
||||
try
|
||||
{
|
||||
ChartEntity entity = event.getEntity();
|
||||
String key = null;
|
||||
String category = null;
|
||||
if (entity instanceof CategoryItemEntity)
|
||||
{
|
||||
CategoryItemEntity item = ((CategoryItemEntity)entity);
|
||||
Comparable<?> colKey = item.getColumnKey();
|
||||
Comparable<?> rowKey = item.getRowKey();
|
||||
if (colKey != null && rowKey !=null)
|
||||
{
|
||||
key = colKey.toString();
|
||||
category = rowKey.toString();
|
||||
}
|
||||
}
|
||||
else if (entity instanceof PieSectionEntity)
|
||||
{
|
||||
Comparable<?> sectionKey = ((PieSectionEntity)entity).getSectionKey();
|
||||
if (sectionKey != null)
|
||||
{
|
||||
key = sectionKey.toString();
|
||||
}
|
||||
}
|
||||
|
||||
if ( key == null )
|
||||
return;
|
||||
|
||||
MQuery query = chartModel.getQuery("null".equals(category) ? key : category + "__" + key);
|
||||
if (query != null)
|
||||
AEnv.zoom(query);
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chartMouseMoved(ChartMouseEvent arg0) {}
|
||||
|
||||
@Override
|
||||
public void setField(GridField mField) {}
|
||||
|
||||
@Override
|
||||
public String getDisplay() {return null;}
|
||||
|
||||
@Override
|
||||
public Object getValue() {return null;}
|
||||
|
||||
@Override
|
||||
public boolean isMandatory() {return false;}
|
||||
|
||||
@Override
|
||||
public boolean isReadWrite() {return false;}
|
||||
|
||||
@Override
|
||||
public void setBackground(boolean error) {}
|
||||
|
||||
@Override
|
||||
public void setMandatory(boolean mandatory) {}
|
||||
|
||||
@Override
|
||||
public void setReadWrite(boolean rw) {}
|
||||
|
||||
@Override
|
||||
public void setValue(Object value) {}
|
||||
|
||||
@Override
|
||||
public GridField getField() { return null; }
|
||||
|
||||
}
|
|
@ -619,17 +619,11 @@ public abstract class AbstractADWindowContent extends AbstractUIPart implements
|
|||
}
|
||||
|
||||
//
|
||||
StringBuffer where = new StringBuffer();
|
||||
StringBuffer where = new StringBuffer(Env.parseContext(ctx, curWindowNo, mTab.getWhereExtended(), false));
|
||||
// Query automatically if high volume and no query
|
||||
boolean require = mTab.isHighVolume();
|
||||
if (!require && !m_onlyCurrentRows) // No Trx Window
|
||||
{
|
||||
String wh1 = Env.parseContext(ctx, curWindowNo, mTab.getWhereExtended(), false);
|
||||
if (wh1 == null || wh1.length() == 0)
|
||||
wh1 = mTab.getWhereClause();
|
||||
if (wh1 != null && wh1.length() > 0)
|
||||
where.append(wh1);
|
||||
//
|
||||
if (query != null)
|
||||
{
|
||||
String wh2 = query.getWhereClause();
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.adempiere.webui.editor.WAccountEditor;
|
|||
import org.adempiere.webui.editor.WAssignmentEditor;
|
||||
import org.adempiere.webui.editor.WBinaryEditor;
|
||||
import org.adempiere.webui.editor.WButtonEditor;
|
||||
import org.adempiere.webui.editor.WChartEditor;
|
||||
import org.adempiere.webui.editor.WDateEditor;
|
||||
import org.adempiere.webui.editor.WDatetimeEditor;
|
||||
import org.adempiere.webui.editor.WEditor;
|
||||
|
@ -119,6 +120,12 @@ public class DefaultEditorFactory implements IEditorFactory {
|
|||
editor = new WDateEditor(gridField);
|
||||
}
|
||||
|
||||
/** Chart */
|
||||
else if(displayType == DisplayType.Chart)
|
||||
{
|
||||
editor = new WChartEditor(gridField, gridTab.getWindowNo());
|
||||
}
|
||||
|
||||
/** Button */
|
||||
else if (displayType == DisplayType.Button)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue