帆软报表设计器源代码。
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

89 lines
3.0 KiB

package com.fr.design.cell.editor;
import com.fr.base.chart.BaseChartCollection;
import com.fr.design.dialog.DialogActionListener;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.module.DesignModuleFactory;
import com.fr.grid.Grid;
import com.fr.report.cell.FloatElement;
import com.fr.stable.StringUtils;
import com.fr.stable.bridge.StableFactory;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.SwingUtilities;
import java.awt.Component;
import java.awt.Window;
public class ChartFloatEditor extends AbstractFloatEditor implements DialogActionListener {
private MiddleChartDialog chartFloatEditorDialog = null;
private MiddleChartComponent glyphComponent = null;
/**
* Constructor
*/
public ChartFloatEditor() {
}
/**
* Return the value of the FloatEditor
*/
@Override
public Object getFloatEditorValue() throws Exception {
if (this.glyphComponent != null) {
MiddleChartComponent newComponent = this.glyphComponent;
return newComponent.update();
}
BaseChartCollection cc = this.chartFloatEditorDialog.getChartCollection();
// 判断条件以及返回值
if (cc != null) {
return cc;
} else {
return StringUtils.EMPTY;
}
}
@Override
public Component getFloatEditorComponent(final Grid grid, FloatElement floatElement, int resolution) {
Object valueCell = floatElement.getValue();
if (valueCell instanceof BaseChartCollection) {
this.chartFloatEditorDialog = null;
if (glyphComponent == null) {
glyphComponent = DesignModuleFactory.getChartComponent((BaseChartCollection)valueCell);
glyphComponent.addStopEditingListener(new PropertyChangeAdapter() {
@Override
public void propertyChange() {
stopFloatEditing();
grid.requestFocus();// kunsnat: 补充, 编辑图表reset之后, Grid也算停止编辑 重获焦点 bug20443
}
});
} else {
glyphComponent.populate((BaseChartCollection) valueCell);
}
return glyphComponent;
}
this.chartFloatEditorDialog = getMiddleChartDialog(SwingUtilities.getWindowAncestor(grid));
this.chartFloatEditorDialog.addDialogActionListener(this);
BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
this.chartFloatEditorDialog.populate(cc);
this.glyphComponent = null;
return this.chartFloatEditorDialog;
}
@Override
public void doOk() {
stopFloatEditing();
}
@Override
public void doCancel() {
cancelFloatEditing();
}
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getChartDialog(window);
}
}