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 0b33b7adfc..ba68ab36f5 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-base/src/main/java/com/fr/design/mainframe/JTemplate.java b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java index 2a13279203..483e74d9d7 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java @@ -47,6 +47,7 @@ import com.fr.design.menu.MenuDef; import com.fr.design.menu.NameSeparator; import com.fr.design.menu.ShortCut; import com.fr.design.preview.PagePreview; +import com.fr.design.ui.util.UIUtil; import com.fr.design.write.submit.DBManipulationInWidgetEventPane; import com.fr.design.write.submit.DBManipulationPane; import com.fr.event.EventDispatcher; @@ -79,7 +80,6 @@ import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JComponent; import javax.swing.JOptionPane; -import javax.swing.SwingWorker; import javax.swing.tree.DefaultMutableTreeNode; import javax.swing.undo.UndoManager; import java.util.ArrayList; @@ -340,30 +340,18 @@ public abstract class JTemplate> public void refreshResource(FILE file) { - - new SwingWorker() { - + setTargetByFile(file); + UIUtil.invokeLaterIfNeeded(new Runnable() { @Override - protected Void doInBackground() throws Exception { - setTargetByFile(file); - return null; - } + public void run() { + // 先移除旧的。 + removeCenterPane(); + // 加入新的 + addCenterPane(); - @Override - public void done() { - try { - get(); - // 先移除旧的。 - removeCenterPane(); - // 加入新的 - addCenterPane(); - - refreshToolArea(); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } + refreshToolArea(); } - }.execute(); + }); } diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java b/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java index 909501857a..fcdc594b5f 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorAdjustPane.java @@ -206,6 +206,10 @@ public class ColorAdjustPane extends JPanel implements UIObserver { public void setVisible(boolean b) { super.setVisible(b); } + + protected boolean selectRealTime() { + return false; + } }; colorPane.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { diff --git a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java index c82eac0c0d..68c1b2b992 100644 --- a/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java +++ b/designer-base/src/main/java/com/fr/design/style/color/ColorSelectPane.java @@ -115,12 +115,16 @@ public class ColorSelectPane extends TransparentPane implements ColorSelectable row1Pane.setPreferredSize(new Dimension(135, 24)); // 宽度为 16 * 8 + 7 // 最近使用 - UsedColorPane usedColorPane = new UsedColorPane(1, 8, 1, this, true, true); + UsedColorPane usedColorPane = new UsedColorPane(1, 8, 1, this, true, selectRealTime()); usedColorPane.getPane().setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8)); row1Pane.add(usedColorPane.getPane()); return row1Pane; } + protected boolean selectRealTime() { + return true; + } + protected Color[] getColorArray() { return ColorFactory.MenuColors; } 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 9b494a1a45..54c010119d 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/VanChartRichEditorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java deleted file mode 100644 index 6f308ad431..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java +++ /dev/null @@ -1,191 +0,0 @@ -package com.fr.van.chart.designer.component; - -import com.fr.concurrent.NamedThreadFactory; -import com.fr.design.DesignerEnvManager; -import com.fr.design.ui.ModernUIPane; -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; -import com.teamdev.jxbrowser.chromium.Browser; -import com.teamdev.jxbrowser.chromium.JSValue; -import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter; -import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent; - -import java.util.Locale; -import java.util.Map; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -public class VanChartRichEditorPane { - - private static final String namespace = "Pool"; - private static final String variable = "data"; - private static final String richEditorPath = "/com/fr/design/editor/rich_editor.html"; - private static final String expression = "dispatch()"; - - private static ModernUIPane richEditorPane; - private static Browser browser; - - public static void initRichEditorPane() { - ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor(new NamedThreadFactory("VanChartRichEditor")); - - try { - singleThreadExecutor.submit(new Runnable() { - @Override - public void run() { - try { - richEditorPane = initPane(new RichEditorModel()); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage(), e); - } - } - }); - } finally { - singleThreadExecutor.shutdown(); - } - } - - public static ModernUIPane createRichEditorPane(AttrTooltipRichText richEditor) { - RichEditorModel model = getRichEditorModel(richEditor); - - if (richEditorPane == null) { - richEditorPane = initPane(model); - } else if (browser != null) { - updatePane(browser, model); - } - - return richEditorPane; - } - - public static ModernUIPane initPane(RichEditorModel model) { - return new ModernUIPane.Builder() - .prepare(new ScriptContextAdapter() { - public void onScriptContextCreated(ScriptContextEvent event) { - browser = event.getBrowser(); - browser.getCacheStorage().clearCache(); - - browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/fineui.min.js")); - browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/design/editor/script/i18n.js")); - browser.executeJavaScript(generateTransformI18nJS()); - browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/materials.min.js")); - - JSValue ns = browser.executeJavaScriptAndReturnValue("window." + namespace); - ns.asObject().setProperty(variable, model); - } - }) - .withEMB(richEditorPath) - .namespace(namespace).build(); - } - - public static void updatePane(Browser browser, RichEditorModel model) { - JSValue ns = browser.executeJavaScriptAndReturnValue("window." + namespace); - ns.asObject().setProperty(variable, model); - browser.executeJavaScript("window." + namespace + "." + expression); - } - - public static RichEditorModel getRichEditorModel(AttrTooltipRichText richText) { - Map paramsMap = richText.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); - } - - String content = richText.getContent(); - String initParams = StringUtils.EMPTY; - String align = StringUtils.EMPTY; - - if (content.contains("data-id") && !content.contains("class")) { - initParams = richText.getInitParamsContent(); - - String left = TextAlign.LEFT.getAlign(); - String center = TextAlign.CENTER.getAlign(); - - align = content.contains(left) ? left : center; - } - - return new RichEditorModel(content, richText.isAuto(), paramsStr.toString(), initParams, align); - } - - public static String generateTransformI18nJS() { - String language = "zh_CN"; - - Locale locale = DesignerEnvManager.getEnvManager().getLanguage(); - - if (locale != null) { - language = locale.toString(); - } - - 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/VanChartTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java index b5f03a728a..f2c5662307 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 @@ -15,7 +15,12 @@ import com.fr.design.ui.ModernUIPane; import com.fr.general.ComparatorUtils; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.AttrTooltipRichText; +import com.fr.plugin.chart.base.TableFieldCollection; +import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat; +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.stable.StringUtils; import com.fr.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; @@ -31,7 +36,10 @@ 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; +import com.fr.van.chart.designer.component.richText.VanChartRichTextPane; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JComponent; @@ -45,6 +53,9 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * 数据点提示内容界面,含有通用设置、富文本编辑器、自定义JS界面 @@ -92,7 +103,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane pane = VanChartRichEditorPane.createRichEditorPane(richText); - BasicDialog dialog = new VanChartRichEditorDialog(DesignerContext.getDesignerFrame(), pane); + AttrTooltipRichText richText = this.richTextTooltipContent.getRichTextAttr(); + + ModernUIPane richEditorPane = VanChartRichEditorPane.createRichEditorPane(richText); + VanChartRichTextPane richTextPane = this.createRichTextPane(richEditorPane); - pane.populate(VanChartRichEditorPane.getRichEditorModel(richText)); + BasicDialog richTextDialog = new VanChartRichTextDialog(DesignerContext.getDesignerFrame(), richTextPane); - dialog.addDialogActionListener(new DialogActionAdapter() { + richTextPane.populateBean(this.richTextTooltipContent); + richEditorPane.populate(VanChartRichEditorPane.getRichEditorModel(richText)); + + richTextDialog.addDialogActionListener(new DialogActionAdapter() { public void doOk() { - VanChartRichEditorPane.RichEditorModel model = pane.update(); + AttrTooltipContent temporary = richTextPane.updateBean(); + VanChartRichEditorModel model = richEditorPane.update(); String content = model.getContent(); updateLocalRichText(content, model.isAuto()); - SwingUtilities.getWindowAncestor(pane).setVisible(false); + TableFieldCollection fieldCollection = temporary.getFieldCollection(); + if (fieldCollection != null) { + fieldCollection.checkFieldDefinition(content); + } + + updateTooltipFormat(richTextTooltipContent, temporary); + + SwingUtilities.getWindowAncestor(richEditorPane).setVisible(false); } public void doCancel() { - SwingUtilities.getWindowAncestor(pane).setVisible(false); + SwingUtilities.getWindowAncestor(richEditorPane).setVisible(false); } }); - dialog.setVisible(true); + richTextDialog.setVisible(true); if (parent != null) { parent.attributeChanged(); } } + protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + return new VanChartRichTextPane(richEditorPane); + } + + protected String[] getRichTextFieldNames() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"), + Toolkit.i18nText("Fine-Design_Chart_Series_Name"), + Toolkit.i18nText("Fine-Design_Chart_Use_Value"), + Toolkit.i18nText("Fine-Design_Chart_Use_Percent") + }; + } + + protected AttrTooltipFormat[] getRichTextFieldFormats() { + return new AttrTooltipFormat[]{ + new AttrTooltipCategoryFormat(), + new AttrTooltipSeriesFormat(), + new AttrTooltipValueFormat(), + new AttrTooltipPercentFormat() + }; + } + + private void refreshRichTextParams(AttrTooltipRichText richText) { + String[] fieldNames = getRichTextFieldNames(); + AttrTooltipFormat[] fieldFormats = getRichTextFieldFormats(); + + Map params = new HashMap<>(); + + for (int i = 0, len = fieldNames.length; i < len; i++) { + params.put(fieldNames[i], fieldFormats[i].getJs()); + } + + List tableFieldNames = VanChartRichEditorPane.getFieldNames(); + + if (tableFieldNames != null) { + for (String fieldName : tableFieldNames) { + params.put(fieldName, fieldName); + } + } + + richText.setParams(params); + } + private JPanel createHtmlPane() { double p = TableLayout.PREFERRED; double f = TableLayout.FILL; @@ -695,28 +759,13 @@ public class VanChartTooltipContentPane extends BasicBeanPane richEditorPane; + private List tableFieldNameList; + private List tableFieldButtonList = new ArrayList<>(); + private TableFieldCollection tableFieldCollection = new TableFieldCollection(); + + private VanChartFieldListener fieldListener; + + public VanChartFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + + List richEditorFieldNames = VanChartRichEditorPane.getFieldNames(); + + this.tableFieldNameList = richEditorFieldNames == null ? new ArrayList<>() : richEditorFieldNames; + + this.fieldAttrPane = fieldAttrPane; + this.richEditorPane = richEditorPane; + + initFieldListListener(); + initDefaultFieldButton(); + + registerAttrListener(); + + this.setLayout(new BorderLayout()); + + this.add(createDefaultFieldPane(), BorderLayout.CENTER); + this.add(createTableFieldPane(), BorderLayout.SOUTH); + } + + public VanChartFieldButton getCategoryNameButton() { + return categoryNameButton; + } + + public void setCategoryNameButton(VanChartFieldButton categoryNameButton) { + this.categoryNameButton = categoryNameButton; + } + + public VanChartFieldButton getSeriesNameButton() { + return seriesNameButton; + } + + public void setSeriesNameButton(VanChartFieldButton seriesNameButton) { + this.seriesNameButton = seriesNameButton; + } + + public VanChartFieldButton getValueButton() { + return valueButton; + } + + public void setValueButton(VanChartFieldButton valueButton) { + this.valueButton = valueButton; + } + + public VanChartFieldButton getPercentButton() { + return percentButton; + } + + public void setPercentButton(VanChartFieldButton percentButton) { + this.percentButton = percentButton; + } + + public VanChartFieldListener getFieldListener() { + return fieldListener; + } + + private JPanel createDefaultFieldPane() { + JPanel fieldPane = new JPanel(); + + fieldPane.setLayout(new GridLayout(0, 1, 1, 0)); + + addDefaultFieldButton(fieldPane); + + fieldPane.setPreferredSize(new Dimension(FIELD_ADD_W, getDefaultFieldButtonList().size() * FIELD_ADD_H)); + fieldPane.setBorder(BorderFactory.createEmptyBorder(10, 5, 0, 0)); + + return fieldPane; + } + + protected void initDefaultFieldButton() { + categoryNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Category_Use_Name"), + new AttrTooltipCategoryFormat(), false, fieldListener); + + seriesNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Series_Name"), + new AttrTooltipSeriesFormat(), false, fieldListener); + + valueButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Value"), + new AttrTooltipValueFormat(), false, fieldListener); + + percentButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Percent"), + new AttrTooltipPercentFormat(), false, fieldListener); + } + + protected void addDefaultFieldButton(JPanel fieldPane) { + fieldPane.add(categoryNameButton); + fieldPane.add(seriesNameButton); + fieldPane.add(valueButton); + fieldPane.add(percentButton); + } + + 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, new AttrTooltipFieldFormat(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(); + model.setAddition(fieldName); + VanChartRichEditorPane.richEditorAddField(model); + + if (tableFieldNameList.contains(fieldName)) { + int index = tableFieldNameList.indexOf(fieldName); + + VanChartFieldButton fieldButton = tableFieldButtonList.get(index); + Format fieldFormat = fieldButton.getFormat(); + DataFunction dataFunction = fieldButton.getDataFunction(); + + tableFieldCollection.addFieldDefinition(fieldName, new TableFieldDefinition(fieldName, fieldFormat, dataFunction)); + } + } + + 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()); + + if (tableFieldNameList.contains(fieldName)) { + Format fieldFormat = fieldButton.getFormat(); + DataFunction dataFunction = fieldButton.getDataFunction(); + + tableFieldCollection.addFieldDefinition(fieldName, new TableFieldDefinition(fieldName, fieldFormat, dataFunction)); + } + } + }; + } + + 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(); + } + } + + public void populate(AttrTooltipContent tooltipContent) { + populateDefaultField(tooltipContent); + populateTableField(tooltipContent); + + // 初次打开富文本界面选中第一个 + checkFieldListSelected(); + } + + public void populateDefaultField(AttrTooltipContent tooltipContent) { + populateButtonFormat(categoryNameButton, tooltipContent.getRichTextCategoryFormat()); + populateButtonFormat(seriesNameButton, tooltipContent.getRichTextSeriesFormat()); + populateButtonFormat(valueButton, tooltipContent.getRichTextValueFormat()); + populateButtonFormat(percentButton, tooltipContent.getRichTextPercentFormat()); + } + + public void populateButtonFormat(VanChartFieldButton button, AttrTooltipFormat format) { + if (button == null || format == null) { + return; + } + + button.setEnable(format.isEnable()); + button.setFormat(format.getFormat()); + } + + public void populateTableField(AttrTooltipContent tooltipContent) { + TableFieldCollection fieldCollection = tooltipContent.getFieldCollection(); + + if (fieldCollection == null) { + return; + } + + Map fieldDefinitionGroup = fieldCollection.getFieldNameFormulaMap(); + + if (fieldDefinitionGroup == null || fieldDefinitionGroup.isEmpty()) { + return; + } + + this.tableFieldCollection = new TableFieldCollection(); + + for (int i = 0, len = tableFieldNameList.size(); i < len; i++) { + String fieldName = tableFieldNameList.get(i); + VanChartFieldButton fieldButton = tableFieldButtonList.get(i); + TableFieldDefinition fieldDefinition = fieldDefinitionGroup.get(fieldName); + + if (fieldDefinitionGroup.containsKey(fieldName)) { + Format fieldFormat = fieldDefinition.getFormat(); + DataFunction dataFunction = fieldDefinition.getDataFunction(); + + fieldButton.setFormat(fieldFormat); + fieldButton.setDataFunction(dataFunction); + + this.tableFieldCollection.addFieldDefinition(fieldName, new TableFieldDefinition(fieldName, fieldFormat, dataFunction)); + } + } + } + + public void update(AttrTooltipContent tooltipContent) { + updateDefaultField(tooltipContent); + updateTableField(tooltipContent); + } + + public void updateDefaultField(AttrTooltipContent tooltipContent) { + updateButtonFormat(categoryNameButton, tooltipContent.getRichTextCategoryFormat()); + updateButtonFormat(seriesNameButton, tooltipContent.getRichTextSeriesFormat()); + updateButtonFormat(valueButton, tooltipContent.getRichTextValueFormat()); + updateButtonFormat(percentButton, tooltipContent.getRichTextPercentFormat()); + } + + public void updateTableField(AttrTooltipContent tooltipContent) { + try { + tooltipContent.setFieldCollection(this.tableFieldCollection); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } + } + + public void updateButtonFormat(VanChartFieldButton button, AttrTooltipFormat format) { + if (button == null || format == null) { + return; + } + + format.setEnable(button.isEnable()); + format.setFormat(button.getFormat()); + } +} 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 new file mode 100644 index 0000000000..62f0966636 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartFieldListener.java @@ -0,0 +1,17 @@ +package com.fr.van.chart.designer.component.richText; + +import com.fr.design.event.GlobalNameListener; + +public interface VanChartFieldListener extends GlobalNameListener { + + public VanChartFieldButton getSelectedField(); + + public void refreshSelectedPane(String fieldName); + + public void addSelectedField(String fieldName, String fieldId); + + public void populateFieldFormatPane(); + + public void updateFieldFormatPane(); + +} 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 0000000000..83df27c0fb --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorModel.java @@ -0,0 +1,75 @@ +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(); + private String addition = StringUtils.EMPTY; + + 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; + this.addition = StringUtils.EMPTY; + } + + 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; + } + + public String getAddition() { + return addition; + } + + public void setAddition(String addition) { + this.addition = addition; + } + +} 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 new file mode 100644 index 0000000000..dcec83deb4 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichEditorPane.java @@ -0,0 +1,195 @@ +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; +import com.teamdev.jxbrowser.chromium.Browser; +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; + +public class VanChartRichEditorPane { + + private static final String NAME_SPACE = "Pool"; + private static final String VARIABLE = "data"; + + private static final String RICH_EDITOR_HTML = "/com/fr/design/editor/rich_editor.html"; + + private static final String REFRESH = "refresh()"; + private static final String ADD_FIELD = "addField()"; + + 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); + return createRichEditorPane(model); + } + + public static ModernUIPane createRichEditorPane(VanChartRichEditorModel model) { + if (richEditorPane == null) { + richEditorPane = initPane(model); + } else { + richEditorRefresh(model); + } + + return richEditorPane; + } + + public static void richEditorRefresh(VanChartRichEditorModel model) { + if (richEditorPane != null && browser != null) { + refresh(browser, model); + } + } + + public static void richEditorAddField(VanChartRichEditorModel model) { + if (richEditorPane != null && browser != null) { + addField(browser, model); + } + } + + public static ModernUIPane initPane(VanChartRichEditorModel model) { + return new ModernUIPane.Builder() + .prepare(new ScriptContextAdapter() { + public void onScriptContextCreated(ScriptContextEvent event) { + browser = event.getBrowser(); + browser.getCacheStorage().clearCache(); + + browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/fineui.min.js")); + browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/design/editor/script/i18n.js")); + browser.executeJavaScript(generateTransformI18nJS()); + browser.executeJavaScript(IOUtils.readResourceAsString("/com/fr/web/ui/materials.min.js")); + + JSValue ns = browser.executeJavaScriptAndReturnValue("window." + NAME_SPACE); + ns.asObject().setProperty(VARIABLE, model); + } + }) + .withEMB(RICH_EDITOR_HTML) + .namespace(NAME_SPACE).build(); + } + + public static void refresh(Browser browser, VanChartRichEditorModel model) { + stateChange(browser, model, REFRESH); + } + + public static void addField(Browser browser, VanChartRichEditorModel model) { + stateChange(browser, model, ADD_FIELD); + } + + public static void stateChange(Browser browser, VanChartRichEditorModel model, String trigger) { + JSValue ns = browser.executeJavaScriptAndReturnValue("window." + NAME_SPACE); + ns.asObject().setProperty(VARIABLE, model); + browser.executeJavaScript("window." + NAME_SPACE + "." + trigger); + } + + public static VanChartRichEditorModel getRichEditorModel(AttrTooltipRichText richText) { + Map paramsMap = richText.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); + } + + String content = richText.getContent(); + String initParams = StringUtils.EMPTY; + String align = StringUtils.EMPTY; + + if (content.contains("data-id") && !content.contains("class")) { + initParams = richText.getInitParamsContent(); + + String left = TextAlign.LEFT.getAlign(); + String center = TextAlign.CENTER.getAlign(); + + align = content.contains(left) ? left : center; + } + + return new VanChartRichEditorModel(content, richText.isAuto(), paramsStr.toString(), initParams, align); + } + + public static String generateTransformI18nJS() { + String language = "zh_CN"; + + Locale locale = DesignerEnvManager.getEnvManager().getLanguage(); + + if (locale != null) { + language = locale.toString(); + } + + return "!(function () { window.transformI18n && window.transformI18n('" + language + "' || 'zh_CN'); }());"; + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorDialog.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextDialog.java similarity index 73% rename from designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorDialog.java rename to designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextDialog.java index a13208df56..2cf7050dc1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorDialog.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextDialog.java @@ -1,4 +1,4 @@ -package com.fr.van.chart.designer.component; +package com.fr.van.chart.designer.component.richText; import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicPane; @@ -8,17 +8,17 @@ import com.fr.design.utils.gui.GUICoreUtils; import java.awt.Dimension; import java.awt.Frame; -public class VanChartRichEditorDialog extends BasicDialog { +public class VanChartRichTextDialog extends BasicDialog { public static final Dimension DEFAULT = new Dimension(960, 600); - public VanChartRichEditorDialog(Frame parent, BasicPane pane) { + public VanChartRichTextDialog(Frame parent, BasicPane pane) { super(parent, pane); this.setTitle(Toolkit.i18nText("Fine-Design_Report_RichTextEditor")); this.setBasicDialogSize(DEFAULT); GUICoreUtils.centerWindow(this); - this.setResizable(true); + this.setResizable(false); this.setModal(true); } 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 new file mode 100644 index 0000000000..b7c4e968d3 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/richText/VanChartRichTextPane.java @@ -0,0 +1,95 @@ +package com.fr.van.chart.designer.component.richText; + +import com.fr.design.beans.BasicBeanPane; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.ui.ModernUIPane; +import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import java.awt.BorderLayout; +import java.awt.Dimension; + +// 标签提示中的富文本面板,包含字段设置和富文本编辑器 +public class VanChartRichTextPane extends BasicBeanPane { + + private static final int FIELD_PANE_W = 470; + private static final int FIELD_PANE_H = 270; + + private static final int RICH_EDITOR_W = 940; + private static final int RICH_EDITOR_H = 260; + + private VanChartFieldListPane fieldListPane; + private VanChartFieldAttrPane fieldAttrPane; + + public VanChartRichTextPane(ModernUIPane richEditor) { + fieldAttrPane = new VanChartFieldAttrPane(); + fieldListPane = createFieldListPane(fieldAttrPane, richEditor); + + this.setLayout(new BorderLayout()); + this.add(createFieldContentPane(), BorderLayout.CENTER); + this.add(createRichEditorPane(richEditor), BorderLayout.SOUTH); + } + + public VanChartFieldListPane getFieldListPane() { + return fieldListPane; + } + + private JPanel createFieldContentPane() { + JPanel fieldPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); + + // 新增字段目录 + JPanel fieldListContent = new JPanel(); + fieldListContent.setLayout(new BorderLayout()); + fieldListContent.add(fieldListPane, BorderLayout.NORTH); + + JScrollPane fieldListScrollPane = new JScrollPane(fieldListContent); + fieldListScrollPane.setPreferredSize(new Dimension(FIELD_PANE_W, FIELD_PANE_H)); + fieldListScrollPane.setHorizontalScrollBar(null); + fieldListScrollPane.setBorder(BorderFactory.createTitledBorder("添加字段")); + + // 字段格式和汇总 + JScrollPane fieldAttrScrollPane = new JScrollPane(fieldAttrPane); + fieldAttrScrollPane.setPreferredSize(new Dimension(FIELD_PANE_W, FIELD_PANE_H)); + fieldAttrScrollPane.setBorder(BorderFactory.createTitledBorder("字段设置")); + + fieldPane.add(fieldListScrollPane); + fieldPane.add(fieldAttrScrollPane); + + return fieldPane; + } + + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + return new VanChartFieldListPane(fieldAttrPane, richEditor); + } + + private JPanel createRichEditorPane(JPanel richEditor) { + JPanel richEditorPane = new JPanel(); + + richEditorPane.setLayout(new BorderLayout()); + richEditorPane.setPreferredSize(new Dimension(RICH_EDITOR_W, RICH_EDITOR_H)); + richEditorPane.add(richEditor, BorderLayout.CENTER); + + return richEditorPane; + } + + protected AttrTooltipContent getInitialTooltipContent() { + return new AttrTooltipContent(); + } + + public void populateBean(AttrTooltipContent tooltipContent) { + fieldListPane.populate(tooltipContent); + } + + public AttrTooltipContent updateBean() { + AttrTooltipContent content = getInitialTooltipContent(); + fieldListPane.update(content); + return content; + } + + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } +} 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 32a4f8e547..bb8df99fdb 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 @@ -5,6 +5,7 @@ import com.fr.design.dialog.BasicPane; import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.mainframe.chart.gui.ChartStylePane; 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; @@ -75,4 +76,8 @@ public class VanChartStylePane extends ChartStylePane { protected void addVanChartTooltipPane(List paneList) { paneList.add(new VanChartTooltipPane(VanChartStylePane.this)); } + + public void refreshTableFieldNames() { + VanChartRichEditorPane.refreshFieldNames(getChart()); + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/VanChartMapRichTextFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/VanChartMapRichTextFieldListPane.java new file mode 100644 index 0000000000..91e1817ef5 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/VanChartMapRichTextFieldListPane.java @@ -0,0 +1,41 @@ +package com.fr.van.chart.map.designer.style; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.ui.ModernUIPane; +import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat; +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.component.richText.VanChartFieldAttrPane; +import com.fr.van.chart.designer.component.richText.VanChartFieldButton; +import com.fr.van.chart.designer.component.richText.VanChartFieldListPane; +import com.fr.van.chart.designer.component.richText.VanChartFieldListener; +import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; + +public class VanChartMapRichTextFieldListPane extends VanChartFieldListPane { + + public VanChartMapRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + super(fieldAttrPane, richEditorPane); + } + + protected void initDefaultFieldButton() { + VanChartFieldListener fieldListener = getFieldListener(); + + VanChartFieldButton categoryNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Area_Name"), + new AttrTooltipAreaNameFormat(), false, fieldListener); + + VanChartFieldButton seriesNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Series_Name"), + new AttrTooltipSeriesFormat(), false, fieldListener); + + VanChartFieldButton valueButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Value"), + new AttrTooltipValueFormat(), false, fieldListener); + + VanChartFieldButton percentButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Percent"), + new AttrTooltipPercentFormat(), false, fieldListener); + + setCategoryNameButton(categoryNameButton); + setSeriesNameButton(seriesNameButton); + setValueButton(valueButton); + setPercentButton(percentButton); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java index 084953c996..baec70ca92 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java @@ -1,18 +1,19 @@ package com.fr.van.chart.map.designer.style.label; +import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat; +import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipMapValueFormat; +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.plugin.chart.type.TextAlign; import com.fr.van.chart.designer.component.VanChartLabelContentPane; import com.fr.van.chart.designer.component.format.MapAreaNameFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.MapAreaNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -21,6 +22,7 @@ import javax.swing.JPanel; * Created by Mitisky on 16/5/20. */ public class VanChartMapLabelContentPane extends VanChartLabelContentPane { + public VanChartMapLabelContentPane(VanChartStylePane parent, JPanel showOnPane, boolean inCondition) { super(parent, showOnPane, inCondition); } @@ -33,12 +35,22 @@ public class VanChartMapLabelContentPane extends VanChartLabelContentPane { setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); } - @Override - protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { - setRichTextCategoryNameFormatPane(new MapAreaNameFormatPaneWithoutCheckBox(parent, showOnPane)); - setRichTextSeriesNameFormatPane(new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane)); - setRichTextValueFormatPane(new ValueFormatPaneWithoutCheckBox(parent, showOnPane)); - setRichTextPercentFormatPane(new PercentFormatPaneWithoutCheckBox(parent, showOnPane)); + protected String[] getRichTextFieldNames() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Area_Name"), + Toolkit.i18nText("Fine-Design_Chart_Series_Name"), + Toolkit.i18nText("Fine-Design_Chart_Use_Value"), + Toolkit.i18nText("Fine-Design_Chart_Use_Percent") + }; + } + + protected AttrTooltipFormat[] getRichTextFieldFormats() { + return new AttrTooltipFormat[]{ + new AttrTooltipAreaNameFormat(), + new AttrTooltipSeriesFormat(), + new AttrTooltipValueFormat(), + new AttrTooltipPercentFormat() + }; } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java index 12948b14dd..03f720bf73 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java @@ -1,17 +1,18 @@ package com.fr.van.chart.map.designer.style.tooltip; +import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.base.format.AttrTooltipAreaNameFormat; +import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipMapValueFormat; +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.component.VanChartTooltipContentPane; import com.fr.van.chart.designer.component.format.MapAreaNameFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.MapAreaNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -32,12 +33,22 @@ public class VanChartMapTooltipContentPane extends VanChartTooltipContentPane { setPercentFormatPane(new PercentFormatPaneWithCheckBox(parent, showOnPane)); } - @Override - protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { - setRichTextCategoryNameFormatPane(new MapAreaNameFormatPaneWithoutCheckBox(parent, showOnPane)); - setRichTextSeriesNameFormatPane(new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane)); - setRichTextValueFormatPane(new ValueFormatPaneWithoutCheckBox(parent, showOnPane)); - setRichTextPercentFormatPane(new PercentFormatPaneWithoutCheckBox(parent, showOnPane)); + protected String[] getRichTextFieldNames() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Area_Name"), + Toolkit.i18nText("Fine-Design_Chart_Series_Name"), + Toolkit.i18nText("Fine-Design_Chart_Use_Value"), + Toolkit.i18nText("Fine-Design_Chart_Use_Percent") + }; + } + + protected AttrTooltipFormat[] getRichTextFieldFormats() { + return new AttrTooltipFormat[]{ + new AttrTooltipAreaNameFormat(), + new AttrTooltipSeriesFormat(), + new AttrTooltipValueFormat(), + new AttrTooltipPercentFormat() + }; } @Override diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java index db7ce4152f..e5416b1c21 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java @@ -62,14 +62,7 @@ public class VanChartScatterRefreshTooltipContentPane extends VanChartScatterToo @Override protected Component[][] getRichTextComponents() { - return new Component[][]{ - new Component[]{getRichTextSeriesNameFormatPane(), null}, - new Component[]{getRichTextXFormatPane(), null}, - new Component[]{getRichTextYFormatPane(), null}, - new Component[]{getRichTextSizeFormatPane(), null}, - new Component[]{richTextChangedSizeFormatPane, null}, - new Component[]{getRichTextChangedPercentFormatPane(), null} - }; + return null; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRichTextFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRichTextFieldListPane.java new file mode 100644 index 0000000000..776d5397d8 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRichTextFieldListPane.java @@ -0,0 +1,93 @@ +package com.fr.van.chart.scatter; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.ui.ModernUIPane; +import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.format.AttrTooltipSizeFormat; +import com.fr.plugin.chart.base.format.AttrTooltipXFormat; +import com.fr.plugin.chart.base.format.AttrTooltipYFormat; +import com.fr.plugin.chart.scatter.attr.ScatterAttrTooltipContent; +import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; +import com.fr.van.chart.designer.component.richText.VanChartFieldButton; +import com.fr.van.chart.designer.component.richText.VanChartFieldListPane; +import com.fr.van.chart.designer.component.richText.VanChartFieldListener; +import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; + +import javax.swing.JPanel; +import java.util.ArrayList; +import java.util.List; + +public class VanChartScatterRichTextFieldListPane extends VanChartFieldListPane { + + private VanChartFieldButton richTextXFormatPane; + private VanChartFieldButton richTextYFormatPane; + private VanChartFieldButton richTextSizeFormatPane; + + public VanChartScatterRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + super(fieldAttrPane, richEditorPane); + } + + public VanChartFieldButton getRichTextXFormatPane() { + return richTextXFormatPane; + } + + public VanChartFieldButton getRichTextYFormatPane() { + return richTextYFormatPane; + } + + public VanChartFieldButton getRichTextSizeFormatPane() { + return richTextSizeFormatPane; + } + + protected void initDefaultFieldButton() { + super.initDefaultFieldButton(); + + VanChartFieldListener listener = getFieldListener(); + + richTextXFormatPane = new VanChartFieldButton("x", new AttrTooltipXFormat(), false, listener); + richTextYFormatPane = new VanChartFieldButton("y", new AttrTooltipYFormat(), false, listener); + richTextSizeFormatPane = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Value"), new AttrTooltipSizeFormat(), false, listener); + } + + protected void addDefaultFieldButton(JPanel fieldPane) { + fieldPane.add(getSeriesNameButton()); + fieldPane.add(richTextXFormatPane); + fieldPane.add(richTextYFormatPane); + fieldPane.add(richTextSizeFormatPane); + } + + protected List getDefaultFieldButtonList() { + List fieldButtonList = new ArrayList<>(); + + fieldButtonList.add(getSeriesNameButton()); + fieldButtonList.add(richTextXFormatPane); + fieldButtonList.add(richTextYFormatPane); + fieldButtonList.add(richTextSizeFormatPane); + + return fieldButtonList; + } + + public void populateDefaultField(AttrTooltipContent tooltipContent) { + super.populateDefaultField(tooltipContent); + + if (tooltipContent instanceof ScatterAttrTooltipContent) { + ScatterAttrTooltipContent scatter = (ScatterAttrTooltipContent) tooltipContent; + + populateButtonFormat(richTextXFormatPane, scatter.getRichTextXFormat()); + populateButtonFormat(richTextYFormatPane, scatter.getRichTextYFormat()); + populateButtonFormat(richTextSizeFormatPane, scatter.getRichTextSizeFormat()); + } + } + + public void updateDefaultField(AttrTooltipContent tooltipContent) { + super.updateDefaultField(tooltipContent); + + if (tooltipContent instanceof ScatterAttrTooltipContent) { + ScatterAttrTooltipContent scatter = (ScatterAttrTooltipContent) tooltipContent; + + updateButtonFormat(richTextXFormatPane, scatter.getRichTextXFormat()); + updateButtonFormat(richTextYFormatPane, scatter.getRichTextYFormat()); + updateButtonFormat(richTextSizeFormatPane, scatter.getRichTextSizeFormat()); + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java index 39b20bedbd..396edc6fe1 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java @@ -1,17 +1,22 @@ package com.fr.van.chart.scatter; +import com.fr.design.i18n.Toolkit; +import com.fr.design.ui.ModernUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; -import com.fr.plugin.chart.base.AttrTooltipRichText; import com.fr.plugin.chart.base.format.AttrTooltipFormat; +import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; +import com.fr.plugin.chart.base.format.AttrTooltipSizeFormat; +import com.fr.plugin.chart.base.format.AttrTooltipXFormat; +import com.fr.plugin.chart.base.format.AttrTooltipYFormat; import com.fr.plugin.chart.scatter.attr.ScatterAttrTooltipContent; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; 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.VanChartFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.XFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.XFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.YFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.YFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; +import com.fr.van.chart.designer.component.richText.VanChartFieldListPane; +import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; +import com.fr.van.chart.designer.component.richText.VanChartRichTextPane; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -26,10 +31,6 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa private YFormatPaneWithCheckBox yFormatPane; private ValueFormatPaneWithCheckBox sizeFormatPane; - private XFormatPaneWithoutCheckBox richTextXFormatPane; - private YFormatPaneWithoutCheckBox richTextYFormatPane; - private ValueFormatPaneWithoutCheckBox richTextSizeFormatPane; - public XFormatPaneWithCheckBox getXFormatPane() { return xFormatPane; } @@ -42,18 +43,6 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa return sizeFormatPane; } - public XFormatPaneWithoutCheckBox getRichTextXFormatPane() { - return richTextXFormatPane; - } - - public YFormatPaneWithoutCheckBox getRichTextYFormatPane() { - return richTextYFormatPane; - } - - public ValueFormatPaneWithoutCheckBox getRichTextSizeFormatPane() { - return richTextSizeFormatPane; - } - public VanChartScatterTooltipContentPane(VanChartStylePane parent, JPanel showOnPane){ super(parent, showOnPane); } @@ -71,13 +60,18 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa sizeFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); } - @Override - protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { - super.initRichTextFormatPane(parent, showOnPane); + protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + + return new VanChartRichTextPane(richEditorPane) { - richTextXFormatPane = new XFormatPaneWithoutCheckBox(parent, showOnPane); - richTextYFormatPane = new YFormatPaneWithoutCheckBox(parent, showOnPane); - richTextSizeFormatPane = new ValueFormatPaneWithoutCheckBox(parent, showOnPane); + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + return new VanChartScatterRichTextFieldListPane(fieldAttrPane, richEditor); + } + + protected AttrTooltipContent getInitialTooltipContent() { + return createAttrTooltip(); + } + }; } @Override @@ -90,16 +84,6 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa }; } - @Override - protected Component[][] getRichTextComponents() { - return new Component[][]{ - new Component[]{getRichTextSeriesNameFormatPane(), null}, - new Component[]{richTextXFormatPane, null}, - new Component[]{richTextYFormatPane, null}, - new Component[]{richTextSizeFormatPane, null} - }; - } - @Override protected void populateFormatPane(AttrTooltipContent attrTooltipContent) { super.populateFormatPane(attrTooltipContent); @@ -111,30 +95,20 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa } } - protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { - if (attrTooltipContent instanceof ScatterAttrTooltipContent) { - ScatterAttrTooltipContent scatterAttrTooltipContent = (ScatterAttrTooltipContent) attrTooltipContent; + protected String[] getRichTextFieldNames() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Series_Name"), + "x", + "y", + Toolkit.i18nText("Fine-Design_Chart_Use_Value")}; + } - VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{ - getRichTextSeriesNameFormatPane(), - richTextXFormatPane, - richTextYFormatPane, - richTextSizeFormatPane - }; - - AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ - scatterAttrTooltipContent.getRichTextSeriesFormat(), - scatterAttrTooltipContent.getRichTextXFormat(), - scatterAttrTooltipContent.getRichTextYFormat(), - scatterAttrTooltipContent.getRichTextSizeFormat() - }; - - setRichTextAttr(new AttrTooltipRichText()); - populateRichTextFormat(formatPaneGroup, formatGroup); - populateRichText(attrTooltipContent.getRichTextAttr()); - - checkRichEditorState(attrTooltipContent); - } + protected AttrTooltipFormat[] getRichTextFieldFormats() { + return new AttrTooltipFormat[]{ + new AttrTooltipSeriesFormat(), + new AttrTooltipXFormat(), + new AttrTooltipYFormat(), + new AttrTooltipSizeFormat()}; } @Override @@ -148,14 +122,16 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa } } - protected void updateRichEditor(AttrTooltipContent attrTooltipContent) { - super.updateRichEditor(attrTooltipContent); + protected void updateTooltipFormat(AttrTooltipContent target, AttrTooltipContent source) { + super.updateTooltipFormat(target, source); - if (attrTooltipContent instanceof ScatterAttrTooltipContent) { - ScatterAttrTooltipContent scatterAttrTooltipContent = (ScatterAttrTooltipContent) attrTooltipContent; - richTextXFormatPane.update(scatterAttrTooltipContent.getRichTextXFormat()); - richTextYFormatPane.update(scatterAttrTooltipContent.getRichTextYFormat()); - richTextSizeFormatPane.update(scatterAttrTooltipContent.getRichTextSizeFormat()); + if (target instanceof ScatterAttrTooltipContent && source instanceof ScatterAttrTooltipContent) { + ScatterAttrTooltipContent targetScatter = (ScatterAttrTooltipContent) target; + ScatterAttrTooltipContent sourceScatter = (ScatterAttrTooltipContent) source; + + targetScatter.setRichTextXFormat(sourceScatter.getRichTextXFormat()); + targetScatter.setRichTextYFormat(sourceScatter.getRichTextYFormat()); + targetScatter.setRichTextSizeFormat(sourceScatter.getRichTextSizeFormat()); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRichTextFieldListPane.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRichTextFieldListPane.java new file mode 100644 index 0000000000..3394e6f05b --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRichTextFieldListPane.java @@ -0,0 +1,41 @@ +package com.fr.van.chart.wordcloud.designer.style; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.ui.ModernUIPane; +import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; +import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; +import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; +import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; +import com.fr.van.chart.designer.component.richText.VanChartFieldAttrPane; +import com.fr.van.chart.designer.component.richText.VanChartFieldButton; +import com.fr.van.chart.designer.component.richText.VanChartFieldListPane; +import com.fr.van.chart.designer.component.richText.VanChartFieldListener; +import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; + +public class VanChartWordCloudRichTextFieldListPane extends VanChartFieldListPane { + + public VanChartWordCloudRichTextFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditorPane) { + super(fieldAttrPane, richEditorPane); + } + + protected void initDefaultFieldButton() { + VanChartFieldListener fieldListener = getFieldListener(); + + VanChartFieldButton categoryNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"), + new AttrTooltipCategoryFormat(), false, fieldListener); + + VanChartFieldButton seriesNameButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Word_Name"), + new AttrTooltipNameFormat(), false, fieldListener); + + VanChartFieldButton valueButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Word_Value"), + new AttrTooltipValueFormat(), false, fieldListener); + + VanChartFieldButton percentButton = new VanChartFieldButton(Toolkit.i18nText("Fine-Design_Chart_Use_Percent"), + new AttrTooltipPercentFormat(), false, fieldListener); + + setCategoryNameButton(categoryNameButton); + setSeriesNameButton(seriesNameButton); + setValueButton(valueButton); + setPercentButton(percentButton); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java index c0e9ac6c37..0abd60ac1b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java @@ -2,17 +2,22 @@ package com.fr.van.chart.wordcloud.designer.style; import com.fr.design.i18n.Toolkit; +import com.fr.design.ui.ModernUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; +import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; +import com.fr.plugin.chart.base.format.AttrTooltipPercentFormat; +import com.fr.plugin.chart.base.format.AttrTooltipValueFormat; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; -import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; 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.richText.VanChartFieldAttrPane; +import com.fr.van.chart.designer.component.richText.VanChartFieldListPane; +import com.fr.van.chart.designer.component.richText.VanChartRichEditorModel; +import com.fr.van.chart.designer.component.richText.VanChartRichTextPane; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -53,31 +58,37 @@ public class VanChartWordCloudTooltipContentPane extends VanChartTooltipContentP setPercentFormatPane(percentFormatPane); } - protected void initRichTextFormatPane(VanChartStylePane parent, JPanel showOnPane) { - CategoryNameFormatPaneWithoutCheckBox richTextCategoryNameFormatPane = new CategoryNameFormatPaneWithoutCheckBox(parent, showOnPane) { - protected String getCheckBoxText() { - return Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"); + protected VanChartRichTextPane createRichTextPane(ModernUIPane richEditorPane) { + return new VanChartRichTextPane(richEditorPane) { + + protected VanChartFieldListPane createFieldListPane(VanChartFieldAttrPane fieldAttrPane, ModernUIPane richEditor) { + return new VanChartWordCloudRichTextFieldListPane(fieldAttrPane, richEditor); } - }; - SeriesNameFormatPaneWithoutCheckBox richTextSeriesNameFormatPane = new SeriesNameFormatPaneWithoutCheckBox(parent, showOnPane) { - protected String getCheckBoxText() { - return Toolkit.i18nText("Fine-Design_Chart_Word_Name"); + + protected AttrTooltipContent getInitialTooltipContent() { + return createAttrTooltip(); } }; - ValueFormatPaneWithoutCheckBox richTextValueFormatPane = new ValueFormatPaneWithoutCheckBox(parent, showOnPane) { - protected String getCheckBoxText() { - return Toolkit.i18nText("Fine-Design_Chart_Word_Value"); - } + } + + protected String[] getRichTextFieldNames() { + return new String[]{ + Toolkit.i18nText("Fine-Design_Chart_MultiPie_Series_Name"), + Toolkit.i18nText("Fine-Design_Chart_Word_Name"), + Toolkit.i18nText("Fine-Design_Chart_Word_Value"), + Toolkit.i18nText("Fine-Design_Chart_Use_Percent") }; - PercentFormatPaneWithoutCheckBox richTextPercentFormatPane = new PercentFormatPaneWithoutCheckBox(parent, showOnPane); + } - setRichTextCategoryNameFormatPane(richTextCategoryNameFormatPane); - setRichTextSeriesNameFormatPane(richTextSeriesNameFormatPane); - setRichTextValueFormatPane(richTextValueFormatPane); - setRichTextPercentFormatPane(richTextPercentFormatPane); + protected AttrTooltipFormat[] getRichTextFieldFormats() { + return new AttrTooltipFormat[]{ + new AttrTooltipCategoryFormat(), + new AttrTooltipNameFormat(), + new AttrTooltipValueFormat(), + new AttrTooltipPercentFormat() + }; } - @Override protected AttrTooltipContent createAttrTooltip() { AttrTooltipContent attrTooltipContent = new AttrTooltipContent(); attrTooltipContent.setSeriesFormat(new AttrTooltipNameFormat()); diff --git a/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html b/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html index e6c769f0a3..f62d7dbb2f 100644 --- a/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html +++ b/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html @@ -88,8 +88,7 @@ {type: "bi.rich_editor_color_chooser"}, {type: "bi.rich_editor_align_left_button"}, {type: "bi.rich_editor_align_center_button"}, - {type: "bi.rich_editor_align_right_button"}, - {type: "bi.design.chart.common.editor.insert_param"} + {type: "bi.rich_editor_align_right_button"} ] }, ref: function (_ref) { @@ -97,7 +96,7 @@ } }); - Pool.dispatch = function () { + Pool.refresh = function () { var content = Pool.data.getContent(); var isAuto = Pool.data.isAuto(); var params = Pool.data.getParams(); @@ -117,7 +116,31 @@ }); rich_editor.setFocus(); - } + }; + + Pool.addField = function () { + var editorService = BI.Services.getService("bi.service.design.chart.common.editor"); + + var content = Pool.data.getContent(); + var isAuto = Pool.data.isAuto(); + var params = Pool.data.getParams(); + var addition = Pool.data.getAddition(); + + if (addition) { + // todo 暂时先处理成在content后加一行 + content += '

' + editorService.getEditorParamImage(addition) + '

'; + } + + rich_editor.editor.bindToolbar(rich_editor.bar); + + rich_editor.setValue({ + content: content, + isAuto: isAuto, + dimensionIds: getDimensionIds(params) + }); + + rich_editor.setFocus(); + }; Pool.update = function () { var {content, isAuto} = rich_editor.getValue(); 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 f3e0536797..a2b5dd6a7f 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") + ": ",