Browse Source

CHART-9141 ChartRequestService新增+chart service move to chart module+chartdata remove from engine-cross

research/10.0
zheng 5 years ago
parent
commit
eba5d13d8f
  1. 128
      designer-chart/src/main/java/com/fr/design/chart/ChartControlPane.java
  2. 94
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java

128
designer-chart/src/main/java/com/fr/design/chart/ChartControlPane.java

@ -1,128 +0,0 @@
package com.fr.design.chart;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.NameObject;
import com.fr.stable.Nameable;
import java.awt.*;
import java.util.HashMap;
/**
* 管理图表类型Pane
* @author kunsnat: ChartComponent移出.
*/
public class ChartControlPane extends JListControlPane {
private static final long serialVersionUID = 7336270815128413184L;
public ChartControlPane() {
super();
// 重新设定大小. 因为JControlPane默认的(450,450) 不适合图表这边 @ChartSize
// this.setPreferredSize(new Dimension(770, 520));
}
@Override
public NameableCreator[] createNameableCreators() {
return new NameableCreator[] {
new NameObjectCreator(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Chart"), Chart.class, ChartTypeUpdatePane.class)
};
}
@Override
protected String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Manage_Chart_Type");
}
public void populate(ChartCollection cc) {
if(cc == null)return;
NameObject[] nameObjects = new NameObject[cc.getChartCount()];
for (int i = 0; i < nameObjects.length; i++) {
nameObjects[i] = new NameObject(cc.getChartName(i), cc.getChart(i));
}
populate(nameObjects);
// kunsnat: 选中当前图表选中的name
String chartSelectedName = cc.getChartName(cc.getSelectedIndex() < cc.getChartCount() ? cc.getSelectedIndex() : 0);
setSelectedName(chartSelectedName);
}
public void update(ChartCollection cc) {
HashMap namesChart = new HashMap();// 暂存判断是否有必要更新
for(int i = 0; i < cc.getChartCount(); i++) {
try {
namesChart.put(cc.getChartName(i), cc.getChart(i).clone());
} catch (CloneNotSupportedException e) {
}
}
Nameable[] nameables = update();
if (nameables.length == 0 || cc == null) {
return;
}
cc.removeAllNameObject();
String select = getSelectedName();
for (int i = 0; i < nameables.length; i++) {
if (nameables[i] instanceof NameObject && ((NameObject)nameables[i]).getObject() instanceof Chart) {
NameObject no = (NameObject)nameables[i];
String name = no.getName();
Chart chart = (Chart)no.getObject();
if(namesChart.containsKey(name)) {
Chart tmpChart = (Chart)namesChart.get(name);
if(chart.getPlot() != null && tmpChart.getPlot() != null
&& chart.getPlot().match4GUI(tmpChart.getPlot())) {
chart = tmpChart;// 代替之前做过编辑的Chart
}
}
cc.addNamedChart(name, chart);
if(no.getName().equals(select)) {
cc.setSelectedIndex(i);
}
}
}
}
/*
* alex:继承UpdatePane的ChartTypePane
*/
public static class ChartTypeUpdatePane extends BasicBeanPane<Chart> {
private static final long serialVersionUID = -7058348930816218415L;
private Chart editing;
private ChartTypePane typePane;
public ChartTypeUpdatePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
typePane = new ChartTypePane();
this.add(typePane, BorderLayout.CENTER);
}
@Override
protected String title4PopupWindow() {
return "Chart Type";
}
@Override
public void populateBean(Chart ob) {
editing = ob;
typePane.populate(ob);
}
@Override
public Chart updateBean() {
typePane.update(editing);
return editing;
}
}
}

94
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/other/ChartSwitchPane.java

@ -1,94 +0,0 @@
package com.fr.design.mainframe.chart.gui.other;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import com.fr.design.chart.ChartControlPane;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
public class ChartSwitchPane extends AbstractAttrNoScrollPane{
private UIButton changeButton;
private ChartCollection editingChartCollection;
private ChartEditPane currentChartEditPane;
public ChartSwitchPane() {
}
@Override
protected JPanel createContentPane() {
JPanel pane = new JPanel();
pane.setLayout(new BorderLayout());
changeButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Switch"));
pane.add(changeButton, BorderLayout.NORTH);
changeButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
final ChartControlPane chartTypeManager = new ChartControlPane();
chartTypeManager.populate(editingChartCollection);
BasicDialog dlg = chartTypeManager.showWindow4ChartType(SwingUtilities.getWindowAncestor(new JPanel()), new DialogActionAdapter() {
public void doOk() {
chartTypeManager.update(editingChartCollection);//kunsnat: 确定刷新"chartSelectIndex"
if(currentChartEditPane != null) {
currentChartEditPane.populate(editingChartCollection);// 选中新Plot之后 刷新对应界面, 比如超级链接等, 然后才能update.
currentChartEditPane.gotoPane(PaneTitleConstants.CHART_TYPE_TITLE);
currentChartEditPane.gotoPane(PaneTitleConstants.CHART_OTHER_TITLE, PaneTitleConstants.CHART_OTHER_TITLE_CHANGE);
currentChartEditPane.fire();
}
}
});
dlg.setVisible(true);
}
});
return pane;
}
/**
* 注册 切换事件的改变 和超链不同.
* @param listener
*/
public void registerChartEditPane(ChartEditPane currentChartEditPane) {
this.currentChartEditPane = currentChartEditPane;
}
public void populateBean(ChartCollection c) {
this.editingChartCollection = c;
}
public void updateBean(ChartCollection c) {
}
/**
* 界面标题
* @param 返回标题
*/
public String title4PopupWindow() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Switch_Chart");
}
@Override
public String getIconPath() {
return null;
}
}
Loading…
Cancel
Save