From b72b41e03472780d22bd3ba9da456dcca9efc8c8 Mon Sep 17 00:00:00 2001 From: "Qinghui.Liu" Date: Thu, 24 Dec 2020 17:29:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A4=84=E7=90=86=E6=96=B0=E7=9A=84=E5=AF=8C?= =?UTF-8?q?=E6=96=87=E6=9C=AC=E7=95=8C=E9=9D=A2=E4=BA=A4=E4=BA=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/style/FormatPane.java | 6 + .../component/VanChartTooltipContentPane.java | 91 +++--- .../richText/VanChartFieldAttrPane.java | 81 +++++ ...dAddPane.java => VanChartFieldButton.java} | 29 +- .../richText/VanChartFieldGroupPane.java | 115 ------- .../richText/VanChartFieldListPane.java | 294 ++++++++++++++++++ .../richText/VanChartFieldListener.java | 6 +- .../richText/VanChartRichEditorModel.java | 64 ++++ .../richText/VanChartRichEditorPane.java | 80 +---- .../richText/VanChartRichTextPane.java | 117 +++---- .../com/fr/design/editor/script/editor.js | 1 + 11 files changed, 563 insertions(+), 321 deletions(-) create mode 100644 designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldAttrPane.java rename designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/{VanChartFieldAddPane.java => VanChartFieldButton.java} (82%) delete mode 100644 designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldGroupPane.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java create mode 100644 designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorModel.java diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java b/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java index 0b33b7adf..ba68ab36f 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java @@ -6,6 +6,7 @@ import com.fr.base.Style; import com.fr.base.TextFormat; import com.fr.data.core.FormatField; import com.fr.data.core.FormatField.FormatContents; +import com.fr.design.event.UIObserverListener; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.i18n.Toolkit; import com.fr.design.border.UIRoundedBorder; @@ -469,6 +470,11 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse globalNameListener = listener; } + public void registerChangeListener(UIObserverListener listener) { + typeComboBox.registerChangeListener(listener); + textField.registerChangeListener(listener); + } + @Override public boolean shouldResponseNameListener() { return false; 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 b6e768e34..9700e4faa 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 @@ -2,7 +2,6 @@ package com.fr.van.chart.designer.component; import com.fr.design.beans.BasicBeanPane; import com.fr.design.dialog.BasicDialog; -import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonGroup; @@ -33,11 +32,11 @@ 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; import com.fr.van.chart.designer.component.richText.VanChartRichTextPane; import com.fr.van.chart.designer.style.VanChartStylePane; -import org.nfunk.jep.function.Str; import javax.swing.JComponent; import javax.swing.JPanel; @@ -99,7 +98,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane richEditorPane = VanChartRichEditorPane.createRichEditorPane(richText); - - BasicPane panel = new VanChartRichTextPane(parent, getDefaultFieldNames(), getTableFieldNames(), richEditorPane); - BasicDialog dialog = new VanChartRichTextDialog(DesignerContext.getDesignerFrame(), panel); + AttrTooltipRichText richText = this.richTextTooltipContent.getRichTextAttr(); + ModernUIPane richEditorPane = VanChartRichEditorPane.createRichEditorPane(richText); + VanChartRichTextPane richTextPane = new VanChartRichTextPane(parent, getTableFieldNames(), richEditorPane); + BasicDialog richTextDialog = new VanChartRichTextDialog(DesignerContext.getDesignerFrame(), richTextPane); + // 更新字段格式和汇总方式 + richTextPane.populateBean(this.richTextTooltipContent); + // 更新富文本编辑器内容 richEditorPane.populate(VanChartRichEditorPane.getRichEditorModel(richText)); - dialog.addDialogActionListener(new DialogActionAdapter() { + richTextDialog.addDialogActionListener(new DialogActionAdapter() { public void doOk() { - VanChartRichEditorPane.RichEditorModel model = richEditorPane.update(); + + // 收集字段格式和汇总方式 + updateTooltipFormat(richTextTooltipContent, richTextPane.updateBean()); + VanChartRichEditorModel model = richEditorPane.update(); String content = model.getContent(); + // 收集编辑后的富文本内容 updateLocalRichText(content, model.isAuto()); SwingUtilities.getWindowAncestor(richEditorPane).setVisible(false); @@ -468,24 +467,13 @@ public class VanChartTooltipContentPane extends BasicBeanPane getDefaultFieldNames() { - List fieldNames = new ArrayList<>(); - - fieldNames.add("分类"); - fieldNames.add("系列"); - fieldNames.add("值"); - fieldNames.add("百分比"); - - return fieldNames; - } - private List getTableFieldNames() { List fieldNames = new ArrayList<>(); @@ -745,8 +733,11 @@ public class VanChartTooltipContentPane extends BasicBeanPane defaultFieldNameList; - private List tableFieldNameList; - - private List defaultFieldPaneList = new ArrayList<>(); - private List tableFieldPaneList = new ArrayList<>(); - - private VanChartFieldListener fieldListener; - - public VanChartFieldGroupPane(List defaultFieldNameList, List tableFieldNameList) { - this.defaultFieldNameList = defaultFieldNameList; - this.tableFieldNameList = tableFieldNameList; - - initFieldListener(); - - this.setLayout(new BorderLayout()); - - this.add(createDefaultFieldPane(), BorderLayout.CENTER); - this.add(createTableFieldPane(), BorderLayout.SOUTH); - } - - private JPanel createDefaultFieldPane() { - JPanel defaultField = new JPanel(); - - defaultField.setLayout(new GridLayout(0, 1, 1, 0)); - - for (String title : defaultFieldNameList) { - VanChartFieldAddPane fieldAddPane = new VanChartFieldAddPane(title, fieldListener); - - defaultField.add(fieldAddPane); - defaultFieldPaneList.add(fieldAddPane); - } - - defaultField.setPreferredSize(new Dimension(FIELD_ADD_W, defaultFieldNameList.size() * FIELD_ADD_H)); - defaultField.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); - - return defaultField; - } - - private JPanel createTableFieldPane() { - JPanel tableField = new JPanel(); - - tableField.setLayout(new GridLayout(0, 1, 1, 0)); - - for (String title : tableFieldNameList) { - VanChartFieldAddPane fieldAddPane = new VanChartFieldAddPane(title, fieldListener); - - tableField.add(fieldAddPane); - tableFieldPaneList.add(fieldAddPane); - } - - tableField.setPreferredSize(new Dimension(FIELD_ADD_W, defaultFieldNameList.size() * FIELD_ADD_H)); - - return TableLayout4VanChartHelper.createExpandablePaneWithTitleTopGap("数据集字段", tableField); - } - - private void initFieldListener() { - - fieldListener = new VanChartFieldListener() { - - private String fieldName; - - public void setGlobalName(String fieldName) { - this.fieldName = fieldName; - } - - public String getGlobalName() { - return this.fieldName; - } - - public void refreshSelectedField(String fieldName) { - if (ComparatorUtils.equals(fieldName, this.fieldName)) { - return; - } - - for (VanChartFieldAddPane fieldAddPane : defaultFieldPaneList) { - fieldAddPane.setSelectedState(ComparatorUtils.equals(fieldAddPane.getFieldName(), fieldName)); - } - - for (VanChartFieldAddPane fieldAddPane : tableFieldPaneList) { - fieldAddPane.setSelectedState(ComparatorUtils.equals(fieldAddPane.getFieldName(), fieldName)); - } - } - - public void addSelectedField(String fieldName) { - System.out.println(fieldName); - } - - public void populateFieldFormatPane() { - - } - - public void updateFieldFormatPane() { - - } - }; - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java new file mode 100644 index 000000000..aa3dbd17b --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListPane.java @@ -0,0 +1,294 @@ +package com.fr.van.chart.designer.component.richText; + +import com.fr.data.util.function.AbstractDataFunction; +import com.fr.design.event.UIObserverListener; +import com.fr.design.i18n.Toolkit; +import com.fr.design.ui.ModernUIPane; +import com.fr.general.ComparatorUtils; +import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; +import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; +import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; +import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; +import com.fr.van.chart.designer.TableLayout4VanChartHelper; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Dimension; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.text.Format; +import java.util.ArrayList; +import java.util.List; + +public class VanChartFieldListPane extends JPanel { + + private static final int FIELD_ADD_W = 400; + private static final int FIELD_ADD_H = 28; + + private VanChartFieldButton categoryNameButton; + private VanChartFieldButton seriesNameButton; + private VanChartFieldButton valueButton; + private VanChartFieldButton percentButton; + + private VanChartFieldAttrPane fieldAttrPane; + private ModernUIPane richEditorPane; + private List tableFieldNameList; + private List tableFieldButtonList = new ArrayList<>(); + + private VanChartFieldListener fieldListener; + + public VanChartFieldListPane(List tableFieldNameList, VanChartFieldAttrPane fieldAttrPane, + ModernUIPane richEditorPane) { + + this.tableFieldNameList = tableFieldNameList; + + this.fieldAttrPane = fieldAttrPane; + this.richEditorPane = richEditorPane; + + initFieldListListener(); + registerAttrListener(); + + this.setLayout(new BorderLayout()); + + this.add(createDefaultFieldPane(), BorderLayout.CENTER); + this.add(createTableFieldPane(), BorderLayout.SOUTH); + } + + private JPanel createDefaultFieldPane() { + JPanel defaultField = new JPanel(); + + defaultField.setLayout(new GridLayout(0, 1, 1, 0)); + createDefaultButtonGroup(defaultField); + + List defaultFieldButtonList = getDefaultFieldButtonList(); + + defaultField.setPreferredSize(new Dimension(FIELD_ADD_W, defaultFieldButtonList.size() * FIELD_ADD_H)); + defaultField.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); + + return defaultField; + } + + protected void createDefaultButtonGroup(JPanel field) { + categoryNameButton = createCategoryFieldButton(); + seriesNameButton = createSeriesFieldButton(); + valueButton = createValueFieldButton(); + percentButton = createPercentFieldButton(); + + field.add(categoryNameButton); + field.add(seriesNameButton); + field.add(valueButton); + field.add(percentButton); + } + + // 不同图表的name和id不一样 + protected VanChartFieldButton createCategoryFieldButton() { + String name = Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"); + String id = new AttrTooltipCategoryFormat().getFormatJSONKey(); + + return new VanChartFieldButton(name, id, false, fieldListener); + } + + protected VanChartFieldButton createSeriesFieldButton() { + String name = Toolkit.i18nText("Fine-Design_Chart_Series_Name"); + String id = new AttrTooltipSeriesFormat().getFormatJSONKey(); + + return new VanChartFieldButton(name, id, false, fieldListener); + } + + protected VanChartFieldButton createValueFieldButton() { + String name = Toolkit.i18nText("Fine-Design_Chart_Use_Value"); + String id = new AttrTooltipValueFormat().getFormatJSONKey(); + + return new VanChartFieldButton(name, id, false, fieldListener); + } + + protected VanChartFieldButton createPercentFieldButton() { + String name = Toolkit.i18nText("Fine-Design_Chart_Use_Percent"); + String id = new AttrTooltipPercentFormat().getFormatJSONKey(); + + return new VanChartFieldButton(name, id, false, fieldListener); + } + + private JPanel createTableFieldPane() { + if (tableFieldNameList == null || tableFieldNameList.isEmpty()) { + return new JPanel(); + } + + JPanel tableField = new JPanel(); + + tableField.setLayout(new GridLayout(0, 1, 1, 0)); + + for (String name : tableFieldNameList) { + VanChartFieldButton fieldButton = new VanChartFieldButton(name, name, true, fieldListener); + + tableField.add(fieldButton); + tableFieldButtonList.add(fieldButton); + } + + tableField.setPreferredSize(new Dimension(FIELD_ADD_W, tableFieldNameList.size() * FIELD_ADD_H)); + + return TableLayout4VanChartHelper.createExpandablePaneWithTitleTopGap("数据集字段", tableField); + } + + protected List getDefaultFieldButtonList() { + List defaultFieldButtonList = new ArrayList<>(); + + defaultFieldButtonList.add(categoryNameButton); + defaultFieldButtonList.add(seriesNameButton); + defaultFieldButtonList.add(valueButton); + defaultFieldButtonList.add(percentButton); + + return defaultFieldButtonList; + } + + private void initFieldListListener() { + + fieldListener = new VanChartFieldListener() { + + private String fieldName; + + public void setGlobalName(String fieldName) { + this.fieldName = fieldName; + } + + public String getGlobalName() { + return this.fieldName; + } + + public VanChartFieldButton getSelectedField() { + List defaultFieldButtonList = getDefaultFieldButtonList(); + + for (VanChartFieldButton fieldButton : defaultFieldButtonList) { + if (ComparatorUtils.equals(fieldButton.getFieldName(), this.fieldName)) { + return fieldButton; + } + } + + for (VanChartFieldButton fieldButton : tableFieldButtonList) { + if (ComparatorUtils.equals(fieldButton.getFieldName(), this.fieldName)) { + return fieldButton; + } + } + + return null; + } + + public void refreshSelectedPane(String fieldName) { + if (ComparatorUtils.equals(fieldName, this.fieldName)) { + return; + } + + List defaultFieldButtonList = getDefaultFieldButtonList(); + + for (VanChartFieldButton fieldButton : defaultFieldButtonList) { + fieldButton.setSelectedState(ComparatorUtils.equals(fieldButton.getFieldName(), fieldName)); + } + + for (VanChartFieldButton fieldButton : tableFieldButtonList) { + fieldButton.setSelectedState(ComparatorUtils.equals(fieldButton.getFieldName(), fieldName)); + } + } + + public void addSelectedField(String fieldName, String fieldId) { + VanChartRichEditorModel model = richEditorPane.update(); + String content = model.getContent() + getFieldRichText(fieldName, fieldId); + model.setContent(content); + VanChartRichEditorPane.createRichEditorPane(model); + } + + public void populateFieldFormatPane() { + VanChartFieldButton fieldButton = this.getSelectedField(); + + if (fieldButton == null) { + return; + } + + Format format = fieldButton.getFormat(); + AbstractDataFunction dataFunction = (AbstractDataFunction) fieldButton.getDataFunction(); + boolean showDataFunction = fieldButton.isShowDataFunction(); + + fieldAttrPane.populate(format, dataFunction, showDataFunction); + } + + public void updateFieldFormatPane() { + VanChartFieldButton fieldButton = this.getSelectedField(); + + if (fieldButton == null) { + return; + } + + fieldButton.setFormat(fieldAttrPane.updateFormat()); + fieldButton.setDataFunction(fieldAttrPane.updateDataFunction()); + } + }; + } + + private void registerAttrListener() { + + fieldAttrPane.registerFunctionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + fieldListener.updateFieldFormatPane(); + } + }); + + fieldAttrPane.registerChangeListener(new UIObserverListener() { + public void doChange() { + fieldListener.updateFieldFormatPane(); + } + }); + } + + private void checkFieldListSelected() { + List defaultFieldButtonList = getDefaultFieldButtonList(); + + if (defaultFieldButtonList != null && defaultFieldButtonList.size() > 0) { + String selected = defaultFieldButtonList.get(0).getFieldName(); + + fieldListener.refreshSelectedPane(selected); + fieldListener.setGlobalName(selected); + fieldListener.populateFieldFormatPane(); + } + } + + private String getFieldRichText(String fieldName, String fieldId) { + return "

" + fieldName + "

"; + } + + public void populate(AttrTooltipContent tooltipContent) { + populateDefaultField(tooltipContent); + populateTableField(tooltipContent); + + // 初次打开富文本界面选中第一个 + checkFieldListSelected(); + } + + public void populateDefaultField(AttrTooltipContent tooltipContent) { + categoryNameButton.setFormat(tooltipContent.getRichTextCategoryFormat().getFormat()); + seriesNameButton.setFormat(tooltipContent.getRichTextSeriesFormat().getFormat()); + valueButton.setFormat(tooltipContent.getRichTextValueFormat().getFormat()); + percentButton.setFormat(tooltipContent.getRichTextPercentFormat().getFormat()); + } + + public void populateTableField(AttrTooltipContent tooltipContent) { + + } + + public void update(AttrTooltipContent tooltipContent) { + updateDefaultField(tooltipContent); + updateTableField(tooltipContent); + } + + public void updateDefaultField(AttrTooltipContent tooltipContent) { + tooltipContent.getRichTextCategoryFormat().setFormat(categoryNameButton.getFormat()); + tooltipContent.getRichTextSeriesFormat().setFormat(seriesNameButton.getFormat()); + tooltipContent.getRichTextValueFormat().setFormat(valueButton.getFormat()); + tooltipContent.getRichTextPercentFormat().setFormat(percentButton.getFormat()); + } + + public void updateTableField(AttrTooltipContent tooltipContent) { + + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListener.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListener.java index 738492d67..62f096663 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListener.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListener.java @@ -4,9 +4,11 @@ import com.fr.design.event.GlobalNameListener; public interface VanChartFieldListener extends GlobalNameListener { - public void refreshSelectedField(String fieldName); + public VanChartFieldButton getSelectedField(); - public void addSelectedField(String fieldName); + public void refreshSelectedPane(String fieldName); + + public void addSelectedField(String fieldName, String fieldId); public void populateFieldFormatPane(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorModel.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorModel.java new file mode 100644 index 000000000..245eaa951 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorModel.java @@ -0,0 +1,64 @@ +package com.fr.van.chart.designer.component.richText; + +import com.fr.plugin.chart.type.TextAlign; +import com.fr.stable.StringUtils; + +public class VanChartRichEditorModel { + + private String content = StringUtils.EMPTY; + private boolean auto = true; + private String params = StringUtils.EMPTY; + private String initParams = StringUtils.EMPTY; + private String align = TextAlign.LEFT.getAlign(); + + public VanChartRichEditorModel() { + } + + public VanChartRichEditorModel(String content, boolean auto, String params, String initParams, String align) { + this.content = content; + this.auto = auto; + this.params = params; + this.initParams = initParams; + this.align = align; + } + + 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; + } + + public String getInitParams() { + return initParams; + } + + public void setInitParams(String initParams) { + this.initParams = initParams; + } + + public String getAlign() { + return align; + } + + public void setAlign(String align) { + this.align = align; + } +} 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 66453a157..99afba30e 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 @@ -25,7 +25,7 @@ public class VanChartRichEditorPane { private static final String richEditorPath = "/com/fr/design/editor/rich_editor.html"; private static final String expression = "dispatch()"; - private static ModernUIPane richEditorPane; + private static ModernUIPane richEditorPane; private static Browser browser; public static void initRichEditorPane() { @@ -36,7 +36,7 @@ public class VanChartRichEditorPane { @Override public void run() { try { - richEditorPane = initPane(new RichEditorModel()); + richEditorPane = initPane(new VanChartRichEditorModel()); } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } @@ -47,9 +47,12 @@ public class VanChartRichEditorPane { } } - public static ModernUIPane createRichEditorPane(AttrTooltipRichText richEditor) { - RichEditorModel model = getRichEditorModel(richEditor); + public static ModernUIPane createRichEditorPane(AttrTooltipRichText richEditor) { + VanChartRichEditorModel model = getRichEditorModel(richEditor); + return createRichEditorPane(model); + } + public static ModernUIPane createRichEditorPane(VanChartRichEditorModel model) { if (richEditorPane == null) { richEditorPane = initPane(model); } else if (browser != null) { @@ -59,8 +62,8 @@ public class VanChartRichEditorPane { return richEditorPane; } - public static ModernUIPane initPane(RichEditorModel model) { - return new ModernUIPane.Builder() + public static ModernUIPane initPane(VanChartRichEditorModel model) { + return new ModernUIPane.Builder() .prepare(new ScriptContextAdapter() { public void onScriptContextCreated(ScriptContextEvent event) { browser = event.getBrowser(); @@ -79,13 +82,13 @@ public class VanChartRichEditorPane { .namespace(namespace).build(); } - public static void updatePane(Browser browser, RichEditorModel model) { + public static void updatePane(Browser browser, VanChartRichEditorModel model) { JSValue ns = browser.executeJavaScriptAndReturnValue("window." + namespace); ns.asObject().setProperty(variable, model); browser.executeJavaScript("window." + namespace + "." + expression); } - public static RichEditorModel getRichEditorModel(AttrTooltipRichText richText) { + public static VanChartRichEditorModel getRichEditorModel(AttrTooltipRichText richText) { Map paramsMap = richText.getParams(); StringBuilder paramsStr = new StringBuilder(StringUtils.EMPTY); @@ -115,7 +118,7 @@ public class VanChartRichEditorPane { align = content.contains(left) ? left : center; } - return new RichEditorModel(content, richText.isAuto(), paramsStr.toString(), initParams, align); + return new VanChartRichEditorModel(content, richText.isAuto(), paramsStr.toString(), initParams, align); } public static String generateTransformI18nJS() { @@ -129,63 +132,4 @@ public class VanChartRichEditorPane { return "!(function () { window.transformI18n && window.transformI18n('" + language + "' || 'zh_CN'); }());"; } - - public static class RichEditorModel { - private String content = StringUtils.EMPTY; - private boolean auto = true; - private String params = StringUtils.EMPTY; - private String initParams = StringUtils.EMPTY; - private String align = TextAlign.LEFT.getAlign(); - - public RichEditorModel() { - } - - public RichEditorModel(String content, boolean auto, String params, String initParams, String align) { - this.content = content; - this.auto = auto; - this.params = params; - this.initParams = initParams; - this.align = align; - } - - 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; - } - - public String getInitParams() { - return initParams; - } - - public void setInitParams(String initParams) { - this.initParams = initParams; - } - - public String getAlign() { - return align; - } - - public void setAlign(String align) { - this.align = align; - } - } } 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 927fbdaae..e48050619 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 @@ -1,25 +1,16 @@ package com.fr.van.chart.designer.component.richText; import com.fr.design.beans.BasicBeanPane; -import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.ilable.UILabel; -import com.fr.design.gui.style.FormatPane; -import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.layout.TableLayout; -import com.fr.design.mainframe.chart.gui.data.CalculateComboBox; +import com.fr.design.ui.ModernUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.stable.StringUtils; -import com.fr.van.chart.designer.TableLayout4VanChartHelper; -import com.fr.van.chart.designer.component.format.FormatPaneWithOutFont; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.SwingConstants; import java.awt.BorderLayout; -import java.awt.Component; import java.awt.Dimension; import java.util.List; @@ -32,110 +23,74 @@ public class VanChartRichTextPane extends BasicBeanPane { private static final int RICH_EDITOR_W = 940; private static final int RICH_EDITOR_H = 260; - private static final double P = TableLayout.PREFERRED; - private static final double D = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; - private static final double E = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; - - private JScrollPane fieldContentPane; - private JScrollPane fieldPropsPane; - - private FormatPane fieldFormatPane; - private JPanel fieldSummaryPane; - - private UIComboBox fieldSummaryBox; + private VanChartFieldListPane fieldListPane; + private VanChartFieldAttrPane fieldAttrPane; private VanChartStylePane parent; - private List defaultFieldsFormat; private List tableFieldsFormat; - public VanChartRichTextPane(VanChartStylePane parent, List defaultFieldsFormat, List tableFieldsFormat, JPanel richEditor) { - this.parent = parent; + private ModernUIPane richEditor; - this.defaultFieldsFormat = defaultFieldsFormat; + public VanChartRichTextPane(VanChartStylePane parent, List tableFieldsFormat, ModernUIPane richEditor) { + this.parent = parent; this.tableFieldsFormat = tableFieldsFormat; + this.richEditor = richEditor; - initFieldContentPane(); - initFieldPropsPane(); + initFieldContent(); this.setLayout(new BorderLayout()); - this.add(createFieldDetailPane(), BorderLayout.CENTER); - this.add(createRichEditorPane(richEditor), BorderLayout.SOUTH); + this.add(createFieldContentPane(), BorderLayout.CENTER); + this.add(createRichEditorPane(), BorderLayout.SOUTH); } - private void initFieldContentPane() { - JPanel content = new JPanel(); - content.setLayout(new BorderLayout()); - content.add(createDefaultContentPane(), BorderLayout.NORTH); - content.add(createTableFieldsPane(), BorderLayout.CENTER); - - fieldContentPane = new JScrollPane(content); - fieldContentPane.setPreferredSize(new Dimension(FIELD_PANE_W, FIELD_PANE_H)); - fieldContentPane.setHorizontalScrollBar(null); - fieldContentPane.setBorder(BorderFactory.createTitledBorder("添加字段")); - } - - private void initFieldPropsPane() { - fieldFormatPane = new FormatPaneWithOutFont() { - protected JPanel createContentPane(Component[][] components) { - return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{P, P, P}, new double[]{D, E}); - } - }; - - fieldSummaryBox = new CalculateComboBox(); - - Component[][] components = new Component[][]{ - new Component[]{null, null}, - new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Summary_Method"), SwingConstants.LEFT), fieldSummaryBox} - }; - - fieldSummaryPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{P, P}, new double[]{D, E}); - - JPanel props = new JPanel(); - props.setLayout(new BorderLayout()); - props.add(fieldFormatPane, BorderLayout.NORTH); - props.add(fieldSummaryPane, BorderLayout.CENTER); - props.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0)); - - fieldPropsPane = new JScrollPane(props); - fieldPropsPane.setPreferredSize(new Dimension(FIELD_PANE_W, FIELD_PANE_H)); - fieldPropsPane.setBorder(BorderFactory.createTitledBorder("字段设置")); + private void initFieldContent() { + fieldAttrPane = new VanChartFieldAttrPane(); + fieldListPane = new VanChartFieldListPane(tableFieldsFormat, fieldAttrPane, richEditor); } - private JPanel createDefaultContentPane() { + private JPanel createFieldContentPane() { + JPanel fieldPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - return new VanChartFieldGroupPane(defaultFieldsFormat, tableFieldsFormat); - } + // 新增字段目录 + JPanel fieldListContent = new JPanel(); + fieldListContent.setLayout(new BorderLayout()); + fieldListContent.add(fieldListPane, BorderLayout.NORTH); - private JPanel createTableFieldsPane() { - return new JPanel(); - } + JScrollPane fieldListScrollPane = new JScrollPane(fieldListContent); + fieldListScrollPane.setPreferredSize(new Dimension(FIELD_PANE_W, FIELD_PANE_H)); + fieldListScrollPane.setHorizontalScrollBar(null); + fieldListScrollPane.setBorder(BorderFactory.createTitledBorder("添加字段")); - private JPanel createFieldDetailPane() { - JPanel fieldPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + // 字段格式和汇总 + JScrollPane fieldAttrScrollPane = new JScrollPane(fieldAttrPane); + fieldAttrScrollPane.setPreferredSize(new Dimension(FIELD_PANE_W, FIELD_PANE_H)); + fieldAttrScrollPane.setBorder(BorderFactory.createTitledBorder("字段设置")); - fieldPane.add(fieldContentPane); - fieldPane.add(fieldPropsPane); + fieldPane.add(fieldListScrollPane); + fieldPane.add(fieldAttrScrollPane); return fieldPane; } - private JPanel createRichEditorPane(JPanel richEditor) { + private JPanel createRichEditorPane() { JPanel richEditorPane = new JPanel(); richEditorPane.setLayout(new BorderLayout()); richEditorPane.setPreferredSize(new Dimension(RICH_EDITOR_W, RICH_EDITOR_H)); - richEditorPane.add(richEditor, BorderLayout.CENTER); + richEditorPane.add(this.richEditor, BorderLayout.CENTER); return richEditorPane; } - public void populateBean(AttrTooltipContent ob) { - + public void populateBean(AttrTooltipContent tooltipContent) { + fieldListPane.populate(tooltipContent); } public AttrTooltipContent updateBean() { - return null; + AttrTooltipContent content = new AttrTooltipContent(); + fieldListPane.update(content); + return content; } protected String title4PopupWindow() { diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js index f3e053679..a2b5dd6a7 100644 --- a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js @@ -50,6 +50,7 @@ }, items: [{ type: "bi.htape", + tgap: 5, items: [{ type: "bi.label", text: BI.i18nText("BI-Design_Font_Style") + ": ",