diff --git a/designer_base/src/com/fr/design/gui/HyperlinkFilterHelper.java b/designer_base/src/com/fr/design/gui/HyperlinkFilterHelper.java new file mode 100644 index 0000000000..db6aa9c4d9 --- /dev/null +++ b/designer_base/src/com/fr/design/gui/HyperlinkFilterHelper.java @@ -0,0 +1,59 @@ +package com.fr.design.gui; + +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.mainframe.BaseJForm; +import com.fr.design.mainframe.JTemplate; +import com.fr.general.ComparatorUtils; +import com.fr.general.Inter; + +/** + * Created by mengao on 2017/9/22. + * 单元格超链、图表超链在不同类型模版中,下拉选项不同 + */ +public class HyperlinkFilterHelper { + + public static boolean whetherAddHyperlink4cell(String itemName){ + JTemplate jTemplate = getCurrentEditingTemplate (); + if (jTemplate == null) { + return false; + } + //先屏蔽掉这个,之后还有别的 + String[] names = {Inter.getLocText("FR-Hyperlink_Chart_Float")}; + for (String name : names) { + if (!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)) { + return false; + } + } + return whetherAddFormLink(jTemplate, itemName); + } + + public static boolean whetherAddHyperlink4Chart(String itemName){ + JTemplate jTemplate = getCurrentEditingTemplate (); + if (jTemplate == null) { + return false; + } + //先屏蔽掉这个,之后还有别的 + String[] names = {Inter.getLocText("FR-Hyperlink_Chart_Float"), Inter.getLocText("FR-Hyperlink_Chart_Cell")}; + for (String name : names){ + if(!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName,name)){ + if(jTemplate.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB && ComparatorUtils.equals(itemName, names[0])){ + //表单报表块中图表悬浮元素超链,只屏蔽联动悬浮元素 + return false; + } else if(jTemplate.getEditingReportIndex() == BaseJForm.FORM_TAB) { + //表单图表超链屏蔽掉联动悬浮元素和联动单元格 + return false; + } + } + } + return whetherAddFormLink(jTemplate, itemName); + } + + private static JTemplate getCurrentEditingTemplate () { + return HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); + } + + private static boolean whetherAddFormLink(JTemplate jTemplate, String itemName) { + String formName = Inter.getLocText("Hyperlink-Form_link"); + return !(jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, formName)); + } +} diff --git a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java index 474b1ca6ff..83cf7a50d3 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/JListControlPane.java @@ -8,13 +8,12 @@ import com.fr.design.data.tabledata.tabledatapane.GlobalMultiTDTableDataPane; import com.fr.design.data.tabledata.tabledatapane.GlobalTreeTableDataPane; import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane; import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane; -import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.gui.HyperlinkFilterHelper; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ModNameActionListener; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.LineSeparator; import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; @@ -384,7 +383,7 @@ public abstract class JListControlPane extends JControlPane { private void wrapActionListener(NameableCreator[] creators) { for (final NameableCreator creator : creators) { - if (!whetherAdd(creator.menuName())) { + if (!HyperlinkFilterHelper.whetherAddHyperlink4cell(creator.menuName())) { continue; } boolean isTrue = ComparatorUtils.equals(creator.menuName(), Inter.getLocText("Datasource-Stored_Procedure")) || @@ -414,22 +413,6 @@ public abstract class JListControlPane extends JControlPane { }); } } - - private boolean whetherAdd(String itemName) { - JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jTemplate == null) { - return false; - } - //先屏蔽掉这个,之后还有别的 - String[] names = {Inter.getLocText("FR-Hyperlink_Chart_Float")}; - for (String name : names) { - if (!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)) { - return false; - } - } - String formName = Inter.getLocText("Hyperlink-Form_link"); - return !(jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, formName)); - } } /* diff --git a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java index 5047fcb7b5..f1cd5f8740 100644 --- a/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java +++ b/designer_base/src/com/fr/design/gui/controlpane/UIListControlPane.java @@ -11,7 +11,7 @@ import com.fr.design.data.tabledata.tabledatapane.GlobalMultiTDTableDataPane; import com.fr.design.data.tabledata.tabledatapane.GlobalTreeTableDataPane; import com.fr.design.data.tabledata.tabledatapane.MultiTDTableDataPane; import com.fr.design.data.tabledata.tabledatapane.TreeTableDataPane; -import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.gui.HyperlinkFilterHelper; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilist.ListModelElement; @@ -19,7 +19,6 @@ import com.fr.design.gui.ilist.ModNameActionListener; import com.fr.design.gui.ilist.UINameEdList; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.mainframe.JTemplate; import com.fr.design.menu.LineSeparator; import com.fr.design.menu.MenuDef; import com.fr.design.menu.ShortCut; @@ -562,19 +561,7 @@ public abstract class UIListControlPane extends UIControlPane { } protected boolean whetherAdd(String itemName){ - JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jTemplate == null) { - return false; - } - //先屏蔽掉这个,之后还有别的 - String[] names = {Inter.getLocText("FR-Hyperlink_Chart_Float")}; - for (String name : names) { - if (!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, name)) { - return false; - } - } - String formName = Inter.getLocText("Hyperlink-Form_link"); - return !(jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, formName)); + return HyperlinkFilterHelper.whetherAddHyperlink4cell(itemName); } } diff --git a/designer_base/src/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java b/designer_base/src/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java index b2e30f41f5..3ed7994b93 100644 --- a/designer_base/src/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java +++ b/designer_base/src/com/fr/design/gui/frpane/UICorrelationComboBoxPane.java @@ -1,28 +1,14 @@ package com.fr.design.gui.frpane; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Container; -import java.awt.Dimension; -import java.awt.LayoutManager; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.JFrame; -import javax.swing.JPanel; -import javax.swing.JPopupMenu; -import javax.swing.SwingUtilities; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - import com.fr.base.BaseUtils; -import com.fr.design.constants.UIConstants; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.dialog.DialogActionListener; +import com.fr.design.dialog.UIDialog; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; -import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.gui.HyperlinkFilterHelper; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.imenu.UIMenuItem; import com.fr.design.gui.imenutable.UIMenuNameableCreator; @@ -30,11 +16,7 @@ import com.fr.design.gui.imenutable.UIMenuTable; import com.fr.design.hyperlink.ReportletHyperlinkPane; import com.fr.design.hyperlink.WebHyperlinkPane; import com.fr.design.javascript.EmailPane; -import com.fr.design.mainframe.BaseJForm; -import com.fr.design.mainframe.JTemplate; -import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.dialog.DialogActionListener; -import com.fr.design.dialog.UIDialog; +import com.fr.design.utils.gui.GUICoreUtils; import com.fr.general.ComparatorUtils; import com.fr.general.Inter; import com.fr.js.AbstractJavaScript; @@ -43,7 +25,15 @@ import com.fr.js.ReportletHyperlink; import com.fr.js.WebHyperlink; import com.fr.stable.ArrayUtils; import com.fr.stable.StringUtils; -import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.List; public class UICorrelationComboBoxPane extends JPanel implements UIObserver { private static final Dimension DIALOG_SIZE = new Dimension(500, 500); @@ -98,7 +88,7 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { if (values.size() > 1) { for (UIMenuNameableCreator value : values) { final String itemName = value.getName(); - if(!whetherAdd(itemName)){ + if(!HyperlinkFilterHelper.whetherAddHyperlink4Chart(itemName)){ continue; } UIMenuItem item = new UIMenuItem(itemName); @@ -135,25 +125,6 @@ public class UICorrelationComboBoxPane extends JPanel implements UIObserver { initAddButtonListener(); } - private boolean whetherAdd(String itemName){ - JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - //先屏蔽掉这个,之后还有别的 - String[] names = {Inter.getLocText("FR-Hyperlink_Chart_Float"), Inter.getLocText("FR-Hyperlink_Chart_Cell")}; - for (String name : names){ - if(!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName,name)){ - if(jTemplate.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB && ComparatorUtils.equals(itemName, names[0])){ - //表单报表块中图表悬浮元素超链,只屏蔽联动悬浮元素 - return false; - } else if(jTemplate.getEditingReportIndex() == BaseJForm.FORM_TAB) { - //表单图表超链屏蔽掉联动悬浮元素和联动单元格 - return false; - } - } - } - String formName = Inter.getLocText("Hyperlink-Form_link"); - return !(jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, formName)); - } - private String createUnrepeatedName(String prefix) { List all = tablePane.updateBean(); // richer:生成的名字从1开始. kunsnat: 添加属性从0开始. diff --git a/designer_chart/src/com/fr/plugin/chart/custom/component/VanChartHyperLinkPane.java b/designer_chart/src/com/fr/plugin/chart/custom/component/VanChartHyperLinkPane.java index e5a73a7bc0..2f0e0c628f 100644 --- a/designer_chart/src/com/fr/plugin/chart/custom/component/VanChartHyperLinkPane.java +++ b/designer_chart/src/com/fr/plugin/chart/custom/component/VanChartHyperLinkPane.java @@ -7,15 +7,12 @@ import com.fr.chart.web.ChartHyperRelateFloatLink; import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.BasicBeanPane; import com.fr.design.designer.TargetComponent; -import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.fun.HyperlinkProvider; +import com.fr.design.gui.HyperlinkFilterHelper; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.imenutable.UIMenuNameableCreator; -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.Inter; import com.fr.general.NameObject; import com.fr.js.EmailJavaScript; @@ -228,33 +225,15 @@ public class VanChartHyperLinkPane extends VanChartUIListControlPane { return null; } - protected class AddVanChartItemMenuDef extends AddItemMenuDef{ + protected class AddVanChartItemMenuDef extends AddItemMenuDef { public AddVanChartItemMenuDef(NameableCreator[] creators) { super(creators); } @Override - protected boolean whetherAdd(String itemName){ - JTemplate jTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate(); - if (jTemplate == null) { - return false; - } - //先屏蔽掉这个,之后还有别的 - String[] names = {Inter.getLocText("FR-Hyperlink_Chart_Float"), Inter.getLocText("FR-Hyperlink_Chart_Cell")}; - for (String name : names){ - if(!jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName,name)){ - if(jTemplate.getEditingReportIndex() == BaseJForm.ELEMENTCASE_TAB && ComparatorUtils.equals(itemName, names[0])){ - //表单报表块中图表悬浮元素超链,只屏蔽联动悬浮元素 - return false; - } else if(jTemplate.getEditingReportIndex() == BaseJForm.FORM_TAB) { - //表单图表超链屏蔽掉联动悬浮元素和联动单元格 - return false; - } - } - } - String formName = Inter.getLocText("Hyperlink-Form_link"); - return !(jTemplate.isJWorkBook() && ComparatorUtils.equals(itemName, formName)); + protected boolean whetherAdd(String itemName) { + return HyperlinkFilterHelper.whetherAddHyperlink4Chart(itemName); } }