diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java index 0d01ddbdaa..37fef509db 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JControlPane.java @@ -9,10 +9,16 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.menu.ToolBarDef; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.ArrayUtils; +import com.fr.stable.Filter; import com.fr.stable.Nameable; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.JSplitPane; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.util.Arrays; +import java.util.stream.Stream; /** * Coder: zack @@ -27,6 +33,8 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S ShortCut4JControlPane[] shorts; NameableCreator[] creators; + + protected Filter creatorsFilter; private ToolBarDef toolbarDef; UIToolbar toolBar; @@ -38,6 +46,7 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S JControlPane() { this.initShortCutFactory(); + this.initCreatorsFilter(); this.initComponentPane(); } @@ -106,6 +115,10 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S this.checkButtonEnabled(); } + protected void initCreatorsFilter() { + this.creatorsFilter = nameableCreator -> true; + } + protected void initCardPane() { this.controlUpdatePane = createControlUpdatePane(); @@ -183,7 +196,12 @@ abstract class JControlPane extends BasicPane implements UnrepeatedNameHelper, S } public NameableCreator[] creators() { - return creators == null ? new NameableCreator[0] : creators; + if (creators == null) { + return new NameableCreator[0]; + } else { + Stream nameableCreatorStream = Arrays.stream(creators).filter(creator -> creatorsFilter.accept(creator)); + return nameableCreatorStream.toArray(NameableCreator[]::new); + } } /** diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java index 7d16995435..da0b552682 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/shortcutfactory/ShortCutFactory.java @@ -142,10 +142,6 @@ public class ShortCutFactory extends AbstractShortCutFactory { private void wrapActionListener(NameableCreator[] creators) { for (final NameableCreator creator : creators) { - Filter> filter = DesignModuleFactory.getHyperlinkGroupType().getFilter(); - if (!filter.accept(creator.getHyperlink())) { - continue; - } boolean isTrue = ComparatorUtils.equals(creator.menuName(), com.fr.design.i18n.Toolkit.i18nText("Datasource-Stored_Procedure")) || ComparatorUtils.equals(creator.menuName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Relation_TableData")) || ComparatorUtils.equals(creator.menuName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_DS_Multi_Dimensional_Database")); if (isTrue) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java index 7b74d1576a..75ec5d3ce2 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java @@ -14,6 +14,7 @@ import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateCellLinkP import com.fr.design.chart.series.SeriesCondition.impl.ChartHyperRelateFloatLinkPane; import com.fr.design.chart.series.SeriesCondition.impl.FormHyperlinkPane; import com.fr.design.designer.TargetComponent; +import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.fun.HyperlinkProvider; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; @@ -22,7 +23,10 @@ import com.fr.design.hyperlink.ReportletHyperlinkPane; import com.fr.design.hyperlink.WebHyperlinkPane; import com.fr.design.javascript.JavaScriptImplPane; import com.fr.design.javascript.ParameterJavaScriptPane; +import com.fr.design.mainframe.BaseJForm; +import com.fr.design.mainframe.JTemplate; import com.fr.design.module.DesignModuleFactory; +import com.fr.general.ComparatorUtils; import com.fr.general.NameObject; import com.fr.js.EmailJavaScript; import com.fr.js.FormHyperlinkProvider; @@ -297,5 +301,24 @@ public class VanChartHyperLinkPane extends VanChartUIListControlPane { } } - + @Override + protected void initCreatorsFilter() { + this.creatorsFilter = nameableCreator -> { + Class clazz = nameableCreator.getHyperlink(); + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + if (!JTemplate.isValid(template)) { + return false; + } + Class[] classes = new Class[]{ChartHyperRelateCellLink.class, ChartHyperRelateFloatLink.class}; + for (Class aClass : classes) { + if (template.getEditingReportIndex() == BaseJForm.FORM_TAB) { + // 编辑的是决策报表中的图表,那么没有ChartHyperRelateFloatLink 和 ChartHyperRelateCellLink 选项,有FormHyperlink 选项 + if (ComparatorUtils.equals(aClass, clazz)) { + return false; + } + } + } + return true; + }; + } } \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java b/designer-form/src/main/java/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java index 7afb15828e..4c3b769a38 100644 --- a/designer-form/src/main/java/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java +++ b/designer-form/src/main/java/com/fr/design/gui/xpane/FormHyperlinkGroupPane.java @@ -1,13 +1,14 @@ package com.fr.design.gui.xpane; +import com.fr.chart.web.ChartHyperRelateFloatLink; import com.fr.design.form.javascript.FormEmailPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.general.ComparatorUtils; - import com.fr.js.EmailJavaScript; +import com.fr.js.JavaScript; public class FormHyperlinkGroupPane extends HyperlinkGroupPane { private static FormHyperlinkGroupPane singleton; @@ -23,6 +24,16 @@ public class FormHyperlinkGroupPane extends HyperlinkGroupPane { return singleton; } + @Override + protected void initCreatorsFilter() { + this.creatorsFilter = nameableCreator -> { + Class clazz = nameableCreator.getHyperlink(); + // 决策报表没有 ChartHyperRelateFloatLink + return !ComparatorUtils.equals(clazz, ChartHyperRelateFloatLink.class); + }; + } + + /** * 生成添加按钮的NameableCreator * 由于表单报表块的单元格超链和单元格条件属性超链中的emailPane都要用表单的emailPane,这里调整下 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ReportHyperlinkGroupPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/ReportHyperlinkGroupPane.java index 20886536ae..b190884a13 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ReportHyperlinkGroupPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ReportHyperlinkGroupPane.java @@ -1,21 +1,11 @@ package com.fr.design.mainframe; -import com.fr.base.Style; -import com.fr.design.actions.utils.ReportActionUtils; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.frpane.HyperlinkGroupPane; import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; -import com.fr.general.FRFont; -import com.fr.grid.selection.CellSelection; -import com.fr.grid.selection.FloatSelection; -import com.fr.grid.selection.Selection; -import com.fr.js.NameJavaScriptGroup; -import com.fr.report.cell.CellElement; -import com.fr.report.cell.FloatElement; -import com.fr.report.elementcase.TemplateElementCase; -import com.fr.stable.Constants; - -import java.awt.*; +import com.fr.general.ComparatorUtils; +import com.fr.js.FormHyperlinkProvider; +import com.fr.stable.bridge.StableFactory; /** * Created by plough on 2017/7/21. @@ -37,10 +27,20 @@ public class ReportHyperlinkGroupPane extends HyperlinkGroupPane { } protected void refreshPane() { - ElementCasePane reportPane = ((JWorkBook)HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()).getEditingElementCasePane(); + ElementCasePane reportPane = ((JWorkBook) HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()).getEditingElementCasePane(); if (reportPane == null) { return; } populate(reportPane); } + + + @Override + protected void initCreatorsFilter() { + this.creatorsFilter = nameableCreator -> { + // 如果是普通报表单元格,那么没有 FormHyperlink 选项 + FormHyperlinkProvider formHyperlink = StableFactory.getMarkedInstanceObjectFromClass(FormHyperlinkProvider.XML_TAG, FormHyperlinkProvider.class); + return !ComparatorUtils.equals(nameableCreator.getHyperlink(), formHyperlink.getClass()); + }; + } }