From 4854fa76501f08351135f725572e7a3798c36281 Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Thu, 31 Dec 2020 15:56:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AF=8C=E6=96=87=E6=9C=AC=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E5=99=A8=E5=A2=9E=E5=8A=A0=E5=AD=97=E6=AE=B5=E5=90=8D=E7=9A=84?= =?UTF-8?q?=E7=B1=BB=E5=B1=9E=E6=80=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mainframe/chart/gui/ChartOtherPane.java | 8 ++- .../component/VanChartTooltipContentPane.java | 44 +++----------- .../richText/VanChartFieldListPane.java | 7 ++- .../richText/VanChartRichEditorPane.java | 60 +++++++++++++++++++ .../richText/VanChartRichTextPane.java | 11 ++-- .../designer/style/VanChartStylePane.java | 55 +---------------- 6 files changed, 85 insertions(+), 100 deletions(-) diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java index 9b494a1a4..54c010119 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/ChartOtherPane.java @@ -13,6 +13,7 @@ import com.fr.design.mainframe.chart.gui.other.ChartConditionAttrPane; import com.fr.design.mainframe.chart.gui.other.ChartInteractivePane; import com.fr.design.mainframe.chart.gui.type.ChartTabPane; import com.fr.design.mainframe.chart.info.ChartInfoCollector; +import com.fr.van.chart.designer.component.richText.VanChartRichEditorPane; import javax.swing.JPanel; import java.util.ArrayList; @@ -76,11 +77,11 @@ public class ChartOtherPane extends AbstractChartAttrPane { public String title4PopupWindow() { return PaneTitleConstants.CHART_OTHER_TITLE; } - + private boolean isHaveCondition() { return hasCondition; } - + /** * 设置选中的界面id */ @@ -110,6 +111,7 @@ public class ChartOtherPane extends AbstractChartAttrPane { public void populateBean(Chart chart) { interactivePane.populateBean(chart); if (ChartOtherPane.this.isHaveCondition()) { + VanChartRichEditorPane.refreshFieldNames(chart); conditionAttrPane.populateBean(chart); } } @@ -126,7 +128,7 @@ public class ChartOtherPane extends AbstractChartAttrPane { //特效埋点 ChartInfoCollector.getInstance().updateChartConfig(chart, ConfigType.EFFECT, chart.getBuryingPointEffectConfig()); } - + /** * 注册 切换按钮的切换事件. * @param currentChartEditPane 当前编辑的图表编辑界面. diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java index 66f04a3d3..544bd3825 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java @@ -36,7 +36,6 @@ import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutChe import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; import com.fr.van.chart.designer.component.richText.VanChartRichEditorPane; import com.fr.van.chart.designer.component.richText.VanChartRichTextDialog; @@ -445,7 +444,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane richEditorPane = VanChartRichEditorPane.createRichEditorPane(richText); - VanChartRichTextPane richTextPane = this.createRichTextPane(getTableFieldNames(), richEditorPane); + VanChartRichTextPane richTextPane = this.createRichTextPane(richEditorPane); BasicDialog richTextDialog = new VanChartRichTextDialog(DesignerContext.getDesignerFrame(), richTextPane); @@ -483,19 +482,11 @@ public class VanChartTooltipContentPane extends BasicBeanPane getTableFieldNames() { - if (parent == null) { - return null; - } - - return parent.getDataModelColumnNames(); - } - - protected VanChartRichTextPane createRichTextPane(List tableFieldNames, ModernUIPane richEditorPane) { - return new VanChartRichTextPane(tableFieldNames, richEditorPane); + protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + return new VanChartRichTextPane(richEditorPane); } - protected void refreshRichTextFormat(AttrTooltipRichText richText) { + protected void refreshRichTextParams(AttrTooltipRichText richText) { String[] fieldNames = new String[]{ Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"), Toolkit.i18nText("Fine-Design_Chart_Series_Name"), @@ -516,7 +507,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane tableFieldNames = this.getTableFieldNames(); + List tableFieldNames = VanChartRichEditorPane.getFieldNames(); if (tableFieldNames != null) { for (String fieldName : tableFieldNames) { @@ -757,30 +748,13 @@ public class VanChartTooltipContentPane extends BasicBeanPane tableFieldNameList, VanChartFieldAttrPane fieldAttrPane, - ModernUIPane richEditorPane) { + public VanChartFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { - this.tableFieldNameList = tableFieldNameList == null ? new ArrayList<>() : tableFieldNameList; + List richEditorFieldNames = VanChartRichEditorPane.getFieldNames(); + + this.tableFieldNameList = richEditorFieldNames == null ? new ArrayList<>() : richEditorFieldNames; this.fieldAttrPane = fieldAttrPane; this.richEditorPane = richEditorPane; diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java index 87710da55..dcec83deb 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java @@ -1,8 +1,19 @@ package com.fr.van.chart.designer.component.richText; +import com.fr.base.TableData; +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartdata.MoreNameCDDefinition; +import com.fr.chart.chartdata.OneValueCDDefinition; +import com.fr.data.TableDataSource; +import com.fr.data.impl.EmbeddedTableData; +import com.fr.design.DesignModelAdapter; import com.fr.design.DesignerEnvManager; +import com.fr.design.data.DesignTableDataManager; import com.fr.design.ui.ModernUIPane; +import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.base.AttrTooltipRichText; import com.fr.plugin.chart.type.TextAlign; import com.fr.stable.StringUtils; @@ -11,6 +22,7 @@ import com.teamdev.jxbrowser.chromium.JSValue; import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; +import java.util.List; import java.util.Locale; import java.util.Map; @@ -26,6 +38,54 @@ public class VanChartRichEditorPane { private static ModernUIPane richEditorPane; private static Browser browser; + private static List fieldNames; + + public static List getFieldNames() { + return fieldNames; + } + + public static void refreshFieldNames(Chart chart) { + VanChartRichEditorPane.fieldNames = null; + + if (chart == null) { + return; + } + + TopDefinitionProvider definition = chart.getFilterDefinition(); + + if (definition == null) { + return; + } + + DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter(); + TableDataSource tableDataSource = adapter == null ? null : adapter.getBook(); + + TableData tableData = null; + + if (ComparatorUtils.equals(definition.getDataDefinitionType(), OneValueCDDefinition.DEFINITION_TYPE)) { + OneValueCDDefinition oneValueCDDefinition = (OneValueCDDefinition) definition; + tableData = oneValueCDDefinition.getTableData(); + } + + if (ComparatorUtils.equals(definition.getDataDefinitionType(), MoreNameCDDefinition.DEFINITION_TYPE)) { + MoreNameCDDefinition moreNameCDDefinition = (MoreNameCDDefinition) definition; + tableData = moreNameCDDefinition.getTableData(); + } + + if (tableData == null) { + return; + } + + try { + EmbeddedTableData embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataSource, + tableData, TableData.RESULT_NOT_NEED, false); + + List fieldNames = DesignTableDataManager.getColumnNamesByTableData(embeddedTableData); + VanChartRichEditorPane.fieldNames = fieldNames; + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } public static ModernUIPane createRichEditorPane(AttrTooltipRichText richEditor) { VanChartRichEditorModel model = getRichEditorModel(richEditor); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java index 83ef4853e..93fb9048a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java @@ -11,7 +11,6 @@ import javax.swing.JPanel; import javax.swing.JScrollPane; import java.awt.BorderLayout; import java.awt.Dimension; -import java.util.List; // 标签提示中的富文本面板,包含字段设置和富文本编辑器 public class VanChartRichTextPane extends BasicBeanPane { @@ -25,10 +24,9 @@ public class VanChartRichTextPane extends BasicBeanPane { private VanChartFieldListPane fieldListPane; private VanChartFieldAttrPane fieldAttrPane; - public VanChartRichTextPane(List tableFieldNames, ModernUIPane richEditor) { - + public VanChartRichTextPane(ModernUIPane richEditor) { fieldAttrPane = new VanChartFieldAttrPane(); - fieldListPane = createFieldListPane(tableFieldNames, fieldAttrPane, richEditor); + fieldListPane = createFieldListPane(fieldAttrPane, richEditor); this.setLayout(new BorderLayout()); this.add(createFieldContentPane(), BorderLayout.CENTER); @@ -59,9 +57,8 @@ public class VanChartRichTextPane extends BasicBeanPane { return fieldPane; } - protected VanChartFieldListPane createFieldListPane(List tableFieldNames, VanChartFieldAttrPane fieldAttrPane, - ModernUIPane richEditor) { - return new VanChartFieldListPane(tableFieldNames, fieldAttrPane, richEditor); + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + return new VanChartFieldListPane(fieldAttrPane, richEditor); } private JPanel createRichEditorPane(JPanel richEditor) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java index f9d0720dc..bb8df99fd 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartStylePane.java @@ -1,21 +1,11 @@ package com.fr.van.chart.designer.style; -import com.fr.base.TableData; -import com.fr.base.chart.chartdata.TopDefinitionProvider; -import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Plot; -import com.fr.chart.chartdata.MoreNameCDDefinition; -import com.fr.chart.chartdata.OneValueCDDefinition; -import com.fr.data.TableDataSource; -import com.fr.data.impl.EmbeddedTableData; -import com.fr.design.DesignModelAdapter; -import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.gui.ChartStylePane; -import com.fr.general.ComparatorUtils; -import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.attr.plot.VanChartAxisPlot; +import com.fr.van.chart.designer.component.richText.VanChartRichEditorPane; import com.fr.van.chart.designer.style.axis.VanChartAxisPane; import com.fr.van.chart.designer.style.background.VanChartAreaPane; import com.fr.van.chart.designer.style.datasheet.VanChartDataSheetPane; @@ -87,46 +77,7 @@ public class VanChartStylePane extends ChartStylePane { paneList.add(new VanChartTooltipPane(VanChartStylePane.this)); } - public List getDataModelColumnNames() { - Chart chart = getChart(); - - if (chart == null) { - return null; - } - - TopDefinitionProvider definition = chart.getFilterDefinition(); - - if (definition == null) { - return null; - } - - DesignModelAdapter adapter = DesignModelAdapter.getCurrentModelAdapter(); - TableDataSource tableDataSource = adapter == null ? null : adapter.getBook(); - - TableData tableData = null; - - if (ComparatorUtils.equals(definition.getDataDefinitionType(), OneValueCDDefinition.DEFINITION_TYPE)) { - OneValueCDDefinition oneValueCDDefinition = (OneValueCDDefinition) definition; - tableData = oneValueCDDefinition.getTableData(); - } - - if (ComparatorUtils.equals(definition.getDataDefinitionType(), MoreNameCDDefinition.DEFINITION_TYPE)) { - MoreNameCDDefinition moreNameCDDefinition = (MoreNameCDDefinition) definition; - tableData = moreNameCDDefinition.getTableData(); - } - - if (tableData == null) { - return null; - } - - try { - EmbeddedTableData embeddedTableData = DesignTableDataManager.previewTableDataNotNeedInputParameters(tableDataSource, - tableData, TableData.RESULT_NOT_NEED, false); - - return DesignTableDataManager.getColumnNamesByTableData(embeddedTableData); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - return null; - } + public void refreshTableFieldNames() { + VanChartRichEditorPane.refreshFieldNames(getChart()); } } \ No newline at end of file