diff --git a/build.gradle b/build.gradle index 6446da4044..fa342ced2f 100644 --- a/build.gradle +++ b/build.gradle @@ -64,7 +64,7 @@ allprojects { implementation 'org.swingexplorer:swexpl:2.0.1' implementation 'org.swingexplorer:swag:1.0' implementation 'net.java.dev.jna:jna:5.4.0' - implementation 'org.apache.tomcat:tomcat-catalina:8.5.32' + implementation 'org.apache.tomcat:tomcat-catalina:8.5.57' implementation 'io.socket:socket.io-client:0.7.0' implementation 'com.fr.third:fine-third:' + frVersion implementation 'com.fr.core:fine-core:' + frDevVersion @@ -73,6 +73,7 @@ allprojects { implementation 'com.fr.decision:fine-decision:' + frVersion implementation 'com.fr.schedule:fine-schedule:' + frVersion implementation 'com.fr.report:fine-report-engine:' + frDevVersion + implementation 'com.fr.design:design-i18n' + frDevVersion testImplementation 'org.easymock:easymock:3.5.1' testImplementation 'org.powermock:powermock-module-junit4:1.7.1' testImplementation 'org.powermock:powermock-api-easymock:1.7.1' diff --git a/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java b/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java index 42791ad522..8fbb2d2a5d 100644 --- a/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java +++ b/designer-base/src/main/java/com/fr/design/extra/LoginDialog.java @@ -24,7 +24,7 @@ public class LoginDialog extends UIDialog { } private void init(Component pane) { - if (StableUtils.getMajorJavaVersion() == 8) { + if (StableUtils.getMajorJavaVersion() >= 8) { setUndecorated(true); } JPanel panel = (JPanel) getContentPane(); diff --git a/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java b/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java index 72fa6149b6..69ad0f08d1 100644 --- a/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java +++ b/designer-base/src/main/java/com/fr/design/extra/ShopDialog.java @@ -16,7 +16,7 @@ public class ShopDialog extends UIDialog { public ShopDialog(Frame frame, BasicPane pane) { super(frame); - if (StableUtils.getMajorJavaVersion() == 8) { + if (StableUtils.getMajorJavaVersion() >= 8) { setUndecorated(true); } JPanel panel = (JPanel) getContentPane(); diff --git a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/ReportDataPane.java b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/ReportDataPane.java index 3403bf3413..3393e3aaf5 100644 --- a/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/ReportDataPane.java +++ b/designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/ReportDataPane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.chart.gui.data; +import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.Plot; @@ -8,6 +9,7 @@ import com.fr.design.ChartTypeInterfaceManager; import com.fr.design.beans.FurtherBasicBeanPane; import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.data.report.AbstractReportDataContentPane; +import com.fr.plugin.chart.custom.CustomDefinition; import java.awt.*; @@ -45,7 +47,8 @@ public class ReportDataPane extends FurtherBasicBeanPane{ * @return 界面是否接受对象 */ public boolean accept(Object ob) { - return ob instanceof ChartCollection && ((ChartCollection)ob).getSelectedChart().getFilterDefinition() instanceof ReportDataDefinition; + TopDefinitionProvider filterDefinition = ((ChartCollection) ob).getSelectedChartProvider(Chart.class).getFilterDefinition(); + return ob instanceof ChartCollection && filterDefinition instanceof ReportDataDefinition && !(filterDefinition instanceof CustomDefinition); } /** diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java new file mode 100644 index 0000000000..4dfd250a1d --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorPane.java @@ -0,0 +1,130 @@ +package com.fr.van.chart.designer.component; + +import com.fr.design.ui.ModernUIPane; +import com.fr.plugin.chart.base.AttrTooltipRichText; +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.net.URLEncoder; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +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 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(); + + 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); + } + + return new RichEditorModel(richText.getContent(), richText.isAuto(), paramsStr.toString()); + } + + public static List richParamsParser(String content, Map paramsMap) { + if (content == null || paramsMap == null) { + return null; + } + + List result = new ArrayList<>(); + + for (Map.Entry entry : paramsMap.entrySet()) { + String param = entry.getValue(); + if (content.contains(URLEncoder.encode(param))) { + result.add(param); + } + } + + return result; + } + + public static class RichEditorModel { + private String content; + private boolean auto; + private String params; + + public RichEditorModel(String content, boolean auto, String params) { + this.content = content; + this.auto = auto; + this.params = params; + } + + public String getContent() { + return content; + } + + public void setContent(String content) { + this.content = content; + } + + public boolean isAuto() { + return auto; + } + + public void setAuto(boolean auto) { + this.auto = auto; + } + + public String getParams() { + return params; + } + + public void setParams(String params) { + this.params = params; + } + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java index 5920dd969f..a5aafc79af 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java @@ -1,12 +1,19 @@ package com.fr.van.chart.designer.component; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonGroup; import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; - +import com.fr.design.ui.ModernUIPane; +import com.fr.general.ComparatorUtils; 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.van.chart.designer.TableLayout4VanChartHelper; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; @@ -14,15 +21,22 @@ import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithChec import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; +import javax.swing.JComponent; +import javax.swing.JFrame; import javax.swing.JPanel; +import javax.swing.SwingUtilities; import java.awt.BorderLayout; import java.awt.CardLayout; import java.awt.Component; import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; /** * 内容界面 。数据点提示 @@ -43,22 +57,28 @@ public class VanChartTooltipContentPane extends BasicBeanPane(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Common"), - com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Custom")}); + content = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Common"), + Toolkit.i18nText("Fine-Design_Chart_Custom") + }); initFormatPane(parent, showOnPane); @@ -80,8 +100,8 @@ public class VanChartTooltipContentPane extends BasicBeanPane pane = VanChartRichEditorPane.createRichEditorPane(richText); + BasicDialog dialog = pane.showWindow(new JFrame()); + + pane.populate(VanChartRichEditorPane.getRichEditorModel(richText)); + + dialog.addDialogActionListener(new DialogActionAdapter() { + + public void doOk() { + VanChartRichEditorPane.RichEditorModel model = pane.update(); + + String content = model.getContent(); + List params = VanChartRichEditorPane.richParamsParser(content, richText.getParams()); + populateFormatParams(params); + updateLocalRichText(content, model.isAuto()); + + SwingUtilities.getWindowAncestor(pane).setVisible(false); + } + + public void doCancel() { + SwingUtilities.getWindowAncestor(pane).setVisible(false); + } + }); + + dialog.setVisible(true); + + if (parent != null) { + parent.attributeChanged(); + } + } + protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane){ categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane); seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); @@ -154,13 +244,17 @@ public class VanChartTooltipContentPane extends BasicBeanPane", + "\"%24%7BSERIES%7D\"", + "\"%24%7BVALUE%7D\"", + "\"%24%7BPERCENT%7D\"", + "\"%24%7BCHANGEDVALUE%7D\"", + "\"%24%7BCHANGEDPERCENT%7D\"" + }; + + StringBuilder result = new StringBuilder("

"); + + for (int i = 0, len = formatPaneGroup.length; i < len; i++) { + VanChartFormatPaneWithCheckBox formatPane = formatPaneGroup[i]; + String paramRichText = richTextGroup[i]; + + if (formatPane != null && formatPane.isSelected()) { + result.append(paramRichText); + } + } + + result.append("

"); + + return result.toString(); + } + @Override protected String title4PopupWindow() { return ""; @@ -211,26 +358,72 @@ public class VanChartTooltipContentPane extends BasicBeanPane params) { + if (params == null) { + return; + } + + VanChartFormatPaneWithCheckBox[] formatPaneGroup = getFormatPaneGroup(); + + for (VanChartFormatPaneWithCheckBox formatPane : formatPaneGroup) { + if (formatPane != null) { + formatPane.setSelected(false); + } + } + + for (String param : params) { + VanChartFormatPaneWithCheckBox formatPane = getTargetFormatPane(param); + + if (formatPane != null) { + formatPane.setSelected(true); + } } } public AttrTooltipContent updateBean() { AttrTooltipContent attrTooltipContent = createAttrTooltip(); - attrTooltipContent.setCommon(content.getSelectedIndex() == 0); + boolean isCommon = content.getSelectedIndex() == 0; - updateFormatPane(attrTooltipContent); + attrTooltipContent.setCommon(isCommon); + if (isDirty() && isCommon) { + updateLocalRichText(getParamsRichText(), false); + setDirty(false); + } + updateFormatPane(attrTooltipContent); + updateTooltipRichText(attrTooltipContent); updateFormatsWithPaneWidth(attrTooltipContent); htmlLabelPane.update(attrTooltipContent.getHtmlLabel()); @@ -256,6 +449,19 @@ public class VanChartTooltipContentPane extends BasicBeanPane paramMap, String value) { + String key = this.getCheckBoxText(); + + if (paramMap != null && !paramMap.containsKey(key)) { + paramMap.put(key, value); + } + } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java index a4b53796fd..9cf9165547 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/type/AbstractVanChartTypePane.java @@ -1,10 +1,13 @@ package com.fr.van.chart.designer.type; import com.fr.base.BaseUtils; +import com.fr.base.chart.chartdata.TopDefinitionProvider; import com.fr.chart.base.AttrFillStyle; import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Legend; import com.fr.chart.chartattr.Plot; +import com.fr.chart.chartdata.NormalReportDataDefinition; +import com.fr.chart.chartdata.NormalTableDataDefinition; import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionCollection; import com.fr.chart.chartglyph.DataSheet; @@ -167,6 +170,7 @@ public abstract class AbstractVanChartTypePane extends AbstractChartTypePane