Browse Source

Pull request #1713: CHART-13666 图表类型自动匹配设计器面板

Merge in DESIGN/design from ~BJORN/design:release/10.0 to release/10.0

* commit '2f58e87ed88eff1cd557cdd3a3f1df3f8ff2beeb':
  CHART-13666 代码质量
  CHART-13666 代码质量
  CHART-13666  增加注释
  CHART-13666
  CHART-13666 图表类型自动匹配设计器面板
  还原
  还原
  CHART-14022  父类方法改变,子类增加参数
feature/big-screen
Bjorn 5 years ago
parent
commit
0f868156b2
  1. 21
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java
  2. 9
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java
  3. 28
      designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java
  4. BIN
      designer-base/src/main/resources/com/fr/design/images/m_insert/auto_chart.png
  5. 1
      designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java
  6. 69
      designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java
  7. 104
      designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java
  8. 199
      designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java
  9. 1
      designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java
  10. 39
      designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java
  11. 3
      designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java
  12. 41
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java
  13. BIN
      designer-chart/src/main/resources/com/fr/design/images/form/toolbar/auto_chart.png
  14. 113
      designer-form/src/main/java/com/fr/design/designer/creator/XAutoChartCreator.java
  15. 19
      designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java
  16. 2
      designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java
  17. 58
      designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java
  18. 54
      designer-realize/src/main/java/com/fr/design/actions/insert/flot/AutoChartFloatAction.java
  19. 11
      designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java
  20. 24
      designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartCellEditor.java
  21. 18
      designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartFloatEditor.java
  22. 18
      designer-realize/src/main/java/com/fr/design/cell/editor/ChartCellEditor.java
  23. 16
      designer-realize/src/main/java/com/fr/design/cell/editor/ChartFloatEditor.java
  24. 10
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java
  25. 5
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

21
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java

@ -11,6 +11,10 @@ import com.fr.general.IOUtils;
import javax.swing.JCheckBox;
import javax.swing.JPanel;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
@ -22,10 +26,6 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
public class UICheckListPopup extends UIPopupMenu {
private List<ActionListener> listeners = new ArrayList<ActionListener>();
@ -53,7 +53,7 @@ public class UICheckListPopup extends UIPopupMenu {
public void setMaxDisplayNumber(int maxDisplayNumber) {
this.maxDisplayNumber = maxDisplayNumber;
addCheckboxValues(values);
addCheckboxValues();
}
private void initComponent() {
@ -65,16 +65,21 @@ public class UICheckListPopup extends UIPopupMenu {
this.setLayout(new BorderLayout());
this.add(jScrollPane, BorderLayout.CENTER);
addCheckboxValues(values);
addCheckboxValues();
}
public void refreshCheckboxValues(Object[] values){
this.values = values;
addCheckboxValues();
}
public void addCheckboxValues(Object[] value) {
private void addCheckboxValues() {
checkboxPane.removeAll();
checkBoxList.clear();
//全选加在第一个位置
addOneCheckValue(SELECT_ALL);
for (Object checkValue : value) {
for (Object checkValue : values) {
addOneCheckValue(checkValue);
}
addSelectListener();

9
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java

@ -17,6 +17,9 @@ import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@ -29,9 +32,6 @@ import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* 设计器下拉复选框组件
@ -198,7 +198,8 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
*/
public void refreshCombo(Object[] value) {
this.values = value;
this.popup.addCheckboxValues(value);
//CHART-13666 控件之前的刷新有bug,没有刷新popup中values的值,导致数组越界
this.popup.refreshCheckboxValues(value);
}
/**

28
designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java

@ -19,11 +19,10 @@ import com.fr.plugin.solution.sandbox.collection.PluginSandboxCollections;
import com.fr.stable.StableUtils;
import org.jetbrains.annotations.NotNull;
import java.lang.reflect.Constructor;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.Window;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
/**
* Created by IntelliJ IDEA.
@ -45,6 +44,7 @@ public class DesignModuleFactory {
private Class<Widget> chartEditorClass;
private Class<MiddleChartComponent> chartComponentClass;
private Class<MiddleChartDialog> chartDialogClass;
private Class<MiddleChartDialog> autoChartDialogClass;
private Class<? extends BaseChartPropertyPane> chartPropertyPaneClass;
private Class newFormAction;
private Class formParaDesigner;
@ -100,6 +100,10 @@ public class DesignModuleFactory {
instance.chartDialogClass = cd;
}
public static void registerAutoChartDialogClass(Class autoChartDialogClass) {
instance.autoChartDialogClass = autoChartDialogClass;
}
public static void registerChartPropertyPaneClass(Class<? extends BaseChartPropertyPane> p) {
instance.chartPropertyPaneClass = p;
}
@ -205,6 +209,26 @@ public class DesignModuleFactory {
return null;
}
/**
* 初始化图表向导对话框, 调用静态方法showWindow, 参数window.
*
* @return 返回调出的图表自动推荐AutoChartDialog
*/
public static MiddleChartDialog getAutoChartDialog(Window window) {
try {
Constructor<MiddleChartDialog> c;
if (window instanceof Frame) {
c = instance.autoChartDialogClass.getConstructor(Frame.class);
} else {
c = instance.autoChartDialogClass.getConstructor(Dialog.class);
}
return c.newInstance(window);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
}
/**
* kunsnat: 获取图表属性界面
*

BIN
designer-base/src/main/resources/com/fr/design/images/m_insert/auto_chart.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

1
designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java

@ -164,6 +164,7 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr
String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs();
ChartWidgetOption[] child = new ChartWidgetOption[chartIDs.length];
int index = 0;
for (String chartID : chartIDs) {
ChartProvider[] rowChart = ChartTypeManager.getInstance().getCharts(chartID);
if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(chartID)) {

69
designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java

@ -0,0 +1,69 @@
package com.fr.design.chart;
import com.fr.base.chart.BaseChartCollection;
import com.fr.base.chart.chartdata.TopDefinitionProvider;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.plugin.chart.vanchart.VanChart;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartDialog extends ChartDialog {
private AutoChartTypePane autoChartTypePane;
public AutoChartDialog(Frame owner) {
super(owner);
}
public AutoChartDialog(Dialog owner) {
super(owner);
}
protected Component initCenterPane() {
autoChartTypePane = new AutoChartTypePane();
return autoChartTypePane;
}
protected ActionListener getActionListener() {
return new ActionListener() {
public void actionPerformed(ActionEvent e) {
ChartCollection chartCollection = (ChartCollection) getChartCollection();
autoChartTypePane.update(chartCollection);
if (chartCollection.getChartCount() > 0) {
doOK();
} else {
doCancel();
}
}
};
}
/**
* 更新新建的图表 ChartCollection
*/
public void populate(BaseChartCollection cc) {
super.populate(cc);
ChartCollection chartCollection = (ChartCollection) getChartCollection();
VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class);
if (vanChart == null) {
return;
}
TopDefinitionProvider filterDefinition = vanChart.getFilterDefinition();
if (filterDefinition == null) {
return;
}
String tableName = vanChart.getFilterDefinition().getTableName();
String[] dataFields = vanChart.getFilterDefinition().getDataFields();
autoChartTypePane.populate(tableName, dataFields);
}
}

104
designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java

@ -0,0 +1,104 @@
package com.fr.design.chart;
import com.fr.base.chart.BaseChartPainter;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.base.chart.result.WebChartIDInfo;
import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.script.Calculator;
import javax.swing.Icon;
import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Paint;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-29
*/
public class AutoChartIcon implements Icon {
private static final int WIDTH = 500;
private static final int HEIGHT = 281;
private ChartCollection chartCollection;
private CallbackEvent callbackEvent;
private String chartName;
public AutoChartIcon(ChartCollection chartCollection) {
this.chartCollection = chartCollection;
initChartName();
}
public ChartCollection getChartCollection() {
return chartCollection;
}
public String getChartName() {
return chartName;
}
private void initChartName() {
Chart chart = chartCollection.getSelectedChart(Chart.class);
String[] subName = ChartTypeInterfaceManager.getInstance().getSubName(chart.getPlot().getPlotID());
chartName = subName[0];
}
public void registerCallBackEvent(CallbackEvent callbackEvent) {
this.callbackEvent = callbackEvent;
}
/**
* 画出缩略图Icon
*
* @param g 图形的上下文
* @param c 所在的Component
* @param x 缩略图的起始坐标x
* @param y 缩略图的起始坐标y
*/
@Override
public void paintIcon(Component c, Graphics g, int x, int y) {
BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(),
WebChartIDInfo.createEmptyDesignerInfo(), getIconWidth(), getIconHeight());
int resolution = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getJTemplateResolution();
Graphics2D g2d = (Graphics2D) g;
Paint oldPaint = g2d.getPaint();
g.translate(x, y);
g2d.setPaint(Color.white);
g2d.fillRect(0, 0, getIconWidth(), getIconHeight());
painter.paint(g2d, getIconWidth(), getIconHeight(), resolution, null, callbackEvent);
g.translate(-x, -y);
g2d.setPaint(oldPaint);
}
/**
* 返回缩略图的宽度
*
* @return int 缩略图宽度
*/
@Override
public int getIconWidth() {
return WIDTH;
}
/**
* 返回缩略图的高度
*
* @return int 缩略图高度
*/
@Override
public int getIconHeight() {
return HEIGHT;
}
}

199
designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java

@ -0,0 +1,199 @@
package com.fr.design.chart;
import com.fr.base.chart.chartdata.CallbackEvent;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chartx.attr.ChartProvider;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataComboBox;
import com.fr.design.data.tabledata.wrapper.TableDataWrapper;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombocheckbox.UIComboCheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.BorderFactory;
import javax.swing.DefaultListCellRenderer;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.ListCellRenderer;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-29
*/
public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent {
private JList chartViewList;
private DefaultListModel chartResultModel;
private UIButton refreshButton;
private TableDataComboBox tableNameComboBox;
private UIComboCheckBox dataFieldBox;
public AutoChartTypePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
initButtonGroup();
initRefreshLabel();
initDataFiledBox();
JPanel contentPane = createContentPane();
chartViewList = new JList();
chartResultModel = new DefaultListModel();
chartViewList.setModel(chartResultModel);
chartViewList.setVisibleRowCount(0);
chartViewList.setLayoutOrientation(JList.HORIZONTAL_WRAP);
chartViewList.setCellRenderer(iconCellRenderer);
JScrollPane subListPane = new JScrollPane(chartViewList);
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, contentPane, subListPane);
splitPane.setDividerLocation(60);
splitPane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type")));
this.add(splitPane);
}
ListCellRenderer iconCellRenderer = new DefaultListCellRenderer() {
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
this.setText("");
AutoChartIcon chartIcon = (AutoChartIcon) value;
this.setIcon(chartIcon);
setHorizontalAlignment(UILabel.CENTER);
if (isSelected) {
// 深蓝色.
this.setBackground(new Color(57, 107, 181));
this.setBorder(GUICoreUtils.createTitledBorder(chartIcon.getChartName(), Color.WHITE));
} else {
this.setBorder(GUICoreUtils.createTitledBorder(chartIcon.getChartName()));
}
return this;
}
};
private JPanel createContentPane() {
JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
JPanel tableDataPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
panel.add(tableDataPane);
tableDataPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":"));
tableNameComboBox.setPreferredSize(new Dimension(96, 20));
tableDataPane.add(tableNameComboBox);
JPanel areaNamePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
panel.add(areaNamePane);
areaNamePane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Field") + ":"));
areaNamePane.add(dataFieldBox);
panel.add(refreshButton);
return panel;
}
private void initButtonGroup() {
dataFieldBox = new UIComboCheckBox(new Object[0]);
dataFieldBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
checkButtonState();
}
});
}
private void initDataFiledBox() {
tableNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource());
tableNameComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
refreshBox();
checkButtonState();
}
}
});
}
private void checkButtonState() {
if (tableNameComboBox.getSelectedItem() != null && dataFieldBox.getSelectedValues().length > 0) {
refreshButton.setEnabled(true);
} else {
refreshButton.setEnabled(false);
}
}
private void refreshBox() {
TableDataWrapper dataWrap = tableNameComboBox.getSelectedItem();
if (dataWrap == null) {
return;
}
dataFieldBox.clearText();
List<String> columnNameList = dataWrap.calculateColumnNameList();
dataFieldBox.refreshCombo(columnNameList.toArray());
}
private void initRefreshLabel() {
refreshButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Recommend"));
refreshButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
calculateAutoChart();
}
});
refreshButton.setEnabled(false);
}
private void calculateAutoChart() {
chartResultModel.clear();
}
@Override
public void populate(ChartCollection cc) {
}
@Override
public void update(ChartCollection cc) {
if (chartViewList.getSelectedIndex() < 0) {
return;
}
AutoChartIcon chartIcon = (AutoChartIcon) chartViewList.getSelectedValue();
ChartProvider chartProvider = chartIcon.getChartCollection().getSelectedChartProvider(ChartProvider.class);
if (cc.getChartCount() > 0) {
cc.setSelectChart(chartProvider);
} else {
cc.addChart(chartProvider);
}
}
public void populate(String tableName, String[] dataFields) {
tableNameComboBox.setSelectedTableDataByName(tableName);
Map<Object, Boolean> map = new HashMap();
for (String dataField : dataFields) {
map.put(dataField, true);
}
dataFieldBox.setSelectedValues(map);
}
@Override
public void callback() {
this.repaint();
}
}

1
designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java

@ -39,6 +39,7 @@ public class ChartDesignerActivator extends Activator implements Prepare {
DesignModuleFactory.registerChartComponentClass(ChartComponent.class);
DesignModuleFactory.registerChartDialogClass(ChartDialog.class);
DesignModuleFactory.registerAutoChartDialogClass(AutoChartDialog.class);
DesignModuleFactory.registerChartPropertyPaneClass(ChartPropertyPane.class);

39
designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java

@ -10,6 +10,7 @@ import com.fr.third.joda.time.DateTime;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dialog;
import java.awt.FlowLayout;
import java.awt.Frame;
@ -18,6 +19,7 @@ import java.awt.event.ActionListener;
/**
* 封装一层 图表新建的对话框, 配合属性表确定: 先单独只要一种图表类型的对话框.
*
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2013-1-7 下午07:29:15
*/
@ -27,6 +29,8 @@ public class ChartDialog extends MiddleChartDialog {
private UIButton ok;
private UIButton cancel;
private ChartTypePane chartTypePane;
private String createTime;
public ChartDialog(Frame owner) {
super(owner);
@ -39,45 +43,50 @@ public class ChartDialog extends MiddleChartDialog {
}
private void initComponent() {
final String createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss");
this.setModal(true);
this.setLayout(new BorderLayout());
final ChartTypePane chartTypePane = new ChartTypePane();
setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_M_Popup_Chart_Type"));
this.applyClosingAction();
this.applyEscapeAction();
this.setBasicDialogSize(BasicDialog.DEFAULT);
this.add(chartTypePane, BorderLayout.CENTER);
this.add(initCenterPane(), BorderLayout.CENTER);
JPanel buttonPane = new JPanel();
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
this.add(buttonPane, BorderLayout.SOUTH);
ok = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_OK"));
cancel = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cancel"));
buttonPane.add(ok);
buttonPane.add(cancel);
ok.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
chartTypePane.update((ChartCollection)cc, createTime);
doOK();
}
});
ok.addActionListener(getActionListener());
cancel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
doCancel();
}
});
buttonPane.add(ok);
buttonPane.add(cancel);
GUICoreUtils.setWindowCenter(getOwner(), this);
}
protected Component initCenterPane() {
chartTypePane = new ChartTypePane();
return chartTypePane;
}
protected ActionListener getActionListener() {
return new ActionListener() {
public void actionPerformed(ActionEvent e) {
chartTypePane.update((ChartCollection) cc, createTime);
doOK();
}
};
}
/**
* 不处理
*/

3
designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java

@ -140,6 +140,9 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene
public void paintComponent(Graphics g) { //
super.paintComponent(g);
if(chartCollection4Design.getChartCount() == 0) {
return;
}
Graphics2D g2d = (Graphics2D) g;

41
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java

@ -6,28 +6,36 @@ import com.fr.chartx.attr.ChartProvider;
import com.fr.design.ChartTypeInterfaceManager;
import com.fr.design.beans.FurtherBasicBeanPane;
import com.fr.design.dialog.BasicScrollPane;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.gui.frpane.UIComboBoxPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.chart.AbstractChartAttrPane;
import com.fr.design.mainframe.chart.ChartEditPane;
import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.mainframe.chart.gui.item.FlexibleComboBox;
import com.fr.design.mainframe.chart.gui.item.ItemEventType;
import com.fr.design.mainframe.chart.gui.type.AbstractChartTypePane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* 图表 属性表, 类型选择 界面.
@ -39,6 +47,7 @@ public class ChartTypePane extends AbstractChartAttrPane{
private ChartTypeButtonPane buttonPane;
private ChartEditPane editPane;
private ChartCollection editingCollection;
private UIButton autoButton;
@Override
protected JPanel createContentPane() {
@ -79,6 +88,11 @@ public class ChartTypePane extends AbstractChartAttrPane{
buttonPane.setEditingChartPane(chartTypeComBox);
if(ChartTypeManager.AUTO_CHART) {
initAutoButton();
content.add(autoButton, BorderLayout.SOUTH);
}
return content;
}
@ -97,6 +111,25 @@ public class ChartTypePane extends AbstractChartAttrPane{
return PaneTitleConstants.CHART_TYPE_TITLE;
}
private void initAutoButton(){
//TODO @Bjorn 视觉样式优化
autoButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type"));
autoButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
final MiddleChartDialog autoChartDialog = DesignModuleFactory.getAutoChartDialog(DesignerContext.getDesignerFrame());
autoChartDialog.populate(editingCollection);
autoChartDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
populate(editingCollection);
}
});
autoChartDialog.setVisible(true);
}
});
}
class ComboBoxPane extends UIComboBoxPane<ChartProvider> {
private Map<String, Map<String, FurtherBasicBeanPane<? extends ChartProvider>>> allChartTypePane;

BIN
designer-chart/src/main/resources/com/fr/design/images/form/toolbar/auto_chart.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

113
designer-form/src/main/java/com/fr/design/designer/creator/XAutoChartCreator.java

@ -0,0 +1,113 @@
package com.fr.design.designer.creator;
import com.fr.base.GraphHelper;
import com.fr.base.chart.BaseChartCollection;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.mainframe.BaseJForm;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.EditingMouseListener;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.module.DesignModuleFactory;
import com.fr.form.ui.ChartAutoEditor;
import com.fr.stable.bridge.StableFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-26
*/
public class XAutoChartCreator extends XChartEditor {
private MiddleChartDialog autoChartDialog;
private EditingMouseListener editingMouseListener;
public XAutoChartCreator(ChartAutoEditor editor, Dimension size) {
super(editor, size);
}
/**
* 返回组件默认名
*
* @return 组件类名(小写)
*/
public String createDefaultName() {
return "auto_chart";
}
@Override
public ChartAutoEditor toData() {
return (ChartAutoEditor) data;
}
/**
* 点击选中的时候, 刷新界面
* 右键 reset之后, 触发事件 populate此方法
*
* @param jform 表单
* @param formDesigner 表单设计器
* @return 控件.
*/
public JComponent createToolPane(final BaseJForm jform, final FormDesigner formDesigner) {
if (toData().isChartSelect()) {
return super.createToolPane(jform, formDesigner);
}
if (isEditing) {
if (autoChartDialog != null && autoChartDialog.isVisible()) {
return new JPanel();
}
final BaseChartCollection chartCollection = (BaseChartCollection) StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
autoChartDialog = DesignModuleFactory.getAutoChartDialog(DesignerContext.getDesignerFrame());
autoChartDialog.populate(chartCollection);
autoChartDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
initChart(autoChartDialog.getChartCollection());
formDesigner.fireTargetModified();
}
@Override
public void doCancel() {
editingMouseListener.stopEditing();
}
});
autoChartDialog.setVisible(true);
}
return toData().isChartSelect() ? super.createToolPane(jform, formDesigner) : new JPanel();
}
/**
* 响应点击事件
*
* @param editingMouseListener 鼠标点击位置处理器
* @param e 鼠标点击事件
*/
public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) {
this.editingMouseListener = editingMouseListener;
super.respondClick(editingMouseListener, e);
}
public void paint(Graphics g) {
//TODO @Bjorn 视觉样式优化
g.setColor(Color.RED);
GraphHelper.fill(g, new Rectangle(0, 0, getWidth(), getHeight()));
super.paint(g);
}
private void initChart(BaseChartCollection chartCollection) {
((MiddleChartComponent) getDesignerEditor().getEditorTarget()).populate(chartCollection);
this.toData().resetChangeChartCollection(chartCollection);
this.toData().setChartSelect(true);
}
}

19
designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java

@ -28,13 +28,13 @@ import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.beans.IntrospectionException;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.beans.IntrospectionException;
/**
* form中的图表按钮弹出的控件, 创建初始化图表内容.
@ -52,7 +52,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
//marro:无奈的属性,暂时想不出好办法
private boolean isRefreshing = false;
private boolean isEditing = false;
protected boolean isEditing = false;
private boolean isHovering = false;
private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30);
@ -79,6 +79,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/**
* 返回组件默认名
*
* @return 组件类名(小写)
*/
public String createDefaultName() {
@ -87,6 +88,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/**
* 是否支持设置标题
*
* @return 是返回true
*/
public boolean hasTitleStyle() {
@ -98,8 +100,10 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
isEditing = false;
}
/**
* 得到属性名
*
* @return 属性名
* @throws java.beans.IntrospectionException
*/
@ -111,7 +115,8 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
@Override
public void propertyChange() {
makeVisible(toData().isVisible());}
makeVisible(toData().isVisible());
}
}),
new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass(
WLayoutBorderStyleEditor.class).setI18NName(
@ -128,6 +133,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/**
* 该组件是否可以拖入参数面板
*
* @return 是则返回true
*/
public boolean canEnterIntoParaPane() {
@ -137,7 +143,6 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/**
* 编辑状态的时候需要重新绘制下边框
*
*/
@Override
public void paintBorder(Graphics g, Rectangle bounds) {
@ -206,8 +211,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
}
});
return (JComponent) propertyPane;
}
else{
} else {
return (JComponent) DesignModuleFactory.getWidgetPropertyPane(formDesigner);
}
}
@ -305,6 +309,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/**
* 是否展现覆盖的pane
*
* @param display 是否
*/
public void displayCoverPane(boolean display) {
@ -329,7 +334,6 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/**
* data属性改变触发其他操作
*
*/
public void firePropertyChange() {
initStyle();
@ -342,6 +346,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator {
/**
* 是否支持共享-现只支持报表块图表tab块绝对布局
*
* @return
*/
public boolean isSupportShared() {

2
designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java

@ -19,6 +19,7 @@ import com.fr.form.parameter.FormSubmitButton;
import com.fr.form.ui.Button;
import com.fr.form.ui.CardAddButton;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.ChartAutoEditor;
import com.fr.form.ui.CheckBox;
import com.fr.form.ui.CheckBoxGroup;
import com.fr.form.ui.ComboBox;
@ -174,6 +175,7 @@ public class XCreatorUtils {
private static void putExtraEditor() {
if (DesignModuleFactory.getChartEditorClass() != null) {
objectMap.put(DesignModuleFactory.getChartEditorClass(), XChartEditor.class);
objectMap.put(ChartAutoEditor.class, XAutoChartCreator.class);
}
}

58
designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java

@ -0,0 +1,58 @@
package com.fr.design.actions.insert.cell;
import com.fr.base.BaseUtils;
import com.fr.chart.chartattr.AutoChartCollection;
import com.fr.design.actions.core.WorkBookSupportable;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import javax.swing.KeyStroke;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartCellAction extends AbstractCellAction implements WorkBookSupportable {
public AutoChartCellAction() {
initAction();
}
public AutoChartCellAction(ElementCasePane t) {
super(t);
initAction();
}
private void initAction() {
this.setMenuKeySet(INSERT_AUTO_CHART);
this.setName(getMenuKeySet().getMenuKeySetName() + "...");
this.setMnemonic(getMenuKeySet().getMnemonic());
//TODO @Bjorn 视觉样式优化icon
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/auto_chart.png"));
}
public static final MenuKeySet INSERT_AUTO_CHART = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'M';
}
@Override
public String getMenuName() {
return Toolkit.i18nText("Fine-Design_Report_M_Insert_Auto_Chart");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
@Override
public Class getCellValueClass() {
return AutoChartCollection.class;
}
}

54
designer-realize/src/main/java/com/fr/design/actions/insert/flot/AutoChartFloatAction.java

@ -0,0 +1,54 @@
package com.fr.design.actions.insert.flot;
import com.fr.base.BaseUtils;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.module.DesignModuleFactory;
import javax.swing.KeyStroke;
import java.awt.Window;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartFloatAction extends ChartFloatAction {
/**
* 构造函数 图表插入悬浮元素
*/
public AutoChartFloatAction(ElementCasePane t) {
super(t);
}
protected void init() {
this.setMenuKeySet(FLOAT_INSERT_AUTO_CHART);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/m_insert/auto_chart.png"));
}
public static final MenuKeySet FLOAT_INSERT_AUTO_CHART = new MenuKeySet() {
@Override
public char getMnemonic() {
return 'M';
}
@Override
public String getMenuName() {
return Toolkit.i18nText("Fine-Design_Report_M_Insert_Auto_Chart");
}
@Override
public KeyStroke getKeyStroke() {
return null;
}
};
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getAutoChartDialog(window);
}
}

11
designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java

@ -27,6 +27,7 @@ import com.fr.stable.unit.OLDPIX;
import javax.swing.KeyStroke;
import java.awt.Color;
import java.awt.Window;
/**
* 图表插入悬浮元素的操作.
@ -40,6 +41,10 @@ public class ChartFloatAction extends ElementCaseAction {
*/
public ChartFloatAction(ElementCasePane t) {
super(t);
init();
}
protected void init() {
this.setMenuKeySet(FLOAT_INSERT_CHART);
this.setName(getMenuKeySet().getMenuKeySetName());
this.setMnemonic(getMenuKeySet().getMnemonic());
@ -78,7 +83,7 @@ public class ChartFloatAction extends ElementCaseAction {
reportPane.stopEditing();
final BaseChartCollection cc = (BaseChartCollection) StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
final MiddleChartDialog chartDialog = DesignModuleFactory.getChartDialog(DesignerContext.getDesignerFrame());
final MiddleChartDialog chartDialog = getMiddleChartDialog(DesignerContext.getDesignerFrame());
chartDialog.populate(cc);
chartDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
@ -124,4 +129,8 @@ public class ChartFloatAction extends ElementCaseAction {
chartDialog.setVisible(true);
return isRecordNeeded;
}
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getChartDialog(window);
}
}

24
designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartCellEditor.java

@ -0,0 +1,24 @@
package com.fr.design.cell.editor;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.report.elementcase.TemplateElementCase;
import java.awt.Window;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartCellEditor extends ChartCellEditor {
public AutoChartCellEditor(ElementCasePane<? extends TemplateElementCase> ePane) {
super(ePane);
}
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getAutoChartDialog(window);
}
}

18
designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartFloatEditor.java

@ -0,0 +1,18 @@
package com.fr.design.cell.editor;
import com.fr.design.gui.chart.MiddleChartDialog;
import com.fr.design.module.DesignModuleFactory;
import java.awt.Window;
/**
* @author Bjorn
* @version 10.0
* Created by Bjorn on 2020-05-28
*/
public class AutoChartFloatEditor extends ChartFloatEditor {
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getAutoChartDialog(window);
}
}

18
designer-realize/src/main/java/com/fr/design/cell/editor/ChartCellEditor.java

@ -1,21 +1,21 @@
package com.fr.design.cell.editor;
import java.awt.Component;
import javax.swing.SwingUtilities;
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.design.dialog.DialogActionListener;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.module.DesignModuleFactory;
import com.fr.grid.Grid;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.bridge.StableFactory;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.SwingUtilities;
import java.awt.Component;
import java.awt.Window;
/**
* CellEditor used to edit Chart object.
*/
@ -67,7 +67,7 @@ public class ChartCellEditor extends AbstractCellEditor implements DialogActionL
this.chartCellEditorDialog = null;
return glyphComponent;
}
this.chartCellEditorDialog = DesignModuleFactory.getChartDialog(SwingUtilities.getWindowAncestor(grid));
this.chartCellEditorDialog = getMiddleChartDialog(SwingUtilities.getWindowAncestor(grid));
this.chartCellEditorDialog.addDialogActionListener(this);
BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
this.chartCellEditorDialog.populate(cc);
@ -84,4 +84,8 @@ public class ChartCellEditor extends AbstractCellEditor implements DialogActionL
public void doCancel() {
cancelCellEditing();
}
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getChartDialog(window);
}
}

16
designer-realize/src/main/java/com/fr/design/cell/editor/ChartFloatEditor.java

@ -1,20 +1,20 @@
package com.fr.design.cell.editor;
import java.awt.Component;
import javax.swing.SwingUtilities;
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.design.dialog.DialogActionListener;
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;
@ -65,7 +65,7 @@ public class ChartFloatEditor extends AbstractFloatEditor implements DialogActio
}
return glyphComponent;
}
this.chartFloatEditorDialog = DesignModuleFactory.getChartDialog(SwingUtilities.getWindowAncestor(grid));
this.chartFloatEditorDialog = getMiddleChartDialog(SwingUtilities.getWindowAncestor(grid));
this.chartFloatEditorDialog.addDialogActionListener(this);
BaseChartCollection cc = (BaseChartCollection)StableFactory.createXmlObject(BaseChartCollection.XML_TAG);
this.chartFloatEditorDialog.populate(cc);
@ -82,4 +82,8 @@ public class ChartFloatEditor extends AbstractFloatEditor implements DialogActio
public void doCancel() {
cancelFloatEditing();
}
protected MiddleChartDialog getMiddleChartDialog(Window window) {
return DesignModuleFactory.getChartDialog(window);
}
}

10
designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java

@ -9,6 +9,7 @@ import com.fr.base.Formula;
import com.fr.base.ScreenResolution;
import com.fr.base.Style;
import com.fr.base.vcs.DesignerMode;
import com.fr.chart.chartattr.AutoChartCollection;
import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
@ -52,6 +53,8 @@ import com.fr.design.cell.bar.DynamicScrollBar;
import com.fr.design.cell.clipboard.CellElementsClip;
import com.fr.design.cell.clipboard.ElementsTransferable;
import com.fr.design.cell.clipboard.FloatElementsClip;
import com.fr.design.cell.editor.AutoChartCellEditor;
import com.fr.design.cell.editor.AutoChartFloatEditor;
import com.fr.design.cell.editor.BiasTextPainterCellEditor;
import com.fr.design.cell.editor.CellEditor;
import com.fr.design.cell.editor.ChartCellEditor;
@ -118,6 +121,8 @@ import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollBar;
import javax.swing.KeyStroke;
import java.lang.reflect.Constructor;
import java.util.Set;
import java.awt.AWTEvent;
import java.awt.Adjustable;
import java.awt.Dimension;
@ -131,8 +136,6 @@ import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.lang.reflect.Constructor;
import java.util.Set;
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER;
@ -399,6 +402,9 @@ public abstract class ElementCasePane<T extends TemplateElementCase> extends Tar
grid.setDefaultFloatEditor(chartClass, new ChartFloatEditor());
}
grid.setDefaultCellEditor(AutoChartCollection.class, new AutoChartCellEditor(this));
grid.setDefaultFloatEditor(AutoChartCollection.class, new AutoChartFloatEditor());
addExtraCellEditor(grid);
grid.setDefaultFloatEditor(Formula.class, new FormulaFloatEditor());

5
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -112,11 +112,11 @@ import com.fr.start.BBSGuestPaneProvider;
import com.fr.task.Once;
import com.fr.xml.ReportXMLUtils;
import java.awt.*;
import java.awt.image.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.awt.Image;
import java.awt.image.BufferedImage;
/**
* Created by juhaoyu on 2018/1/31.
@ -240,6 +240,7 @@ public class DesignerActivator extends Activator {
for (ElementUIProvider provider : providers) {
classes.add(provider.actionForInsertFloatElement());
}
return ArrayUtils.addAll(new Class<?>[]{
TextBoxFloatAction.class,
FormulaFloatAction.class,

Loading…
Cancel
Save