?? editchartaction.java
字號:
/*
* Copyright (C) 2003 Erik Swenson - eswenson@opensourcesoft.net
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
* Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
package org.efs.openreports.actions.admin;
import java.util.HashMap;
import java.util.List;
import com.opensymphony.xwork.ActionSupport;
import org.apache.log4j.Logger;
import org.efs.openreports.objects.ReportChart;
import org.efs.openreports.objects.ReportParameter;
import org.efs.openreports.objects.chart.ChartValue;
import org.efs.openreports.providers.*;
public class EditChartAction extends ActionSupport implements DataSourceProviderAware, ChartProviderAware
{
protected static Logger log =
Logger.getLogger(EditChartAction.class);
private String command;
private String submitType;
private int id;
private String name;
private String description;
private String query;
private int dataSourceId = Integer.MIN_VALUE;
private int chartType;
private int width;
private int height;
private String xAxisLabel;
private String yAxisLabel;
private ReportChart reportChart;
private ChartValue[] chartValues;
private DataSourceProvider dataSourceProvider;
private ChartProvider chartProvider;
public String execute()
{
try
{
if (command.equals("edit"))
{
reportChart =
chartProvider.getReportChart(new Integer(id));
}
else
{
reportChart = new ReportChart();
}
if (command.equals("edit") && submitType == null)
{
name = reportChart.getName();
description = reportChart.getDescription();
query = reportChart.getQuery();
chartType = reportChart.getChartType();
width = reportChart.getWidth();
height = reportChart.getHeight();
xAxisLabel = reportChart.getXAxisLabel();
yAxisLabel = reportChart.getYAxisLabel();
id = reportChart.getId().intValue();
if (reportChart.getDataSource() != null)
{
dataSourceId =
reportChart.getDataSource().getId().intValue();
}
}
if (submitType == null)
return INPUT;
reportChart.setName(name);
reportChart.setDescription(description);
reportChart.setQuery(query);
reportChart.setChartType(chartType);
reportChart.setWidth(width);
reportChart.setHeight(height);
reportChart.setXAxisLabel(xAxisLabel);
reportChart.setYAxisLabel(yAxisLabel);
if (dataSourceId != -1)
reportChart.setDataSource(
dataSourceProvider.getDataSource(
new Integer(dataSourceId)));
if (submitType.equals("Validate"))
{
if (query.toUpperCase().indexOf("$P{") > -1)
{
addActionError("Validation not supported on queries with parameters.");
}
else
{
chartValues =
chartProvider.getChartValues(reportChart, new HashMap());
}
return INPUT;
}
if (command.equals("edit"))
{
chartProvider.updateReportChart(reportChart);
}
if (command.equals("add"))
{
chartProvider.insertReportChart(reportChart);
}
return SUCCESS;
}
catch (Exception e)
{
addActionError(e.getMessage());
return INPUT;
}
}
public String getCommand()
{
return command;
}
public void setCommand(String command)
{
this.command = command;
}
public String getSubmitType()
{
return submitType;
}
public void setSubmitType(String submitType)
{
this.submitType = submitType;
}
public int getDataSourceId()
{
return dataSourceId;
}
public String getName()
{
return name;
}
public void setDataSourceId(int dataSourceId)
{
this.dataSourceId = dataSourceId;
}
public void setName(String name)
{
this.name = name;
}
public List getDataSources()
{
try
{
return dataSourceProvider.getDataSources();
}
catch (Exception e)
{
addActionError(e.getMessage());
return null;
}
}
public String[] getTypes()
{
return ReportParameter.TYPES;
}
public String[] getClassNames()
{
return ReportParameter.CLASS_NAMES;
}
public int getId()
{
return id;
}
public void setId(int id)
{
this.id = id;
}
public void setDataSourceProvider(DataSourceProvider dataSourceProvider)
{
this.dataSourceProvider = dataSourceProvider;
}
public String getDescription()
{
return description;
}
public void setDescription(String description)
{
this.description = description;
}
public void setChartProvider(ChartProvider chartProvider)
{
this.chartProvider = chartProvider;
}
public String getQuery()
{
return query;
}
public void setQuery(String query)
{
this.query = query;
}
public int getChartType()
{
return chartType;
}
public void setChartType(int chartType)
{
this.chartType = chartType;
}
public int getHeight()
{
return height;
}
public void setHeight(int height)
{
this.height = height;
}
public int getWidth()
{
return width;
}
public void setWidth(int width)
{
this.width = width;
}
public ChartValue[] getChartValues()
{
return chartValues;
}
public String getXAxisLabel()
{
return xAxisLabel;
}
public void setXAxisLabel(String axisLabel)
{
xAxisLabel = axisLabel;
}
public String getYAxisLabel()
{
return yAxisLabel;
}
public void setYAxisLabel(String axisLabel)
{
yAxisLabel = axisLabel;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -