From 21d0422f021e4b5e7c3bf6044ab173b22dedd00e Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Wed, 2 Sep 2020 10:15:55 +0800 Subject: [PATCH] =?UTF-8?q?CHART-15510=20=E6=A0=87=E7=AD=BE=E5=92=8C?= =?UTF-8?q?=E6=8F=90=E7=A4=BA=E4=B8=AD=E6=8F=92=E5=85=A5BI=E7=9A=84?= =?UTF-8?q?=E5=AF=8C=E6=96=87=E6=9C=AC=E7=BC=96=E8=BE=91=E5=99=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../component/VanChartRichEditorPane.java | 78 +++++++ .../component/VanChartTooltipContentPane.java | 194 ++++++++++++++++-- .../VanChartFormatPaneWithCheckBox.java | 13 +- 3 files changed, 264 insertions(+), 21 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java new file mode 100644 index 000000000..c4588ce1c --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java @@ -0,0 +1,78 @@ +package com.fr.van.chart.designer.component; + +import com.fr.design.ui.ModernUIPane; +import com.fr.plugin.chart.base.AttrTooltipRichEditor; +import com.fr.stable.StringUtils; + +import java.util.Map; + +public class VanChartRichEditorPane { + + private static ModernUIPane richEditorPane; + + public static ModernUIPane getInstance() { + if (richEditorPane == null) { + richEditorPane = new ModernUIPane.Builder() + .withEMB("/com/fr/design/editor/rich_editor.html") + .namespace("Pool").build(); + } + + return richEditorPane; + } + + public static RichEditorModel getRichEditorModel(AttrTooltipRichEditor richEditor) { + Map paramsMap = richEditor.getParams(); + StringBuilder paramsStr = new StringBuilder(StringUtils.EMPTY); + + if (paramsMap != null) { + for (Map.Entry entry : paramsMap.entrySet()) { + paramsStr.append(entry.getKey()).append(":").append(entry.getValue()); + paramsStr.append("-"); + } + } + + int len = paramsStr.length(); + + if (len > 0) { + paramsStr.deleteCharAt(len - 1); + } + + return new RichEditorModel(richEditor.getContent(), richEditor.isAuto(), paramsStr.toString()); + } + + public static class RichEditorModel { + private String content; + private boolean auto; + private String params; + + public RichEditorModel(String content, boolean auto, String params) { + this.content = content; + this.auto = auto; + this.params = params; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public boolean isAuto() { + return auto; + } + + public void setAuto(boolean auto) { + this.auto = auto; + } + + public String getParams() { + return params; + } + + public void setParams(String params) { + this.params = params; + } + } +} 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 5920dd969..b52e4fda4 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 @@ -1,12 +1,23 @@ package com.fr.van.chart.designer.component; +import com.fr.design.DesignerEnvManager; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.autocomplete.AutoCompletion; +import com.fr.design.gui.autocomplete.DefaultCompletionProvider; import com.fr.design.gui.ibutton.UIButtonGroup; +import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.syntax.ui.rtextarea.RTextArea; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; - +import com.fr.design.ui.ModernUIPane; +import com.fr.log.FineLoggerFactory; import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.AttrTooltipRichEditor; +import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; @@ -14,15 +25,23 @@ import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithChec import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; +import javax.swing.JComponent; +import javax.swing.JFrame; import javax.swing.JPanel; +import javax.swing.KeyStroke; +import javax.swing.SwingUtilities; +import javax.swing.text.Document; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; /** * 内容界面 。数据点提示 @@ -43,22 +62,29 @@ public class VanChartTooltipContentPane extends BasicBeanPane(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")}); + content = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Common"), + Toolkit.i18nText("Fine-Design_Chart_Custom") + }); initFormatPane(parent, showOnPane); @@ -80,8 +106,8 @@ public class VanChartTooltipContentPane extends BasicBeanPane pane = VanChartRichEditorPane.getInstance(); + BasicDialog dialog = pane.showWindow(new JFrame()); + + pane.populate(VanChartRichEditorPane.getRichEditorModel(richEditor)); + + dialog.addDialogActionListener(new DialogActionAdapter() { + + public void doOk() { + VanChartRichEditorPane.RichEditorModel model = pane.update(); + + String content = model.getContent(); + + populateContentTextArea(content); + + richEditor.setContent(content); + richEditor.setAuto(model.isAuto()); + + SwingUtilities.getWindowAncestor(pane).setVisible(false); + } + + public void doCancel() { + SwingUtilities.getWindowAncestor(pane).setVisible(false); + } + }); + + dialog.setVisible(true); + + if (parent != null) { + parent.attributeChanged(); + } + } + protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane){ categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane); seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); @@ -154,13 +267,17 @@ public class VanChartTooltipContentPane extends BasicBeanPane paramMap, String value) { + String key = this.getCheckBoxText(); + + if (paramMap != null && !paramMap.containsKey(key)) { + paramMap.put(key, value); + } + } }