From 1e5f8d36f1401cee6a1401e251d9ed89b8201142 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Fri, 22 May 2020 16:20:26 +0800 Subject: [PATCH 1/8] =?UTF-8?q?CHART-14022=20=20=E7=88=B6=E7=B1=BB?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E6=94=B9=E5=8F=98=EF=BC=8C=E5=AD=90=E7=B1=BB?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/van/chart/designer/PlotFactory.java | 4 ++-- .../designer/component/format/FormatPaneWithNormalType.java | 2 +- .../designer/component/format/FormatPaneWithOutFont.java | 2 +- .../van/chart/designer/style/axis/VanChartBaseAxisPane.java | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java index d3e1adbb9..e92afa38f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java @@ -63,12 +63,12 @@ import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; -import java.awt.Component; import java.lang.reflect.Constructor; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; +import java.awt.Component; /** * Created by Mitisky on 16/3/1. @@ -339,7 +339,7 @@ public class PlotFactory { public static FormatPane createAutoFormatPane() { FormatPane formatPane = new FormatPane() { - protected Component[][] getComponent(JPanel fontPane, JPanel centerPane, JPanel typePane) { + protected Component[][] getComponent(JPanel fontPane, JPanel centerPane, JPanel typePane, JPanel optionPane) { typePane.setBorder(BorderFactory.createEmptyBorder()); return new Component[][]{ new Component[]{typePane, null}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithNormalType.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithNormalType.java index 728bc1b1c..959194ad1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithNormalType.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithNormalType.java @@ -23,7 +23,7 @@ public class FormatPaneWithNormalType extends FormatPaneWithOutFont { setForDataSheet(); } - protected Component[][] getComponent(JPanel fontPane, JPanel centerPane, JPanel typePane) { + protected Component[][] getComponent(JPanel fontPane, JPanel centerPane, JPanel typePane, JPanel optionPane) { return new Component[][]{ new Component[]{null, centerPane}, }; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithOutFont.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithOutFont.java index 7275ad074..f225156d8 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithOutFont.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithOutFont.java @@ -28,7 +28,7 @@ public class FormatPaneWithOutFont extends FormatPane { return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); } - protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane) { + protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane, JPanel optionPane) { typePane.setBorder(BorderFactory.createEmptyBorder()); return new Component[][]{ new Component[]{null, null}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java index 064a7156b..1858f0a40 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java @@ -445,7 +445,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { protected FormatPane createFormatPane(){ return new FormatPane(){ - protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane) { + protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane, JPanel optionPane) { typePane.setBorder(BorderFactory.createEmptyBorder()); return new Component[][]{ new Component[]{typePane,null}, From 1c96cd163aa8b06b73503d72e23dd719fc7514e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Fri, 22 May 2020 16:28:02 +0800 Subject: [PATCH 2/8] =?UTF-8?q?=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/van/chart/designer/PlotFactory.java | 2 +- .../designer/component/format/FormatPaneWithNormalType.java | 2 +- .../chart/designer/component/format/FormatPaneWithOutFont.java | 2 +- .../fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java index e92afa38f..5b5547d06 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java @@ -339,7 +339,7 @@ public class PlotFactory { public static FormatPane createAutoFormatPane() { FormatPane formatPane = new FormatPane() { - protected Component[][] getComponent(JPanel fontPane, JPanel centerPane, JPanel typePane, JPanel optionPane) { + protected Component[][] getComponent(JPanel fontPane, JPanel centerPane, JPanel typePane) { typePane.setBorder(BorderFactory.createEmptyBorder()); return new Component[][]{ new Component[]{typePane, null}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithNormalType.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithNormalType.java index 959194ad1..728bc1b1c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithNormalType.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithNormalType.java @@ -23,7 +23,7 @@ public class FormatPaneWithNormalType extends FormatPaneWithOutFont { setForDataSheet(); } - protected Component[][] getComponent(JPanel fontPane, JPanel centerPane, JPanel typePane, JPanel optionPane) { + protected Component[][] getComponent(JPanel fontPane, JPanel centerPane, JPanel typePane) { return new Component[][]{ new Component[]{null, centerPane}, }; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithOutFont.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithOutFont.java index f225156d8..7275ad074 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithOutFont.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/format/FormatPaneWithOutFont.java @@ -28,7 +28,7 @@ public class FormatPaneWithOutFont extends FormatPane { return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); } - protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane, JPanel optionPane) { + protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane) { typePane.setBorder(BorderFactory.createEmptyBorder()); return new Component[][]{ new Component[]{null, null}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java index 1858f0a40..064a7156b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/VanChartBaseAxisPane.java @@ -445,7 +445,7 @@ public class VanChartBaseAxisPane extends FurtherBasicBeanPane { protected FormatPane createFormatPane(){ return new FormatPane(){ - protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane, JPanel optionPane) { + protected Component[][] getComponent (JPanel fontPane, JPanel centerPane, JPanel typePane) { typePane.setBorder(BorderFactory.createEmptyBorder()); return new Component[][]{ new Component[]{typePane,null}, From 18483728b00d75721a91fa7630791405b611daf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Fri, 22 May 2020 17:24:06 +0800 Subject: [PATCH 3/8] =?UTF-8?q?=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/fr/van/chart/designer/PlotFactory.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java index 5b5547d06..d3e1adbb9 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/PlotFactory.java @@ -63,12 +63,12 @@ import javax.swing.BorderFactory; import javax.swing.JLabel; import javax.swing.JList; import javax.swing.JPanel; +import java.awt.Component; import java.lang.reflect.Constructor; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; -import java.awt.Component; /** * Created by Mitisky on 16/3/1. From e6df73ae3026db6235fb5d588cd9e6eb527d7cda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Tue, 2 Jun 2020 18:33:53 +0800 Subject: [PATCH 4/8] =?UTF-8?q?CHART-13666=20=E5=9B=BE=E8=A1=A8=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E8=87=AA=E5=8A=A8=E5=8C=B9=E9=85=8D=E8=AE=BE=E8=AE=A1?= =?UTF-8?q?=E5=99=A8=E9=9D=A2=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/icombocheckbox/UICheckListPopup.java | 13 +- .../gui/icombocheckbox/UIComboCheckBox.java | 8 +- .../fr/design/module/DesignModuleFactory.java | 28 +- .../fr/design/images/m_insert/auto_chart.png | Bin 0 -> 135 bytes .../fr/design/ChartTypeInterfaceManager.java | 17 +- .../com/fr/design/chart/AutoChartDialog.java | 69 ++ .../com/fr/design/chart/AutoChartIcon.java | 108 +++ .../fr/design/chart/AutoChartTypePane.java | 230 +++++++ .../design/chart/ChartDesignerActivator.java | 1 + .../java/com/fr/design/chart/ChartDialog.java | 102 +-- .../fr/design/chart/gui/ChartComponent.java | 3 + .../mainframe/chart/gui/ChartTypePane.java | 47 +- .../design/images/form/toolbar/auto_chart.png | Bin 0 -> 179 bytes .../designer/creator/XAutoChartCreator.java | 113 ++++ .../design/designer/creator/XChartEditor.java | 625 +++++++++--------- .../designer/creator/XCreatorUtils.java | 2 + .../insert/cell/AutoChartCellAction.java | 57 ++ .../insert/flot/AutoChartFloatAction.java | 53 ++ .../actions/insert/flot/ChartFloatAction.java | 11 +- .../cell/editor/AutoChartCellEditor.java | 24 + .../cell/editor/AutoChartFloatEditor.java | 18 + .../design/cell/editor/ChartCellEditor.java | 18 +- .../design/cell/editor/ChartFloatEditor.java | 16 +- .../fr/design/mainframe/ElementCasePane.java | 10 +- .../fr/start/module/DesignerActivator.java | 49 +- 25 files changed, 1209 insertions(+), 413 deletions(-) create mode 100644 designer-base/src/main/resources/com/fr/design/images/m_insert/auto_chart.png create mode 100644 designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java create mode 100644 designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java create mode 100644 designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java create mode 100644 designer-chart/src/main/resources/com/fr/design/images/form/toolbar/auto_chart.png create mode 100644 designer-form/src/main/java/com/fr/design/designer/creator/XAutoChartCreator.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/actions/insert/flot/AutoChartFloatAction.java create mode 100644 designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartCellEditor.java create mode 100644 designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartFloatEditor.java diff --git a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java index b0b57f29c..cfc4dbfb0 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java +++ b/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 listeners = new ArrayList(); @@ -68,6 +68,11 @@ public class UICheckListPopup extends UIPopupMenu { addCheckboxValues(values); } + public void refreshCheckboxValues(Object[] value){ + this.values = value; + addCheckboxValues(values); + } + public void addCheckboxValues(Object[] value) { checkboxPane.removeAll(); checkBoxList.clear(); diff --git a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java index 0652f9cf8..b88c157a8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java +++ b/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,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam */ public void refreshCombo(Object[] value) { this.values = value; - this.popup.addCheckboxValues(value); + this.popup.refreshCheckboxValues(value); } /** diff --git a/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java b/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java index 9669b7cf9..fbf269477 100644 --- a/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java +++ b/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 chartEditorClass; private Class chartComponentClass; private Class chartDialogClass; + private Class autoChartDialogClass; private Class 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 p) { instance.chartPropertyPaneClass = p; } @@ -205,6 +209,26 @@ public class DesignModuleFactory { return null; } + /** + * kunsnat: 初始化图表向导对话框, 调用静态方法showWindow, 参数window. + * + * @return 返回调出的图表自动推荐ChartDialog + */ + public static MiddleChartDialog getAutoChartDialog(Window window) { + try { + Constructor 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: 获取图表属性界面 * diff --git a/designer-base/src/main/resources/com/fr/design/images/m_insert/auto_chart.png b/designer-base/src/main/resources/com/fr/design/images/m_insert/auto_chart.png new file mode 100644 index 0000000000000000000000000000000000000000..c6de0fe5e05a697ee5ae011930c47bd18ea5ecfc GIT binary patch literal 135 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|96eneLo5W7 z6BY;3W8U9kpP49tfO gIGB?zbNiJt7+UZsWXSz~4>XLy)78&qol`;+0E~brMF0Q* literal 0 HcmV?d00001 diff --git a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java index 4eb725834..e37409075 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -12,8 +12,10 @@ import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.chart.fun.ChartTypeUIProvider; import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.condition.ConditionAttributesPane; +import com.fr.design.gui.core.CustomWidgetOption; import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.frpane.AttributeChangeListener; +import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.ChartsConfigPane; @@ -41,6 +43,7 @@ import com.fr.design.type.ui.RangeChartTypeUI; import com.fr.design.type.ui.StockChartTypeUI; import com.fr.design.type.ui.XYScatterChartTypeUI; import com.fr.extended.chart.AbstractChart; +import com.fr.form.ui.ChartAutoEditor; import com.fr.form.ui.ChartEditor; import com.fr.general.GeneralContext; import com.fr.general.IOUtils; @@ -162,8 +165,13 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr public static WidgetOption[] initWidgetOption() { String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs(); - ChartWidgetOption[] child = new ChartWidgetOption[chartIDs.length]; - int index = 0; + List child = new ArrayList<>(); + if (ChartTypeManager.AUTO_CHART) { + //TODO @Bjorn 视觉样式优化icon + child.add(new CustomWidgetOption(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type"), + IOUtils.readIcon("com/fr/design/images/form/toolbar/auto_chart.png"), ChartAutoEditor.class)); + } + for (String chartID : chartIDs) { ChartProvider[] rowChart = ChartTypeManager.getInstance().getCharts(chartID); if (ArrayUtils.isEmpty(rowChart) && !ChartTypeManager.innerChart(chartID)) { @@ -172,11 +180,10 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr String name = ChartTypeInterfaceManager.getInstance().getName(chartID); String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(chartID); Icon icon = IOUtils.readIcon(iconPath); - child[index] = new ChartWidgetOption(name, icon, ChartEditor.class, chartID); - index++; + child.add(new ChartWidgetOption(name, icon, ChartEditor.class, chartID)); } - return child; + return child.toArray(new WidgetOption[child.size()]); } private static void readVanChart() { diff --git a/designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java b/designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java new file mode 100644 index 000000000..4c5225a5a --- /dev/null +++ b/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 void addOkAction() { + ok.addActionListener(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); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java b/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java new file mode 100644 index 000000000..426dab040 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java @@ -0,0 +1,108 @@ +package com.fr.design.chart; + +import com.fr.base.ScreenResolution; +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.HistoryTemplateListPane; +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 = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); + if (resolution == 0) { + resolution = ScreenResolution.getScreenResolution(); + } + + 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; + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java new file mode 100644 index 000000000..8100e2ad5 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java @@ -0,0 +1,230 @@ +package com.fr.design.chart; + +import com.fr.base.chart.BaseChartCollection; +import com.fr.base.chart.BaseChartGetter; +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 com.fr.plugin.chart.area.VanChartAreaPlot; +import com.fr.plugin.chart.column.VanChartColumnPlot; +import com.fr.plugin.chart.line.VanChartLinePlot; +import com.fr.plugin.chart.vanchart.VanChart; + +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 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(); + + //TODO 使用以下模拟数据,计算规则待补充 + BaseChartCollection chartCollection = BaseChartGetter.createChartCollection(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID); + VanChart selectedChart = ((ChartCollection) chartCollection).getSelectedChart(VanChart.class); + selectedChart.getTitle().setTextObject("自动图表标题"); + + BaseChartCollection chartCollection1 = BaseChartGetter.createChartCollection(VanChartLinePlot.VAN_CHART_LINE_PLOT); + VanChart selectedChart1 = ((ChartCollection) chartCollection1).getSelectedChart(VanChart.class); + selectedChart1.getTitle().setTextObject("自动图表标题"); + + BaseChartCollection chartCollection2 = BaseChartGetter.createChartCollection(VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID); + VanChart selectedChart2 = ((ChartCollection) chartCollection2).getSelectedChart(VanChart.class); + selectedChart2.getTitle().setTextObject("自动图表标题"); + + AutoChartIcon autoChartIcon = new AutoChartIcon((ChartCollection) chartCollection); + autoChartIcon.registerCallBackEvent(this); + AutoChartIcon autoChartIcon1 = new AutoChartIcon((ChartCollection) chartCollection1); + autoChartIcon1.registerCallBackEvent(this); + AutoChartIcon autoChartIcon2 = new AutoChartIcon((ChartCollection) chartCollection2); + autoChartIcon2.registerCallBackEvent(this); + + chartResultModel.addElement(autoChartIcon); + chartResultModel.addElement(autoChartIcon1); + chartResultModel.addElement(autoChartIcon2); + chartViewList.setSelectedIndex(0); + } + + @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 map = new HashMap(); + for (String dataField : dataFields) { + map.put(dataField, true); + } + dataFieldBox.setSelectedValues(map); + } + + @Override + public void callback() { + this.repaint(); + } +} diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java b/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java index 65d6abd64..098b965d0 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartDesignerActivator.java +++ b/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); diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java b/designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java index 623271873..bd6a2cf7e 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java +++ b/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,15 +19,17 @@ import java.awt.event.ActionListener; /** * 封装一层 图表新建的对话框, 配合属性表确定: 先单独只要一种图表类型的对话框. + * * @author kunsnat E-mail:kunsnat@gmail.com * @version 创建时间:2013-1-7 下午07:29:15 */ public class ChartDialog extends MiddleChartDialog { - - private BaseChartCollection cc; - - private UIButton ok; - private UIButton cancel; + + private BaseChartCollection cc; + + protected UIButton ok; + protected UIButton cancel; + private ChartTypePane chartTypePane; public ChartDialog(Frame owner) { super(owner); @@ -37,57 +40,62 @@ public class ChartDialog extends MiddleChartDialog { super(owner); initComponent(); } - - private void initComponent() { - final String 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")); + private void initComponent() { + this.setModal(true); + this.setLayout(new BorderLayout()); + 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); - - 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(); - } - }); - - cancel.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - doCancel(); - } - }); - - GUICoreUtils.setWindowCenter(getOwner(), this); + this.setBasicDialogSize(BasicDialog.DEFAULT); + 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")); + + addOkAction(); + 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 void addOkAction() { + final String createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); + ok.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + chartTypePane.update((ChartCollection) cc, createTime); + doOK(); + } + }); } /** * 不处理 */ - public void checkValid() throws Exception { - - } - - /** - * 更新新建的图表 ChartCollection - */ + public void checkValid() throws Exception { + + } + + /** + * 更新新建的图表 ChartCollection + */ public void populate(BaseChartCollection cc) { if (cc == null) { return; diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java index aa7f9107b..85b13aef7 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java +++ b/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; diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java index 6c7edc2d2..6719401bb 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartTypePane.java +++ b/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,11 +47,12 @@ public class ChartTypePane extends AbstractChartAttrPane{ private ChartTypeButtonPane buttonPane; private ChartEditPane editPane; private ChartCollection editingCollection; + private UIButton autoButton; @Override protected JPanel createContentPane() { JPanel content = new JPanel(new BorderLayout()); - + buttonPane = new ChartTypeButtonPane(this); content.add(buttonPane, BorderLayout.NORTH); @@ -76,9 +85,14 @@ public class ChartTypePane extends AbstractChartAttrPane{ } }; content.add(scrollPane, BorderLayout.CENTER); - + 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 { private Map>> allChartTypePane; diff --git a/designer-chart/src/main/resources/com/fr/design/images/form/toolbar/auto_chart.png b/designer-chart/src/main/resources/com/fr/design/images/form/toolbar/auto_chart.png new file mode 100644 index 0000000000000000000000000000000000000000..e07ad0583983e651035913baa10b34351d528b3b GIT binary patch literal 179 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP*AeO zHKHUqKdq!Zu_%?nF(p4KRlzeiF+DXXH8G{K@MNkDP?3YDi(^Q|t)xHy|JyU0eRw@V zwTor;-9opVS2H9uSeWw}xK~Pvq}% - private DesignerEditor designerEditor; - // private DesignerEditor designerEditor; - //marro:无奈的属性,暂时想不出好办法 - private boolean isRefreshing = false; - - private boolean isEditing = false; - - private boolean isHovering = false; - private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30); - private static final Color INNER_BORDER_COLOR = new Color(65, 155, 249); - - public XChartEditor(BaseChartEditor editor) { - this(editor, new Dimension(250, 150)); - } - - public XChartEditor(BaseChartEditor editor, Dimension size) { - super((Widget)editor, size); - } - - @Override - public String getIconPath() { - return super.getIconPath(); - } - - - @Override - protected String getIconName() { - return "Chart.png"; - } - - /** - * 返回组件默认名 - * @return 组件类名(小写) - */ - public String createDefaultName() { - return "chart"; - } - - /** - * 是否支持设置标题 - * @return 是返回true - */ - public boolean hasTitleStyle() { - return true; - } - - @Override - public void stopEditing() { - isEditing = false; - } - - /** - * 得到属性名 - * @return 属性名 - * @throws java.beans.IntrospectionException - */ - public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { - return new CRPropertyDescriptor[] { - new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Toolkit.i18nText("Fine-Design_Form_Form_Widget_Name")), - new CRPropertyDescriptor("visible", this.data.getClass()).setI18NName( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Visible")).setPropertyChangeListener(new PropertyChangeAdapter() { - - @Override - public void propertyChange() { - makeVisible(toData().isVisible());} - }), - new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( - WLayoutBorderStyleEditor.class).setI18NName( - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") - .setPropertyChangeListener(new PropertyChangeAdapter() { - - @Override - public void propertyChange() { - initStyle(); - } - }), - }; - } - - /** - * 该组件是否可以拖入参数面板 - * @return 是则返回true - */ - public boolean canEnterIntoParaPane(){ - return false; - } - - - /** - * 编辑状态的时候需要重新绘制下边框 - * - */ - @Override - public void paintBorder(Graphics g, Rectangle bounds){ - if(isEditing){ - g.setColor(OUTER_BORDER_COLOR); - GraphHelper.draw(g, new Rectangle(bounds.x - BORDER_WIDTH, bounds.y - BORDER_WIDTH, bounds.width + BORDER_WIDTH + 1, bounds.height + BORDER_WIDTH + 1), Constants.LINE_LARGE); - }else if(!isHovering){ - super.paintBorder(g, bounds); - } - } - - - /** - * 返回设计器的Editor - */ - public DesignerEditor getDesignerEditor() { - return designerEditor; - } - - @Override - protected void initXCreatorProperties() { - super.initXCreatorProperties(); - initBorderStyle(); - BaseChartCollection collection = ((BaseChartEditor) data).getChartCollection(); - isRefreshing = true; - ((MiddleChartComponent) designerEditor.getEditorTarget()).populate(collection); - isRefreshing = false; - } - - /** - * 点击选中的时候, 刷新界面 - * 右键 reset之后, 触发事件 populate此方法 - * - * @param jform 表单 - * @param formDesigner 表单设计器 - * @return 控件. - */ - public JComponent createToolPane(final BaseJForm jform, final FormDesigner formDesigner) { - MiddleChartComponent middleChartComponent = getDesignerEditorTarget(); - if (null != middleChartComponent) { - middleChartComponent.addStopEditingListener(new PropertyChangeAdapter() { - public void propertyChange() { - JComponent pane = jform.getEditingPane(); - if (pane instanceof BaseChartPropertyPane) { - ((BaseChartPropertyPane) pane).setSupportCellData(true); - MiddleChartComponent middleChartComponent = getDesignerEditorTarget(); - if (null != middleChartComponent) { - ((BaseChartPropertyPane) pane).populateChartPropertyPane(middleChartComponent.update(), formDesigner); - } - } - } - }); - } - if (isEditing){ - final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartPropertyPane(); - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - if (getDesignerEditor().getEditorTarget() != null) { - propertyPane.setSupportCellData(true); - MiddleChartComponent middleChartComponent = getDesignerEditorTarget(); - if (null != middleChartComponent) { - propertyPane.populateChartPropertyPane(middleChartComponent.update(), formDesigner); - } - } - } - }); - return (JComponent)propertyPane; - } - else{ - return (JComponent)DesignModuleFactory.getWidgetPropertyPane(formDesigner); - } - } - - private MiddleChartComponent getDesignerEditorTarget() { - MiddleChartComponent bcc = null; - if (getDesignerEditor().getEditorTarget() instanceof MiddleChartComponent) { - bcc = (MiddleChartComponent) getDesignerEditor().getEditorTarget(); - } - return bcc; - } - - /** - * 渲染Painter - */ - public void paint(Graphics g) { - designerEditor.paintEditor(g, this.getSize()); - super.paint(g); - if(isEditing){ - g.setColor(INNER_BORDER_COLOR); - GraphHelper.draw(g, new Rectangle(0, 0, getWidth(), getHeight()), Constants.LINE_MEDIUM); - } - } - - /** - * 初始化Editor大小. - * - * @return 返回大小. - */ - public Dimension initEditorSize() { - return BORDER_PREFERRED_SIZE; - } - - /** - * 响应点击事件 - * - * @param editingMouseListener 鼠标点击,位置处理器 - * @param e 鼠标点击事件 - */ - public void respondClick(EditingMouseListener editingMouseListener,MouseEvent e){ - FormDesigner designer = editingMouseListener.getDesigner(); - SelectionModel selectionModel = editingMouseListener.getSelectionModel(); - isEditing = e.getButton() == MouseEvent.BUTTON1 && - (e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR); - displayCoverPane(!isEditing); - selectionModel.selectACreatorAtMouseEvent(e); - - if (editingMouseListener.stopEditing()) { - if (this != (XCreator)designer.getRootComponent()) { - ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); - editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter); - } - } - HelpDialogManager.getInstance().setPane(coverPanel); - if (this.isHelpBtnOnFocus()) { - coverPanel.setMsgDisplay(e); - } - } - - @Override - protected JComponent initEditor() { - if (designerEditor == null) { - final MiddleChartComponent chartComponent = DesignModuleFactory.getChartComponent(((BaseChartEditor) data).getChartCollection()); - if (chartComponent != null) { - JComponent jChart = chartComponent; - jChart.setBorder(BorderFactory.createLineBorder(Color.lightGray)); - designerEditor = new DesignerEditor(jChart); - chartComponent.addStopEditingListener(designerEditor); - designerEditor.addPropertyChangeListener(new PropertyChangeAdapter() { - public void propertyChange() { - if (!isRefreshing) { - ((BaseChartEditor) data).resetChangeChartCollection(chartComponent.update()); - } - } - }); - } - } - - if (editor == null) { - setBorder(DEFALUTBORDER); - editor = new JPanel(); - editor.setBackground(null); - editor.setLayout(null); - editor.setOpaque(false); - - coverPanel = new CoverReportPane(); - coverPanel.setPreferredSize(this.getPreferredSize()); - coverPanel.setBounds(this.getBounds()); - - editor.add(coverPanel); - coverPanel.setVisible(false); - } - return editor; - } - - /** - * 是否展现覆盖的pane - * @param display 是否 - */ - public void displayCoverPane(boolean display){ - isHovering = display; - coverPanel.setVisible(display); - coverPanel.setPreferredSize(editor.getPreferredSize()); - coverPanel.setBounds(editor.getBounds()); - editor.repaint(); - } - - public JComponent getCoverPane(){ - return coverPanel; - } - - /** - * 是否支持设置可用 - * return boolean - */ - public boolean supportSetEnable(){ - return false; - } - - /** - * data属性改变触发其他操作 - * - */ - public void firePropertyChange(){ - initStyle(); - } - - @Override - public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { - return new WidgetPropertyUIProvider[]{ new ChartEditorPropertyUI(this)}; - } - - /** - * 是否支持共享-现只支持报表块、图表、tab块、绝对布局 - * @return - */ - public boolean isSupportShared() { - return true; - } - - @Override - public boolean supportMobileStyle() { - return false; - } + private static final long serialVersionUID = -7009439442104836657L; + private static final int BORDER_WIDTH = 2; + //具体来说是DesignerEditor + private DesignerEditor designerEditor; + // private DesignerEditor designerEditor; + //marro:无奈的属性,暂时想不出好办法 + private boolean isRefreshing = false; + + protected boolean isEditing = false; + + private boolean isHovering = false; + private static final Color OUTER_BORDER_COLOR = new Color(65, 155, 249, 30); + private static final Color INNER_BORDER_COLOR = new Color(65, 155, 249); + + public XChartEditor(BaseChartEditor editor) { + this(editor, new Dimension(250, 150)); + } + + public XChartEditor(BaseChartEditor editor, Dimension size) { + super((Widget) editor, size); + } + + @Override + public String getIconPath() { + return super.getIconPath(); + } + + + @Override + protected String getIconName() { + return "Chart.png"; + } + + /** + * 返回组件默认名 + * + * @return 组件类名(小写) + */ + public String createDefaultName() { + return "chart"; + } + + /** + * 是否支持设置标题 + * + * @return 是返回true + */ + public boolean hasTitleStyle() { + return true; + } + + @Override + public void stopEditing() { + isEditing = false; + } + + + /** + * 得到属性名 + * + * @return 属性名 + * @throws java.beans.IntrospectionException + */ + public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { + return new CRPropertyDescriptor[]{ + new CRPropertyDescriptor("widgetName", this.data.getClass()).setI18NName(Toolkit.i18nText("Fine-Design_Form_Form_Widget_Name")), + new CRPropertyDescriptor("visible", this.data.getClass()).setI18NName( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Visible")).setPropertyChangeListener(new PropertyChangeAdapter() { + + @Override + public void propertyChange() { + makeVisible(toData().isVisible()); + } + }), + new CRPropertyDescriptor("borderStyle", this.data.getClass()).setEditorClass( + WLayoutBorderStyleEditor.class).setI18NName( + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Style")).putKeyValue(XCreatorConstants.PROPERTY_CATEGORY, "Fine-Design_Basic_Advanced") + .setPropertyChangeListener(new PropertyChangeAdapter() { + + @Override + public void propertyChange() { + initStyle(); + } + }), + }; + } + + /** + * 该组件是否可以拖入参数面板 + * + * @return 是则返回true + */ + public boolean canEnterIntoParaPane() { + return false; + } + + + /** + * 编辑状态的时候需要重新绘制下边框 + */ + @Override + public void paintBorder(Graphics g, Rectangle bounds) { + if (isEditing) { + g.setColor(OUTER_BORDER_COLOR); + GraphHelper.draw(g, new Rectangle(bounds.x - BORDER_WIDTH, bounds.y - BORDER_WIDTH, bounds.width + BORDER_WIDTH + 1, bounds.height + BORDER_WIDTH + 1), Constants.LINE_LARGE); + } else if (!isHovering) { + super.paintBorder(g, bounds); + } + } + + + /** + * 返回设计器的Editor + */ + public DesignerEditor getDesignerEditor() { + return designerEditor; + } + + @Override + protected void initXCreatorProperties() { + super.initXCreatorProperties(); + initBorderStyle(); + BaseChartCollection collection = ((BaseChartEditor) data).getChartCollection(); + isRefreshing = true; + ((MiddleChartComponent) designerEditor.getEditorTarget()).populate(collection); + isRefreshing = false; + } + + /** + * 点击选中的时候, 刷新界面 + * 右键 reset之后, 触发事件 populate此方法 + * + * @param jform 表单 + * @param formDesigner 表单设计器 + * @return 控件. + */ + public JComponent createToolPane(final BaseJForm jform, final FormDesigner formDesigner) { + MiddleChartComponent middleChartComponent = getDesignerEditorTarget(); + if (null != middleChartComponent) { + middleChartComponent.addStopEditingListener(new PropertyChangeAdapter() { + public void propertyChange() { + JComponent pane = jform.getEditingPane(); + if (pane instanceof BaseChartPropertyPane) { + ((BaseChartPropertyPane) pane).setSupportCellData(true); + MiddleChartComponent middleChartComponent = getDesignerEditorTarget(); + if (null != middleChartComponent) { + ((BaseChartPropertyPane) pane).populateChartPropertyPane(middleChartComponent.update(), formDesigner); + } + } + } + }); + } + if (isEditing) { + final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartPropertyPane(); + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + if (getDesignerEditor().getEditorTarget() != null) { + propertyPane.setSupportCellData(true); + MiddleChartComponent middleChartComponent = getDesignerEditorTarget(); + if (null != middleChartComponent) { + propertyPane.populateChartPropertyPane(middleChartComponent.update(), formDesigner); + } + } + } + }); + return (JComponent) propertyPane; + } else { + return (JComponent) DesignModuleFactory.getWidgetPropertyPane(formDesigner); + } + } + + private MiddleChartComponent getDesignerEditorTarget() { + MiddleChartComponent bcc = null; + if (getDesignerEditor().getEditorTarget() instanceof MiddleChartComponent) { + bcc = (MiddleChartComponent) getDesignerEditor().getEditorTarget(); + } + return bcc; + } + + /** + * 渲染Painter + */ + public void paint(Graphics g) { + designerEditor.paintEditor(g, this.getSize()); + super.paint(g); + if (isEditing) { + g.setColor(INNER_BORDER_COLOR); + GraphHelper.draw(g, new Rectangle(0, 0, getWidth(), getHeight()), Constants.LINE_MEDIUM); + } + } + + /** + * 初始化Editor大小. + * + * @return 返回大小. + */ + public Dimension initEditorSize() { + return BORDER_PREFERRED_SIZE; + } + + /** + * 响应点击事件 + * + * @param editingMouseListener 鼠标点击,位置处理器 + * @param e 鼠标点击事件 + */ + public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) { + FormDesigner designer = editingMouseListener.getDesigner(); + SelectionModel selectionModel = editingMouseListener.getSelectionModel(); + isEditing = e.getButton() == MouseEvent.BUTTON1 && + (e.getClickCount() == 2 || designer.getCursor().getType() == Cursor.HAND_CURSOR); + displayCoverPane(!isEditing); + selectionModel.selectACreatorAtMouseEvent(e); + + if (editingMouseListener.stopEditing()) { + if (this != (XCreator) designer.getRootComponent()) { + ComponentAdapter adapter = AdapterBus.getComponentAdapter(designer, this); + editingMouseListener.startEditing(this, isEditing ? adapter.getDesignerEditor() : null, adapter); + } + } + HelpDialogManager.getInstance().setPane(coverPanel); + if (this.isHelpBtnOnFocus()) { + coverPanel.setMsgDisplay(e); + } + } + + @Override + protected JComponent initEditor() { + if (designerEditor == null) { + final MiddleChartComponent chartComponent = DesignModuleFactory.getChartComponent(((BaseChartEditor) data).getChartCollection()); + if (chartComponent != null) { + JComponent jChart = chartComponent; + jChart.setBorder(BorderFactory.createLineBorder(Color.lightGray)); + designerEditor = new DesignerEditor(jChart); + chartComponent.addStopEditingListener(designerEditor); + designerEditor.addPropertyChangeListener(new PropertyChangeAdapter() { + public void propertyChange() { + if (!isRefreshing) { + ((BaseChartEditor) data).resetChangeChartCollection(chartComponent.update()); + } + } + }); + } + } + + if (editor == null) { + setBorder(DEFALUTBORDER); + editor = new JPanel(); + editor.setBackground(null); + editor.setLayout(null); + editor.setOpaque(false); + + coverPanel = new CoverReportPane(); + coverPanel.setPreferredSize(this.getPreferredSize()); + coverPanel.setBounds(this.getBounds()); + + editor.add(coverPanel); + coverPanel.setVisible(false); + } + return editor; + } + + /** + * 是否展现覆盖的pane + * + * @param display 是否 + */ + public void displayCoverPane(boolean display) { + isHovering = display; + coverPanel.setVisible(display); + coverPanel.setPreferredSize(editor.getPreferredSize()); + coverPanel.setBounds(editor.getBounds()); + editor.repaint(); + } + + public JComponent getCoverPane() { + return coverPanel; + } + + /** + * 是否支持设置可用 + * return boolean + */ + public boolean supportSetEnable() { + return false; + } + + /** + * data属性改变触发其他操作 + */ + public void firePropertyChange() { + initStyle(); + } + + @Override + public WidgetPropertyUIProvider[] getWidgetPropertyUIProviders() { + return new WidgetPropertyUIProvider[]{new ChartEditorPropertyUI(this)}; + } + + /** + * 是否支持共享-现只支持报表块、图表、tab块、绝对布局 + * + * @return + */ + public boolean isSupportShared() { + return true; + } + + @Override + public boolean supportMobileStyle() { + return false; + } } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java index d14780054..1a2df828c 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java +++ b/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); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java new file mode 100644 index 000000000..13990f7d8 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java @@ -0,0 +1,57 @@ +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.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 com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Insert_Auto_Chart"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; + + + @Override + public Class getCellValueClass() { + return AutoChartCollection.class; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/AutoChartFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/AutoChartFloatAction.java new file mode 100644 index 000000000..92e9cca3d --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/AutoChartFloatAction.java @@ -0,0 +1,53 @@ +package com.fr.design.actions.insert.flot; + +import com.fr.base.BaseUtils; +import com.fr.design.gui.chart.MiddleChartDialog; +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 com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Insert_Auto_Chart"); + } + + @Override + public KeyStroke getKeyStroke() { + return null; + } + }; + + protected MiddleChartDialog getMiddleChartDialog(Window window) { + return DesignModuleFactory.getAutoChartDialog(window); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java index 39b11d4c2..1d1e07c62 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/ChartFloatAction.java +++ b/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); + } } diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartCellEditor.java b/designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartCellEditor.java new file mode 100644 index 000000000..410248766 --- /dev/null +++ b/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 ePane) { + super(ePane); + } + + protected MiddleChartDialog getMiddleChartDialog(Window window) { + return DesignModuleFactory.getAutoChartDialog(window); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartFloatEditor.java b/designer-realize/src/main/java/com/fr/design/cell/editor/AutoChartFloatEditor.java new file mode 100644 index 000000000..19c8788d0 --- /dev/null +++ b/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); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/ChartCellEditor.java b/designer-realize/src/main/java/com/fr/design/cell/editor/ChartCellEditor.java index 2774c8392..67ccc4876 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/ChartCellEditor.java +++ b/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); + } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/cell/editor/ChartFloatEditor.java b/designer-realize/src/main/java/com/fr/design/cell/editor/ChartFloatEditor.java index 90adbb98d..5087ad4ae 100644 --- a/designer-realize/src/main/java/com/fr/design/cell/editor/ChartFloatEditor.java +++ b/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); + } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java index c9c906618..24178bcfd 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePane.java +++ b/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 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()); diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 38efb4c1f..45d31dcb1 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -7,12 +7,14 @@ import com.fr.base.passport.FinePassportListenerAdapter; import com.fr.base.passport.FinePassportManager; import com.fr.base.process.ProcessOperator; import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.charttypes.ChartTypeManager; import com.fr.config.MarketConfig; import com.fr.decision.update.backup.RecoverManager; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.NewFormAction; import com.fr.design.actions.core.ActionFactory; +import com.fr.design.actions.insert.cell.AutoChartCellAction; import com.fr.design.actions.insert.cell.BiasCellAction; import com.fr.design.actions.insert.cell.ChartCellAction; import com.fr.design.actions.insert.cell.DSColumnCellAction; @@ -21,6 +23,7 @@ import com.fr.design.actions.insert.cell.GeneralCellAction; import com.fr.design.actions.insert.cell.ImageCellAction; import com.fr.design.actions.insert.cell.RichTextCellAction; import com.fr.design.actions.insert.cell.SubReportCellAction; +import com.fr.design.actions.insert.flot.AutoChartFloatAction; import com.fr.design.actions.insert.flot.ChartFloatAction; import com.fr.design.actions.insert.flot.FormulaFloatAction; import com.fr.design.actions.insert.flot.ImageFloatAction; @@ -112,11 +115,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. @@ -222,16 +225,21 @@ public class DesignerActivator extends Activator { classes.add(provider.actionForInsertCellElement()); } - return ArrayUtils.addAll(new Class[]{ - DSColumnCellAction.class, - GeneralCellAction.class, - RichTextCellAction.class, - FormulaCellAction.class, - ChartCellAction.class, - ImageCellAction.class, - BiasCellAction.class, - SubReportCellAction.class - }, classes.toArray(new Class[classes.size()])); + List> baseClasses = new ArrayList<>(); + baseClasses.add(DSColumnCellAction.class); + baseClasses.add(GeneralCellAction.class); + baseClasses.add(RichTextCellAction.class); + baseClasses.add(FormulaCellAction.class); + baseClasses.add(ChartCellAction.class); + if(ChartTypeManager.AUTO_CHART) { + baseClasses.add(AutoChartCellAction.class); + } + baseClasses.add(ImageCellAction.class); + baseClasses.add(BiasCellAction.class); + baseClasses.add(SubReportCellAction.class); + + return ArrayUtils.addAll(baseClasses.toArray(new Class[baseClasses.size()]), + classes.toArray(new Class[classes.size()])); } private static Class[] actionsForInsertFloatElement() { @@ -240,12 +248,17 @@ public class DesignerActivator extends Activator { for (ElementUIProvider provider : providers) { classes.add(provider.actionForInsertFloatElement()); } - return ArrayUtils.addAll(new Class[]{ - TextBoxFloatAction.class, - FormulaFloatAction.class, - ChartFloatAction.class, - ImageFloatAction.class - }, classes.toArray(new Class[classes.size()])); + + List> baseClasses = new ArrayList<>(); + baseClasses.add(TextBoxFloatAction.class); + baseClasses.add(FormulaFloatAction.class); + baseClasses.add(ChartFloatAction.class); + if(ChartTypeManager.AUTO_CHART) { + baseClasses.add(AutoChartFloatAction.class); + } + baseClasses.add(ImageFloatAction.class); + return ArrayUtils.addAll(baseClasses.toArray(new Class[baseClasses.size()]), + classes.toArray(new Class[classes.size()])); } private static NameableCreator[] hyperlinkTypes() { From f52bcbdb7f019a85f0219a31c16662c936d04965 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Wed, 3 Jun 2020 09:13:48 +0800 Subject: [PATCH 5/8] CHART-13666 --- .../main/java/com/fr/design/module/DesignModuleFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java b/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java index fbf269477..5881132b3 100644 --- a/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java +++ b/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java @@ -210,9 +210,9 @@ public class DesignModuleFactory { } /** - * kunsnat: 初始化图表向导对话框, 调用静态方法showWindow, 参数window. + * 初始化图表向导对话框, 调用静态方法showWindow, 参数window. * - * @return 返回调出的图表自动推荐ChartDialog + * @return 返回调出的图表自动推荐AutoChartDialog */ public static MiddleChartDialog getAutoChartDialog(Window window) { try { From 2a078f775bea64fa1f21dcfa59d27440e0e4f32e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Wed, 3 Jun 2020 09:44:06 +0800 Subject: [PATCH 6/8] =?UTF-8?q?CHART-13666=20=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java | 1 + 1 file changed, 1 insertion(+) diff --git a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java index b88c157a8..d2479ae04 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java @@ -198,6 +198,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam */ public void refreshCombo(Object[] value) { this.values = value; + //CHART-13666 控件之前的刷新有bug,没有刷新popup中values的值,导致数组越界 this.popup.refreshCheckboxValues(value); } From 87c6994e38814ccad2e50679a306c23a60c27ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Wed, 3 Jun 2020 11:38:20 +0800 Subject: [PATCH 7/8] =?UTF-8?q?CHART-13666=20=E4=BB=A3=E7=A0=81=E8=B4=A8?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../gui/icombocheckbox/UICheckListPopup.java | 14 ++++----- .../com/fr/design/chart/AutoChartDialog.java | 6 ++-- .../com/fr/design/chart/AutoChartIcon.java | 8 ++--- .../fr/design/chart/AutoChartTypePane.java | 31 ------------------- .../java/com/fr/design/chart/ChartDialog.java | 15 ++++----- .../insert/cell/AutoChartCellAction.java | 3 +- 6 files changed, 22 insertions(+), 55 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java index cfc4dbfb0..ec5da8bca 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java +++ b/designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java @@ -53,7 +53,7 @@ public class UICheckListPopup extends UIPopupMenu { public void setMaxDisplayNumber(int maxDisplayNumber) { this.maxDisplayNumber = maxDisplayNumber; - addCheckboxValues(values); + addCheckboxValues(); } private void initComponent() { @@ -65,21 +65,21 @@ public class UICheckListPopup extends UIPopupMenu { this.setLayout(new BorderLayout()); this.add(jScrollPane, BorderLayout.CENTER); - addCheckboxValues(values); + addCheckboxValues(); } - public void refreshCheckboxValues(Object[] value){ - this.values = value; - addCheckboxValues(values); + 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(); diff --git a/designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java b/designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java index 4c5225a5a..3bd54c27c 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java +++ b/designer-chart/src/main/java/com/fr/design/chart/AutoChartDialog.java @@ -34,8 +34,8 @@ public class AutoChartDialog extends ChartDialog { return autoChartTypePane; } - protected void addOkAction() { - ok.addActionListener(new ActionListener() { + protected ActionListener getActionListener() { + return new ActionListener() { public void actionPerformed(ActionEvent e) { ChartCollection chartCollection = (ChartCollection) getChartCollection(); autoChartTypePane.update(chartCollection); @@ -45,7 +45,7 @@ public class AutoChartDialog extends ChartDialog { doCancel(); } } - }); + }; } /** diff --git a/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java b/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java index 426dab040..b85e2194c 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java +++ b/designer-chart/src/main/java/com/fr/design/chart/AutoChartIcon.java @@ -1,13 +1,12 @@ package com.fr.design.chart; -import com.fr.base.ScreenResolution; 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.HistoryTemplateListPane; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.script.Calculator; import javax.swing.Icon; @@ -69,10 +68,7 @@ public class AutoChartIcon implements Icon { BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), WebChartIDInfo.createEmptyDesignerInfo(), getIconWidth(), getIconHeight()); - int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); - if (resolution == 0) { - resolution = ScreenResolution.getScreenResolution(); - } + int resolution = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); Graphics2D g2d = (Graphics2D) g; Paint oldPaint = g2d.getPaint(); diff --git a/designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java b/designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java index 8100e2ad5..b546a330b 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/AutoChartTypePane.java @@ -1,7 +1,5 @@ package com.fr.design.chart; -import com.fr.base.chart.BaseChartCollection; -import com.fr.base.chart.BaseChartGetter; import com.fr.base.chart.chartdata.CallbackEvent; import com.fr.chart.chartattr.ChartCollection; import com.fr.chartx.attr.ChartProvider; @@ -14,10 +12,6 @@ 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 com.fr.plugin.chart.area.VanChartAreaPlot; -import com.fr.plugin.chart.column.VanChartColumnPlot; -import com.fr.plugin.chart.line.VanChartLinePlot; -import com.fr.plugin.chart.vanchart.VanChart; import javax.swing.BorderFactory; import javax.swing.DefaultListCellRenderer; @@ -168,31 +162,6 @@ public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent private void calculateAutoChart() { chartResultModel.clear(); - - //TODO 使用以下模拟数据,计算规则待补充 - BaseChartCollection chartCollection = BaseChartGetter.createChartCollection(VanChartColumnPlot.VAN_CHART_COLUMN_PLOT_ID); - VanChart selectedChart = ((ChartCollection) chartCollection).getSelectedChart(VanChart.class); - selectedChart.getTitle().setTextObject("自动图表标题"); - - BaseChartCollection chartCollection1 = BaseChartGetter.createChartCollection(VanChartLinePlot.VAN_CHART_LINE_PLOT); - VanChart selectedChart1 = ((ChartCollection) chartCollection1).getSelectedChart(VanChart.class); - selectedChart1.getTitle().setTextObject("自动图表标题"); - - BaseChartCollection chartCollection2 = BaseChartGetter.createChartCollection(VanChartAreaPlot.VAN_CHART_AREA_PLOT_ID); - VanChart selectedChart2 = ((ChartCollection) chartCollection2).getSelectedChart(VanChart.class); - selectedChart2.getTitle().setTextObject("自动图表标题"); - - AutoChartIcon autoChartIcon = new AutoChartIcon((ChartCollection) chartCollection); - autoChartIcon.registerCallBackEvent(this); - AutoChartIcon autoChartIcon1 = new AutoChartIcon((ChartCollection) chartCollection1); - autoChartIcon1.registerCallBackEvent(this); - AutoChartIcon autoChartIcon2 = new AutoChartIcon((ChartCollection) chartCollection2); - autoChartIcon2.registerCallBackEvent(this); - - chartResultModel.addElement(autoChartIcon); - chartResultModel.addElement(autoChartIcon1); - chartResultModel.addElement(autoChartIcon2); - chartViewList.setSelectedIndex(0); } @Override diff --git a/designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java b/designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java index bd6a2cf7e..9c2b730ab 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java +++ b/designer-chart/src/main/java/com/fr/design/chart/ChartDialog.java @@ -27,9 +27,10 @@ public class ChartDialog extends MiddleChartDialog { private BaseChartCollection cc; - protected UIButton ok; - protected UIButton cancel; + private UIButton ok; + private UIButton cancel; private ChartTypePane chartTypePane; + private String createTime; public ChartDialog(Frame owner) { super(owner); @@ -42,6 +43,7 @@ public class ChartDialog extends MiddleChartDialog { } private void initComponent() { + createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); this.setModal(true); this.setLayout(new BorderLayout()); setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_M_Popup_Chart_Type")); @@ -58,7 +60,7 @@ public class ChartDialog extends MiddleChartDialog { 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")); - addOkAction(); + ok.addActionListener(getActionListener()); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { doCancel(); @@ -76,14 +78,13 @@ public class ChartDialog extends MiddleChartDialog { return chartTypePane; } - protected void addOkAction() { - final String createTime = DateTime.now().toString("yyyy-MM-dd HH:mm:ss"); - ok.addActionListener(new ActionListener() { + protected ActionListener getActionListener() { + return new ActionListener() { public void actionPerformed(ActionEvent e) { chartTypePane.update((ChartCollection) cc, createTime); doOK(); } - }); + }; } /** diff --git a/designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java index 13990f7d8..6ee1a74c4 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/insert/cell/AutoChartCellAction.java @@ -3,6 +3,7 @@ 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; @@ -40,7 +41,7 @@ public class AutoChartCellAction extends AbstractCellAction implements WorkBookS @Override public String getMenuName() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Insert_Auto_Chart"); + return Toolkit.i18nText("Fine-Design_Report_M_Insert_Auto_Chart"); } @Override From 2f58e87ed88eff1cd557cdd3a3f1df3f8ff2beeb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E5=B2=B3?= <445798420@qq.com> Date: Wed, 3 Jun 2020 17:31:22 +0800 Subject: [PATCH 8/8] =?UTF-8?q?CHART-13666=20=E4=BB=A3=E7=A0=81=E8=B4=A8?= =?UTF-8?q?=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../fr/design/ChartTypeInterfaceManager.java | 16 +++---- .../insert/flot/AutoChartFloatAction.java | 3 +- .../fr/start/module/DesignerActivator.java | 44 +++++++------------ 3 files changed, 23 insertions(+), 40 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java index e37409075..014778cac 100644 --- a/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java +++ b/designer-chart/src/main/java/com/fr/design/ChartTypeInterfaceManager.java @@ -12,10 +12,8 @@ import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.chart.fun.ChartTypeUIProvider; import com.fr.design.chart.gui.ChartWidgetOption; import com.fr.design.condition.ConditionAttributesPane; -import com.fr.design.gui.core.CustomWidgetOption; import com.fr.design.gui.core.WidgetOption; import com.fr.design.gui.frpane.AttributeChangeListener; -import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.chart.AbstractChartAttrPane; import com.fr.design.mainframe.chart.ChartEditPane; import com.fr.design.mainframe.chart.ChartsConfigPane; @@ -43,7 +41,6 @@ import com.fr.design.type.ui.RangeChartTypeUI; import com.fr.design.type.ui.StockChartTypeUI; import com.fr.design.type.ui.XYScatterChartTypeUI; import com.fr.extended.chart.AbstractChart; -import com.fr.form.ui.ChartAutoEditor; import com.fr.form.ui.ChartEditor; import com.fr.general.GeneralContext; import com.fr.general.IOUtils; @@ -165,12 +162,8 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr public static WidgetOption[] initWidgetOption() { String[] chartIDs = ChartTypeManager.getInstance().getAllChartIDs(); - List child = new ArrayList<>(); - if (ChartTypeManager.AUTO_CHART) { - //TODO @Bjorn 视觉样式优化icon - child.add(new CustomWidgetOption(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type"), - IOUtils.readIcon("com/fr/design/images/form/toolbar/auto_chart.png"), ChartAutoEditor.class)); - } + ChartWidgetOption[] child = new ChartWidgetOption[chartIDs.length]; + int index = 0; for (String chartID : chartIDs) { ChartProvider[] rowChart = ChartTypeManager.getInstance().getCharts(chartID); @@ -180,10 +173,11 @@ public class ChartTypeInterfaceManager implements ExtraChartDesignClassManagerPr String name = ChartTypeInterfaceManager.getInstance().getName(chartID); String iconPath = ChartTypeInterfaceManager.getInstance().getIconPath(chartID); Icon icon = IOUtils.readIcon(iconPath); - child.add(new ChartWidgetOption(name, icon, ChartEditor.class, chartID)); + child[index] = new ChartWidgetOption(name, icon, ChartEditor.class, chartID); + index++; } - return child.toArray(new WidgetOption[child.size()]); + return child; } private static void readVanChart() { diff --git a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/AutoChartFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/AutoChartFloatAction.java index 92e9cca3d..bb0389731 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/insert/flot/AutoChartFloatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/insert/flot/AutoChartFloatAction.java @@ -2,6 +2,7 @@ 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; @@ -38,7 +39,7 @@ public class AutoChartFloatAction extends ChartFloatAction { @Override public String getMenuName() { - return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_M_Insert_Auto_Chart"); + return Toolkit.i18nText("Fine-Design_Report_M_Insert_Auto_Chart"); } @Override diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 45d31dcb1..c0a979d6e 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -7,14 +7,12 @@ import com.fr.base.passport.FinePassportListenerAdapter; import com.fr.base.passport.FinePassportManager; import com.fr.base.process.ProcessOperator; import com.fr.chart.chartattr.ChartCollection; -import com.fr.chart.charttypes.ChartTypeManager; import com.fr.config.MarketConfig; import com.fr.decision.update.backup.RecoverManager; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.actions.NewFormAction; import com.fr.design.actions.core.ActionFactory; -import com.fr.design.actions.insert.cell.AutoChartCellAction; import com.fr.design.actions.insert.cell.BiasCellAction; import com.fr.design.actions.insert.cell.ChartCellAction; import com.fr.design.actions.insert.cell.DSColumnCellAction; @@ -23,7 +21,6 @@ import com.fr.design.actions.insert.cell.GeneralCellAction; import com.fr.design.actions.insert.cell.ImageCellAction; import com.fr.design.actions.insert.cell.RichTextCellAction; import com.fr.design.actions.insert.cell.SubReportCellAction; -import com.fr.design.actions.insert.flot.AutoChartFloatAction; import com.fr.design.actions.insert.flot.ChartFloatAction; import com.fr.design.actions.insert.flot.FormulaFloatAction; import com.fr.design.actions.insert.flot.ImageFloatAction; @@ -225,21 +222,16 @@ public class DesignerActivator extends Activator { classes.add(provider.actionForInsertCellElement()); } - List> baseClasses = new ArrayList<>(); - baseClasses.add(DSColumnCellAction.class); - baseClasses.add(GeneralCellAction.class); - baseClasses.add(RichTextCellAction.class); - baseClasses.add(FormulaCellAction.class); - baseClasses.add(ChartCellAction.class); - if(ChartTypeManager.AUTO_CHART) { - baseClasses.add(AutoChartCellAction.class); - } - baseClasses.add(ImageCellAction.class); - baseClasses.add(BiasCellAction.class); - baseClasses.add(SubReportCellAction.class); - - return ArrayUtils.addAll(baseClasses.toArray(new Class[baseClasses.size()]), - classes.toArray(new Class[classes.size()])); + return ArrayUtils.addAll(new Class[]{ + DSColumnCellAction.class, + GeneralCellAction.class, + RichTextCellAction.class, + FormulaCellAction.class, + ChartCellAction.class, + ImageCellAction.class, + BiasCellAction.class, + SubReportCellAction.class + }, classes.toArray(new Class[classes.size()])); } private static Class[] actionsForInsertFloatElement() { @@ -249,16 +241,12 @@ public class DesignerActivator extends Activator { classes.add(provider.actionForInsertFloatElement()); } - List> baseClasses = new ArrayList<>(); - baseClasses.add(TextBoxFloatAction.class); - baseClasses.add(FormulaFloatAction.class); - baseClasses.add(ChartFloatAction.class); - if(ChartTypeManager.AUTO_CHART) { - baseClasses.add(AutoChartFloatAction.class); - } - baseClasses.add(ImageFloatAction.class); - return ArrayUtils.addAll(baseClasses.toArray(new Class[baseClasses.size()]), - classes.toArray(new Class[classes.size()])); + return ArrayUtils.addAll(new Class[]{ + TextBoxFloatAction.class, + FormulaFloatAction.class, + ChartFloatAction.class, + ImageFloatAction.class + }, classes.toArray(new Class[classes.size()])); } private static NameableCreator[] hyperlinkTypes() {