diff --git a/designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java b/designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java index 4d1493e01b..11634c5906 100644 --- a/designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java +++ b/designer-base/src/main/java/com/fr/design/ExtraDesignClassManager.java @@ -114,7 +114,7 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement for (ParameterWidgetOptionProvider provider : set) { WidgetOption option = WidgetOptionFactory.createByWidgetClass( provider.nameForWidget(), - IOUtils.readIcon(provider.iconPathForWidget()), + provider.iconPathForWidget(), provider.classForWidget() ); result.add(option); @@ -186,7 +186,7 @@ public class ExtraDesignClassManager extends AbstractExtraClassManager implement if (provider.isContainer() == isContainer) { WidgetOption option = WidgetOptionFactory.createByWidgetClass( provider.nameForWidget(), - BaseUtils.readIcon(provider.iconPathForWidget()), + provider.iconPathForWidget(), provider.classForWidget() ); result.add(option); diff --git a/designer-base/src/main/java/com/fr/design/actions/AllowAuthorityEditAction.java b/designer-base/src/main/java/com/fr/design/actions/AllowAuthorityEditAction.java index 1a0509d267..546a702979 100644 --- a/designer-base/src/main/java/com/fr/design/actions/AllowAuthorityEditAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/AllowAuthorityEditAction.java @@ -1,9 +1,9 @@ package com.fr.design.actions; -import com.fr.base.svg.IconUtils; import com.fr.base.vcs.DesignerMode; import com.fr.design.constants.UIConstants; import com.fr.design.menu.KeySetUtils; +import com.fr.design.module.DesignModuleFactory; import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.designer.TargetComponent; @@ -61,6 +61,8 @@ public class AllowAuthorityEditAction extends TemplateComponentAction { DesignerContext.getDesignerFrame().refreshDottedLine(); EastRegionContainerPane.getInstance().replaceConfiguredRolesPane(RolesAlreadyEditedPane.getInstance()); EastRegionContainerPane.getInstance().removeParameterPane(); + //进入时要关闭查找替换面板 + DesignModuleFactory.getReplaceOperator().close(); //画虚线 return true; diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineCloudConstants.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineCloudConstants.java new file mode 100644 index 0000000000..9fb243d1e8 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineCloudConstants.java @@ -0,0 +1,200 @@ +package com.fr.design.actions.help.alphafine; + +import com.fr.design.i18n.Toolkit; +import com.fr.general.CloudCenter; +import com.fr.json.JSONArray; + +import java.util.HashMap; +import java.util.Map; + +/** + * 云端变量统一管理 + * + * @author Link + * @version 11.0 + * Created by Link on 2022/9/21 + */ +public class AlphaFineCloudConstants { + + private static final String PLUGIN_SEARCH_API = "plugin.searchAPI"; + private static final String PLUGIN_ALL_SEARCH_API = "plugin.all.searchAPI"; + private static final String AF_PLUGIN_INFO = "af.pluginInfo"; + private static final String AF_REUSE_INFO = "af.reuseInfo"; + private static final String AF_DOC_VIEW = "af.doc_view"; + private static final String AF_DOC_SEARCH = "af.doc_search"; + private static final String AF_DOC_INFO = "af.doc_info"; + private static final String AF_PLUGIN_IMAGE = "af.plugin_image"; + private static final String AF_RECORD = "af.record"; + private static final String AF_CLOUD_SEARCH = "af.cloud_search"; + private static final String AF_SIMILAR_SEARCH = "af.similar_search"; + private static final String AF_ADVICE_SEARCH = "af.advice_search"; + private static final String AF_HOT_SEARCH = "af.hot_search"; + private static final String AF_GO_FORUM = "af.go_fourm"; + private static final String AF_GO_WEB = "af.go_web"; + private static final String AF_PREVIEW = "af.preview"; + private static final String AF_CID_NEW = "af.cid.new"; + private static final String AF_CID_USER_GROUP_INFO = "af.cid.user.group.info"; + private static final String AF_HELP_QUICK_START = "af.help.quick.start"; + private static final String AF_HELP_REPORT_LEARNING_PATH = "af.help.report.learning.path"; + private static final String AF_HELP_PARAM_LEARNING_PATH = "af.help.param.learning.path"; + private static final String AF_HELP_FILL_LEARNING_PATH = "af.help.fill.learning.path"; + private static final String AF_HELP_API_SUMMARY = "af.help.api.summary"; + private static final String AF_HELP_MONTHLY_DOCUMENT = "af.help.monthly.document"; + private static final String AF_RECOMMEND = "af.recommend"; + + private static final String LINK_NAME = "name"; + private static final String LINK_URL = "link"; + + /** + * 获取插件搜索api + */ + public static String getPluginSearchUrl() { + return CloudCenter.getInstance().acquireUrlByKind(PLUGIN_SEARCH_API); + }; + + /** + * 帆软市场里全部插件api + */ + public static String getSearchAllPluginUrl() { + return CloudCenter.getInstance().acquireUrlByKind(PLUGIN_ALL_SEARCH_API); + } + + /** + * 获取插件信息api + */ + public static String getPluginUrl() { + return CloudCenter.getInstance().acquireUrlByKind(AF_PLUGIN_INFO); + } + + /** + * 获取组件信息api + */ + public static String getReuseUrl() { + return CloudCenter.getInstance().acquireUrlByKind(AF_REUSE_INFO); + } + + /** + * 获取帮助文档url + */ + public static String getDocumentDocUrl() { + return CloudCenter.getInstance().acquireUrlByKind(AF_DOC_VIEW); + } + + /** + * 帮助文档搜索api + */ + public static String getDocumentSearchUrl() { + return CloudCenter.getInstance().acquireUrlByKind(AF_DOC_SEARCH); + } + + /** + * 帮助文档信息api + */ + public static String getDocumentInformationUrl() { + return CloudCenter.getInstance().acquireUrlByKind(AF_DOC_INFO); + } + + /** + * 插件图片api + */ + public static String getPluginImageUrl() { + return CloudCenter.getInstance().acquireUrlByKind(AF_PLUGIN_IMAGE); + } + + /** + * 获取云端接口,用于上传alphafine搜索记录 + */ + public static String getCloudServerUrl() { + return CloudCenter.getInstance().acquireUrlByKind(AF_RECORD); + } + + /** + * 获取搜索api,输入搜索词,返回fr的相关功能 + */ + public static String getSearchApi() { + return CloudCenter.getInstance().acquireUrlByKind(AF_CLOUD_SEARCH); + } + + /** + * 获取模糊搜索api前缀,输入搜索词,返回alphaFine相关内容,插件,文档,功能等 + */ + public static String getSimilarSearchUrlPrefix() { + return CloudCenter.getInstance().acquireUrlByKind(AF_SIMILAR_SEARCH); + } + + /** + * 补全建议搜索结果 api,与AF_SIMILAR_SEARCH接口类似,但是返回的信息更全 + */ + public static String getComplementAdviceSearchUrlPrefix() { + return CloudCenter.getInstance().acquireUrlByKind(AF_ADVICE_SEARCH); + } + + /** + * 获取热门问题 + */ + public static String getAlphaHotSearch() { + return CloudCenter.getInstance().acquireUrlByKind(AF_HOT_SEARCH); + } + + /** + * 跳转论坛url + */ + public static String getAlphaGoToForum() { + return CloudCenter.getInstance().acquireUrlByKind(AF_GO_FORUM); + } + + /** + * 推荐搜索api,输入搜索词,返回猜你想搜的内容(html格式) + */ + public static String getAlphaGoToWeb() { + return CloudCenter.getInstance().acquireUrlByKind(AF_GO_WEB); + } + + /** + * 帆软智能客服页面url + */ + public static String getAlphaPreview() { + return CloudCenter.getInstance().acquireUrlByKind(AF_PREVIEW); + } + + /** + * cid系统的产品动态api + */ + public static String getAlphaCid() { + return CloudCenter.getInstance().acquireUrlByKind(AF_CID_NEW); + } + + /** + * cid系统的 用户组信息api + */ + public static String getAlphaCidUserGroupInfo() { + return CloudCenter.getInstance().acquireUrlByKind(AF_CID_USER_GROUP_INFO); + } + + private static String getDefaultRecommend() { + String[][] links = new String[][]{ + {Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Quick_Start"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_QUICK_START)}, + {Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Report_Learning"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_REPORT_LEARNING_PATH)}, + {Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Parameter_Learning"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_PARAM_LEARNING_PATH)}, + {Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Fill_Learning"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_FILL_LEARNING_PATH)}, + {Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Api_Summary"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_API_SUMMARY)}, + {Toolkit.i18nText("Fine-Design_Report_AlphaFine_Doc_Monthly_Document"), CloudCenter.getInstance().acquireUrlByKind(AF_HELP_MONTHLY_DOCUMENT)} + }; + JSONArray jsonArray = new JSONArray(); + for (String[] link : links) { + Map map = new HashMap<>(); + map.put(LINK_NAME, link[0]); + map.put(LINK_URL, link[1]); + jsonArray.put(map); + } + + return jsonArray.toString(); + } + + /** + * 获取默认推荐帮助文档url + */ + public static String getAlphaHelpRecommend() { + return CloudCenter.getInstance().acquireUrlByKind(AF_RECOMMEND, getDefaultRecommend()); + } +} diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java index b7df52c30f..2e78d1062d 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigManager.java @@ -29,6 +29,7 @@ import java.util.Stack; */ public class AlphaFineConfigManager implements XMLable { + public static final String COMMA = ","; private static final long serialVersionUID = -8170289826729582122L; private static AlphaFineConfigManager alphaFineConfigManager = new AlphaFineConfigManager(); /** @@ -91,19 +92,20 @@ public class AlphaFineConfigManager implements XMLable { * 是否提醒 */ private boolean needRemind = true; - /** * 产品动态 */ private boolean productDynamics = true; - /** * 模板商城是否展示 - * */ + */ private boolean showTemplateShop = true; - + /** + * tab页排序 + * 默认排序:动态,模板商城,帮助文档,插件中心,功能,我的模板 + */ + private String[] tabOrder; private Map actionSearchTextCache = new HashMap<>(8); - private String cacheBuildNO; @@ -158,6 +160,7 @@ public class AlphaFineConfigManager implements XMLable { this.setShortcuts(reader.getAttrAsString("shortcuts", getDefaultShortCuts())); this.setNeedRemind(reader.getAttrAsBoolean("isNeedRemind", true)); this.setOperateCount(reader.getAttrAsInt("operateCount", 0)); + this.setTabOrder(reader.getAttrAsString("tabOrder", getDefaultTabOrder()).split(",")); } else if (reader.isChildNode()) { if (ComparatorUtils.equals(reader.getTagName(), "ActionSearchTextCache")) { readActionSearchTextCacheXML(reader); @@ -198,7 +201,7 @@ public class AlphaFineConfigManager implements XMLable { if (ComparatorUtils.equals(reader.getTagName(), "history")) { String tmpVal = reader.getElementValue(); if (tmpVal != null) { - tmpVal = tmpVal.replace("[",StringUtils.EMPTY).replace("]",StringUtils.EMPTY); + tmpVal = tmpVal.replace("[", StringUtils.EMPTY).replace("]", StringUtils.EMPTY); Stack stack = new SizedStack<>(3); String[] historyList = tmpVal.split(","); for (String history : historyList) { @@ -222,7 +225,7 @@ public class AlphaFineConfigManager implements XMLable { if (ComparatorUtils.equals(reader.getTagName(), "readId")) { String tmpVal = reader.getElementValue(); if (tmpVal != null) { - tmpVal = tmpVal.replace("[",StringUtils.EMPTY).replace("]",StringUtils.EMPTY); + tmpVal = tmpVal.replace("[", StringUtils.EMPTY).replace("]", StringUtils.EMPTY); String[] idArr = tmpVal.split(","); Set setId = new HashSet<>(); for (String id : idArr) { @@ -254,7 +257,8 @@ public class AlphaFineConfigManager implements XMLable { .attr("operateCount", this.getOperateCount()) .attr("needSegmentationCheckbox", this.isNeedSegmentationCheckbox()) .attr("needIntelligentCustomerService", this.isNeedIntelligentCustomerService()) - .attr("productDynamics", this.isProductDynamics()); + .attr("productDynamics", this.isProductDynamics()) + .attr("tabOrder", this.getTabOrderString()); writeActionSearchTextCacheXML(writer); writeSearchHistory(writer); writeReadSet(writer); @@ -317,6 +321,13 @@ public class AlphaFineConfigManager implements XMLable { return OperatingSystem.isMacOS() ? "meta + D" : "ctrl + D"; } + /** + * 返回默认排序 + */ + private String getDefaultTabOrder() { + return AlphaFineConstants.PRODUCT_NEWS + COMMA + AlphaFineConstants.TEMPLATE_SHOP + COMMA + AlphaFineConstants.HELP + COMMA + AlphaFineConstants.PLUGIN + COMMA + AlphaFineConstants.FUNCTION + COMMA + AlphaFineConstants.MY_TEMPLATES; + } + public boolean isContainAction() { return containAction; } @@ -333,14 +344,14 @@ public class AlphaFineConfigManager implements XMLable { this.containDocument = containDocument; } - public void setContainMyTemplate(boolean containMyTemplate) { - this.containMyTemplate = containMyTemplate; - } - public boolean isContainMyTemplate() { return containMyTemplate; } + public void setContainMyTemplate(boolean containMyTemplate) { + this.containMyTemplate = containMyTemplate; + } + public boolean isContainTemplate() { return containTemplate; } @@ -461,6 +472,10 @@ public class AlphaFineConfigManager implements XMLable { return productDynamics && FRContext.isChineseEnv(); } + public void setProductDynamics(boolean productDynamics) { + this.productDynamics = productDynamics; + } + public boolean hasTemplateShop() { return showTemplateShop && FRContext.isChineseEnv(); } @@ -469,7 +484,36 @@ public class AlphaFineConfigManager implements XMLable { this.showTemplateShop = showTemplateShop; } - public void setProductDynamics(boolean productDynamics) { - this.productDynamics = productDynamics; + /** + * 是否展示alphafine窗口,设置-搜索范围 0勾选,则不显示 + */ + public boolean needShowAlphaFineDialog() { + return hasTemplateShop() || isContainDocument() || isContainPlugin() || + isContainAction() || isProductDynamics() || isContainMyTemplate(); + } + + /** + * 返回tab显示顺序 + */ + public String[] getTabOrder() { + if (tabOrder == null) { + tabOrder = getDefaultTabOrder().split(COMMA); + } + return tabOrder; + } + + public void setTabOrder(String[] tabOrder) { + this.tabOrder = tabOrder; + } + + /** + * getTabOrder的tostring + */ + public String getTabOrderString() { + StringBuilder sb = new StringBuilder(); + for (String s : getTabOrder()) { + sb.append(s + COMMA); + } + return sb.toString(); } } diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java index fa0f4a8f0a..dcc20f6ea7 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java @@ -3,8 +3,11 @@ package com.fr.design.actions.help.alphafine; import com.fr.base.FRContext; import com.fr.base.svg.IconUtils; import com.fr.design.DesignerEnvManager; +import com.fr.design.actions.help.alphafine.component.CustomSortPane; +import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.imenu.UIPopupMenu; import com.fr.design.gui.itextfield.UITextField; @@ -17,6 +20,7 @@ import com.fr.log.FineLoggerFactory; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JPanel; +import javax.swing.JPopupMenu; import javax.swing.KeyStroke; import java.awt.BorderLayout; import java.awt.Color; @@ -30,6 +34,8 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.util.ArrayList; +import java.util.List; /** * Created by XiaXiang on 2017/4/6. @@ -39,14 +45,24 @@ public class AlphaFineConfigPane extends BasicPane { private static final String DISPLAY_TYPE = "+"; private static final Color LABEL_TEXT = new Color(0x919193); + private static final int SEARCH_CONFIG_PANE_HEIGHT = 70; + private static final int SEARCH_CONFIG_PANE_WIDTH = 87; private static final double COLUMN_WIDTH = 150; private static final double ROW_HEIGHT = 25; private KeyStroke shortCutKeyStore = null; private UICheckBox enabledCheckbox, searchOnlineCheckbox, needSegmentationCheckbox; private UICheckBox productDynamicsCheckbox, containTemplateShopCheckbox, containDocumentCheckbox, containPluginCheckbox, containActionCheckbox, containMyTemplateCheckbox; + // 自定义排序按钮 + private ActionLabel customSortLabel; private UITextField shortcutsField; + + + // 当前tab排序。点击确定后会保存到配置文件中 + private String[] currentOrder; + + // 搜索范围-我的模板,相关组件 private JPanel containMyTemplatePane; private JButton myTemplateSearchConfigButton; @@ -79,7 +95,8 @@ public class AlphaFineConfigPane extends BasicPane { double[] rowSize = {ROW_HEIGHT, ROW_HEIGHT, ROW_HEIGHT}; double[] columnSize = {COLUMN_WIDTH, COLUMN_WIDTH, COLUMN_WIDTH}; - JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Search_Range")); + JPanel searchConfigWrapperPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_AlphaFine_Search_Range")); + // 搜索选项 productDynamicsCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Product_News")); containActionCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Function")); containPluginCheckbox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon")); @@ -89,10 +106,39 @@ public class AlphaFineConfigPane extends BasicPane { containTemplateShopCheckbox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Shop")); containMyTemplateCheckbox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_My_Templates")); JPanel searchConfigPane = TableLayoutHelper.createTableLayoutPane(initSearchRangeComponents(), rowSize, columnSize); - northPane.add(searchConfigPane); - contentPane.add(northPane); + + // 自定义排序 + JPanel customSortWrapperPane = new JPanel(); + customSortWrapperPane.setPreferredSize(new Dimension(SEARCH_CONFIG_PANE_HEIGHT, SEARCH_CONFIG_PANE_WIDTH)); + customSortWrapperPane.setAlignmentY(JPanel.TOP_ALIGNMENT); + customSortLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Config_Custom_Sort"), false); + customSortLabel.setForeground(UIConstants.NORMAL_BLUE); + customSortLabel.addActionListener((event)->{ + if (customSortLabel.isEnabled()) { + openCustomSortMenu(); + } + }); + customSortWrapperPane.add(customSortLabel); + if (!hasSelectedSearchRangeCheckBox()) { + customSortLabel.setEnabled(false); + } + + searchConfigWrapperPane.add(searchConfigPane); + searchConfigWrapperPane.add(customSortWrapperPane); + contentPane.add(searchConfigWrapperPane); } + /** + * 打开自定义排序面板 + * */ + private void openCustomSortMenu() { + CustomSortPane customSortPane = new CustomSortPane(getSelectedSearchRangeCheckBox(), this); + JPopupMenu popupMenu = new JPopupMenu(); + popupMenu.add(customSortPane); + GUICoreUtils.showPopupMenu(popupMenu, customSortLabel, 0, customSortLabel.getHeight()); + } + + private Component[][] initSearchRangeComponents() { // 我的模板checkbox设置,点击后 initMyTemplateSearchPane(); @@ -102,12 +148,12 @@ public class AlphaFineConfigPane extends BasicPane { new Component[]{containPluginCheckbox, containActionCheckbox, containMyTemplatePane}, }; - for (int i = 0; i < components.length; i++) { - for (int j = 0; j < components[i].length; j++) { - if (components[i][j] instanceof UICheckBox) { - UICheckBox box = (UICheckBox) components[i][j]; - } - } + // 添加选项点事件,无选中选项时自定排序按钮置灰 + UICheckBox[] checkBoxes = new UICheckBox[]{productDynamicsCheckbox, containTemplateShopCheckbox, containDocumentCheckbox, containPluginCheckbox, containActionCheckbox, containMyTemplateCheckbox}; + for (UICheckBox box : checkBoxes) { + box.addActionListener((e)->{ + customSortLabel.setEnabled(hasSelectedSearchRangeCheckBox()); + }); } return components; } @@ -120,25 +166,39 @@ public class AlphaFineConfigPane extends BasicPane { || containPluginCheckbox.isSelected() || containActionCheckbox.isSelected() || containMyTemplateCheckbox.isSelected(); } - // 搜索范围-我的模板 + /** + * 获取当前选中的搜索范围选项 + * */ + private List getSelectedSearchRangeCheckBox() { + List res = new ArrayList<>(); + UICheckBox[] checkBoxes = new UICheckBox[]{productDynamicsCheckbox, containTemplateShopCheckbox, containDocumentCheckbox, containPluginCheckbox, containActionCheckbox, containMyTemplateCheckbox}; + for (UICheckBox c : checkBoxes) { + if (c.isSelected()) { + res.add(c); + } + } + return res; + } + + /** + * 搜索范围-我的模板 + */ private void initMyTemplateSearchPane() { - containMyTemplatePane = new JPanel(new FlowLayout(FlowLayout.LEFT,4,5)); + containMyTemplatePane = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 5)); containMyTemplateCheckbox.setBorder(BorderFactory.createEmptyBorder()); - containMyTemplateCheckbox.addActionListener( - new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (containMyTemplateCheckbox.isSelected()) { - myTemplateSearchConfigButton.setVisible(true); - } else { - myTemplateSearchConfigButton.setVisible(false); - } - } + containMyTemplateCheckbox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (containMyTemplateCheckbox.isSelected()) { + myTemplateSearchConfigButton.setVisible(true); + } else { + myTemplateSearchConfigButton.setVisible(false); } - ); + } + }); myTemplateSearchConfigButton = new JButton(); myTemplateSearchConfigButton.setBorder(BorderFactory.createEmptyBorder()); - myTemplateSearchConfigButton.setMargin(new Insets(0,0,0,0)); + myTemplateSearchConfigButton.setMargin(new Insets(0, 0, 0, 0)); myTemplateSearchConfigButton.setIcon(IconUtils.readIcon("/com/fr/design/mainframe/alphafine/images/config.svg")); myTemplateSearchMenu = new UIPopupMenu(); containTemplateNameSearchCheckbox = new UICheckBox(Toolkit.i18nText("Fine-Design_AlphaFine_Config_Name_Search")); @@ -280,6 +340,14 @@ public class AlphaFineConfigPane extends BasicPane { this.needSegmentationCheckbox.setSelected(alphaFineConfigManager.isNeedSegmentationCheckbox()); shortCutKeyStore = convert2KeyStroke(alphaFineConfigManager.getShortcuts()); + + this.currentOrder = alphaFineConfigManager.getTabOrder().clone(); + + if (!hasSelectedSearchRangeCheckBox()) { + customSortLabel.setEnabled(false); + } else { + customSortLabel.setEnabled(true); + } } public void update() { @@ -296,6 +364,9 @@ public class AlphaFineConfigPane extends BasicPane { alphaFineConfigManager.setContainFileContent(this.containFileContentSearchCheckbox.isSelected()); alphaFineConfigManager.setNeedSegmentationCheckbox(this.needSegmentationCheckbox.isSelected()); alphaFineConfigManager.setShortcuts(shortCutKeyStore != null ? shortCutKeyStore.toString().replace(TYPE, DISPLAY_TYPE) : this.shortcutsField.getText()); + alphaFineConfigManager.setTabOrder(currentOrder); + + designerEnvManager.setAlphaFineConfigManager(alphaFineConfigManager); try { DesignerEnvManager.loadLogSetting(); @@ -327,4 +398,12 @@ public class AlphaFineConfigPane extends BasicPane { public void setIsContainFileContentCheckbox(UICheckBox isContainFileContentCheckbox) { this.containFileContentSearchCheckbox = isContainFileContentCheckbox; } + + public String[] getCurrentOrder() { + return currentOrder; + } + + public void setCurrentOrder(String[] currentOrder) { + this.currentOrder = currentOrder; + } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConstants.java similarity index 64% rename from designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java rename to designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConstants.java index 935d2d0e35..b723e08b16 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/AlphaFineConstants.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConstants.java @@ -1,10 +1,9 @@ -package com.fr.design.mainframe.alphafine; +package com.fr.design.actions.help.alphafine; import com.fr.base.extension.FileExtension; import com.fr.base.svg.IconUtils; import com.fr.design.i18n.Toolkit; import com.fr.design.utils.DesignUtils; -import com.fr.general.CloudCenter; import com.fr.general.IOUtils; import javax.swing.Icon; @@ -22,6 +21,19 @@ import java.util.Set; */ public class AlphaFineConstants { + + public static final String FUNCTION = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Function"); + + public static final String MY_TEMPLATES = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_My_Templates"); + + public static final String PRODUCT_NEWS = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Product_News"); + + public static final String HELP = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help"); + + public static final String PLUGIN = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Plugin_Addon"); + + public static final String TEMPLATE_SHOP = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Shop"); + public static final int SHOW_SIZE = 5; public static final int MAX_FILE_SIZE = 1000; @@ -40,7 +52,7 @@ public class AlphaFineConstants { public static final int CONTENT_HEIGHT = 405; - public static final int CELL_HEIGHT = 32; + public static final int CELL_HEIGHT = 29; public static final int CELL_TITLE_HEIGHT = 24; @@ -55,11 +67,9 @@ public class AlphaFineConstants { /** * 帮助文档搜索间隔(ms) api限制了1s之内只能搜索一次 - * */ public static final long DOCUMENT_SEARCH_GAP = 1000; - public static final Dimension FULL_SIZE = new Dimension(680, 460); public static final Dimension CONTENT_SIZE = new Dimension(680, 405); @@ -113,25 +123,6 @@ public class AlphaFineConstants { public static final String ALPHA_HOT_IMAGE_NAME = "alphafine_hot"; - public static final String PLUGIN_SEARCH_URL = CloudCenter.getInstance().acquireUrlByKind("plugin.searchAPI"); - - public static final String PLUGIN_URL = CloudCenter.getInstance().acquireUrlByKind("af.pluginInfo"); - - public static final String REUSE_URL = CloudCenter.getInstance().acquireUrlByKind("af.reuseInfo"); - - - public static final String DOCUMENT_DOC_URL = CloudCenter.getInstance().acquireUrlByKind("af.doc_view"); - - public static final String DOCUMENT_SEARCH_URL = CloudCenter.getInstance().acquireUrlByKind("af.doc_search"); - - public static final String DOCUMENT_INFORMATION_URL = CloudCenter.getInstance().acquireUrlByKind("af.doc_info"); - - public static final String PLUGIN_IMAGE_URL = CloudCenter.getInstance().acquireUrlByKind("af.plugin_image"); - - public static final String CLOUD_SERVER_URL = CloudCenter.getInstance().acquireUrlByKind("af.record"); - - public static final String SEARCH_API = CloudCenter.getInstance().acquireUrlByKind("af.cloud_search"); - public static final String SPECIAL_CHARACTER_REGEX = "[`~!@#$%^&*()+=|{}':;',\\[\\].<>/?~!@#¥%……&*()——+|{}【】';:”“’。,、?]"; public static final String BOTTOM_REGEX_FIRST = "
([\\s\\S]*?)class=\"jiaoyes\">YES
"; @@ -144,36 +135,8 @@ public class AlphaFineConstants { public static final String ALPHA_ROBOT_SEARCH_TOKEN = "K8dl0Np6l0gs"; - public static final String SIMILAR_SEARCH_URL_PREFIX = CloudCenter.getInstance().acquireUrlByKind("af.similar_search"); - - public static final String COMPLEMENT_ADVICE_SEARCH_URL_PREFIX = CloudCenter.getInstance().acquireUrlByKind("af.advice_search"); - - public static final String ALPHA_HOT_SEARCH = CloudCenter.getInstance().acquireUrlByKind("af.hot_search"); - - public static final String ALPHA_GO_TO_FORUM = CloudCenter.getInstance().acquireUrlByKind("af.go_fourm"); - - public static final String ALPHA_GO_TO_WEB = CloudCenter.getInstance().acquireUrlByKind("af.go_web"); - - public static final String ALPHA_PREVIEW = CloudCenter.getInstance().acquireUrlByKind("af.preview"); - - public static final String ALPHA_CID = CloudCenter.getInstance().acquireUrlByKind("af.cid.new"); - - public static final String ALPHA_CID_USER_GROUP_INFO = CloudCenter.getInstance().acquireUrlByKind("af.cid.user.group.info"); - public static final String SEARCH_BY_ID = "?id="; - private static final String QUICK_START_URL = CloudCenter.getInstance().acquireUrlByKind("af.help.quick.start"); - private static final String REPORT_LEARNING_PATH = CloudCenter.getInstance().acquireUrlByKind("af.help.report.learning.path"); - private static final String PARAMETER_LEARNING_PATH = CloudCenter.getInstance().acquireUrlByKind("af.help.param.learning.path"); - private static final String FILL_LEARNING_PATH = CloudCenter.getInstance().acquireUrlByKind("af.help.fill.learning.path"); - private static final String API_SUMMARY = CloudCenter.getInstance().acquireUrlByKind("af.help.api.summary"); - private static final String MONTHLY_DOCUMENT = CloudCenter.getInstance().acquireUrlByKind("af.help.monthly.document"); - - - private static final String DEFAULT_RECOMMEND = "[ { \"name\":\"快速入门指南\", \"link\":\"" + QUICK_START_URL + "\" }, { \"name\":\"报表应用学习路径\", \"link\":\"" + REPORT_LEARNING_PATH + "\" }, { \"name\":\"参数应用学习路径\", \"link\":\"" + PARAMETER_LEARNING_PATH + "\" }, { \"name\":\"填报学习路径\", \"link\":\"" + FILL_LEARNING_PATH + "\" }, { \"name\":\"API接口汇总\", \"link\":\"" + API_SUMMARY + "\" }, { \"name\":\"文档月刊\", \"link\":\"" + MONTHLY_DOCUMENT + "\" } ]"; - - public static final String ALPHA_HELP_RECOMMEND = CloudCenter.getInstance().acquireUrlByKind("af.recommend", DEFAULT_RECOMMEND); - public static final String JAVASCRIPT_PREFIX = "javascript:SendJava"; public static final String CHINESE_CHARACTERS = "[\\u4e00-\\u9fa5]"; diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java new file mode 100644 index 0000000000..c544bbac0b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java @@ -0,0 +1,209 @@ +package com.fr.design.actions.help.alphafine.component; + +import com.fr.base.svg.IconUtils; +import com.fr.design.actions.help.alphafine.AlphaFineConfigPane; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.plaf.PanelUI; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.function.Function; + +/** + * alphafine设置 - 搜索范围 - 自定义排序 - 弹出面板 + * + * @author Link + * @version 11.0 + * Created by Link on 2022/9/18 + */ +public class CustomSortPane extends JPanel { + + + private static final int WIDTH = 147; + private static final int ITEM_HEIGHT = 23; + private static final int GAP = 1; + private static final Color BACKGROUND_COLOR = new Color(0xdadadd); + + private UIButton top; + private UIButton bottom; + private UIButton up; + private UIButton down; + private JPanel toolbarPane; + private MenuLabelPane sortItemPane; + private List sortItems; + private MenuLabel selectedLabel; + private AlphaFineConfigPane parentPane; + + public CustomSortPane(List items, AlphaFineConfigPane parentPane) { + this.sortItems = items; + this.parentPane = parentPane; + setLayout(new BorderLayout(GAP, GAP)); + int height = (sortItems.size() + 1) * (ITEM_HEIGHT + GAP) + GAP; + setPreferredSize(new Dimension(WIDTH, height)); + initComponent(); + add(toolbarPane, BorderLayout.NORTH); + add(sortItemPane, BorderLayout.CENTER); + revalidate(); + this.setVisible(true); + } + + @Override + public void setUI(PanelUI ui) { + super.setUI(ui); + setBackground(BACKGROUND_COLOR); + + } + + private void initComponent() { + createToolbarPane(); + createSortItemPane(); + } + + private void createToolbarPane() { + top = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/top.svg"), false); + bottom = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/bottom.svg"), false); + up = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/up.svg"), false); + down = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/down.svg"), false); + top.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/top_disable.svg")); + bottom.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/bottom_disable.svg")); + up.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/up_disable.svg")); + down.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/down_disable.svg")); + top.addActionListener(e -> { + SwingUtilities.invokeLater(() -> { + sortItemPane.setComponentZOrder(selectedLabel, 0); + setToolbarEnable(false, false, true, true); + CustomSortPane.this.revalidate(); + CustomSortPane.this.repaint(); + refreshCurrentOrder(); + }); + + }); + bottom.addActionListener(e -> { + SwingUtilities.invokeLater(() -> { + sortItemPane.setComponentZOrder(selectedLabel, sortItemPane.getComponentCount() - 1); + setToolbarEnable(true, true, false, false); + CustomSortPane.this.revalidate(); + CustomSortPane.this.repaint(); + refreshCurrentOrder(); + }); + + }); + up.addActionListener(e -> { + SwingUtilities.invokeLater(() -> { + sortItemPane.setComponentZOrder(selectedLabel, sortItemPane.getComponentZOrder(selectedLabel) - 1); + setToolbarEnable(true, true, true, true); + CustomSortPane.this.revalidate(); + CustomSortPane.this.repaint(); + refreshCurrentOrder(); + }); + + }); + down.addActionListener(e -> { + SwingUtilities.invokeLater(() -> { + sortItemPane.setComponentZOrder(selectedLabel, sortItemPane.getComponentZOrder(selectedLabel) + 1); + setToolbarEnable(true, true, true, true); + CustomSortPane.this.revalidate(); + CustomSortPane.this.repaint(); + refreshCurrentOrder(); + }); + + }); + toolbarPane = new JPanel(new FlowLayout(FlowLayout.TRAILING, GAP, GAP)); + toolbarPane.setBorder(BorderFactory.createEmptyBorder()); + toolbarPane.add(top); + toolbarPane.add(bottom); + toolbarPane.add(up); + toolbarPane.add(down); + } + + private void createSortItemPane() { + String[] currentTabOrder = parentPane.getCurrentOrder(); + Map sortMap = new HashMap<>(); + for (int i = 0; i < currentTabOrder.length; i++) { + sortMap.put(currentTabOrder[i], i); + } + List sortLabels = new ArrayList<>(); + for (UICheckBox item : sortItems) { + MenuLabel label = new MenuLabel(item.getText(), (Function) o -> { + selectedLabel = o; + disableButton(); + return null; + }); + sortLabels.add(label); + } + sortLabels.sort(Comparator.comparingInt(tab -> sortMap.get(tab.getText()))); + sortItemPane = new MenuLabelPane(sortLabels); + } + + /** + * 如果选中第一个和最后一个,则置灰向上和向下的按钮 + */ + private void disableButton() { + int order = sortItemPane.getComponentZOrder(selectedLabel); + if (order == 0) { + setToolbarEnable(false, false, true, true); + } else if (order == sortItemPane.getComponentCount() - 1) { + setToolbarEnable(true, true, false, false); + } else { + setToolbarEnable(true, true, true, true); + } + } + + /** + * 设置 置顶,上移,下移,置底 按钮的状态 + * true:启用 + * false:关闭 + */ + private void setToolbarEnable(boolean top, boolean up, boolean down, boolean bottom) { + this.top.setEnabled(top); + this.up.setEnabled(up); + this.down.setEnabled(down); + this.bottom.setEnabled(bottom); + } + + private void refreshCurrentOrder() { + String[] currentTabOrder = parentPane.getCurrentOrder(); + HashSet selectedTab = new HashSet<>(); + for (UICheckBox item : sortItems) { + selectedTab.add(item.getText()); + } + + // 未选中的tab,保持原排序不变 + Map exTab = new HashMap<>(); + for (int i = 0; i < currentTabOrder.length; i++) { + if (!selectedTab.contains(currentTabOrder[i])) { + exTab.put(currentTabOrder[i], i); + } + } + + // 计算当前排序 + String[] newOrder = new String[currentTabOrder.length]; + Component[] components = sortItemPane.getComponents(); + for (String s : exTab.keySet()) { + newOrder[exTab.get(s)] = s; + } + + int t = 0; + for (int i = 0; i < newOrder.length; i++) { + if (StringUtils.isEmpty(newOrder[i])) { + newOrder[i] = ((MenuLabel) components[t++]).getText(); + } + } + parentPane.setCurrentOrder(newOrder); + } + +} diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java new file mode 100644 index 0000000000..5f3708ed97 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java @@ -0,0 +1,96 @@ +package com.fr.design.actions.help.alphafine.component; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.utils.DesignUtils; + +import javax.swing.BorderFactory; +import javax.swing.plaf.LabelUI; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.util.function.Function; + +/** + * 菜单选项label + * + * @author Link + * @version 11.0 + * Created by Link on 2022/9/18 + */ +public class MenuLabel extends UILabel { + + private static final Color BACKGROUND_COLOR = Color.white; + private static final Color SELECTED_COLOR = new Color(0x419BF9); + private static final Color HOVERED_COLOR = new Color(0xd9ebfe); + private static final int HEIGHT = 23; + private static final int WIDTH = 147; + + private MenuLabelPane parentMenu; + private final Function function; + private boolean selected; + + public MenuLabel(String text, Function function) { + super(text); + this.function = function; + setOpaque(true); + addMouseListener(createMouseListener()); + } + + public void setParentMenu(MenuLabelPane menu) { + this.parentMenu = menu; + } + + + @Override + public void setUI(LabelUI ui) { + super.setUI(ui); + this.setBackground(BACKGROUND_COLOR); + this.setBorder(BorderFactory.createEmptyBorder(2, 10, 1, 10)); + this.setPreferredSize(new Dimension(WIDTH, HEIGHT)); + this.setFont(DesignUtils.getDefaultGUIFont().applySize(12)); + } + + public boolean isSelected() { + return selected; + } + + public void setSelected(boolean selected) { + if (selected) { + parentMenu.setNoneSelected(); + setBackground(SELECTED_COLOR); + function.apply(this); + this.selected = true; + } else { + setBackground(BACKGROUND_COLOR); + this.selected = false; + } + } + + MouseListener createMouseListener() { + return new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + super.mouseClicked(e); + setSelected(true); + } + + @Override + public void mouseEntered(MouseEvent e) { + super.mouseEntered(e); + if (!selected) { + setBackground(HOVERED_COLOR); + } + } + + @Override + public void mouseExited(MouseEvent e) { + super.mouseExited(e); + if (!selected) { + setBackground(BACKGROUND_COLOR); + } + } + }; + } +} diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabelPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabelPane.java new file mode 100644 index 0000000000..929f54837c --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabelPane.java @@ -0,0 +1,34 @@ +package com.fr.design.actions.help.alphafine.component; + +import javax.swing.JPanel; +import java.awt.FlowLayout; +import java.util.List; + +/** + * 简单菜单面板 + * + * @author Link + * @version 11.0 + * Created by Link on 2022/9/18 + */ +public class MenuLabelPane extends JPanel { + + private static final int GAP = 1; + + private List labels; + + public MenuLabelPane(List labels) { + this.labels = labels; + setLayout(new FlowLayout(FlowLayout.CENTER, GAP, GAP)); + for (MenuLabel label : labels) { + label.setParentMenu(this); + add(label); + } + } + + public void setNoneSelected() { + for (MenuLabel label : labels) { + label.setSelected(false); + } + } +} diff --git a/designer-base/src/main/java/com/fr/design/actions/help/replace/ITReplaceOperator.java b/designer-base/src/main/java/com/fr/design/actions/help/replace/ITReplaceOperator.java new file mode 100644 index 0000000000..bbaaedd651 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/actions/help/replace/ITReplaceOperator.java @@ -0,0 +1,19 @@ +package com.fr.design.actions.help.replace; + + +/** + * 定义一些底层操作 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-27 + */ +public interface ITReplaceOperator { + + + /** + * 关闭面板 + */ + void close(); + +} diff --git a/designer-base/src/main/java/com/fr/design/carton/EventDispatchThreadHangMonitor.java b/designer-base/src/main/java/com/fr/design/carton/EventDispatchThreadHangMonitor.java index f472d901a1..56ccaa2c48 100644 --- a/designer-base/src/main/java/com/fr/design/carton/EventDispatchThreadHangMonitor.java +++ b/designer-base/src/main/java/com/fr/design/carton/EventDispatchThreadHangMonitor.java @@ -7,7 +7,6 @@ import com.fr.stable.ArrayUtils; import com.fr.stable.ProductConstantsBase; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; -import com.fr.third.ibm.icu.text.SimpleDateFormat; import org.jetbrains.annotations.NotNull; import javax.swing.SwingUtilities; @@ -22,6 +21,7 @@ import java.io.IOException; import java.lang.management.ManagementFactory; import java.lang.management.ThreadInfo; import java.lang.management.ThreadMXBean; +import java.text.SimpleDateFormat; import java.util.LinkedList; import java.util.Timer; import java.util.TimerTask; diff --git a/designer-base/src/main/java/com/fr/design/gui/core/WidgetOption.java b/designer-base/src/main/java/com/fr/design/gui/core/WidgetOption.java index 258f558a71..4c9db5a6a0 100644 --- a/designer-base/src/main/java/com/fr/design/gui/core/WidgetOption.java +++ b/designer-base/src/main/java/com/fr/design/gui/core/WidgetOption.java @@ -1,6 +1,7 @@ package com.fr.design.gui.core; import com.fr.base.BaseUtils; +import com.fr.base.svg.IconUtils; import com.fr.form.ui.Button; import com.fr.form.ui.CheckBox; import com.fr.form.ui.CheckBoxGroup; @@ -14,6 +15,7 @@ import com.fr.form.ui.ListEditor; import com.fr.form.ui.MultiFileEditor; import com.fr.form.ui.NumberEditor; import com.fr.form.ui.Password; +import com.fr.form.ui.PictureWidget; import com.fr.form.ui.RadioGroup; import com.fr.form.ui.TextArea; import com.fr.form.ui.TextEditor; @@ -142,7 +144,7 @@ public abstract class WidgetOption implements Serializable { */ public static WidgetOption[] getFormWidgetIntance() { return new WidgetOption[]{TEXTEDITOR, LABEL, FREEBUTTON, COMBOBOX, COMBOCHECKBOX, DATEEDITOR, - NUMBEREDITOR, TREECOMBOBOX, RADIOGROUP, CHECKBOXGROUP, TEXTAREA, PASSWORD, CHECKBOX, TREE, MULTI_FILEEDITOR}; + NUMBEREDITOR, TREECOMBOBOX, RADIOGROUP, CHECKBOXGROUP, TEXTAREA, PASSWORD, CHECKBOX, TREE, MULTI_FILEEDITOR,PICTURE}; } public static final WidgetOption DATEEDITOR = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Type_Date"), @@ -214,4 +216,7 @@ public abstract class WidgetOption implements Serializable { public static final WidgetOption IFRAMEDITOR = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Form_Iframe"), BaseUtils.readIcon("/com/fr/web/images/form/resources/iframe_16.png"), IframeEditor.class); + public static final WidgetOption PICTURE = WidgetOptionFactory.createByWidgetClass(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Widget_Type_Image"), IconUtils.readIcon("/com/fr/web/images/form/resources/picture_widget_16.png"), + PictureWidget.class); + } diff --git a/designer-base/src/main/java/com/fr/design/gui/core/WidgetOptionFactory.java b/designer-base/src/main/java/com/fr/design/gui/core/WidgetOptionFactory.java index e9ba427880..8d290ac2a8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/core/WidgetOptionFactory.java +++ b/designer-base/src/main/java/com/fr/design/gui/core/WidgetOptionFactory.java @@ -4,7 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.base.svg.IconUtils; import com.fr.form.ui.Widget; -import javax.swing.*; +import javax.swing.Icon; public class WidgetOptionFactory { diff --git a/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPaneActionProvider.java b/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPaneActionProvider.java index 525bb5b792..be0d8e8523 100644 --- a/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPaneActionProvider.java +++ b/designer-base/src/main/java/com/fr/design/gui/frpane/HyperlinkGroupPaneActionProvider.java @@ -8,6 +8,8 @@ import com.fr.design.designer.TargetComponent; */ public interface HyperlinkGroupPaneActionProvider { + String XML_TAG = "HyperlinkGroupPane"; + /** * 刷新面板展示 * diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java index 335397d908..e5f2c03ff8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java @@ -61,6 +61,14 @@ public class UIButton extends JButton implements UIObserver, UITextComponent { init(); } + public UIButton(Icon icon, boolean decorate) { + this(icon); + if (!decorate) { + setContentAreaFilled(false); + setFocusPainted(false); + setBorderPainted(false); + } + } public UIButton(Icon icon) { super(icon); @@ -397,4 +405,8 @@ public class UIButton extends JButton implements UIObserver, UITextComponent { public boolean shouldResponseChangeListener() { return true; } + + + + } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java index 6aabb9ff53..6a83a159b8 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/toolbar/ToolBarMenuDock.java @@ -60,6 +60,7 @@ import com.fr.design.menu.MenuDef; import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.ShortCut; import com.fr.design.menu.ToolBarDef; +import com.fr.design.module.DesignModuleFactory; import com.fr.design.os.impl.SupportOSImpl; import com.fr.design.remote.action.RemoteDesignAuthManagerAction; import com.fr.design.update.actions.SoftwareUpdateAction; @@ -579,6 +580,13 @@ public abstract class ToolBarMenuDock { } shortCuts.add(new AboutAction()); + try { + if (DesignModuleFactory.getITReplaceAction() != null) { + shortCuts.add((ShortCut) DesignModuleFactory.getITReplaceAction().newInstance()); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e.getMessage(), e); + } return shortCuts.toArray(new ShortCut[0]); } diff --git a/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java b/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java index 5ff882f642..bab9bb1ac8 100644 --- a/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java +++ b/designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java @@ -1,6 +1,7 @@ package com.fr.design.module; import com.fr.base.chart.BaseChartCollection; +import com.fr.design.actions.help.replace.ITReplaceOperator; import com.fr.design.gui.chart.BaseChartPropertyPane; import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartDialog; @@ -47,8 +48,10 @@ public class DesignModuleFactory { private Class autoChartDialogClass; private Class chartPropertyPaneClass; private Class newFormAction; + private Class ITReplaceAction; private Class formParaDesigner; private Class paraPropertyPane; + private static ITReplaceOperator replaceHelper; private Class formHierarchyPaneCls; private Class widgetPropertyPane; private Class buttonDetailPaneClass; @@ -69,7 +72,7 @@ public class DesignModuleFactory { @NotNull public static NameableCreator[] getCreators4Hyperlink() { - return instance.creators4Hyperlink == null? new NameableCreator[0]:instance.creators4Hyperlink; + return instance.creators4Hyperlink == null ? new NameableCreator[0] : instance.creators4Hyperlink; } public static void registerExtraWidgetOptions(WidgetOption[] options) { @@ -117,6 +120,35 @@ public class DesignModuleFactory { return instance.newFormAction; } + /** + * 注册一下查找替换 + * + * @param r + */ + public static void registerReplaceActionClass(Class r) { + instance.ITReplaceAction = r; + } + + public static Class getITReplaceAction() { + return instance.ITReplaceAction; + } + + /** + * 注册一下查找替换面板 + * @param + */ + public static void registerReplace(ITReplaceOperator replace) { + replaceHelper = replace; + } + + /** + * 获取查找替换面板的操作类 + * @return + */ + public static ITReplaceOperator getReplaceOperator() { + return replaceHelper; + } + public static void registerParaPropertyPaneClass(Class p) { instance.paraPropertyPane = p; } diff --git a/designer-base/src/main/java/com/fr/design/remote/button/IconButton.java b/designer-base/src/main/java/com/fr/design/remote/button/IconButton.java index 598ec7f057..d2d04b8d4c 100644 --- a/designer-base/src/main/java/com/fr/design/remote/button/IconButton.java +++ b/designer-base/src/main/java/com/fr/design/remote/button/IconButton.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.StringUtils; +import javax.swing.Icon; import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JPanel; @@ -15,14 +16,19 @@ import java.awt.Graphics2D; import java.awt.Point; public final class IconButton extends JButton { - public IconButton() { + + public IconButton(Icon icon) { super(StringUtils.EMPTY); setContentAreaFilled(false); setFocusPainted(false); - setIcon(BaseUtils.readIcon("com/fr/design/remote/images/icon_tab_close_normal.png")); + setIcon(icon); setBorder(null); } + public IconButton() { + this(BaseUtils.readIcon("com/fr/design/remote/images/icon_tab_close_normal.png")); + } + @Override protected void paintBorder(Graphics g) { } diff --git a/designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java b/designer-base/src/main/java/com/fr/design/report/SelectImagePane.java similarity index 96% rename from designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java rename to designer-base/src/main/java/com/fr/design/report/SelectImagePane.java index bcad15c76c..7781233aac 100644 --- a/designer-realize/src/main/java/com/fr/design/report/SelectImagePane.java +++ b/designer-base/src/main/java/com/fr/design/report/SelectImagePane.java @@ -13,22 +13,24 @@ import com.fr.report.cell.Elem; import com.fr.report.cell.cellattr.CellImage; import com.fr.report.cell.painter.CellImagePainter; import com.fr.stable.Constants; - -import javax.swing.BorderFactory; -import javax.swing.ButtonGroup; -import javax.swing.JFileChooser; -import javax.swing.JPanel; -import javax.swing.JScrollPane; import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.Image; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JFileChooser; +import javax.swing.JPanel; +import javax.swing.JScrollPane; /** - * 这个类主要用于插入图片时的设置 - */ + *

这个类主要用于插入图片时的设置

+ *

这个类原本在designer-realize包下面,现在表单也可选择图片,所以应该抽为公用的base包。包名不变,应该不影响插件使用

+ * + * @author Jimmy.Zheng created on 2022/8/11 21:22 + **/ public class SelectImagePane extends BasicPane { private ImagePreviewPane previewPane = null; @@ -39,8 +41,31 @@ public class SelectImagePane extends BasicPane { private UIRadioButton adjustRadioButton = null; private Style imageStyle = null; + ActionListener layoutActionListener = new ActionListener() { + @Override + public void actionPerformed(ActionEvent evt) { + setImageStyle(); + changeImageStyle(); + } + }; private File imageFile; + /** + * Select picture. + */ + ActionListener selectPictureActionListener = new ActionListener() { + + @Override + public void actionPerformed(ActionEvent evt) { + int returnVal = imageFileChooser + .showOpenDialog(SelectImagePane.this); + if (returnVal != JFileChooser.CANCEL_OPTION) { + File selectedFile = imageFileChooser.getSelectedFile(); + imageFile = selectedFile; + ImgChooseWrapper.getInstance(previewPane, imageFileChooser, imageStyle, null).dealWithImageFile(returnVal); + } + } + }; public SelectImagePane() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); @@ -102,23 +127,6 @@ public class SelectImagePane extends BasicPane { imageFileChooser.setMultiSelectionEnabled(false); } - /** - * Select picture. - */ - ActionListener selectPictureActionListener = new ActionListener() { - - @Override - public void actionPerformed(ActionEvent evt) { - int returnVal = imageFileChooser - .showOpenDialog(SelectImagePane.this); - if (returnVal != JFileChooser.CANCEL_OPTION) { - File selectedFile = imageFileChooser.getSelectedFile(); - imageFile = selectedFile; - ImgChooseWrapper.getInstance(previewPane, imageFileChooser, imageStyle, null).dealWithImageFile(returnVal); - } - } - }; - // 调整图片样式,只有水平和垂直对齐以及拉伸。相对于背景,平铺不予考虑。 private void changeImageStyle() { previewPane.setImageStyle(this.imageStyle); @@ -137,15 +145,6 @@ public class SelectImagePane extends BasicPane { } } - ActionListener layoutActionListener = new ActionListener() { - - @Override - public void actionPerformed(ActionEvent evt) { - setImageStyle(); - changeImageStyle(); - } - }; - @Override protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Image"); diff --git a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java index f15de856e9..0a0cdb4aac 100644 --- a/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java +++ b/designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java @@ -162,6 +162,7 @@ public class StartupPageWindow extends JFrame { revalidate(); setFullScreen(); + } private void setFullScreen() { diff --git a/designer-base/src/main/resources/com/fr/design/images/buttonicon/widget/picture_widget_16.png b/designer-base/src/main/resources/com/fr/design/images/buttonicon/widget/picture_widget_16.png new file mode 100644 index 0000000000..fbf334ad22 Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/buttonicon/widget/picture_widget_16.png differ diff --git a/designer-base/src/main/resources/com/fr/design/images/form/designer/widget/picture_widget_designer_bg.png b/designer-base/src/main/resources/com/fr/design/images/form/designer/widget/picture_widget_designer_bg.png new file mode 100644 index 0000000000..9e731c557b Binary files /dev/null and b/designer-base/src/main/resources/com/fr/design/images/form/designer/widget/picture_widget_designer_bg.png differ diff --git a/designer-form/src/main/java/com/fr/design/actions/NewFormAction.java b/designer-form/src/main/java/com/fr/design/actions/NewFormAction.java index 5ce51b673c..aa50c13f69 100644 --- a/designer-form/src/main/java/com/fr/design/actions/NewFormAction.java +++ b/designer-form/src/main/java/com/fr/design/actions/NewFormAction.java @@ -43,7 +43,7 @@ public class NewFormAction extends UpdateAction { @Override public KeyStroke getKeyStroke() { - return KeyStroke.getKeyStroke(KeyEvent.VK_F, DEFAULT_MODIFIER); + return null; } }; } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java index 997af89c70..f75e08d723 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java @@ -131,6 +131,29 @@ public class SelectionModel { } } + /** + * 用于强制定位所需组件,不对布局组件的顶层布局进行编辑判定,即使上层未展开或者未处于编辑状态依然可以强制跳转到对应的子组件 + * @param comp 设计组件 + */ + public void selectACreator4ITLocation(XCreator comp) { + // 如果父层是scale和title两个专属容器,返回其父层,组件本身是不让被选中的 + if (comp != designer.getRootComponent() && comp != designer.getParaComponent()) { + dealParentContainer(comp); + } + if (selection.removeSelectedCreator(comp) || selection.addSelectedCreator(comp)) { + designer.getEditListenerTable().fireCreatorModified(comp, DesignerEvent.CREATOR_SELECTED); + designer.repaint(); + } + } + + private void dealParentContainer(XCreator comp) { + XCreator parentContainer = (XCreator) comp.getParent(); + if (parentContainer != null) { + comp = parentContainer.isDedicateContainer() || comp instanceof XCardSwitchButton ? parentContainer : comp; + } + + } + /** * 将所选组件剪切到剪切板上 */ diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java index eb1f3497a3..1ebd19ec3d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XCreatorUtils.java @@ -4,6 +4,7 @@ package com.fr.design.designer.creator; import com.fr.base.chart.BaseChartCollection; +import com.fr.base.svg.IconUtils; import com.fr.base.theme.FineColorSynchronizer; import com.fr.base.theme.FormTheme; import com.fr.base.theme.TemplateTheme; @@ -18,6 +19,7 @@ import com.fr.design.designer.creator.cardlayout.XWCardTagLayout; import com.fr.design.designer.creator.cardlayout.XWCardTitleLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.fit.common.TemplateTool; import com.fr.design.fun.ChartWidgetOptionProvider; import com.fr.design.fun.FormWidgetOptionProvider; import com.fr.design.fun.ParameterWidgetOptionProvider; @@ -38,6 +40,7 @@ import com.fr.form.ui.ComboCheckBox; import com.fr.form.ui.DateEditor; import com.fr.form.ui.EditorHolder; import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.FieldEditor; import com.fr.form.ui.FileEditor; import com.fr.form.ui.FreeButton; import com.fr.form.ui.IframeEditor; @@ -46,10 +49,12 @@ import com.fr.form.ui.MultiFileEditor; import com.fr.form.ui.NameWidget; import com.fr.form.ui.NumberEditor; import com.fr.form.ui.Password; +import com.fr.form.ui.PictureWidget; import com.fr.form.ui.Radio; import com.fr.form.ui.RadioGroup; import com.fr.form.ui.TextArea; import com.fr.form.ui.TextEditor; +import com.fr.form.ui.ToggleButton; import com.fr.form.ui.TreeComboBoxEditor; import com.fr.form.ui.TreeEditor; import com.fr.form.ui.Widget; @@ -71,7 +76,6 @@ import com.fr.form.ui.container.cardlayout.WCardTitleLayout; import com.fr.form.ui.container.cardlayout.WTabFitLayout; import com.fr.general.ComparatorUtils; import com.fr.general.GeneralContext; -import com.fr.general.IOUtils; import com.fr.invoke.Reflect; import com.fr.log.FineLoggerFactory; import com.fr.plugin.context.PluginContext; @@ -84,13 +88,13 @@ import com.fr.report.fit.ReportFitAttr; import com.fr.report.fit.ReportFitConfig; import com.fr.stable.StringUtils; import com.fr.third.javax.annotation.Nonnull; -import java.util.Set; import org.jetbrains.annotations.Nullable; import javax.swing.Icon; import java.awt.Container; import java.awt.Dimension; import java.util.List; +import java.util.Set; /** * XCreator的相关处理 @@ -183,6 +187,7 @@ public class XCreatorUtils { objectMap.put(CardSwitchButton.class, XCardSwitchButton.class); objectMap.put(CardAddButton.class, XCardAddButton.class); objectMap.put(WidgetErrorMarker.class, ErrorCreator.class); + objectMap.put(PictureWidget.class, XPicture.class); } private static void reInitExtra() { @@ -236,14 +241,30 @@ public class XCreatorUtils { } public static XCreator createThemedXCreator(Widget widget) { + JTemplate template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); TemplateTheme theme = template.getTemplateTheme(); if (theme instanceof FormTheme) { widget = setupTemplateTheme(widget, true, (FormTheme) theme, TemplateThemeCompatible.NONE); } + if (TemplateTool.isCurrentEditingNewJForm()){ + resetWidgetDefaultProperty(widget); + } return createXCreator(widget); } + /** + * 新表单下控件的字体默认都为9pt + * @param widget 控件 + */ + private static void resetWidgetDefaultProperty(Widget widget) { + if (widget.acceptType(FieldEditor.class)) { + ((FieldEditor) widget).setFontSize(Widget.DEFAULT_FONT_PT_SIZE); + } else if (widget.acceptType(ToggleButton.class)) { + ((ToggleButton) widget).setFontSize(Widget.DEFAULT_FONT_PT_SIZE); + } + } + /** * 创建creator * @@ -361,7 +382,7 @@ public class XCreatorUtils { if (StringUtils.isEmpty(iconPath)) { return null; } - return IOUtils.readIcon(iconPath); + return IconUtils.readIcon(iconPath); } public static boolean containComponent(Container ancestor, Container xCreator) { diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XPicture.java b/designer-form/src/main/java/com/fr/design/designer/creator/XPicture.java new file mode 100644 index 0000000000..7dd23bd4ce --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XPicture.java @@ -0,0 +1,74 @@ +package com.fr.design.designer.creator; + +import com.fr.design.designer.ui.ImgPanel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.widget.editors.PictureEditor; +import com.fr.design.mainframe.widget.editors.UrlLinkEditor; +import com.fr.design.mainframe.widget.renderer.PictureRenderer; +import com.fr.design.mainframe.widget.renderer.UrlLinkRenderer; +import com.fr.form.ui.PictureWidget; +import com.fr.general.IOUtils; +import com.fr.stable.ArrayUtils; +import java.awt.Dimension; +import java.awt.Image; +import java.beans.IntrospectionException; +import javax.swing.JComponent; + +/** +* +*

图片控件的creator

+* +* @author Jimmy.Zheng created on 2022/8/11 21:16 +**/ +public class XPicture extends XWidgetCreator { + + public XPicture(PictureWidget widget, Dimension dimension) { + super(widget, dimension); + } + + @Override + protected String getIconName() { + return "picture_widget_16.png"; + } + + @Override + public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException { + return (CRPropertyDescriptor[]) ArrayUtils.addAll(super.supportedDescriptor(), new CRPropertyDescriptor[]{ + new CRPropertyDescriptor("picUrl", toData().getClass()) + .setI18NName(Toolkit.i18nText("Fine-Design_Basic_Widget_Type_Image")) + .setEditorClass(PictureEditor.class) + .setRendererClass(PictureRenderer.class) + .putKeyValue("category", "Fine-Design_Basic_Advanced"), + new CRPropertyDescriptor("urlLink", toData().getClass()) + .setI18NName(Toolkit.i18nText("Fine-Design_Basic_Hyperlink")) + .setEditorClass(UrlLinkEditor.class) + .setRendererClass(UrlLinkRenderer.class) + .putKeyValue( + "category", "Fine-Design_Basic_Advanced")}); + } + + @Override + protected JComponent initEditor() { + PictureWidget pictureWidget = (PictureWidget) this.data; + if (this.editor == null) { + this.editor = FRGUIPaneFactory.createBorderLayout_S_Pane(); + Object value = pictureWidget.getPicUrl().getValue(); + ImgPanel imgPanel = new ImgPanel(); + if (value instanceof Image) { + imgPanel.setBackgroundImage((Image) value); + imgPanel.setImageDisplayMode(pictureWidget.getShowType()); + } else { + imgPanel.setBackgroundImage(IOUtils.readImage("com/fr/design/images/form/designer/widget/picture_widget_designer_bg.png")); + imgPanel.setImageDisplayMode(0); + } + this.editor.add(imgPanel, "Center"); + } + return this.editor; + } + + @Override + public boolean canEnterIntoParaPane() { + return false; + } +} diff --git a/designer-form/src/main/java/com/fr/design/designer/ui/ImgPanel.java b/designer-form/src/main/java/com/fr/design/designer/ui/ImgPanel.java new file mode 100644 index 0000000000..1c17c56c34 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/designer/ui/ImgPanel.java @@ -0,0 +1,113 @@ +package com.fr.design.designer.ui; + +import com.fr.general.ImageWithSuffix; +import com.fr.stable.Constants; +import java.awt.Graphics; +import java.awt.Image; +import javax.swing.JComponent; + + +/** + *

图片控件中的已选图片展示面板

+ * + * @author Jimmy.Zheng created on 2022/8/11 21:17 + **/ +public class ImgPanel extends JComponent { + private static final long serialVersionUID = 1L; + private Image backgroundImage; + private int imageDisplayMode; + private int modeIndex; + + public ImgPanel() { + this(null, 0); + } + + public ImgPanel(Image image, int modeName) { + setBackgroundImage(image); + setImageDisplayMode(modeName); + } + + public Image getBackgroundImage() { + return this.backgroundImage; + } + + public void setBackgroundImage(Image image) { + this.backgroundImage = image; + repaint(); + } + + public int getImageDisplayMode() { + return this.imageDisplayMode; + } + + public void setImageDisplayMode(int modeName) { + switch (modeName) { + case Constants.IMAGE_CENTER: + this.modeIndex = 0; + break; + case Constants.IMAGE_TILED: + this.imageDisplayMode = 0; + this.modeIndex = 1; + break; + case Constants.IMAGE_EXTEND: + this.imageDisplayMode = 2; + this.modeIndex = 2; + break; + case Constants.IMAGE_ADJUST: + this.imageDisplayMode = 4; + this.modeIndex = 3; + break; + default: + } + repaint(); + } + + @Override + protected void paintComponent(Graphics g) { + super.paintComponent(g); + + if (this.backgroundImage != null) { + if (this.backgroundImage instanceof ImageWithSuffix) { + this.backgroundImage = ((ImageWithSuffix) backgroundImage).getImage(); + } + int width = getWidth(); + int height = getHeight(); + int imageWidth = this.backgroundImage.getWidth(this); + int imageHeight = this.backgroundImage.getHeight(this); + + switch (this.modeIndex) { + case 0: + int x = (width - imageWidth) / 2; + int y = (height - imageHeight) / 2; + g.drawImage(this.backgroundImage, x, y, this); + break; + case 1: + for (int ix = 0; ix < width; ix += imageWidth) { + for (int iy = 0; iy < height; iy += imageHeight) { + g.drawImage(this.backgroundImage, ix, iy, this); + } + } + + break; + case 2: + g.drawImage(this.backgroundImage, 0, 0, width, height, this); + break; + case 3: + double sx = 1.0 * width / imageWidth; + double sy = 1.0 * height / imageHeight; + + if (sx > sy) { + sx = sy; + width = (int) (sx * imageWidth); + } else { + sy = sx; + height = (int) (sy * imageHeight); + } + int xx = (getWidth() - width) / 2; + int yy = (getHeight() - height) / 2; + g.drawImage(this.backgroundImage, xx, yy, width, height, this); + default: + } + } + } +} diff --git a/designer-form/src/main/java/com/fr/design/fit/NewJForm.java b/designer-form/src/main/java/com/fr/design/fit/NewJForm.java index 314097bcf1..62c38ca22d 100644 --- a/designer-form/src/main/java/com/fr/design/fit/NewJForm.java +++ b/designer-form/src/main/java/com/fr/design/fit/NewJForm.java @@ -243,7 +243,7 @@ public class NewJForm extends JForm { return; } if (xCreator instanceof XElementCase) { - getFormDesign().getSelectionModel().selectACreator(xCreator); + getFormDesign().getSelectionModel().selectACreator4ITLocation(xCreator); xCreator.startEditing(); if (getElementCaseDesign() != null) { getElementCaseDesign().navigate(trl); @@ -251,7 +251,7 @@ public class NewJForm extends JForm { } else { tabChanged(FORM_TAB); getFormDesign().getSelectionModel().reset(); - getFormDesign().getSelectionModel().selectACreator(xCreator); + getFormDesign().getSelectionModel().selectACreator4ITLocation(xCreator); } }, XCreator.class); } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessiblePictureModelEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessiblePictureModelEditor.java new file mode 100644 index 0000000000..9e72b5c2ac --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessiblePictureModelEditor.java @@ -0,0 +1,77 @@ +package com.fr.design.mainframe.widget.accessibles; + +import com.fr.base.Style; +import com.fr.design.DesignModelAdapter; +import com.fr.design.designer.creator.XPicture; +import com.fr.design.designer.ui.ImgPanel; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.WidgetPropertyPane; +import com.fr.design.mainframe.widget.wrappers.PictureModelWrapper; +import com.fr.design.report.SelectImagePane; +import com.fr.form.ui.PictureWidget; +import com.fr.general.ComparatorUtils; +import com.fr.report.cell.FloatElement; +import com.fr.report.cell.cellattr.CellImage; +import javax.swing.JComponent; + + +/** +* +*

图片控件的图片选择、编辑器

+* +* @author Jimmy.Zheng created on 2022/8/11 21:13 +**/ +public class AccessiblePictureModelEditor extends UneditableAccessibleEditor { + protected FloatElement element = new FloatElement(); + private PictureWidget pic; + + public AccessiblePictureModelEditor(PictureWidget pic) { + super(new PictureModelWrapper()); + this.pic = pic; + } + + @Override + public FloatElement getValue() { + return (FloatElement) super.getValue(); + } + + @Override + protected void showEditorPane() { + final SelectImagePane imageEditorPane = new SelectImagePane(); + if (super.getValue() != null) { + this.element = ((FloatElement) super.getValue()); + } + this.element.setStyle(Style.getInstance().deriveImageLayout(this.pic.getShowType())); + imageEditorPane.populate(this.element); + final Object oldValue = this.element.getValue(); + final Style oldStyle = this.element.getStyle(); + final String oldname = this.element.getName(); + imageEditorPane.showWindow(DesignerContext.getDesignerFrame(), new DialogActionAdapter() { + @Override + public void doOk() { + CellImage cellImage = imageEditorPane.update(); + if ((!ComparatorUtils.equals(cellImage.getImage(), oldValue)) || (!ComparatorUtils.equals(cellImage.getStyle(), oldStyle))) { + AccessiblePictureModelEditor.this.element.setValue(cellImage.getImage()); + AccessiblePictureModelEditor.this.element.setStyle(cellImage.getStyle()); + AccessiblePictureModelEditor.this.element.setName(imageEditorPane.getSelectedImage() == null ? oldname : imageEditorPane.getSelectedImage().toString()); + AccessiblePictureModelEditor.this.setValue(AccessiblePictureModelEditor.this.element); + AccessiblePictureModelEditor.this.pic.setShowType(cellImage.getStyle().getImageLayout()); + AccessiblePictureModelEditor.this.pic.setPicUrl(element); + ImgPanel p = AccessiblePictureModelEditor.this.getCurrentImgPanel(); + p.setBackgroundImage(cellImage.getBufferImage()); + p.setImageDisplayMode(cellImage.getStyle().getImageLayout()); + AccessiblePictureModelEditor.this.fireStateChanged(); + DesignModelAdapter d = DesignModelAdapter.getCurrentModelAdapter(); + d.fireTargetModified(); + } + } + }).setVisible(true); + } + + private ImgPanel getCurrentImgPanel() { + XPicture xPicture = (XPicture) WidgetPropertyPane.getInstance().getEditingFormDesigner().getSelectionModel().getSelection().getSelectedCreator(); + JComponent editor = (JComponent) xPicture.getComponent(0); + return (ImgPanel) editor.getComponent(0); + } +} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleUrlLinkModelEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleUrlLinkModelEditor.java new file mode 100644 index 0000000000..2dd4b54991 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/accessibles/AccessibleUrlLinkModelEditor.java @@ -0,0 +1,57 @@ +package com.fr.design.mainframe.widget.accessibles; + +import com.fr.design.DesignModelAdapter; +import com.fr.design.dialog.BasicDialog; +import com.fr.design.dialog.DialogActionAdapter; +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; +import com.fr.design.gui.xpane.FormHyperlinkGroupPane; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.widget.wrappers.UrlLinkModelWrapper; +import com.fr.js.NameJavaScriptGroup; +import com.fr.stable.bridge.StableFactory; + +/** + *

表单图片控件的链接编辑器

+ * @author Jimmy + */ +public class AccessibleUrlLinkModelEditor extends UneditableAccessibleEditor { + private FormHyperlinkGroupPane hyperlinkPane; + + public AccessibleUrlLinkModelEditor() { + super(new UrlLinkModelWrapper()); + } + /** + * 原插件使用 + *

DesignerContext.getDesignerFrame().getSelectedJTemplate().getHyperLinkPaneNoPop( + * HyperlinkGroupPaneActionImpl.getInstance()));

获取{@see this.hyperlinkPane} + * 合并插件依赖不到,换种方式 用{@see DesignerActivator将实例注册了} + */ + @Override + protected void showEditorPane() { + if (this.hyperlinkPane == null) { + HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider = StableFactory.getMarkedInstanceObjectFromClass(HyperlinkGroupPaneActionProvider.XML_TAG,HyperlinkGroupPaneActionProvider.class); + this.hyperlinkPane = (FormHyperlinkGroupPane) DesignerContext.getDesignerFrame().getSelectedJTemplate().getHyperLinkPaneNoPop( + hyperlinkGroupPaneActionProvider); + } + BasicDialog dialog = this.hyperlinkPane.showWindow(DesignerContext.getDesignerFrame()); + dialog.addDialogActionListener(new DialogActionAdapter() { + @Override + public void doOk() { + super.doOk(); + NameJavaScriptGroup hyperlinks = AccessibleUrlLinkModelEditor.this.hyperlinkPane.updateJSGroup(); + AccessibleUrlLinkModelEditor.this.setValue(hyperlinks); + AccessibleUrlLinkModelEditor.this.fireStateChanged(); + DesignModelAdapter d = DesignModelAdapter.getCurrentModelAdapter(); + d.fireTargetModified(); + } + }); + this.hyperlinkPane.populate(getValue()); + + dialog.setVisible(true); + } + + @Override + public NameJavaScriptGroup getValue() { + return (NameJavaScriptGroup) super.getValue(); + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/PictureEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/PictureEditor.java new file mode 100644 index 0000000000..c7bbff80a3 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/PictureEditor.java @@ -0,0 +1,17 @@ +package com.fr.design.mainframe.widget.editors; + +import com.fr.design.mainframe.widget.accessibles.AccessiblePictureModelEditor; +import com.fr.design.mainframe.widget.accessibles.AccessiblePropertyEditor; +import com.fr.form.ui.PictureWidget; +/** +* +*

图片控件的图片选择、编辑器

+* +* @author Jimmy.Zheng created on 2022/8/11 21:15 +**/ +public class PictureEditor extends AccessiblePropertyEditor { + + public PictureEditor(Object o) { + super(new AccessiblePictureModelEditor((PictureWidget) o)); + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/UrlLinkEditor.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/UrlLinkEditor.java new file mode 100644 index 0000000000..195e8f5250 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/editors/UrlLinkEditor.java @@ -0,0 +1,17 @@ +package com.fr.design.mainframe.widget.editors; + +import com.fr.design.mainframe.widget.accessibles.AccessiblePropertyEditor; +import com.fr.design.mainframe.widget.accessibles.AccessibleUrlLinkModelEditor; + +/** +* +*

图片控件的链接编辑器

+* +* @author Jimmy.Zheng created on 2022/8/11 21:19 +**/ +public class UrlLinkEditor extends AccessiblePropertyEditor { + + public UrlLinkEditor() { + super(new AccessibleUrlLinkModelEditor()); + } +} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/renderer/PictureRenderer.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/renderer/PictureRenderer.java new file mode 100644 index 0000000000..82fcc85b43 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/renderer/PictureRenderer.java @@ -0,0 +1,15 @@ +package com.fr.design.mainframe.widget.renderer; + +import com.fr.design.mainframe.widget.wrappers.PictureModelWrapper; + +/** + *

图片控件的图片编辑器的EncoderCellRenderer

+ * + * @author Jimmy.Zheng created on 2022/8/11 21:29 + **/ +public class PictureRenderer extends EncoderCellRenderer { + + public PictureRenderer() { + super(new PictureModelWrapper()); + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/renderer/UrlLinkRenderer.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/renderer/UrlLinkRenderer.java new file mode 100644 index 0000000000..a81187d2d5 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/renderer/UrlLinkRenderer.java @@ -0,0 +1,16 @@ +package com.fr.design.mainframe.widget.renderer; + + +import com.fr.design.mainframe.widget.wrappers.UrlLinkModelWrapper; + +/** + *

图片控件的链接编辑器的EncoderCellRenderer

+ * + * @author Jimmy.Zheng created on 2022/8/11 21:29 + **/ +public class UrlLinkRenderer extends EncoderCellRenderer { + + public UrlLinkRenderer() { + super(new UrlLinkModelWrapper()); + } +} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/wrappers/PictureModelWrapper.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/wrappers/PictureModelWrapper.java new file mode 100644 index 0000000000..ed9fd0a4ac --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/wrappers/PictureModelWrapper.java @@ -0,0 +1,34 @@ +package com.fr.design.mainframe.widget.wrappers; + +import com.fr.design.Exception.ValidationException; +import com.fr.design.designer.properties.Decoder; +import com.fr.design.designer.properties.Encoder; +import com.fr.report.cell.FloatElement; +import com.fr.stable.StringUtils; + +/** + *

图片选择器 {@link com.fr.design.mainframe.widget.accessibles.AccessiblePictureModelEditor}的 Wrapper

+ *

插件中直接移入,未作改动

+ * + * @author Jimmy.Zheng created on 2022/8/11 21:25 + **/ +public class PictureModelWrapper implements Encoder, Decoder { + + @Override + public FloatElement decode(String txt) { + return null; + } + + @Override + public void validate(String txt) throws ValidationException { + // do nothing + } + + @Override + public String encode(FloatElement v) { + if (v != null) { + return v.getName(); + } + return StringUtils.EMPTY; + } +} diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/wrappers/UrlLinkModelWrapper.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/wrappers/UrlLinkModelWrapper.java new file mode 100644 index 0000000000..a892065ad7 --- /dev/null +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/wrappers/UrlLinkModelWrapper.java @@ -0,0 +1,33 @@ +package com.fr.design.mainframe.widget.wrappers; + +import com.fr.design.Exception.ValidationException; +import com.fr.design.designer.properties.Decoder; +import com.fr.design.designer.properties.Encoder; +import com.fr.js.NameJavaScriptGroup; + +/** + *

链接选择器 {@link com.fr.design.mainframe.widget.accessibles.AccessibleUrlLinkModelEditor}的 Wrapper

+ *

插件中直接移入,未作改动

+ * + * @author Jimmy.Zheng created on 2022/8/11 21:28 + **/ +public class UrlLinkModelWrapper implements Encoder, Decoder { + + @Override + public NameJavaScriptGroup decode(String txt) { + return null; + } + + @Override + public void validate(String txt) throws ValidationException { + // do nothing + } + + @Override + public String encode(NameJavaScriptGroup v) { + if (v.size() > 0) { + return v.getNameHyperlink(0).getName(); + } + return null; + } +} \ No newline at end of file diff --git a/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java b/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java index 69e514b408..176c44fe01 100644 --- a/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java +++ b/designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java @@ -6,6 +6,7 @@ import com.fr.design.fun.impl.AbstractPreviewProvider; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JTemplate; +import com.fr.design.module.DesignModuleFactory; import com.fr.design.worker.WorkerManager; import com.fr.design.worker.save.CallbackSaveWorker; import com.fr.general.web.ParameterConstants; @@ -47,6 +48,8 @@ public class DeveloperPreview extends AbstractPreviewProvider { @Override public void onClick(JTemplate jt) { super.onClick(jt); + //进入时要关闭查找替换面板 + DesignModuleFactory.getReplaceOperator().close(); SwingWorker worker = WorkerManager.getInstance().getWorker(jt.getRuntimeId()); if (worker instanceof CallbackSaveWorker) { CallbackSaveWorker callbackSaveWorker = (CallbackSaveWorker) worker; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ITReplaceAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ITReplaceAction.java new file mode 100644 index 0000000000..358dc19652 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ITReplaceAction.java @@ -0,0 +1,64 @@ +package com.fr.design.actions.replace; + +import com.fr.design.actions.UpdateAction; +import com.fr.design.dialog.UIDialog; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.i18n.Toolkit; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.menu.MenuKeySet; +import com.fr.design.actions.replace.ui.ITReplaceMainDialog; +import com.fr.design.utils.gui.GUICoreUtils; + +import javax.swing.*; +import java.awt.event.ActionEvent; +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; + +import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; + +/** + * 将全局查找替换选项插入帮助菜单底部 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-10 + */ +public class ITReplaceAction extends UpdateAction { + public ITReplaceAction() { + this.setMenuKeySet(IT_REPLACE); + this.setName(getMenuKeySet().getMenuName()); + this.setMnemonic(getMenuKeySet().getMnemonic()); + this.setAccelerator(getMenuKeySet().getKeyStroke()); + } + + private static final MenuKeySet IT_REPLACE = new MenuKeySet() { + @Override + public char getMnemonic() { + return 'I'; + } + + @Override + public String getMenuName() { + return Toolkit.i18nText("Fine-Design_Replace_Title"); + } + + @Override + public KeyStroke getKeyStroke() { + return KeyStroke.getKeyStroke(KeyEvent.VK_F, DEFAULT_MODIFIER); + } + }; + + /** + * 点击选项后的行为 + * + * @param event + */ + public void actionPerformed(ActionEvent event) { + ITReplaceMainDialog mainFrame = ITReplaceMainDialog.getInstance(); + mainFrame.fitScreen(); + mainFrame.setVisible(true); + + } + +} + diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchAction.java new file mode 100644 index 0000000000..7cce5087ea --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchAction.java @@ -0,0 +1,23 @@ +package com.fr.design.actions.replace.action; + +import com.fr.design.mainframe.JTemplate; + + +/** + * 顶层行为接口 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-11 + */ +public interface SearchAction { + + /** + * 搜索模板,获取信息列表 + * + * @param jTemplate 指定搜索的模板 + */ + default void search4Infos(JTemplate jTemplate) { + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchManager.java new file mode 100644 index 0000000000..c5acd2ec79 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchManager.java @@ -0,0 +1,30 @@ +package com.fr.design.actions.replace.action; + +/** + * 管理搜索元素的注册与注销 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-16 + */ +public interface SearchManager { + + /** + * 注册搜索行为 + * @param tag + * @param searchAction + */ + void registerAction(String tag , SearchAction searchAction); + + /** + * 根据tag注销搜索行为 + * @param tag + */ + default void removeAction(String tag){}; + + /** + * 根据行为注销指定的搜索行为 + * @param searchAction + */ + default void removeAction(SearchAction searchAction){}; +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchManagerCenter.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchManagerCenter.java new file mode 100644 index 0000000000..0608bde483 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchManagerCenter.java @@ -0,0 +1,211 @@ +package com.fr.design.actions.replace.action; + +import com.fr.design.actions.replace.action.content.formula.cell.SearchCellFormulaManager; +import com.fr.design.actions.replace.action.content.formula.highlight.SearchHighlightFormulaManager; +import com.fr.design.actions.replace.action.content.formula.highlight.condition.SearchConditionManager; +import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSFormulaManager; +import com.fr.design.actions.replace.action.content.formula.widget.SearchWidgetFormulaManager; + +import com.fr.design.actions.replace.action.content.js.SearchJSManager; + +import org.jetbrains.annotations.Nullable; + +/** + * 管理各个管理类的注入的管理中心 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-16 + */ +public class SearchManagerCenter { + public static final int CELL_FORMULA = 0; + public static final int CONDITION_FORMULA = 1; + public static final int JS_FORMULA = 2; + public static final int HIGHLIGHT_FORMULA = 3; + public static final int WIDGET_FORMULA = 4; + public static final int JS = 5; + + private SearchManagerCenter() { + } + + /** + * 注册 + * + * @param index 指定类型编号 + * @param tag 类名称 + * @param searchAction 对应搜索行为 + */ + public void register(int index, String tag, SearchAction searchAction) { + ManagerType managerType = ManagerType.match(index); + if (managerType != null) { + managerType.registerAction(tag, searchAction); + } + } + + /** + * 注销 + * + * @param index 指定类型编号 + * @param tag 类名称 + */ + public void remove(int index, String tag) { + ManagerType managerType = ManagerType.match(index); + if (managerType != null) { + managerType.removeAction(tag); + } + } + + + /** + * 管理类的类型 + */ + public enum ManagerType implements SearchManager { + /** + * 注册单元格不同值类型中自己特有的公式(数据列、子报表、公式,可自己添加) + */ + CELL_FORMULA(0) { + @Override + public void registerAction(String tag, SearchAction searchAction) { + SearchCellFormulaManager.getInstance().registerAction(tag, searchAction); + } + + @Override + public void removeAction(String tag) { + SearchCellFormulaManager.getInstance().removeAction(tag); + } + }, + /** + * 注册条件属性中的公式(公式类型的条件属性、包装了一个比较器作为条件的条件对象、组合条件,用多个AND或者OR连接起来的条件组成的对象、简单比较的条件、可自己添加) + */ + CONDITION_FORMULA(1) { + @Override + public void registerAction(String tag, SearchAction searchAction) { + SearchConditionManager.getInstance().registerAction(tag, searchAction); + } + + @Override + public void removeAction(String tag) { + SearchConditionManager.getInstance().removeAction(tag); + } + }, + /** + * 注冊超链类型中的自己特有的公式(提交入库、导出事件、移动端弹窗、可自己添加) + * 其他类型的超链都只有参数部分会存在公式,属于公有,统一处理 + */ + JS_FORMULA(2) { + @Override + public void registerAction(String tag, SearchAction searchAction) { + SearchJSFormulaManager.getInstance().registerAction(tag, searchAction); + } + + @Override + public void removeAction(String tag) { + SearchJSFormulaManager.getInstance().removeAction(tag); + } + }, + /** + * 注册条件属性中自己特有的公式(超级链接、控件、... 可自己添加) + */ + HIGHLIGHT_FORMULA(3) { + @Override + public void registerAction(String tag, SearchAction searchAction) { + SearchHighlightFormulaManager.getInstance().registerAction(tag, searchAction); + } + + @Override + public void removeAction(String tag) { + SearchHighlightFormulaManager.getInstance().removeAction(tag); + } + }, + + /** + * 注册不同控件中的公式(非树形数据字典、树形数据字典、无数据字典、可自己添加) + */ + WIDGET_FORMULA(4) { + @Override + public void registerAction(String tag, SearchAction searchAction) { + SearchWidgetFormulaManager.getInstance().registerAction(tag, searchAction); + } + + @Override + public void removeAction(String tag) { + SearchWidgetFormulaManager.getInstance().removeAction(tag); + } + }, + /** + * 注册获取JS的场景(当前:控件、单元格、模板Web属性、悬浮元素、可自行添加) + */ + JS(5) { + @Override + public void registerAction(String tag, SearchAction searchAction) { + SearchJSManager.getInstance().registerAction(tag, searchAction); + } + + @Override + public void removeAction(SearchAction searchAction) { + SearchJSManager.getInstance().removeAction(searchAction); + } + }; + + + int index; + + ManagerType(int index) { + this.index = index; + } + + /** + * 匹配 + * + * @param index + * @return + */ + @Nullable + public static ManagerType match(int index) { + ManagerType[] values = ManagerType.values(); + for (ManagerType value : values) { + if (value.index == index) { + return value; + } + } + return null; + } + + } + + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchManagerCenter getInstance() { + return SearchManagerCenterEnum.SINGLETON.getInstance(); + } + + + /** + * 枚举实现单例 + */ + private enum SearchManagerCenterEnum { + /** + * 单例 + */ + SINGLETON; + private SearchManagerCenter instance; + + SearchManagerCenterEnum() { + instance = new SearchManagerCenter(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchManagerCenter getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java new file mode 100644 index 0000000000..846263c5a9 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java @@ -0,0 +1,428 @@ +package com.fr.design.actions.replace.action; + + +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Title; +import com.fr.design.actions.replace.action.content.cell.SearchCellAction; +import com.fr.design.actions.replace.action.content.component.SearchComponentAction; +import com.fr.design.actions.replace.action.content.floatelement.SearchFloatAction; +import com.fr.design.actions.replace.action.content.formula.SearchFormulaManager; +import com.fr.design.actions.replace.action.content.js.SearchJSManager; +import com.fr.design.actions.replace.action.content.sql.SearchSQLAction; +import com.fr.design.actions.replace.action.content.widget.SearchWidgetAction; +import com.fr.design.actions.replace.info.CellInfo; +import com.fr.design.actions.replace.info.ComponentInfo; +import com.fr.design.actions.replace.info.FloatInfo; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.JSInfo; +import com.fr.design.actions.replace.info.SQLInfo; +import com.fr.design.actions.replace.info.WidgetInfo; +import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.general.GeneralUtils; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.FloatElement; +import com.fr.report.cell.cellattr.core.RichText; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.combination.Pair; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 对展示结果进行处理(获取、过滤) + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-22 + */ +public enum ShowSearchResultAction implements ShowValue { + /** + * 搜索单元格 + */ + CELL(Toolkit.i18nText("Fine-Design_Basic_Cell")) { + @Override + public List showSearchValue(JTemplate jTemplate) { + SearchCellAction.getInstance().search4Infos(jTemplate); + return SearchCellAction.getInstance().getCellInfos(); + } + + @Override + public List addMatchResult(String str, List list) { + List cellInfos = new ArrayList<>(); + for (Info info : list) { + if (((CellInfo) info).isChartExist()) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + ChartCollection chartCollection = (ChartCollection) cellElement.getValue(); + for (int i = 0; i < chartCollection.getChartCount(); i++) { + if (isTitleNameValid(chartCollection.getChart(i).getTitle(), str)) { + String titleName = GeneralUtils.objectToString(chartCollection.getChart(i).getTitle().getTextObject()); + CellInfo cellInfo = ((CellInfo) info).copy(); + cellInfo.setCellChartIndex(i); + cellInfo.getContent().addOtherPos( + Toolkit.i18nText("Fine-Design_Replace_Chart_Title"), + chartCollection.getChartName(i), + titleName + ); + setShowInfo(cellInfo, titleName, str); + cellInfos.add(cellInfo); + } + } + } else { + Map stringHashMap = info.getValue(); + String content = stringHashMap.getOrDefault(objectContentKey, StringUtils.EMPTY); + if (isValueValid(content, str, info)) { + info.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); + info.getContent().setOldShowStr(content); + info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); + info.getContent().setSelected(true); + cellInfos.add((CellInfo) info); + } + } + } + return cellInfos; + } + + private void setShowInfo(CellInfo cellInfo, String titleName, String str) { + cellInfo.getContent().setShowStr(ShowValueUtils.getCommonString(titleName, str)); + cellInfo.getContent().setOldShowStr(titleName); + cellInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(titleName, str)); + cellInfo.getContent().setSelected(true); + } + + private boolean isValueValid(String content, String str, Info info) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + return ShowValueUtils.contains(content, str) && StringUtils.isNotEmpty(content) && !(cellElement.getValue() instanceof RichText); + + } + }, + /** + * 搜索JS事件 + */ + JS(Toolkit.i18nText("Fine-Design_Replace_JS")) { + @Override + public List showSearchValue(JTemplate jTemplate) { + SearchJSManager.getInstance().search4Infos(jTemplate); + return SearchJSManager.getInstance().getJsInfos(); + } + + @Override + public List addMatchResult(String str, List list) { + List jsInfos = new ArrayList<>(); + Map stringHashMap = new HashMap<>(); + for (Info info : list) { + stringHashMap = info.getValue(); + if (StringUtils.isEmpty(str)) { + if (StringUtils.isNotEmpty(stringHashMap.getOrDefault(objectContentKey, StringUtils.EMPTY))) { + JSInfo contentJSInfo = ((JSInfo) info).copy(); + contentJSInfo.getContent().setShowStr(stringHashMap.get(objectContentKey)); + contentJSInfo.getContent().setOldShowStr(stringHashMap.get(objectContentKey)); + contentJSInfo.getContent().setSelected(true); + contentJSInfo.setContentFlag(true); + jsInfos.add(contentJSInfo); + } + if (StringUtils.isNotEmpty(stringHashMap.getOrDefault(objectNameKey, StringUtils.EMPTY))) { + JSInfo nameJSInfo = ((JSInfo) info).copy(); + nameJSInfo.getContent().setShowStr(stringHashMap.get(objectNameKey)); + nameJSInfo.getContent().setOldShowStr(stringHashMap.get(objectNameKey)); + nameJSInfo.getContent().setSelected(true); + nameJSInfo.setContentFlag(false); + jsInfos.add(nameJSInfo); + } + } else { + searchMap4JS(stringHashMap, jsInfos, ((JSInfo) info), str); + } + + } + return jsInfos; + } + + private void searchMap4JS(Map map, List jsInfos, JSInfo info, String str) { + if (map.containsKey(objectNameKey) && StringUtils.isNotEmpty(map.get(objectNameKey))) { + String name = map.get(objectNameKey); + if (ShowValueUtils.contains(name,str)) { + JSInfo nameJSInfo = info.copy(); + nameJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); + nameJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(name, str)); + nameJSInfo.getContent().setOldShowStr(map.get(objectNameKey)); + nameJSInfo.setContentFlag(false); + nameJSInfo.getContent().setSelected(true); + jsInfos.add(nameJSInfo); + } + } + if (map.containsKey(objectContentKey) && StringUtils.isNotEmpty(map.get(objectContentKey))) { + String content = map.get(objectContentKey); + if (ShowValueUtils.contains(content,str)) { + JSInfo contentJSInfo = info.copy(); + contentJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); + contentJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); + contentJSInfo.getContent().setOldShowStr(map.get(objectContentKey)); + contentJSInfo.setContentFlag(true); + contentJSInfo.getContent().setSelected(true); + jsInfos.add(contentJSInfo); + } + } + } + }, + /** + * 搜索SQL + */ + SQL("SQL") { + @Override + public List showSearchValue(JTemplate jTemplate) { + SearchSQLAction.getInstance().search4Infos(jTemplate); + return SearchSQLAction.getInstance().getSqlInfos(); + } + + @Override + public List addMatchResult(String str, List list) { + List sqlInfos = new ArrayList<>(); + Map stringHashMap = new HashMap<>(); + for (Info info : list) { + stringHashMap = ((SQLInfo) info).getValue(); + if (StringUtils.isEmpty(str)) { + info.getContent().setShowStr(stringHashMap.get(objectContentKey)); + info.getContent().setOldShowStr(stringHashMap.get(objectContentKey)); + info.getContent().setSelected(true); + sqlInfos.add((SQLInfo) info); + } else { + searchMap4SQLContent(stringHashMap, sqlInfos, ((SQLInfo) info), str); + } + + } + return sqlInfos; + } + + private void searchMap4SQLContent(Map map, List sqlInfos, SQLInfo info, String str) { + if (map.containsKey(objectContentKey) && StringUtils.isNotEmpty(map.get(objectContentKey))) { + String content = map.get(objectContentKey); + if (ShowValueUtils.contains(content,str)) { + SQLInfo contentJSInfo = info.copy(); + contentJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); + contentJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); + contentJSInfo.getContent().setOldShowStr(map.get(objectContentKey)); + contentJSInfo.getContent().setSelected(true); + sqlInfos.add(contentJSInfo); + } + } + } + + private void updateOperatorArray(int index, int preLength, int strLength, SQLInfo sqlInfo) { + ArrayList> pairs = new ArrayList<>(); + pairs.add(new Pair<>(index + preLength, index + preLength + strLength)); + sqlInfo.getContent().setOperatorArray(pairs); + } + }, + /** + * 搜索悬浮元素 + */ + FLOAT(Toolkit.i18nText("Fine-Design_Basic_Float_Element")) { + @Override + public List showSearchValue(JTemplate jTemplate) { + SearchFloatAction.getInstance().search4Infos(jTemplate); + return SearchFloatAction.getInstance().getFloatInfos(); + } + + @Override + public List addMatchResult(String str, List list) { + List floatInfos = new ArrayList<>(); + for (Info info : list) { + FloatElement floatElement = ((FloatElement) (info.getContent().getReplaceObject())); + //如果存的是图表,就要特殊处理 + if (((FloatInfo) info).isChartExist()) { + ChartCollection chartCollection = (ChartCollection) floatElement.getValue(); + for (int i = 0; i < chartCollection.getChartCount(); i++) { + if (isTitleNameValid(chartCollection.getChart(i).getTitle(), str)) { + String titleName = GeneralUtils.objectToString(chartCollection.getChart(i).getTitle().getTextObject()); + FloatInfo floatInfo = ((FloatInfo) info).copy(); + floatInfo.setFloatChartIndex(i); + floatInfo.getContent().addOtherPos( + Toolkit.i18nText("Fine-Design_Replace_Chart_Title"), + chartCollection.getChartName(i), + titleName); + setShowInfo(floatInfo, titleName, str); + floatInfos.add(floatInfo); + } + } + } else { + if (ShowValueUtils.contains(GeneralUtils.objectToString(floatElement.getValue()), str)) { + FloatInfo floatInfo = ((FloatInfo) info).copy(); + setShowInfo(floatInfo, GeneralUtils.objectToString(floatElement.getValue()), str); + floatInfos.add(floatInfo); + } + } + } + return floatInfos; + } + + private void setShowInfo(FloatInfo floatInfo, String value, String str) { + floatInfo.getContent().setOldShowStr(value); + floatInfo.getContent().setShowStr(ShowValueUtils.getCommonString(value, str)); + floatInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(value, str)); + floatInfo.getContent().setSelected(true); + } + }, + /** + * 搜索组件 + */ + COMPONENT(Toolkit.i18nText("Fine-Design_Replace_Component")) { + @Override + public List showSearchValue(JTemplate jTemplate) { + SearchComponentAction.getInstance().search4Infos(jTemplate); + return SearchComponentAction.getInstance().getComponentInfos(); + } + + @Override + public List addMatchResult(String str, List list) { + ArrayList componentInfos = new ArrayList<>(); + Map map = new HashMap<>(); + for (Info info : list) { + map = info.getValue(info.getContent().getReplaceObject()); + searchMap4Component(map, componentInfos, ((ComponentInfo) info), str); + } + return componentInfos; + } + + private void searchMap4Component(Map stringHashMap, ArrayList componentInfos, ComponentInfo info, String str) { + if (stringHashMap.containsKey(objectContentKey)) { + String content = stringHashMap.get(objectContentKey); + if (ShowValueUtils.contains(content,str)) { + info.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); + info.getContent().setOldShowStr(stringHashMap.get(objectContentKey)); + info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); + info.getContent().setSelected(true); + componentInfos.add(info); + } + } + } + }, + /** + * 搜索控件 + */ + WIDGET(Toolkit.i18nText("Fine-Design_Basic_Widget")) { + @Override + public List showSearchValue(JTemplate jTemplate) { + SearchWidgetAction.getInstance().search4Infos(jTemplate); + return SearchWidgetAction.getInstance().getWidgetInfos(); + } + + @Override + public List addMatchResult(String str, List list) { + ArrayList widgetInfos = new ArrayList<>(); + Map stringHashMap = new HashMap<>(); + for (Info info : list) { + stringHashMap = info.getValue(); + searchMap4Widget(stringHashMap, widgetInfos, ((WidgetInfo) info), str); + } + return widgetInfos; + } + + private void searchMap4Widget(Map map, List widgetInfos, WidgetInfo info, String str) { + if (map.containsKey(objectNameKey)) { + String name = map.get(objectNameKey); + if (StringUtils.isNotEmpty(name) && ShowValueUtils.contains(name,str)) { + WidgetInfo nameInfo = info.copy(info); + nameInfo.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); + nameInfo.getContent().setOldShowStr(map.get(objectNameKey)); + nameInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(name, str)); + nameInfo.getContent().setSelected(true); + nameInfo.setWaterMarkFlag(false); + widgetInfos.add(nameInfo); + } + } + if (map.containsKey(objectWaterMarkKey)) { + String waterMark = map.get(objectWaterMarkKey); + if (StringUtils.isNotEmpty(waterMark) && ShowValueUtils.contains(waterMark,str)) { + WidgetInfo widgetInfo = info.copy(info); + widgetInfo.getContent().setShowStr(ShowValueUtils.getCommonString(waterMark, str)); + widgetInfo.getContent().setOldShowStr(map.get(objectWaterMarkKey)); + widgetInfo.getContent().setShowObject(widgetInfo.getContent().getShowObject() + Toolkit.i18nText("Fine-Design_Form_WaterMark")); + widgetInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(waterMark, str)); + widgetInfo.getContent().setSelected(true); + widgetInfo.setWaterMarkFlag(true); + widgetInfos.add(widgetInfo); + } + } + } + }, + /** + * 搜索公式 + */ + FORMULA(Toolkit.i18nText("Fine-Design_Basic_Formula")) { + @Override + public List showSearchValue(JTemplate jTemplate) { + SearchFormulaManager.getInstance().search4Infos(jTemplate); + return SearchFormulaManager.getInstance().getFormulaInfos(); + } + + @Override + public List addMatchResult(String str, List list) { + List formulaInfos = new ArrayList<>(); + Map stringHashMap = new HashMap<>(); + for (Info info : list) { + stringHashMap = info.getValue(); + searchMap4Formula(stringHashMap, formulaInfos, ((FormulaInfo) info), str); + } + return formulaInfos; + } + + private void searchMap4Formula(Map stringHashMap, List formulaInfos, FormulaInfo info, String str) { + if (stringHashMap.containsKey(objectContentKey)) { + String name = stringHashMap.get(objectContentKey); + if (ShowValueUtils.contains(name,str)) { + info.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); + info.getContent().setOldShowStr(stringHashMap.get(objectContentKey)); + info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(name, str)); + info.getContent().setSelected(true); + formulaInfos.add(info); + } + } + } + }; + + + String name; + //存储的对象名称key值 + String objectNameKey = "name"; + //存储的对象内容key值 + String objectContentKey = "content"; + //存储的对象水印Key值 + String objectWaterMarkKey = "waterMark"; + + ShowSearchResultAction(String name) { + this.name = name; + } + + /** + * 匹配 + * + * @param name + * @return + */ + @Nullable + public static ShowSearchResultAction match(String name) { + ShowSearchResultAction[] values = ShowSearchResultAction.values(); + for (ShowSearchResultAction value : values) { + if (value.name.equals(name)) { + return value; + } + } + return null; + } + + /** + * 标题是否可用 + * + * @param title + * @param str + * @return + */ + public boolean isTitleNameValid(Title title, String str) { + return title != null && ShowValueUtils.contains(GeneralUtils.objectToString(title.getTextObject()), str) && StringUtils.isNotEmpty(GeneralUtils.objectToString(title.getTextObject())); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java new file mode 100644 index 0000000000..02ded341eb --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java @@ -0,0 +1,34 @@ +package com.fr.design.actions.replace.action; + +import com.fr.design.actions.replace.info.Info; +import com.fr.design.mainframe.JTemplate; + +import java.util.List; + +/** + * 用于展示结果的处理(获取、过滤) + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-22 + */ +public interface ShowValue { + + /** + * 获取搜索结果 + * + * @param jTemplate + * @return + */ + List showSearchValue(JTemplate jTemplate); + + /** + * 对搜索结果进行过滤 + * + * @param str + * @param list + * @return + */ + List addMatchResult(String str, List list); + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/cell/SearchCellAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/cell/SearchCellAction.java new file mode 100644 index 0000000000..2711069847 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/cell/SearchCellAction.java @@ -0,0 +1,222 @@ +package com.fr.design.actions.replace.action.content.cell; + +import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.action.content.component.SearchComponentAction; +import com.fr.design.actions.replace.info.ComponentInfo; +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.actions.replace.info.CellInfo; +import com.fr.form.main.Form; +import com.fr.form.ui.ElementCaseEditor; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WTitleLayout; +import com.fr.form.ui.widget.CRBoundsWidget; +import com.fr.general.GeneralUtils; +import com.fr.main.impl.WorkBook; +import com.fr.report.cell.CellElement; +import com.fr.report.elementcase.ElementCase; +import com.fr.report.poly.PolyECBlock; +import com.fr.report.report.Report; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * 获取有内容的单元格相关信息 + *

+ * tips:这边报表分为两块——决策报表(dealForm)和普通报表(dealWorkBook),二者最后都会归于ElementCase + * 决策报表:虽然分为绝对布局和自适应布局,但是单元格可能存在的地方只有report ,二者对它(report)的处理是统一的,都属于WTitleLayout,因此没必要划分两种布局 + * 普通报表:获取elementCase拿到cellIterator遍历即可 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-11 + */ +public class SearchCellAction implements SearchAction { + private List cellInfos; + + private SearchCellAction() { + } + + public List getCellInfos() { + return cellInfos; + } + + public void setCellInfos(List cellInfos) { + this.cellInfos = cellInfos; + } + + + /** + * 搜索对应的信息 + * + * @param jTemplate 要搜索的报表对象 + */ + @Override + public void search4Infos(JTemplate jTemplate) { + ITContent content = new ITContent(); + content.setTemplateName(jTemplate.getTemplateName()); + content.addTRL(jTemplate.getTemplateName()); + content.setTemplatePath(jTemplate.getPath()); + if (jTemplate.getTarget() instanceof Form) { + setCellInfos(dealForm(jTemplate)); + } else if (jTemplate.getTarget() instanceof WorkBook) { + setCellInfos(dealWorkBook((WorkBook) jTemplate.getTarget(), content)); + } else { + setCellInfos(new ArrayList<>()); + } + } + + + /** + * 处理决策报表 + * 流程:dealForm——>getCellInfosFromBoundsWidget——>getCellInfoFromElementCase + * + * @param jTemplate 要搜索的报表对象 + * @return 返回单元格信息Array + */ + private List dealForm(JTemplate jTemplate) { + ArrayList result = new ArrayList<>(); + + SearchComponentAction searchComponentAction = SearchComponentAction.getInstance(); + searchComponentAction.search4Infos(jTemplate); + for (ComponentInfo info : searchComponentAction.getComponentInfos()) { + ITContent content = ITContent.copy(info.getContent()); + getCellInfosFromBoundsWidget(result, content, (Widget) info.getContent().getReplaceObject()); + + } + return result; + } + + /** + * 从组件信息中获取到的layout中的BoundsWidget中获取真正的报表块,并且将信息添加到列表中 + * + * @param result 要操作的Array + * @param content 存储查找替换相关信息的类 + * @param widget 控件和组件的最高层接口 + */ + private void getCellInfosFromBoundsWidget(List result, ITContent content, Widget widget) { + //report在两种布局中都属于WTitleLayout + if (widget instanceof WTitleLayout) { + for (int i = 0; i < ((WTitleLayout) widget).getWidgetCount(); i++) { + //这里它又套了一层BoundsWidget + if (((CRBoundsWidget) ((WTitleLayout) widget).getWidget(i)).getWidget() instanceof ElementCaseEditor) { + ElementCaseEditor editor = (ElementCaseEditor) ((CRBoundsWidget) ((WTitleLayout) widget).getWidget(i)).getWidget(); + ITContent newContent = ITContent.copy(content); + getCellInfoFromElementCase((ElementCase) editor.getElementCase(), result, newContent); + } + } + } + + } + + /** + * 处理普通报表 + * + * @param workBook 要搜索的报表对象 + * @return 对应信息Array + */ + public List dealWorkBook(WorkBook workBook, ITContent workBookContent) { + ArrayList result = new ArrayList<>(); + for (int i = 0; i < workBook.getReportCount(); i++) { + Report report = workBook.getReport(i); + ITContent content = ITContent.copy(workBookContent); + content.setSheetID(String.valueOf(i)); + content.setSheetName(workBook.getReportName(i)); + getCellInfoFromReport(report, result, content); + } + return result; + } + + /** + * 处理普通报表的sheet + * + * @param report sheet + * @param result 要操作的信息Array + * @param content 存储查找替换相关信息的类 + */ + private void getCellInfoFromReport(Report report, List result, ITContent content) { + + if (report != null) { + Iterator it = report.iteratorOfElementCase(); + while (it.hasNext()) { + ITContent newContent = ITContent.copy(content); + ElementCase elementCase = (ElementCase) it.next(); + getCellInfoFromElementCase(elementCase, result, newContent); + } + } + } + + + private void getCellInfoFromElementCase(ElementCase elementCase, List result, ITContent content) { + Iterator cellIterator = elementCase.cellIterator(); + while (cellIterator.hasNext()) { + ITContent newContent = ITContent.copy(content); + CellElement cell = (CellElement) cellIterator.next(); + newContent.setReplaceObject(cell); + //单元格 + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Cell") + cell); + newContent.setShowObject(cell); + newContent.addTRL(newContent.getSheetID()); + if (elementCase instanceof PolyECBlock) { + newContent.setBlockName(((PolyECBlock) elementCase).getBlockName()); + newContent.addTRL(((PolyECBlock) elementCase).getBlockName()); + } + newContent.addTRL(GeneralUtils.objectToString(cell)); + CellInfo cellInfo = new CellInfo(newContent); + if (cell.getValue() instanceof ChartCollection) { + cellInfo.setChartExist(true); + } + result.add(cellInfo); + } + } + + + /** + * 对应的单元格信息列表是否有内容 + * + * @return 判断的布尔值 + */ + public boolean isCellInfosExist() { + return this.getCellInfos().size() > 0; + } + + /** + * 对外开放的获取对象的方法 + * + * @return + */ + public static SearchCellAction getInstance() { + return SearchCellAction.SearchCellActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchCellActionEnum { + /** + * 单例 + */ + SINGLETON; + + private SearchCellAction instance; + + SearchCellActionEnum() { + instance = new SearchCellAction(); + } + + /** + * 获取对象 + * + * @return + */ + public SearchCellAction getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java new file mode 100644 index 0000000000..bb6e190f69 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java @@ -0,0 +1,365 @@ +package com.fr.design.actions.replace.action.content.component; + +import com.fr.design.actions.replace.info.ComponentInfo; +import com.fr.design.actions.replace.info.DealWithInfoValue; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WAbsoluteLayout; +import com.fr.form.ui.container.WCardLayout; +import com.fr.form.ui.container.WLayout; +import com.fr.form.ui.container.WScaleLayout; +import com.fr.form.ui.container.WTitleLayout; +import com.fr.form.ui.container.cardlayout.WCardMainBorderLayout; +import com.fr.form.ui.container.cardlayout.WCardTagLayout; +import com.fr.form.ui.container.cardlayout.WCardTitleLayout; +import com.fr.form.ui.container.cardlayout.WTabFitLayout; +import com.fr.form.ui.widget.CRBoundsWidget; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.combination.Pair; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 决策报表组件类型 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-08 + */ +public enum ComponentType implements DealWithInfoValue { + + /** + * WCardMainBorderLayout属于Tab块组件中的最外层——默认命名方式为tablayout0的类型 + * WCardMainBorderLayout里面放两个,一个WCardTitleLayout,一个WCardLayout + * 处理该类型时需要先将该对象加入我们的组件列表中,再对其包含的内容进行递归处理 + * TIP:该类型对其设置组件名时直接setWidgetName即可,设计器右侧上方和右侧下方面板中的组件名称会同步更改 + */ + W_CARD_MAIN_BORDER_LAYOUT("WCardMainBorderLayout") { + @Override + public void addComponent2Array(List componentInfos, ITContent bodyContent, Widget widget) { + super.addComponent2Array(componentInfos, bodyContent, widget); + ITContent content = ITContent.copy(bodyContent); + content.addOtherPos(widget.getWidgetName()); + for (int i = 0; i < ((WCardMainBorderLayout) widget).getWidgetCount(); i++) { + Widget cardLayoutWidget = ((WCardMainBorderLayout) widget).getWidget(i); + if (cardLayoutWidget instanceof WCardTitleLayout) { + for (int j = 0; j < ((WCardTitleLayout) cardLayoutWidget).getWidgetCount(); j++) { + if (((WCardTitleLayout) cardLayoutWidget).getWidget(j) instanceof WCardTagLayout) { + content.addOtherPos(((WCardTitleLayout) cardLayoutWidget).getWidget(j).getWidgetName()); + } + } + } + } + searchLayout4Component(componentInfos, content, ((WCardMainBorderLayout) widget)); + } + }, + /** + * WCardTitleLayout里面两个,一个CardAddButton——不必处理,一个WCardTagLayout——默认命名方式为tabpane0的类型 + * 处理该类型时不用对该对象进行处理,直接对其包含的内容进行递归处理即可 + */ + W_CARD_TITLE_LAYOUT("WCardTitleLayout") { + @Override + public void addComponent2Array(List componentInfos, ITContent bodyContent, Widget widget) { + searchLayout4Component(componentInfos, bodyContent, (WCardTitleLayout) widget); + } + }, + /** + * 对于WCardLayout 里面就是放的WTabFitLayout——tab00、tab10 + * 处理该类型时不用对该对象进行处理,直接对其包含的内容进行递归处理即可 + */ + W_CARD_LAYOUT("WCardLayout") { + @Override + public void addComponent2Array(List componentInfos, ITContent bodyContent, Widget widget) { + searchLayout4Component(componentInfos, bodyContent, (WCardLayout) widget); + } + }, + /** + * WCardTagLayout——默认命名方式为tabpane0的类型 + * TIP:该类型对其设置组件名时直接setWidgetName即可,设计器右侧上方和右侧下方面板中的组件名称会同步更改 + */ + W_CARD_TAG_LAYOUT("WCardTagLayout") { + @Override + public void addComponent2Array(List componentInfos, ITContent bodyContent, Widget widget) { + super.addComponent2Array(componentInfos, bodyContent, widget); + searchLayout4Component(componentInfos, bodyContent, (WCardTagLayout) widget); + } + }, + /** + * WAbsoluteLayout属于绝对布局块 + * 处理该类型时需要先将该对象加入我们的组件列表中,再对其包含的内容进行递归处理 + * TIP:该类型对其设置组件名时直接setWidgetName即可,设计器右侧上方和右侧下方面板中的组件名称会同步更改 + */ + W_ABSOLUTE_LAYOUT("WAbsoluteLayout") { + @Override + public void addComponent2Array(List componentInfos, ITContent bodyContent, Widget widget) { + super.addComponent2Array(componentInfos, bodyContent, widget); + serachCRBoundsWidget4Component(componentInfos, bodyContent, (WAbsoluteLayout) widget); + } + }, + /** + * WTabFitLayout——里面放的是命名方式为tab00、tab10的tab块,在该块内部可以递归存放所有决策报表组件 + * 处理该类型时需要先将该对象加入我们的组件列表中,再对其包含的内容进行递归处理 + * TIP:该类型对其设置组件名时直接setWidgetName即可,设计器右侧上方和右侧下方面板中的组件名称会同步更改 + */ + W_TAB_FIT_LAYOUT("WTabFitLayout") { + @Override + public void addComponent2Array(List componentInfos, ITContent bodyContent, Widget widget) { + super.addComponent2Array(componentInfos, bodyContent, widget); + serachCRBoundsWidget4Component(componentInfos, bodyContent, (WTabFitLayout) widget); + } + }, + /** + * 自适应布局下报表块和图表的存储方式 + * TIP:该类型对其设置组件名时需要对内外层进行setWidgetName,设计器右侧上方和右侧下方面板中的组件名称不会同步更改 + */ + W_TITLE_LAYOUT("WTitleLayout") { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + if (replaceObject instanceof WTitleLayout) { + WTitleLayout titleLayout = (WTitleLayout) replaceObject; + info.updateOldStr(titleLayout.getWidgetName(), findStr); + titleLayout.setWidgetName(ShowValueUtils.replaceAll(titleLayout.getWidgetName(), findStr, replaceStr)); + CRBoundsWidget crBoundsWidget = ((CRBoundsWidget) titleLayout.getWidget(0)); + crBoundsWidget.getWidget().setWidgetName(ShowValueUtils.replaceAll(crBoundsWidget.getWidget().getWidgetName(), findStr, replaceStr)); + } + } + }, + + /** + * 自适应布局下:下拉框控件、下拉复选框控件、日期控件、数字控件、下拉树控件、密码控件都属于该类型 + * TIP:该类型对其设置组件名时需要对内外层进行setWidgetName,设计器右侧上方和右侧下方面板中的组件名称不会同步更改 + */ + W_SCALE_LAYOUT("WScaleLayout") { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + if (replaceObject instanceof WScaleLayout) { + WScaleLayout scaleLayout = (WScaleLayout) replaceObject; + info.updateOldStr(scaleLayout.getWidgetName(), findStr); + scaleLayout.setWidgetName(ShowValueUtils.replaceAll(scaleLayout.getWidgetName(), findStr, replaceStr)); + CRBoundsWidget crBoundsWidget = ((CRBoundsWidget) scaleLayout.getWidget(0)); + crBoundsWidget.getWidget().setWidgetName(ShowValueUtils.replaceAll(crBoundsWidget.getWidget().getWidgetName(), findStr, replaceStr)); + } + } + }, + /** + * 绝对布局:文本控件 + */ + TEXT_EDITOR("TextEditor"), + + /** + * 自适应布局和绝对布局:标签控件 + */ + LABEL("Label"), + + /** + * 自适应布局和绝对布局:按钮控件 + */ + FREE_BUTTON("FreeButton"), + + /** + * 下绝对布局:拉框控件 + */ + COMBO_BOX("ComboBox"), + + /** + * 绝对布局:下拉复选框控件 + */ + COMBO_CHECK_BOX("ComboCheckBox"), + + /** + * 绝对布局:日期控件 + */ + DATE_EDITOR("DateEditor"), + + /** + * 绝对布局:数字控件 + */ + NUMBER_EDITOR("NumberEditor"), + + /** + * 绝对布局:下拉树控件 + */ + TREE_COMBO_BOX_EDITOR("TreeComboBoxEditor"), + + /** + * 自适应布局和绝对布局:单选按钮组控件 + */ + RADIO_GROUP("RadioGroup"), + + /** + * 自适应布局和绝对布局:复选按钮组控件 + */ + CHECK_BOX_GROUP("CheckBoxGroup"), + + /** + * 自适应布局和绝对布局:查询按钮 + */ + FORM_SUBMIT_BUTTON("FormSubmitButton"), + + /** + * 自适应布局和绝对布局:文本域控件 + */ + TEXT_AREA("TextArea"), + + /** + * 绝对布局:密码控件 + */ + PASS_WORD("Password"), + + /** + * 自适应布局和绝对布局:复选按钮控件 + */ + CHECK_BOX("CheckBox"), + + /** + * 自适应布局和绝对布局:视图树 + */ + TREE_EDITOR("TreeEditor"), + + /** + * 自适应布局和绝对布局:文件控件 + */ + MULTI_FILE_EDITOR("MultiFileEditor"); + + + String name; + + ComponentType(String name) { + this.name = name; + } + + /** + * 匹配 + * + * @param name + * @return + */ + @Nullable + public static ComponentType match(String name) { + ComponentType[] values = ComponentType.values(); + for (ComponentType value : values) { + if (value.name.equals(name)) { + return value; + } + } + return null; + } + + /** + * 添加组件到数组中 + * + * @param componentInfos + * @param bodyContent + * @param widget + */ + public void addComponent2Array(List componentInfos, ITContent bodyContent, Widget widget) { + componentInfos.add(new ComponentInfo(getComponentContent(bodyContent, widget))); + } + + /** + * 处理ITContent + * + * @param componentContent + * @param widget + * @return + */ + public ITContent getComponentContent(ITContent componentContent, Widget widget) { + ITContent content = ITContent.copy(componentContent); + content.setReplaceObject(widget); + String widgetName = widget.getWidgetName(); + if (!(widget instanceof WCardTagLayout)) { + content.addOtherPos(widgetName); + } + content.setBlockName(widgetName); + content.setShowObject(widgetName); + content.addTRL(widgetName); + return content; + } + + /** + * 从Layout里面拿组件 + * + * @param componentInfos + * @param bodyContent + * @param layout + */ + public void searchLayout4Component(List componentInfos, ITContent bodyContent, WLayout layout) { + for (int i = 0; i < layout.getWidgetCount(); i++) { + ComponentType componentType = ComponentType.match(layout.getWidget(i).getClass().getSimpleName()); + if (componentType != null) { + componentType.addComponent2Array(componentInfos, bodyContent, layout.getWidget(i)); + } + } + } + + /** + * 从CRBoundWidget里面拿组件 + * + * @param componentInfos + * @param bodyContent + * @param layout + */ + public void serachCRBoundsWidget4Component(List componentInfos, ITContent bodyContent, WLayout layout) { + for (int i = 0; i < layout.getWidgetCount(); i++) { + //这边会套一层CRBoundsWidget + ComponentType componentType = ComponentType.match(((CRBoundsWidget) (layout.getWidget(i))).getWidget().getClass().getSimpleName()); + if (componentType != null) { + ITContent content = ITContent.copy(bodyContent); + content.addOtherPos(layout.getWidgetName()); + componentType.addComponent2Array(componentInfos, content, ((CRBoundsWidget) (layout.getWidget(i))).getWidget()); + } + } + } + + + @Override + public Map getValue(Object... o) { + HashMap hashMap = new HashMap<>(); + if (o != null && o[0] instanceof Widget) { + hashMap.put("content", ((Widget) o[0]).getWidgetName()); + } + return hashMap; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + if (replaceObject instanceof Widget) { + Widget widget = ((Widget) replaceObject); + info.updateOldStr(widget.getWidgetName(), findStr); + widget.setWidgetName(widget.getWidgetName().replaceAll(findStr, replaceStr)); + } + } + + @Override + public String getInfoShowStr(Info info) { + if (info instanceof ComponentInfo && info.getContent().getReplaceObject() instanceof Widget) { + return ((Widget) info.getContent().getReplaceObject()).getWidgetName(); + } + return StringUtils.EMPTY; + } + + + /** + * 校验是否被修改 + * + * @param info + * @return + */ + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof Widget) { + Widget widget = (Widget) info.getContent().getReplaceObject(); + return StringUtils.equals(widget.getWidgetName(), info.getContent().getOldShowStr()); + } + return false; + } + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/SearchComponentAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/SearchComponentAction.java new file mode 100644 index 0000000000..fd741fdf7e --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/SearchComponentAction.java @@ -0,0 +1,185 @@ +package com.fr.design.actions.replace.action.content.component; + +import com.fr.design.actions.replace.action.SearchAction; + +import com.fr.design.actions.replace.info.ComponentInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.mainframe.JTemplate; +import com.fr.form.main.Form; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WLayout; +import com.fr.form.ui.widget.CRBoundsWidget; + +import java.util.ArrayList; +import java.util.List; + +/** + * 获取决策报表组件 + * TIPS:组件只在决策报表中,只用考虑决策报表Form,分为para和body两部分来处理 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-29 + */ +public class SearchComponentAction implements SearchAction { + + private SearchComponentAction() { + } + + private List componentInfos; + + + public List getComponentInfos() { + return componentInfos; + } + + public void setComponentInfos(List componentInfos) { + this.componentInfos = componentInfos; + } + + + /** + * 搜索决策报表参数面板以及body面板两个地方的组件 + * + * @param jTemplate 要搜索的模板 + */ + @Override + public void search4Infos(JTemplate jTemplate) { + List componentInfos = new ArrayList<>(); + if (jTemplate.getTarget() instanceof Form) { + Form form = (Form) jTemplate.getTarget(); + ITContent content = new ITContent(); + content.setTemplateName(jTemplate.getTemplateName()); + content.setTemplatePath(jTemplate.getPath()); + content.addTRL(jTemplate.getTemplateName()); + content.setFrmFlag(true); + //处理最底层form组件 + dealForm(componentInfos, content, form.getContainer()); + //参数面板 + dealPara(componentInfos, content, form.getParaContainer()); + //body面板 + dealBody(componentInfos, content, form.getBody()); + } + setComponentInfos(componentInfos); + } + + private void dealForm(List componentInfos, ITContent content, WLayout container) { + ITContent formContent = ITContent.copy(content); + formContent.setReplaceObject(container); + dealContent(formContent, container.getWidgetName()); + formContent.addOtherPos(container.getWidgetName()); + formContent.setJumpAble(false); + componentInfos.add(new ComponentInfo(formContent)); + } + + private void dealBody(List componentInfos, ITContent content, Widget body) { + if (body instanceof WLayout) { + ITContent bodyContent = ITContent.copy(content); + bodyContent.addOtherPos(body.getWidgetName()); + //单独处理一下body组件 + dealBodyContainer(componentInfos, bodyContent, (WLayout) body); + //处理body的子组件 + searchBodyComponent(componentInfos, bodyContent, body); + //searchBodyComponent(); + } + } + + private void searchBodyComponent(List componentInfos, ITContent bodyContent, Widget body) { + for (int i = 0; i < ((WLayout) body).getWidgetCount(); i++) { + //body下面的每个控件都会有一层BoundsWidget,为了兼容用了CRBoundsWidget,boundsWidget.getWidget()里面才是真正我们需要的widget + CRBoundsWidget boundsWidget = (CRBoundsWidget) ((WLayout) body).getWidget(i); + ComponentType componentType = ComponentType.match(boundsWidget.getWidget().getClass().getSimpleName()); + if (componentType != null) { + componentType.addComponent2Array(componentInfos, bodyContent, boundsWidget.getWidget()); + } + } + } + + private void dealBodyContainer(List componentInfos, ITContent bodyContent, WLayout body) { + ITContent content = ITContent.copy(bodyContent); + content.setReplaceObject(body); + content.setJumpAble(false); + dealContent(content, body.getWidgetName()); + //WParameterLayout + componentInfos.add(new ComponentInfo(content)); + } + + private void dealPara(List componentInfos, ITContent content, WLayout paraContainer) { + if (paraContainer != null) { + ITContent paraContent = ITContent.copy(content); + paraContent.addOtherPos(paraContainer.getWidgetName()); + paraContent.setJumpAble(false); + //单独处理一下para组件 + dealParaContainer(componentInfos, paraContent, paraContainer); + //处理para的子组件 + searchParaComponent(componentInfos, paraContent, paraContainer); + } + } + + private void searchParaComponent(List componentInfos, ITContent paraContent, WLayout paraContainer) { + for (int i = 0; i < paraContainer.getWidgetCount(); i++) { + ITContent content = ITContent.copy(paraContent); + String widgetName = ((CRBoundsWidget) (paraContainer.getWidget(i))).getWidget().getWidgetName(); + content.addOtherPos(widgetName); + content.setReplaceObject(((CRBoundsWidget) (paraContainer.getWidget(i))).getWidget()); + dealContent(content, widgetName); + componentInfos.add(new ComponentInfo(content)); + + } + } + + /** + * 单独处理WParameterLayout组件 + * + * @param componentInfos + * @param content + * @param paraContainer + */ + private void dealParaContainer(List componentInfos, ITContent content, WLayout paraContainer) { + ITContent paraContent = ITContent.copy(content); + paraContent.setReplaceObject(paraContainer); + dealContent(paraContent, paraContainer.getWidgetName()); + //WParameterLayout + componentInfos.add(new ComponentInfo(paraContent)); + } + + + private void dealContent(ITContent content, String widgetName) { + content.setBlockName(widgetName); + content.setShowObject(widgetName); + content.addTRL(widgetName); + } + + /** + * 对外开放的获取对象的方法 + * + * @return + */ + public static SearchComponentAction getInstance() { + return SearchComponentAction.SearchComponentActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchComponentActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchComponentAction instance; + + SearchComponentActionEnum() { + instance = new SearchComponentAction(); + } + + /** + * 获取对象 + * + * @return + */ + public SearchComponentAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/floatelement/SearchFloatAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/floatelement/SearchFloatAction.java new file mode 100644 index 0000000000..13398be1f1 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/floatelement/SearchFloatAction.java @@ -0,0 +1,136 @@ +package com.fr.design.actions.replace.action.content.floatelement; + +import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.actions.replace.action.SearchAction; + +import com.fr.design.actions.replace.info.FloatInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.general.ImageWithSuffix; +import com.fr.main.impl.WorkBook; +import com.fr.report.cell.FloatElement; +import com.fr.report.elementcase.ElementCase; +import com.fr.report.poly.PolyECBlock; +import com.fr.report.report.Report; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * 查找悬浮元素的信息 + *

+ * 由于决策报表没有悬浮元素,因此不用考虑决策报表,只需要考虑普通报表即可 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-16 + */ +public class SearchFloatAction implements SearchAction { + private List floatInfos; + + /** + * 查找悬浮元素信息,只需要考虑普通报表 + * + * @param jTemplate 指定搜索模板 + */ + @Override + public void search4Infos(JTemplate jTemplate) { + List result = new ArrayList<>(); + if (jTemplate.getTarget() instanceof WorkBook) { + WorkBook workBook = (WorkBook) jTemplate.getTarget(); + for (int i = 0; i < workBook.getReportCount(); i++) { + Report report = workBook.getReport(i); + ITContent content = new ITContent(); + content.setTemplateName(jTemplate.getTemplateName()); + content.setTemplatePath(jTemplate.getPath()); + content.setSheetID(String.valueOf(i)); + content.setSheetName(workBook.getReportName(i)); + content.addTRL(jTemplate.getTemplateName()); + content.addTRL(String.valueOf(i)); + getFloatInfoFromReport(report, result, content); + } + } + setFloatInfos(result); + + } + + + private void getFloatInfoFromReport(Report report, List result, ITContent content) { + + if (report != null) { + Iterator it = report.iteratorOfElementCase(); + while (it.hasNext()) { + ITContent newContent = ITContent.copy(content); + ElementCase elementCase = (ElementCase) it.next(); + getFloatInfoFromElementCase(elementCase, result, newContent); + } + } + } + + private void getFloatInfoFromElementCase(ElementCase elementCase, List result, ITContent content) { + Iterator floatIterator = elementCase.floatIterator(); + while (floatIterator.hasNext()) { + ITContent newContent = ITContent.copy(content); + FloatElement floatElement = (FloatElement) floatIterator.next(); + newContent.setReplaceObject(floatElement); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Float_Element")); + if (elementCase instanceof PolyECBlock) { + newContent.setBlockName(((PolyECBlock) elementCase).getBlockName()); + newContent.addTRL(((PolyECBlock) elementCase).getBlockName()); + } + newContent.setShowObject(floatElement.getName()); + newContent.addTRL(floatElement.getName()); + FloatInfo floatInfo = new FloatInfo(newContent); + if (floatElement.getValue() instanceof ChartCollection) { + floatInfo.setChartExist(true); + } + if (!(floatElement.getValue() instanceof ImageWithSuffix)) { + result.add(floatInfo); + } + } + } + + + public List getFloatInfos() { + return floatInfos; + } + + public void setFloatInfos(List floatInfos) { + this.floatInfos = floatInfos; + } + + /** + * 对外开放的获取对象的方法 + * + * @return + */ + public static SearchFloatAction getInstance() { + return SearchFloatAction.SearchFloatActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + enum SearchFloatActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchFloatAction instance; + + SearchFloatActionEnum() { + instance = new SearchFloatAction(); + } + + /** + * 获取对象 + * + * @return + */ + public SearchFloatAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java new file mode 100644 index 0000000000..02cd18810e --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java @@ -0,0 +1,566 @@ +package com.fr.design.actions.replace.action.content.formula; + +import com.fr.base.BaseFormula; +import com.fr.base.Formula; +import com.fr.base.Parameter; +import com.fr.base.StoreProcedureParameter; +import com.fr.base.core.KV; +import com.fr.base.iofile.attr.WatermarkAttr; +import com.fr.base.present.FormulaPresent; +import com.fr.base.present.Present; +import com.fr.data.condition.FormulaCondition; +import com.fr.data.core.Compare; +import com.fr.design.actions.replace.info.DealWithInfoValue; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.form.main.Form; +import com.fr.function.IF; +import com.fr.general.GeneralUtils; +import com.fr.js.SingleJavaScript; +import com.fr.main.impl.WorkBook; +import com.fr.report.cell.cellattr.CellInsertPolicyAttr; +import com.fr.report.cell.cellattr.core.RichChar; +import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.report.core.sort.sortexpression.FormulaSortExpression; +import com.fr.stable.FormulaProvider; +import com.fr.stable.ParameterProvider; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.combination.Pair; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 公式可能存在的形式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-25 + */ +public enum FormulaReplaceObject implements DealWithInfoValue { + /** + * Formula类型(最基础也是最常见) + */ + FORMULA("Formula") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((Formula) o[0]).getContent())) { + map.put("content", ((Formula) o[0]).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((Formula) replaceObject).getContent(), findStr); + ((Formula) replaceObject).setContent(ShowValueUtils.replaceAll(((Formula) replaceObject).getContent(), findStr, replaceStr)); + } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof Formula){ + Formula formula = (Formula) info.getContent().getReplaceObject(); + return StringUtils.equals(formula.getContent(), info.getContent().getOldShowStr()); + } + return false; + } + }, + /** + * FormulaCondition + */ + FORMULA_CONDITION("FormulaCondition") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((FormulaCondition) o[0]).getFormula())) { + map.put("content", ((FormulaCondition) o[0]).getFormula()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + //更新上一次操作的信息 + info.updateOldStr(((FormulaCondition) replaceObject).getFormula(), findStr); + + ((FormulaCondition) replaceObject).setFormula(ShowValueUtils.replaceAll(((FormulaCondition) replaceObject).getFormula(), findStr, replaceStr)); + } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof FormulaCondition){ + FormulaCondition condition = (FormulaCondition) info.getContent().getReplaceObject(); + return StringUtils.equals(condition.getFormula(), info.getContent().getOldShowStr()); + } + return false; + } + }, + /** + * Compare + */ + COMPARE("Compare") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((Formula) ((Compare) o[0]).getValue()).getContent())) { + map.put("content", ((Formula) ((Compare) o[0]).getValue()).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + if (((Compare) replaceObject).getValue() instanceof Formula) { + Formula formula = (Formula) ((Compare) replaceObject).getValue(); + info.updateOldStr(formula.getContent(), findStr); + + formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr)); + } + } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof Compare){ + Compare compare = (Compare) info.getContent().getReplaceObject(); + return StringUtils.equals(GeneralUtils.objectToString(compare.getValue()), info.getContent().getOldShowStr()); + } + return false; + } + }, + /** + * KV + */ + KV("KV") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((Formula) ((com.fr.base.core.KV) o[0]).getValue()).getContent())) { + map.put("content", ((Formula) ((com.fr.base.core.KV) o[0]).getValue()).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).getContent(), findStr); + + ((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).setContent(ShowValueUtils.replaceAll(((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).getContent(), findStr, replaceStr)); + } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof com.fr.base.core.KV){ + com.fr.base.core.KV kv = (com.fr.base.core.KV) info.getContent().getReplaceObject(); + return StringUtils.equals(GeneralUtils.objectToString(kv.getValue()), info.getContent().getOldShowStr()); + } + return false; + } + }, + /** + * 插入策略 + */ + CELL_INSERT_POLICY_ATTR("CellInsertPolicyAttr") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((Formula) (((CellInsertPolicyAttr) o[0]).getDefaultInsertValue())).getContent())) { + map.put("content", ((Formula) (((CellInsertPolicyAttr) o[0]).getDefaultInsertValue())).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).getContent(), findStr); + ((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).getContent(), findStr, replaceStr)); + } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof CellInsertPolicyAttr){ + CellInsertPolicyAttr policyAttr = (CellInsertPolicyAttr) info.getContent().getReplaceObject(); + return StringUtils.equals(GeneralUtils.objectToString(policyAttr.getDefaultInsertValue()), info.getContent().getOldShowStr()); + } + return false; + } + }, + /** + * present + */ + FORMULA_PRESENT("FormulaPresent") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((FormulaPresent) o[0]).getFormulaContent())) { + map.put("content", ((FormulaPresent) o[0]).getFormulaContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((FormulaPresent) replaceObject).getFormulaContent(), findStr); + + ((FormulaPresent) replaceObject).setFormulaContent(ShowValueUtils.replaceAll(((FormulaPresent) replaceObject).getFormulaContent(), findStr, replaceStr)); + } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof FormulaPresent){ + FormulaPresent present = (FormulaPresent) info.getContent().getReplaceObject(); + return StringUtils.equals(present.getFormulaContent(), info.getContent().getOldShowStr()); + } + return false; + } + }, + /** + * SingleJavaScript + */ + SINGLE_JAVA_SCRIPT("SingleJavaScript") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((SingleJavaScript) o[0]).getFileName())) { + map.put("content", ((SingleJavaScript) o[0]).getFileName()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((SingleJavaScript) replaceObject).getFileName(), findStr); + ((SingleJavaScript) replaceObject).setFileName(ShowValueUtils.replaceAll(((SingleJavaScript) replaceObject).getFileName(), findStr, replaceStr)); + } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof SingleJavaScript){ + SingleJavaScript javaScript = (SingleJavaScript) info.getContent().getReplaceObject(); + return StringUtils.equals(javaScript.getFileName(), info.getContent().getOldShowStr()); + } + return false; + } + }, + /** + * 参数 + */ + PARAMETER_PROVIDER("ParameterProvider") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((Formula) (((ParameterProvider) o[0]).getValue())).getContent())) { + map.put("content", ((Formula) (((ParameterProvider) o[0]).getValue())).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((Formula) (((ParameterProvider) replaceObject).getValue())).getContent(), findStr); + + ((Formula) (((ParameterProvider) replaceObject).getValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((ParameterProvider) replaceObject).getValue())).getContent(), findStr, replaceStr)); + } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof ParameterProvider){ + ParameterProvider provider = (ParameterProvider) info.getContent().getReplaceObject(); + if (provider.getValue() instanceof Formula){ + return StringUtils.equals(GeneralUtils.objectToString(provider.getValue()), info.getContent().getOldShowStr()); + } + } + return false; + } + }, + /** + * FormulaProvider + */ + FORMULA_PROVIDER("FormulaProvider") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((FormulaProvider) o[0]).getContent())) { + map.put("content", ((FormulaProvider) o[0]).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((FormulaProvider) replaceObject).getContent(), findStr); + + ((FormulaProvider) replaceObject).setContent(ShowValueUtils.replaceAll(((FormulaProvider) replaceObject).getContent(), findStr, replaceStr)); + } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof FormulaProvider){ + FormulaProvider provider = (FormulaProvider) info.getContent().getReplaceObject(); + return StringUtils.equals(provider.getContent(), info.getContent().getOldShowStr()); + } + return false; + } + }, + /** + * 参数 + */ + PARAMETER("Parameter") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((Formula) (((Parameter) o[0]).getValue())).getContent())) { + map.put("content", ((Formula) (((Parameter) o[0]).getValue())).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((Formula) (((Parameter) replaceObject).getValue())).getContent(), findStr); + + ((Formula) (((Parameter) replaceObject).getValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((Parameter) replaceObject).getValue())).getContent(), findStr, replaceStr)); + } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof Parameter){ + Parameter parameter = (Parameter) info.getContent().getReplaceObject(); + if (parameter.getValue() instanceof Formula){ + return StringUtils.equals(((Formula) parameter.getValue()).getContent(), info.getContent().getOldShowStr()); + } + } + return false; + } + }, + /** + * 数据列 + */ + DS_COLUMN("DSColumn") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((DSColumn) o[0]).getResult())) { + map.put("content", ((DSColumn) o[0]).getResult()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((DSColumn) replaceObject).getResult(), findStr); + + ((DSColumn) replaceObject).setResult(ShowValueUtils.replaceAll(((DSColumn) replaceObject).getResult(), findStr, replaceStr)); + } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof DSColumn){ + DSColumn column = (DSColumn) info.getContent().getReplaceObject(); + return StringUtils.equals(column.getResult(), info.getContent().getOldShowStr()); + } + return false; + } + }, + /** + * 公式类型 + */ + BASE_FORMULA("BaseFormula") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((BaseFormula) o[0]).getContent())) { + map.put("content", ((BaseFormula) o[0]).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((BaseFormula) replaceObject).getContent(), findStr); + + ((BaseFormula) replaceObject).setContent(ShowValueUtils.replaceAll(((BaseFormula) replaceObject).getContent(), findStr, replaceStr)); + } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof BaseFormula){ + BaseFormula formula = (BaseFormula) info.getContent().getReplaceObject(); + return StringUtils.equals(formula.getContent(), info.getContent().getOldShowStr()); + } + return false; + } + }, + /** + * 存储过程的参数 + */ + STORE_PROCEDURE_PARAMETER("StoreProcedureParameter") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((Formula) ((StoreProcedureParameter) o[0]).getValue()).getContent())) { + map.put("content", ((Formula) ((StoreProcedureParameter) o[0]).getValue()).getContent()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr(((Formula) ((StoreProcedureParameter) replaceObject).getValue()).getContent(), findStr); + + ((Formula) ((StoreProcedureParameter) replaceObject).getValue()).setContent(ShowValueUtils.replaceAll(((Formula) ((StoreProcedureParameter) replaceObject).getValue()).getContent(), findStr, replaceStr)); + } + + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof StoreProcedureParameter){ + StoreProcedureParameter procedureParameter = (StoreProcedureParameter) info.getContent().getReplaceObject(); + if (procedureParameter.getValue() instanceof Formula){ + return StringUtils.equals(GeneralUtils.objectToString(procedureParameter.getValue()), info.getContent().getOldShowStr()); + } + } + return false; + } + }, + /** + * WatermarkAttr水印 + */ + WATER_MARK_ATTR("WatermarkAttr") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((WatermarkAttr) o[0]).getText())) { + map.put("content", ((WatermarkAttr) o[0]).getText()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + WorkBook workBook = (WorkBook) HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget(); + WatermarkAttr watermarkAttr = (WatermarkAttr) info.getContent().getReplaceObject(); + info.updateOldStr(watermarkAttr.getText(), findStr); + watermarkAttr.setText(ShowValueUtils.replaceAll(watermarkAttr.getText(), findStr, replaceStr)); + workBook.addAttrMark(watermarkAttr); + } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof WatermarkAttr){ + WatermarkAttr watermarkAttr = ((WatermarkAttr) info.getContent().getReplaceObject()); + return StringUtils.equals(watermarkAttr.getText(), info.getContent().getOldShowStr()); + } + return false; + } + }, + /** + * 存储字符串类型需要特殊处理 + */ + STRING("String"){ + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(GeneralUtils.objectToString(o[0]))){ + map.put("content", GeneralUtils.objectToString(o[0])); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + FormulaTag formulaTag = FormulaTag.match(info.getContent().getTag()); + if (formulaTag != null){ + info.updateOldStr(GeneralUtils.objectToString(info.getContent().getReplaceObject()), findStr); + formulaTag.setValue(info, findStr, replaceStr, operatorArray); + } + } + + @Override + public boolean check(Info info) { + return true; + } + }, + /** + * 排序 + */ + FORMULA_SORT_EXPRESSION("FormulaSortExpression"){ + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + if (StringUtils.isNotEmpty(((FormulaSortExpression) o[0]).getFormula())) { + map.put("content", ((FormulaSortExpression) o[0]).getFormula()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Object replaceObject = info.getContent().getReplaceObject(); + info.updateOldStr((((FormulaSortExpression) replaceObject).getFormula()), findStr); + ((FormulaSortExpression) replaceObject).setFormula(ShowValueUtils.replaceAll((((FormulaSortExpression) replaceObject).getFormula()), findStr, replaceStr)); + } + + @Override + public boolean check(Info info) { + if (info.getContent().getReplaceObject() instanceof FormulaSortExpression){ + FormulaSortExpression sortExpression = (FormulaSortExpression) info.getContent().getReplaceObject(); + return StringUtils.equals(sortExpression.getFormula(), info.getContent().getOldShowStr()); + } + return false; + } + } + ; + + + String name; + + FormulaReplaceObject(String name) { + this.name = name; + } + + /** + * 匹配 + * + * @param name + * @return + */ + @Nullable + public static FormulaReplaceObject match(String name) { + FormulaReplaceObject[] values = FormulaReplaceObject.values(); + for (FormulaReplaceObject value : values) { + if (value.name.equals(name)) { + return value; + } + } + return null; + } + + /** + * 校验内容 + * @param info + * @return + */ + abstract public boolean check(Info info); + + @Override + public String getInfoShowStr(Info info) { + return info.getContent().getOldShowStr(); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java new file mode 100644 index 0000000000..c3f3c83a1d --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java @@ -0,0 +1,188 @@ +package com.fr.design.actions.replace.action.content.formula; + +import com.fr.chart.chartdata.MeterReportDefinition; +import com.fr.data.VerifyItem; +import com.fr.data.impl.FormulaDictionary; +import com.fr.design.actions.replace.info.DealWithInfoValue; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.base.SearchTag; +import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.general.GeneralUtils; +import com.fr.main.impl.WorkBook; +import com.fr.plugin.chart.map.data.VanMapReportDefinition; +import com.fr.report.cell.cellattr.CellGUIAttr; +import com.fr.stable.collections.combination.Pair; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + + +/** + * 针对特殊类型进行处理,负责公式校验(公式设置值时如果是new一个新的公式都要放进来这里根据持有对象来校验) + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public enum FormulaTag implements DealWithInfoValue { + /** + * 经度 + */ + CHART_DATA_LONGITUDE(SearchTag.CHART_DATA_LONGITUDE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); + definition.setLongitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getLongitude()), findStr, replaceStr)); + } + } + }, + /** + * 纬度 + */ + CHART_DATA_LATITUDE(SearchTag.CHART_DATA_LATITUDE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); + definition.setLatitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getLatitude()), findStr, replaceStr)); + } + } + }, + /** + * 区域名 + */ + CHART_AREA_NAME(SearchTag.CHART_AREA_NAME) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); + definition.setCategoryName(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getCategoryName()), findStr, replaceStr)); + } + } + }, + /** + * 终点经度 + */ + CHART_DATA_END_LONGITUDE(SearchTag.CHART_DATA_END_LONGITUDE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); + definition.setEndLongitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getEndLongitude()), findStr, replaceStr)); + } + } + }, + /** + * 终点纬度 + */ + CHART_DATA_END_LATITUDE(SearchTag.CHART_DATA_END_LATITUDE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); + definition.setEndLatitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getEndLatitude()), findStr, replaceStr)); + } + } + }, + /** + * 终点区域名 + */ + CHART_AREA_END_NAME(SearchTag.CHART_AREA_END_NAME) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); + definition.setEndAreaName(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getEndAreaName()), findStr, replaceStr)); + } + } + }, + /** + * 模板填报属性数据校验提示 + */ + WRITE_ATTR_MESSAGE(SearchTag.WRITE_ATTR_MESSAGE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof VerifyItem) { + VerifyItem item = (VerifyItem) info.getContent().getHoldObject(); + item.setMessage(ShowValueUtils.replaceAll(item.getMessage(), findStr, replaceStr)); + } + } + }, + /** + * sheet名称 + */ + SHEET_NAME(SearchTag.SHEET_NAME) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof WorkBook) { + WorkBook workBook = (WorkBook) info.getContent().getHoldObject(); + int sheetId = Integer.parseInt(info.getContent().getSheetID()); + String name = workBook.getReportName(sheetId); + workBook.setReportName(sheetId, ShowValueUtils.replaceAll(name, findStr, replaceStr)); + } + } + }, + /** + * 单元格属性-其他-内容提示 + */ + CELL_TOOL_TIP(SearchTag.CELL_TOOL_TIP) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof CellGUIAttr) { + CellGUIAttr attr = (CellGUIAttr) info.getContent().getHoldObject(); + attr.setTooltipText(ShowValueUtils.replaceAll(attr.getTooltipText(), findStr, replaceStr)); + } + } + }, + DICT_EXCUTE(SearchTag.DICT_EXCUTE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof FormulaDictionary) { + FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject(); + dictionary.setExcuteFormula(ShowValueUtils.replaceAll(dictionary.getExcuteFormula(), findStr, replaceStr)); + } + } + }, + DICT_PRODUCE(SearchTag.DICT_PRODUCE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof FormulaDictionary) { + FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject(); + dictionary.setProduceFormula(ShowValueUtils.replaceAll(dictionary.getProduceFormula(), findStr, replaceStr)); + } + } + }; + + int index; + + FormulaTag(int index) { + this.index = index; + } + + /** + * 匹配 + * + * @param index + * @return + */ + @Nullable + public static FormulaTag match(int index) { + FormulaTag[] values = FormulaTag.values(); + for (FormulaTag value : values) { + if (value.index == index) { + return value; + } + } + return null; + } + + + @Override + abstract public void setValue(Info info, String findStr, String replaceStr, List> operatorArray); + + @Override + public String getInfoShowStr(Info info) { + return info.getContent().getOldShowStr(); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/SearchFormula.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/SearchFormula.java new file mode 100644 index 0000000000..67bc2e4b1f --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/SearchFormula.java @@ -0,0 +1,38 @@ +package com.fr.design.actions.replace.action.content.formula; + +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.mainframe.JTemplate; + + +import java.util.List; + +/** + * 获取公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-18 + */ +public interface SearchFormula extends SearchAction { + /** + * 获取公式 + * + * @param formulaInfos 存储公式信息的列表 + * @param content ITContent的数据结构 + */ + default void searchFormula(List formulaInfos, ITContent content) { + } + + + /** + * 获取各个地方的公式 + * + * @param jTemplate + * @param formulaInfos + */ + default void searchFormulaFromObject(JTemplate jTemplate, List formulaInfos) { + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/SearchFormulaManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/SearchFormulaManager.java new file mode 100644 index 0000000000..296123405e --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/SearchFormulaManager.java @@ -0,0 +1,106 @@ +package com.fr.design.actions.replace.action.content.formula; + +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.action.content.formula.cell.SearchCellFormulaAction; +import com.fr.design.actions.replace.action.content.formula.data.SearchDataFormulaAction; +import com.fr.design.actions.replace.action.content.formula.floatelement.SearchFloatFormulaAction; +import com.fr.design.actions.replace.action.content.formula.template.SearchTemplateFormulaAction; +import com.fr.design.actions.replace.action.content.formula.widget.SearchWidgetFormulaAction; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.mainframe.JTemplate; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * 管理公式类型搜索的注册 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-17 + */ +public class SearchFormulaManager implements SearchAction { + private List formulaInfos; + private Set formulaProviderSet = new HashSet<>(); + + private SearchFormulaManager() { + register(SearchCellFormulaAction.getInstance()); + register(SearchWidgetFormulaAction.getInstance()); + register(SearchDataFormulaAction.getInstance()); + register(SearchTemplateFormulaAction.getInstance()); + register(SearchFloatFormulaAction.getInstance()); + } + + @Override + public void search4Infos(JTemplate jTemplate) { + List formulaInfos = new ArrayList<>(); + for (SearchFormula searchFormula : formulaProviderSet) { + searchFormula.searchFormulaFromObject(jTemplate, formulaInfos); + } + setFormulaInfos(formulaInfos); + } + + /** + * 注册对应的SearchFormula + * + * @param searchFormula + */ + public void register(SearchFormula searchFormula) { + formulaProviderSet.add(searchFormula); + } + + /** + * 注销对应的SearchFormula + * + * @param searchFormula + */ + public void remove(SearchFormula searchFormula) { + formulaProviderSet.remove(searchFormula); + } + + + public List getFormulaInfos() { + return formulaInfos; + } + + public void setFormulaInfos(List formulaInfos) { + this.formulaInfos = formulaInfos; + } + + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchFormulaManager getInstance() { + return SearchFormulaManagerEnum.SINGLETON.getInstance(); + } + + + /** + * 枚举实现单例 + */ + private enum SearchFormulaManagerEnum { + /** + * 单例 + */ + SINGLETON; + private SearchFormulaManager instance; + + SearchFormulaManagerEnum() { + instance = new SearchFormulaManager(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchFormulaManager getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormula.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormula.java new file mode 100644 index 0000000000..a865449356 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormula.java @@ -0,0 +1,38 @@ +package com.fr.design.actions.replace.action.content.formula.cell; + +import com.fr.design.actions.replace.action.content.formula.SearchFormula; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.mainframe.JTemplate; + +import java.util.List; + +/** + * 查找单元格中可能存在的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-19 + */ +public interface SearchCellFormula extends SearchFormula { + + /** + * 查找单元格可能存在的共有的公式 + * + * @param jTemplate 指定搜索模板 + * @param formulaInfos 要存储对应信息列表的数据结构 + */ + default void searchFormulaFromCell(JTemplate jTemplate, List formulaInfos) { + } + + /** + * 查找不同单元格内容类型各自可能存在的公式 + * + * @param formulaInfos + * @param content + */ + default void searchFormulaFromCellType(List formulaInfos, ITContent content) { + } + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaAction.java new file mode 100644 index 0000000000..39ccf32585 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaAction.java @@ -0,0 +1,315 @@ +package com.fr.design.actions.replace.action.content.formula.cell; + +import com.fr.base.Formula; +import com.fr.base.present.DictPresent; +import com.fr.base.present.FormulaPresent; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.actions.replace.action.content.cell.SearchCellAction; +import com.fr.design.actions.replace.action.content.formula.chart.SearchChartCollectionFormulaAction; +import com.fr.design.actions.replace.action.content.formula.highlight.condition.*; +import com.fr.design.actions.replace.action.content.formula.highlight.SearchHighlightFormulaAction; +import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction; +import com.fr.design.actions.replace.action.content.formula.widget.DictionaryType; +import com.fr.design.actions.replace.info.CellInfo; +import com.fr.design.actions.replace.info.FormulaInfo; + +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.info.base.SearchTag; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.general.data.Condition; +import com.fr.js.NameJavaScriptGroup; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.CellGUIAttr; +import com.fr.report.cell.cellattr.highlight.DefaultHighlight; +import com.fr.report.cell.cellattr.highlight.HighlightAction; +import com.fr.report.cell.cellattr.highlight.HighlightGroup; +import com.fr.report.core.sort.common.CellSortAttr; +import com.fr.report.core.sort.sortexpression.FormulaSortExpression; +import com.fr.report.core.sort.sortexpression.SortExpression; +import com.fr.stable.CommonUtils; + + +import java.util.List; +import java.util.Map; + +/** + * 搜索单元格中的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-17 + */ +public class SearchCellFormulaAction implements SearchCellFormula { + + + private SearchCellFormulaAction() { + } + + @Override + public void searchFormulaFromObject(JTemplate jTemplate, List formulaInfos) { + searchFormulaFromCell(jTemplate, formulaInfos); + } + + /** + * 从单元格中寻找公式 + * + * @param jTemplate 指定搜索模板 + * @param formulaInfos 指定添加信息的数组 + */ + @Override + public void searchFormulaFromCell(JTemplate jTemplate, List formulaInfos) { + SearchCellAction searchCellAction = SearchCellAction.getInstance(); + searchCellAction.search4Infos(jTemplate); + if (searchCellAction.isCellInfosExist()) { + for (CellInfo cellInfo : searchCellAction.getCellInfos()) { + //根据单元格类型的不同来进行不同的操作 + searchFormulaFromCellInfo(cellInfo, formulaInfos); + + if (cellInfo.getContent().getReplaceObject() instanceof TemplateCellElement) { + //单元格属性-排序 + searchCellSortAttr4Formula(cellInfo, formulaInfos); + //单元格属性-形态 + searchCellPresent4Formula(cellInfo, formulaInfos); + //单元格属性-其他-内容提示-自定义 + searchCellToolTip4Formula(cellInfo, formulaInfos); + //单元格属性-其他-插入策略 + searchCellInsertPolicy4Formula(cellInfo, formulaInfos); + //单元格条件属性-参数-公式 + searchCellConditionPara4Formula(cellInfo, formulaInfos); + //单元格条件属性-属性-参数 + searchCellHighlightPara4Formula(cellInfo, formulaInfos); + //单元格超链 + searchCellHyperLink4Formula(cellInfo, formulaInfos); + } + + } + } + + } + + private void searchCellToolTip4Formula(CellInfo cellInfo, List formulaInfos) { + if (cellInfo.getContent().getReplaceObject() instanceof TemplateCellElement) { + TemplateCellElement cellElement = (TemplateCellElement) cellInfo.getContent().getReplaceObject(); + if (isCellGUIAttrValid(cellElement.getCellGUIAttr())) { + CellGUIAttr attr = cellElement.getCellGUIAttr(); + ITContent attrContent = ITContent.copy(cellInfo.getContent()); + attrContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Cell_Attributes"), + Toolkit.i18nText("Fine-Design_Report_Other"), + Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip"), + Toolkit.i18nText("Fine-Design_Basic_Custom") + ); + attrContent.setReplaceObject(attr.getTooltipText()); + attrContent.setHoldObject(attr); + attrContent.setTag(SearchTag.CELL_TOOL_TIP); + formulaInfos.add(new FormulaInfo(attrContent)); + } + } + } + + private boolean isCellGUIAttrValid(CellGUIAttr attr) { + return attr != null && attr.isCustomTooltip() && CommonUtils.canBeFormula(attr.getTooltipText()); + } + + private void searchCellHyperLink4Formula(CellInfo cellInfo, List formulaInfos) { + NameJavaScriptGroup nameJavaScriptGroup = ((CellElement) cellInfo.getContent().getReplaceObject()).getNameHyperlinkGroup(); + if (nameJavaScriptGroup != null) { + for (int i = 0; i < nameJavaScriptGroup.size(); i++) { + SearchJSHighlightAction action = SearchJSHighlightAction.getInstance(); + ITContent content = ITContent.copy(cellInfo.getContent()); + content.addOtherPos(nameJavaScriptGroup.getNameHyperlink(i).getName()); + action.searchJSFormulaFromOther(formulaInfos, content, nameJavaScriptGroup.getNameHyperlink(i).getJavaScript()); + } + } + + } + + private void searchCellHighlightPara4Formula(CellInfo cellInfo, List formulaInfos) { + if (isHighlightGroupEmpty(cellInfo)) { + HighlightGroup highlightGroup = ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getHighlightGroup(); + for (int i = 0; i < highlightGroup.size(); i++) { + for (int j = 0; j < ((DefaultHighlight) highlightGroup.getHighlight(i)).actionCount(); j++) { + HighlightAction highlightAction = ((DefaultHighlight) highlightGroup.getHighlight(i)).getHighlightAction(j); + //处理HighlightAction + SearchHighlightFormulaAction searchHighlightAction = SearchHighlightFormulaAction.getInstance(); + ITContent newContent = ITContent.copy(cellInfo.getContent()); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Condition_Attributes"), + highlightGroup.getHighlight(i).getName()); + searchHighlightAction.dealWithHighlightAction(newContent, formulaInfos, highlightAction); + } + } + } + } + + private void searchCellConditionPara4Formula(CellInfo cellInfo, List formulaInfos) { + if (isHighlightGroupEmpty(cellInfo)) { + HighlightGroup highlightGroup = ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getHighlightGroup(); + for (int i = 0; i < highlightGroup.size(); i++) { + DefaultHighlight defaultHighlight = (DefaultHighlight) highlightGroup.getHighlight(i); + if (isConditionKeyExist(defaultHighlight.getCondition())) { + Map conditionType = SearchConditionManager.getInstance().getConditionType(); + SearchConditionFormula searchCondition = conditionType.get(((DefaultHighlight) highlightGroup.getHighlight(i)).getCondition().getClass().getSimpleName()); + ITContent newContent = ITContent.copy(cellInfo.getContent()); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Condition_Attributes"), + Toolkit.i18nText("Fine-Design_Basic_Formula")); + searchCondition.searchFormulaFromCondition(formulaInfos, newContent, ((DefaultHighlight) highlightGroup.getHighlight(i)).getCondition()); + } + } + } + } + + private boolean isHighlightGroupEmpty(CellInfo cellInfo) { + return ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getHighlightGroup() != null; + } + + private boolean isConditionKeyExist(Condition condition) { + + return SearchConditionManager.getInstance().getConditionType().containsKey(condition.getClass().getSimpleName()); + } + + + private void searchCellPresent4Formula(CellInfo cellInfo, List formulaInfos) { + if (isFormulaPresentValid(cellInfo)) { + ITContent newContent = ITContent.copy(cellInfo.getContent()); + newContent.setReplaceObject((((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getPresent())); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Cell_Attributes"), + Toolkit.i18nText("Fine-Design_Report_Present")); + formulaInfos.add(new FormulaInfo(newContent)); + } + if (isDictPresentValid(cellInfo)) { + ITContent dictContent = ITContent.copy(cellInfo.getContent()); + dictContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Cell_Attributes"), + Toolkit.i18nText("Fine-Design_Report_Present") + ); + DictPresent present = (DictPresent) ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getPresent(); + if (present.getDictionary() != null) { + DictionaryType type = DictionaryType.match(present.getDictionary().getClass().getSimpleName()); + if (type != null) { + type.searchFormulaFromDictionary(dictContent, formulaInfos, present.getDictionary()); + } + } + } + } + + private void searchCellInsertPolicy4Formula(CellInfo cellInfo, List formulaInfos) { + if (isInsertPolicyValid(cellInfo)) { + ITContent newContent = ITContent.copy(cellInfo.getContent()); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Cell_Attributes"), + Toolkit.i18nText("Fine-Design_Report_Other"), + Toolkit.i18nText("Fine-Design_Basic_CellWrite_InsertRow_Policy")); + newContent.setReplaceObject(((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getCellInsertPolicyAttr()); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + + private boolean isFormulaPresentValid(CellInfo cellInfo) { + return ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getPresent() != null + && ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getPresent() instanceof FormulaPresent; + } + + private boolean isDictPresentValid(CellInfo cellInfo) { + return ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getPresent() != null + && ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getPresent() instanceof DictPresent; + } + + private boolean isInsertPolicyValid(CellInfo cellInfo) { + return ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getCellInsertPolicyAttr() != null + && ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getCellInsertPolicyAttr().getDefaultInsertValue() instanceof Formula; + } + + + private void searchCellSortAttr4Formula(CellInfo cellInfo, List formulaInfos) { + if (isSortAttrValid(cellInfo)) { + CellSortAttr sortAttr = ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getCellExpandAttr().getCellSortAttr(); + if (isSortAttrExist(sortAttr)) { + for (SortExpression sortExpression : sortAttr.getSortExpressions()) { + if (sortExpression instanceof FormulaSortExpression) { + ITContent newContent = ITContent.copy(cellInfo.getContent()); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Cell_Attributes"), + Toolkit.i18nText("Fine-Design_Report_Expand"), + Toolkit.i18nText("Fine-Design_Basic_Action_Sort") + ); + newContent.setReplaceObject(sortExpression); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + + } + } + } + + private boolean isSortAttrExist(CellSortAttr sortAttr) { + return sortAttr != null && sortAttr.getSortExpressions() != null; + } + + private boolean isSortAttrValid(CellInfo cellInfo) { + return ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getCellExpandAttr() != null; + } + + private void searchFormulaFromCellInfo(CellInfo cellInfo, List formulaInfos) { + Map cellType = SearchCellFormulaManager.getInstance().getCellType(); + CellElement cellElement = ((CellElement) (cellInfo.getContent().getReplaceObject())); + if (isCellValueValid(cellInfo)) { + SearchCellFormula searchCellFormula = cellType.get(cellElement.getValue().getClass().getSimpleName()); + searchCellFormula.searchFormulaFromCellType(formulaInfos, cellInfo.getContent()); + } else if (isChart(cellInfo)) { + ITContent chartContent = cellInfo.getContent(); + //这边置否的原因是决策报表里面单元格里面放的图表是可以有多个的,每个还是有各自的名字,和普通报表一样处理即可 + chartContent.setFrmFlag(false); + SearchChartCollectionFormulaAction.getInstance().searchChartCollectionFormula(formulaInfos, cellInfo.getContent(), (ChartCollection) cellElement.getValue()); + } + } + + private boolean isChart(CellInfo cellInfo) { + return ((CellElement) (cellInfo.getContent().getReplaceObject())).getValue() != null + && ((CellElement) (cellInfo.getContent().getReplaceObject())).getValue() instanceof ChartCollection; + } + + private boolean isCellValueValid(CellInfo cellInfo) { + Map cellType = SearchCellFormulaManager.getInstance().getCellType(); + return ((CellElement) (cellInfo.getContent().getReplaceObject())).getValue() != null + && cellType.containsKey(((CellElement) (cellInfo.getContent().getReplaceObject())).getValue().getClass().getSimpleName()); + } + + /** + * 获取单例 + * + * @return + */ + public static SearchCellFormulaAction getInstance() { + return SearchCellFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * SearchCellFormulaAction 的单例 + */ + enum SearchCellFormulaActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchCellFormulaAction instance; + + SearchCellFormulaActionEnum() { + instance = new SearchCellFormulaAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchCellFormulaAction getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaManager.java new file mode 100644 index 0000000000..59982245e3 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaManager.java @@ -0,0 +1,108 @@ +package com.fr.design.actions.replace.action.content.formula.cell; + +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.action.SearchManager; + +import java.util.HashMap; +import java.util.Map; + +/** + * 管理要搜索的单元格类型(公式) + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-16 + */ +public class SearchCellFormulaManager implements SearchManager { + private Map cellType = new HashMap<>(); + public static final String DS_COLUMN = "DSColumn"; + public static final String FORMULA = "Formula"; + public static final String RICH_TEXT = "RichText"; + public static final String SUB_REPORT = "SubReport"; + + private SearchCellFormulaManager() { + //数据列 + register(DS_COLUMN, SearchDSColumnFormulaAction.getInstance()); + //公式 + register(FORMULA, SearchCellFormulaTypeAction.getInstance()); + //子报表 + register(SUB_REPORT, SearchSubReportFormulaAction.getInstance()); + + } + + @Override + public void registerAction(String tag, SearchAction searchAction) { + if (searchAction instanceof SearchCellFormula){ + register(tag, (SearchCellFormula) searchAction); + } + + } + + @Override + public void removeAction(String tag) { + remove(tag); + } + + /** + * 注册 + * + * @param tag 用于匹配的类型tag + * @param searchCellFormula 对应的实现类 + */ + private void register(String tag, SearchCellFormula searchCellFormula) { + cellType.put(tag, searchCellFormula); + } + + /** + * 注销 + * + * @param tag 用于匹配的tag + */ + private void remove(String tag) { + cellType.remove(tag); + } + + /** + * 获取单元格类型 + * + * @return + */ + public Map getCellType() { + return cellType; + } + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchCellFormulaManager getInstance() { + return SearchCellFormulaManagerEnum.SINGLETON.getInstance(); + } + + + + /** + * 枚举实现单例 + */ + private enum SearchCellFormulaManagerEnum { + /** + * 单例 + */ + SINGLETON; + private SearchCellFormulaManager instance; + + SearchCellFormulaManagerEnum() { + instance = new SearchCellFormulaManager(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchCellFormulaManager getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaTypeAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaTypeAction.java new file mode 100644 index 0000000000..aed99da757 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaTypeAction.java @@ -0,0 +1,62 @@ +package com.fr.design.actions.replace.action.content.formula.cell; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.report.cell.CellElement; + +import java.util.List; + +/** + * 查找公式时单元格格式如果是公式类型则操作此类 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-18 + */ +public class SearchCellFormulaTypeAction implements SearchCellFormula { + + + private SearchCellFormulaTypeAction(){} + + @Override + public void searchFormulaFromCellType(List formulaInfos, ITContent content) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(((CellElement) (content.getReplaceObject())).getValue()); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Formula")); + formulaInfos.add(new FormulaInfo(newContent)); + } + + /** + * 获取单例 + * + * @return + */ + public static SearchCellFormulaTypeAction getInstance() { + return SearchCellFormulaTypeActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchCellFormulaTypeActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchCellFormulaTypeAction instance; + + SearchCellFormulaTypeActionEnum() { + instance = new SearchCellFormulaTypeAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchCellFormulaTypeAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchDSColumnFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchDSColumnFormulaAction.java new file mode 100644 index 0000000000..5bced089a6 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchDSColumnFormulaAction.java @@ -0,0 +1,156 @@ +package com.fr.design.actions.replace.action.content.formula.cell; + +import com.fr.base.Formula; +import com.fr.base.Parameter; +import com.fr.design.actions.replace.action.content.formula.highlight.condition.SearchConditionFormula; +import com.fr.design.actions.replace.action.content.formula.highlight.condition.SearchConditionManager; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.general.data.Condition; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.report.core.sort.sortexpression.FormulaSortExpression; +import com.fr.report.core.sort.sortexpression.SortExpression; + + +import java.util.List; +import java.util.Map; + +/** + * 查找公式时单元格格式如果是数据列型则操作此类 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-18 + */ +public class SearchDSColumnFormulaAction implements SearchCellFormula { + + private SearchDSColumnFormulaAction(){} + + + + @Override + public void searchFormulaFromCellType(List formulaInfos, ITContent itContent) { + if (itContent.getReplaceObject() instanceof CellElement){ + CellElement cellElement = (CellElement) itContent.getReplaceObject(); + if (cellElement.getValue() instanceof DSColumn) { + if (((DSColumn) cellElement.getValue()).getCondition() != null) { + ITContent content = ITContent.copy(itContent); + //数据列 + content.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_DS_Column")); + DSColumn dsColumn = (DSColumn) ((CellElement) (itContent.getReplaceObject())).getValue(); + //过滤条件中的公式 + addFormulaInfos2ArrayFromCondition(content, dsColumn.getCondition(), formulaInfos); + //动态参数中的公式 + addFormulaInfos2ArrayFromPara(content, dsColumn, formulaInfos); + //高级-排序中的公式 + addFormulaInfos2ArrayFromSortExpression(content, dsColumn, formulaInfos); + //高级-显示值中的公式 + addFormulaInfos2ArrayFromResult(content, dsColumn, formulaInfos); + + } + + } + } + + } + + private void addFormulaInfos2ArrayFromResult(ITContent content, DSColumn dsColumn, List formulaInfos) { + char formulaLabel = '='; + if (dsColumn.getResult() != null && dsColumn.getResult().length() > 0 && dsColumn.getResult().charAt(0) == formulaLabel) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(dsColumn); + //高级-显示值 + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Advanced"), + Toolkit.i18nText("Fine-Design_Basic_Display_Value") + ); + formulaInfos.add(new FormulaInfo(newContent)); + } + + } + + private void addFormulaInfos2ArrayFromSortExpression(ITContent content, DSColumn dsColumn, List formulaInfos) { + if (dsColumn.getCellSortAttr() != null && dsColumn.getCellSortAttr().getSortExpressions() != null) { + for (SortExpression sortExpression : dsColumn.getCellSortAttr().getSortExpressions()) { + if (sortExpression instanceof FormulaSortExpression) { + ITContent newContent = ITContent.copy(content); + //高级-排序 + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Advanced"), + Toolkit.i18nText("Fine-Design_Basic_Action_Sort") + ); + newContent.setReplaceObject(sortExpression); + formulaInfos.add(new FormulaInfo(newContent)); + + } + } + + } + } + + private void addFormulaInfos2ArrayFromPara(ITContent content, DSColumn dsColumn, List formulaInfos) { + for (Parameter parameter : dsColumn.getParameters()) { + if (parameter.getValue() instanceof Formula) { + ITContent newContent = ITContent.copy(content); + //动态参数注入 + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_TableData_Dynamic_Parameter_Setting")); + newContent.setReplaceObject(parameter.getValue()); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + } + + /** + * 数据列过滤条件中的公式 + */ + private void addFormulaInfos2ArrayFromCondition(ITContent content, Condition condition, List formulaInfos) { + //这边condition有三种情况:FormulaCondition、CommonCondition、ListCondition,分别处理 + Map conditionType = SearchConditionManager.getInstance().getConditionType(); + if (conditionType.containsKey(condition.getClass().getSimpleName())){ + SearchConditionFormula searchCondition = conditionType.get(condition.getClass().getSimpleName()); + ITContent newContent = ITContent.copy(content); + //过滤条件 + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Filter_Conditions")); + searchCondition.searchFormulaFromCondition(formulaInfos, newContent, condition); + } + + + } + + + /** + * 获取单例 + * + * @return + */ + public static SearchDSColumnFormulaAction getInstance() { + return SearchDSColumnFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchDSColumnFormulaActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchDSColumnFormulaAction instance; + + SearchDSColumnFormulaActionEnum() { + instance = new SearchDSColumnFormulaAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchDSColumnFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchRichFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchRichFormulaAction.java new file mode 100644 index 0000000000..5e60e17fff --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchRichFormulaAction.java @@ -0,0 +1,79 @@ +package com.fr.design.actions.replace.action.content.formula.cell; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.cellattr.core.RichChar; +import com.fr.report.cell.cellattr.core.RichText; + +import java.util.Iterator; +import java.util.List; + +/** + * 搜索单元格富文本类型的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-18 + */ +public class SearchRichFormulaAction implements SearchCellFormula { + + private SearchRichFormulaAction() { + } + + + @Override + public void searchFormulaFromCellType(List formulaInfos, ITContent content) { + RichText richText = ((RichText) ((CellElement) (content.getReplaceObject())).getValue()); + Iterator it = richText.charIterator(); + while (it.hasNext()) { + RichChar richChar = it.next(); + if (richChar.isFormula()) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(richChar); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Rich_Text"), + Toolkit.i18nText("Fine-Design_Basic_Formula") + ); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + } + + + /** + * 获取单例 + * + * @return + */ + public static SearchRichFormulaAction getInstance() { + return SearchRichFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchRichFormulaActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchRichFormulaAction instance; + + SearchRichFormulaActionEnum() { + instance = new SearchRichFormulaAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchRichFormulaAction getInstance() { + return instance; + } + } + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchSubReportFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchSubReportFormulaAction.java new file mode 100644 index 0000000000..36c86b29ac --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchSubReportFormulaAction.java @@ -0,0 +1,70 @@ +package com.fr.design.actions.replace.action.content.formula.cell; + +import com.fr.base.Formula; +import com.fr.base.core.KV; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.cellattr.core.SubReport; + +import java.util.List; + +/** + * 搜索单元格子报表类型的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-18 + */ +public class SearchSubReportFormulaAction implements SearchCellFormula { + + private SearchSubReportFormulaAction() { + } + + @Override + public void searchFormulaFromCellType(List formulaInfos, ITContent content) { + KV[] kvs = ((SubReport) (((CellElement) content.getReplaceObject()).getValue())).getParameterKVS(); + for (KV kv : kvs) { + if (kv.getValue() instanceof Formula) { + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Sub_Report_Parameter")); + newContent.setReplaceObject(kv); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + } + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchSubReportFormulaAction getInstance() { + return SearchSubReportFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchSubReportFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchSubReportFormulaAction instance; + + SearchSubReportFormulaActionEnum() { + instance = new SearchSubReportFormulaAction(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchSubReportFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartBoxDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartBoxDataFormulaAction.java new file mode 100644 index 0000000000..b677d3e86f --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartBoxDataFormulaAction.java @@ -0,0 +1,95 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.box.data.VanBoxReportDefinition; +import com.fr.plugin.chart.box.data.VanBoxReportDetailedDefinition; +import com.fr.plugin.chart.box.data.VanBoxReportResultDefinition; + +import java.util.List; + +/** + * 箱型图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartBoxDataFormulaAction implements SearchChartDataFormula { + + private SearchChartBoxDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof VanBoxReportDefinition) { + VanBoxReportDefinition definition = (VanBoxReportDefinition) provider; + //明细数据 + ITContent detailContent = ITContent.copy(content); + detailContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Detailed_Data")); + dealDetailDefinition(formulaInfos, detailContent, definition.getDetailedDefinition()); + //结果数据 + ITContent resultContent = ITContent.copy(content); + resultContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Result_Data")); + dealResultDefinition(formulaInfos, resultContent, definition.getResultDefinition()); + } + } + + private void dealResultDefinition(List formulaInfos, ITContent content, VanBoxReportResultDefinition resultDefinition) { + //分类 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Category"), resultDefinition.getCategoryName()); + //系列名 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Series_Name"), resultDefinition.getSeriesName()); + //最大值 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Data_Max"), resultDefinition.getMax()); + //上四分位数 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Data_Q3"), resultDefinition.getQ3()); + //中位数 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Data_Median"), resultDefinition.getMedian()); + //下四分位数 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Data_Q1"), resultDefinition.getQ1()); + //最小值 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Min_Value"), resultDefinition.getMin()); + + } + + private void dealDetailDefinition(List formulaInfos, ITContent content, VanBoxReportDetailedDefinition detailedDefinition) { + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Category_Name"), detailedDefinition.getCategoryName()); + SearchChartMapDataFormulaAction.dealSeriesDefinition(formulaInfos, content, detailedDefinition.getSeriesList()); + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartBoxDataFormulaAction getInstance() { + return SearchChartBoxDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartBoxDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartBoxDataFormulaAction instance; + + SearchChartBoxDataFormulaActionEnum() { + instance = new SearchChartBoxDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartBoxDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartBubbleDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartBubbleDataFormulaAction.java new file mode 100644 index 0000000000..d012ad58b3 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartBubbleDataFormulaAction.java @@ -0,0 +1,79 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartdata.BubbleReportDefinition; +import com.fr.chart.chartdata.BubbleSeriesValue; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; + +import java.util.List; + +/** + * 散点图、气泡图数据 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartBubbleDataFormulaAction implements SearchChartDataFormula { + + private SearchChartBubbleDataFormulaAction() { + } + + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof BubbleReportDefinition) { + BubbleReportDefinition reportDefinition = (BubbleReportDefinition) provider; + for (int i = 0; i < reportDefinition.size(); i++) { + if (reportDefinition.get(i) instanceof BubbleSeriesValue) { + BubbleSeriesValue seriesValue = (BubbleSeriesValue) reportDefinition.get(i); + dealBubbleSeriesValue(formulaInfos, content, seriesValue); + } + } + } + } + + private void dealBubbleSeriesValue(List formulaInfos, ITContent content, BubbleSeriesValue seriesValue) { + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Series_Name"), seriesValue.getBubbleSereisName()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Size"), seriesValue.getBubbleSeriesSize()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_X_Axis"), seriesValue.getBubbleSeriesX()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Y_Axis"), seriesValue.getBubbleSeriesY()); + } + + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartBubbleDataFormulaAction getInstance() { + return SearchChartBubbleDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartBubbleDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartBubbleDataFormulaAction instance; + + SearchChartBubbleDataFormulaActionEnum() { + instance = new SearchChartBubbleDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartBubbleDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java new file mode 100644 index 0000000000..aadf2aee41 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java @@ -0,0 +1,392 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.Formula; +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.base.present.DictPresent; +import com.fr.base.present.FormulaPresent; +import com.fr.base.present.Present; +import com.fr.chart.base.AttrChangeConfig; +import com.fr.chart.chartattr.Axis; +import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Plot; +import com.fr.chart.chartattr.SwitchTitle; +import com.fr.chart.chartattr.Title; + +import com.fr.chart.chartdata.NormalReportDataDefinition; +import com.fr.chart.chartdata.SeriesDefinition; + +import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction; +import com.fr.design.actions.replace.action.content.formula.widget.DictionaryType; +import com.fr.design.actions.replace.info.CellInfo; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.JSInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; + +import com.fr.js.NameJavaScript; +import com.fr.js.NameJavaScriptGroup; +import com.fr.plugin.chart.attr.axis.VanChartAlertValue; +import com.fr.plugin.chart.attr.axis.VanChartAxis; +import com.fr.plugin.chart.attr.axis.VanChartValueAxis; +import com.fr.plugin.chart.custom.CustomPlotFactory; +import com.fr.plugin.chart.custom.VanChartCustomPlot; +import com.fr.plugin.chart.custom.type.CustomPlotType; +import com.fr.report.cell.TemplateCellElement; +import com.fr.stable.StringUtils; + +import java.util.List; +import java.util.Map; + +/** + * 图表类型获取公式汇总 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-12 + */ +public class SearchChartCollectionFormulaAction { + + private SearchChartCollectionFormulaAction() { + } + + /** + * 搜索图表中的公式 + * + * @param formulaInfos + * @param content + * @param chartCollection + */ + public void searchChartCollectionFormula(List formulaInfos, ITContent content, ChartCollection chartCollection) { + for (int i = 0; i < chartCollection.getChartCount(); i++) { + ITContent chartContent = ITContent.copy(content); + searchChartPatternFormula(formulaInfos, chartContent, chartCollection.getChart(i)); + if (isChangeConfigAttrValid(chartCollection.getChangeConfigAttr())) { + //图表切换属性 + dealChangeConfig(formulaInfos, chartContent, chartCollection.getChart(i)); + } + //图表-交互属性-超级链接 + dealChartHyperLink(formulaInfos, chartContent, chartCollection.getChart(i)); + //数据-单元格数据-分类名&系列名&值 + SearchChartDataFormulaManager searchChartDataFormulaManager = SearchChartDataFormulaManager.getInstance(); + Map type = searchChartDataFormulaManager.getChartDataType(); + if (isDefinitionValid(chartCollection.getChart(i).getFilterDefinition())) { + String name = chartCollection.getChart(i).getFilterDefinition().getClass().getSimpleName(); + SearchChartDataFormula searchChartDataFormula = type.get(name); + TopDefinitionProvider provider = chartCollection.getChart(i).getFilterDefinition(); + ITContent dataContent = ITContent.copy(content); + dataContent.addOtherPos(chartCollection.getChart(i).getChartName(), Toolkit.i18nText("Fine-Design_Basic_Data")); + searchChartDataFormula.searchChartDataFormula(formulaInfos, dataContent, provider); + } + //数据-形态 + if (chartCollection.getChart(i).getFilterDefinition() != null) { + ITContent presentContent = ITContent.copy(content); + presentContent.addOtherPos(chartCollection.getChart(i).getChartName(), Toolkit.i18nText("Fine-Design_Basic_Data")); + searchFormulaFromChartPresent(formulaInfos, presentContent, chartCollection.getChart(i).getFilterDefinition()); + } + } + } + + private void dealChartHyperLink(List formulaInfos, ITContent content, Chart chart) { + ITContent conditionContent = ITContent.copy(content); + if (StringUtils.isNotEmpty(chart.getChartName())) { + conditionContent.addOtherPos(chart.getChartName()); + } + conditionContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Animation_Special"), + Toolkit.i18nText("Fine-Design_Chart_Interactive") + ); + + if (chart.getPlot() instanceof VanChartCustomPlot) { + VanChartCustomPlot plot = chart.getPlot(); + for (int i = 0; i < plot.getCustomPlotList().size(); i++) { + ITContent customContent = ITContent.copy(conditionContent); + customContent.addOtherPos(CustomPlotFactory.getTitle(CustomPlotFactory.getCustomType(plot.getCustomPlotList().get(i)))); + dealPlot(formulaInfos, customContent, plot.getCustomPlotList().get(i)); + } + } else if (chart.getPlot() != null) { + dealPlot(formulaInfos, conditionContent, chart.getPlot()); + } + + } + + private void dealPlot(List formulaInfos, ITContent content, Plot plot) { + NameJavaScriptGroup javaScriptGroup = plot.getHotHyperLink(); + if (javaScriptGroup != null) { + for (int i = 0; i < javaScriptGroup.size(); i++) { + NameJavaScript javaScript = javaScriptGroup.getNameHyperlink(i); + content.addOtherPos(javaScript.getName()); + SearchJSHighlightAction action = SearchJSHighlightAction.getInstance(); + action.searchJSFormulaFromOther(formulaInfos, content, javaScript.getJavaScript()); + } + } + } + + private void searchFormulaFromChartPresent(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + searchPresent4Formula(provider.getCategoryPresent(), content, formulaInfos); + searchPresent4Formula(provider.getSeriesPresent(), content, formulaInfos); + + } + + private void searchPresent4Formula(Present present, ITContent content, List formulaInfos) { + if (present instanceof FormulaPresent) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(present); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Style_Present"), + Toolkit.i18nText("Fine-Design_Basic_Present_Formula_Present")); + formulaInfos.add(new FormulaInfo(newContent)); + } + if (present instanceof DictPresent) { + ITContent dictContent = ITContent.copy(content); + dictContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Style_Present"), + Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary") + ); + DictPresent dictPresent = (DictPresent) present; + if (dictPresent.getDictionary() != null) { + DictionaryType type = DictionaryType.match(dictPresent.getDictionary().getClass().getSimpleName()); + if (type != null) { + type.searchFormulaFromDictionary(dictContent, formulaInfos, dictPresent.getDictionary()); + } + } + } + } + + private boolean isChangeConfigAttrValid(AttrChangeConfig attrChangeConfig) { + return attrChangeConfig != null && attrChangeConfig.isEnable(); + } + + private void dealChangeConfig(List formulaInfos, ITContent chartContent, Chart chart) { + ITContent content = ITContent.copy(chartContent); + if (StringUtils.isNotEmpty(chart.getChartName())) { + content.addOtherPos(chart.getChartName()); + } + content.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Type"), + Toolkit.i18nText("Fine-Design_Chart_Change_Config_Attributes") + ); + if (isSwitchTitleValid(chart.getSwitchTitle())) { + SwitchTitle title = chart.getSwitchTitle(); + content.setReplaceObject(title.getContent()); + formulaInfos.add(new FormulaInfo(content)); + } + } + + private boolean isSwitchTitleValid(SwitchTitle title) { + return title != null && title.getContent() instanceof Formula; + } + + private boolean isDefinitionValid(TopDefinitionProvider provider) { + return provider != null && SearchChartDataFormulaManager.getInstance().getChartDataType().containsKey(provider.getClass().getSimpleName()); + } + + + private void searchChartPatternFormula(List formulaInfos, ITContent chartContent, Chart chart) { + //样式-标题 + searchChartPatternFormulaFromTitle(formulaInfos, chartContent, chart); + + //样式-坐标轴-值定义&样式-坐标轴-轴标题 + searchChartPatternFormulaFromAxisValue(formulaInfos, chartContent, chart); + + //样式-背景-警戒线 + searchChartPatternFormulaFromAlertLine(formulaInfos, chartContent, chart); + } + + private void searchChartPatternFormulaFromAlertLine(List formulaInfos, ITContent chartContent, Chart chart) { + if (chart.getPlot() != null) { + Axis xAxis = chart.getPlot().getxAxis(); + Axis yAxis = chart.getPlot().getyAxis(); + ITContent content = ITContent.copy(chartContent); + content.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Pattern"), + Toolkit.i18nText("Fine-Design_Chart_Background"), + Toolkit.i18nText("Fine-Design_Chart_Plot_Region"), + Toolkit.i18nText("Fine-Design_Chart_Alert_Line") + ); + if (xAxis instanceof VanChartAxis) { + List list = ((VanChartAxis) xAxis).getAlertValues(); + for (VanChartAlertValue alertValue : list) { + //警戒线设置 + dealAlertValue(formulaInfos, content, alertValue); + //提示文字 + dealAlertContent(formulaInfos, content, alertValue); + } + } + if (yAxis instanceof VanChartAxis) { + List list = ((VanChartAxis) yAxis).getAlertValues(); + for (VanChartAlertValue alertValue : list) { + //警戒线设置 + dealAlertValue(formulaInfos, content, alertValue); + //提示文字 + dealAlertContent(formulaInfos, content, alertValue); + } + } + } + + + } + + private void dealAlertContent(List formulaInfos, ITContent content, VanChartAlertValue alertValue) { + if (alertValue.getAlertContentFormula() != null) { + ITContent alertContent = ITContent.copy(content); + alertContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Alert_Text")); + alertContent.setReplaceObject(alertValue.getAlertContentFormula()); + formulaInfos.add(new FormulaInfo(alertContent)); + } + } + + private void dealAlertValue(List formulaInfos, ITContent content, VanChartAlertValue alertValue) { + if (alertValue.getAlertValueFormula() != null) { + ITContent valueContent = ITContent.copy(content); + valueContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Alert_Set")); + valueContent.setReplaceObject(alertValue.getAlertValueFormula()); + formulaInfos.add(new FormulaInfo(valueContent)); + } + } + + private void searchChartPatternFormulaFromAxisValue(List formulaInfos, ITContent chartContent, Chart chart) { + if (chart.getPlot() != null) { + Axis xAxis = chart.getPlot().getxAxis(); + Axis yAxis = chart.getPlot().getyAxis(); + //样式-坐标轴-x轴 + if (xAxis != null) { + //轴标题 + ITContent xAxisContent = ITContent.copy(chartContent); + if (!chartContent.isFrm()) { + xAxisContent.addOtherPos(chart.getChartName()); + } + xAxisContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Pattern"), + Toolkit.i18nText("Fine-Design_Chart_Axis"), + Toolkit.i18nText("Fine-Design_Chart_X_Axis") + ); + dealTitle(formulaInfos, xAxisContent, xAxis.getTitle()); + dealChartValueDefine(formulaInfos, xAxisContent, xAxis); + } + + //样式-坐标轴-y轴-轴标题 + if (yAxis != null) { + ITContent yAxisContent = ITContent.copy(chartContent); + yAxisContent.addOtherPos( + chart.getChartName(), + Toolkit.i18nText("Fine-Design_Chart_Pattern"), + Toolkit.i18nText("Fine-Design_Chart_Axis"), + Toolkit.i18nText("Fine-Design_Chart_Y_Axis") + + ); + dealTitle(formulaInfos, yAxisContent, yAxis.getTitle()); + dealChartValueDefine(formulaInfos, yAxisContent, yAxis); + } + } + + } + + private void dealChartValueDefine(List formulaInfos, ITContent axisContent, Axis axis) { + ITContent content = ITContent.copy(axisContent); + content.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Value_Define")); + //自定义最大值最小值 + dealChartMaxAndMinValue(formulaInfos, content, axis); + //自定义主次刻度 + dealChartMainAndSecUnit(formulaInfos, content, axis); + //自定义对数底数 + dealChartLogBase(formulaInfos, content, axis); + + } + + private void dealChartLogBase(List formulaInfos, ITContent content, Axis axis) { + if (axis instanceof VanChartValueAxis) { + if (axis.isLog() && ((VanChartValueAxis) axis).getLogBase() != null) { + ITContent logContent = ITContent.copy(content); + logContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Custom_LogBase_Value")); + logContent.setReplaceObject(((VanChartValueAxis) axis).getLogBase()); + formulaInfos.add(new FormulaInfo(logContent)); + } + } + } + + private void dealChartMainAndSecUnit(List formulaInfos, ITContent content, Axis axis) { + if (axis.isCustomMainUnit() && axis.getMainUnit() != null) { + ITContent mainContent = ITContent.copy(content); + mainContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Custom_Main_Type")); + mainContent.setReplaceObject(axis.getMainUnit()); + formulaInfos.add(new FormulaInfo(mainContent)); + } + if (axis.isCustomSecUnit() && axis.getSecUnit() != null) { + ITContent secContent = ITContent.copy(content); + secContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Custom_Second_Type")); + secContent.setReplaceObject(axis.getSecUnit()); + formulaInfos.add(new FormulaInfo(secContent)); + } + } + + private void dealChartMaxAndMinValue(List formulaInfos, ITContent axisContent, Axis axis) { + if (axis.isCustomMaxValue() && axis.getMaxValue() != null) { + ITContent maxContent = ITContent.copy(axisContent); + maxContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Custom_Max_Value")); + maxContent.setReplaceObject(axis.getMaxValue()); + formulaInfos.add(new FormulaInfo(maxContent)); + } + if (axis.isCustomMinValue() && axis.getMinValue() != null) { + ITContent minContent = ITContent.copy(axisContent); + minContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Custom_Min_Value")); + minContent.setReplaceObject(axis.getMinValue()); + formulaInfos.add(new FormulaInfo(minContent)); + } + } + + private void searchChartPatternFormulaFromTitle(List formulaInfos, ITContent chartContent, Chart chart) { + //样式-标题 + ITContent titleContent = ITContent.copy(chartContent); + titleContent.addOtherPos( + chart.getChartName(), + Toolkit.i18nText("Fine-Design_Chart_Pattern") + + ); + dealTitle(formulaInfos, titleContent, chart.getTitle()); + } + + private void dealTitle(List formulaInfos, ITContent chartContent, Title title) { + if (title != null && title.getTextObject() instanceof Formula) { + ITContent content = ITContent.copy(chartContent); + content.addOtherPos(Toolkit.i18nText("Fine-Design_Form_Title")); + content.setReplaceObject(title.getTextObject()); + formulaInfos.add(new FormulaInfo(content)); + } + } + + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartCollectionFormulaAction getInstance() { + return SearchChartCollectionFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartCollectionFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartCollectionFormulaAction instance; + + SearchChartCollectionFormulaActionEnum() { + instance = new SearchChartCollectionFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartCollectionFormulaAction getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCustomDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCustomDataFormulaAction.java new file mode 100644 index 0000000000..5c63ac52e0 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCustomDataFormulaAction.java @@ -0,0 +1,79 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.plugin.chart.custom.CustomDefinition; +import com.fr.plugin.chart.custom.CustomPlotFactory; +import com.fr.plugin.chart.custom.type.CustomPlotType; + + +import java.util.List; +import java.util.Map; + +/** + * 组合图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartCustomDataFormulaAction implements SearchChartDataFormula { + + private SearchChartCustomDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof CustomDefinition) { + CustomDefinition definition = (CustomDefinition) provider; + Map map = SearchChartDataFormulaManager.getInstance().getChartDataType(); + for (CustomPlotType customPlotType : definition.getDefinitionProviderMap().keySet()) { + TopDefinitionProvider definitionProvider = definition.getDefinitionProviderMap().get(customPlotType); + if (map.containsKey(definitionProvider.getClass().getSimpleName())) { + ITContent customContent = ITContent.copy(content); + customContent.addOtherPos(CustomPlotFactory.getTitle(customPlotType)); + map.get(definitionProvider.getClass().getSimpleName()).searchChartDataFormula(formulaInfos, customContent, definitionProvider); + } + } + + + } + } + + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartCustomDataFormulaAction getInstance() { + return SearchChartCustomDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartCustomDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartCustomDataFormulaAction instance; + + SearchChartCustomDataFormulaActionEnum() { + instance = new SearchChartCustomDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartCustomDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDataFormula.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDataFormula.java new file mode 100644 index 0000000000..6378d9dfb1 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDataFormula.java @@ -0,0 +1,46 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.Formula; +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.design.actions.replace.action.content.formula.SearchFormula; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; + +import java.util.List; + +/** + * 搜索图表-数据中的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public interface SearchChartDataFormula extends SearchFormula { + + + /** + * 搜索图表-数据中的公式 + * + * @param formulaInfos + * @param content + * @param provider + */ + void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider); + + /** + * 快速处理Formula + * + * @param formulaInfos + * @param reportContent + * @param otherPos + * @param o + */ + default void dealFormulaObject(List formulaInfos, ITContent reportContent, String otherPos, Object o) { + if (o instanceof Formula) { + ITContent content = ITContent.copy(reportContent); + content.addOtherPos(otherPos); + content.setReplaceObject(o); + formulaInfos.add(new FormulaInfo(content)); + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDataFormulaManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDataFormulaManager.java new file mode 100644 index 0000000000..f8916a757f --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDataFormulaManager.java @@ -0,0 +1,160 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.action.SearchManager; + +import java.util.HashMap; +import java.util.Map; + +/** + * 管理图表-数据中的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartDataFormulaManager implements SearchManager { + private static Map chartDataType = new HashMap<>(); + /** + * 其余普通类型 + */ + public static final String VAN_CHART_NORMAL_REPORT_DATA_DEFINITION = "VanChartNormalReportDataDefinition"; + /** + * 散点图、气泡图数据 + */ + public static final String BUBBLE_REPORT_DEFINITION = "BubbleReportDefinition"; + /** + * 组合图 + */ + public static final String CUSTOM_DEFINITION = "CustomDefinition"; + /** + * 多层饼图、矩形树图 + */ + public static final String MULTI_PIE_REPORT_DATA_DEFINITION = "MultiPieReportDataDefinition"; + /** + * 地图、热力地图 + */ + public static final String VAN_MAP_DEFINITION = "VanMapDefinition"; + /** + * 钻取地图 + */ + public static final String DRILL_MAP_DEFINITION = "DrillMapDefinition"; + /** + * 词云 + */ + public static final String WORD_CLOUD_REPORT_DEFINITION = "WordCloudReportDefinition"; + /** + * 漏斗图 + */ + public static final String METER_REPORT_DEFINITION = "MeterReportDefinition"; + /** + * 甘特图 + */ + public static final String VAN_GANTT_DEFINITION = "VanGanttDefinition"; + /** + * 框架图 + */ + public static final String STRUCTURE_REPORT_DEFINITION = "StructureReportDefinition"; + /** + * 箱型图 + */ + public static final String VAN_BOX_REPORT_DEFINITION = "VanBoxReportDefinition"; + + /** + * 组合图中的大部分类型 + */ + public static final String NORMAL_REPORT_DATA_DEFINITION = "NormalReportDataDefinition"; + + private SearchChartDataFormulaManager() { + register(VAN_CHART_NORMAL_REPORT_DATA_DEFINITION, SearchChartVanNormalDataFormulaAction.getInstance()); + register(BUBBLE_REPORT_DEFINITION, SearchChartBubbleDataFormulaAction.getInstance()); + register(MULTI_PIE_REPORT_DATA_DEFINITION, SearchChartMultiPieDataFormulaAction.getInstance()); + register(VAN_MAP_DEFINITION, SearchChartMapDataFormulaAction.getInstance()); + register(DRILL_MAP_DEFINITION, SearchChartDrillMapDataFormulaAction.getInstance()); + register(WORD_CLOUD_REPORT_DEFINITION, SearchChartWordCloudDataFormulaAction.getInstance()); + register(METER_REPORT_DEFINITION, SearchChartMeterDataFormulaAction.getInstance()); + register(VAN_GANTT_DEFINITION, SearchChartGanttDataFormulaAction.getInstance()); + register(STRUCTURE_REPORT_DEFINITION, SearchChartStructureDataFormulaAction.getInstance()); + register(VAN_BOX_REPORT_DEFINITION, SearchChartBoxDataFormulaAction.getInstance()); + register(CUSTOM_DEFINITION, SearchChartCustomDataFormulaAction.getInstance()); + register(NORMAL_REPORT_DATA_DEFINITION, SearchChartNormalReportDataFormulaAction.getInstance()); + } + + + /** + * 获取类别 + * + * @return + */ + public Map getChartDataType() { + return chartDataType; + } + + + @Override + public void registerAction(String tag, SearchAction searchAction) { + if (searchAction instanceof SearchChartDataFormula) { + register(tag, (SearchChartDataFormula) searchAction); + } + } + + @Override + public void removeAction(String tag) { + remove(tag); + } + + + /** + * 注册 + * + * @param tag 用于匹配的类型tag + * @param searchChartDataFormula 对应的实现类 + */ + private void register(String tag, SearchChartDataFormula searchChartDataFormula) { + chartDataType.put(tag, searchChartDataFormula); + } + + /** + * 注销 + * + * @param tag 用于匹配的tag + */ + private void remove(String tag) { + chartDataType.remove(tag); + } + + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartDataFormulaManager getInstance() { + return SearchChartCollectionFormulaManagerEnum.SINGLETON.getInstance(); + } + + + /** + * 枚举实现单例 + */ + private enum SearchChartCollectionFormulaManagerEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartDataFormulaManager instance; + + SearchChartCollectionFormulaManagerEnum() { + instance = new SearchChartDataFormulaManager(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartDataFormulaManager getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDrillMapDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDrillMapDataFormulaAction.java new file mode 100644 index 0000000000..e4e6000e85 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartDrillMapDataFormulaAction.java @@ -0,0 +1,93 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chartx.data.AbstractDataDefinition; +import com.fr.chartx.data.DrillMapChartDataDefinition; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.drillmap.data.DrillMapDefinition; +import com.fr.plugin.chart.map.data.VanMapReportDefinition; + +import java.util.List; + +/** + * 钻取地图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartDrillMapDataFormulaAction implements SearchChartDataFormula { + private SearchChartDrillMapDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof DrillMapDefinition) { + DrillMapDefinition definition = (DrillMapDefinition) provider; + + if (definition.isFromBottomData()) { + dealDefinition(formulaInfos, content, definition.getBottomDataDefinition()); + } else { + for (int i = 0; i < definition.getEachLayerDataDefinitionList().size(); i++) { + ITContent listContent = ITContent.copy(content); + int index = i + 1; + listContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Index_Article") + index + Toolkit.i18nText("Fine-Design_Chart_Index_Layer") + ); + dealDefinition(formulaInfos, listContent, definition.getEachLayerDataDefinitionList().get(i)); + } + } + } + } + + /** + * 这边存在点地图和区域地图两种,点地图特殊的地方需要处理一下 + * + * @param formulaInfos + * @param content + * @param provider + */ + private void dealDefinition(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof VanMapReportDefinition) { + SearchChartMapDataFormulaAction.getInstance().dealAreaName(formulaInfos, content, ((VanMapReportDefinition) provider).getCategoryName(), (VanMapReportDefinition) provider); + SearchChartMapDataFormulaAction.dealSeriesDefinition(formulaInfos, content, ((VanMapReportDefinition) provider).getSeriesList()); + SearchChartMapDataFormulaAction.getInstance().dealPointDefinition4Special(formulaInfos, content, provider); + } + + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartDrillMapDataFormulaAction getInstance() { + return SearchChartDrillMapDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartDrillMapDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartDrillMapDataFormulaAction instance; + + SearchChartDrillMapDataFormulaActionEnum() { + instance = new SearchChartDrillMapDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartDrillMapDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartGanttDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartGanttDataFormulaAction.java new file mode 100644 index 0000000000..75c6daf235 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartGanttDataFormulaAction.java @@ -0,0 +1,108 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.Formula; +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.gantt.data.VanGanttDefinition; +import com.fr.plugin.chart.gantt.data.VanGanttLinkReportDefinition; +import com.fr.plugin.chart.gantt.data.VanGanttReportDefinition; + +import java.util.List; + +/** + * 甘特图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartGanttDataFormulaAction implements SearchChartDataFormula { + private SearchChartGanttDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof VanGanttDefinition) { + VanGanttDefinition definition = (VanGanttDefinition) provider; + if (definition.getDataDefinition() instanceof VanGanttReportDefinition) { + VanGanttReportDefinition reportDefinition = (VanGanttReportDefinition) definition.getDataDefinition(); + ITContent reportContent = ITContent.copy(content); + reportContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Gantt_Chart")); + dealReportDefinition(formulaInfos, reportContent, reportDefinition); + } + if (definition.getLinkDefinition() instanceof VanGanttLinkReportDefinition) { + VanGanttLinkReportDefinition linkReportDefinition = (VanGanttLinkReportDefinition) definition.getLinkDefinition(); + ITContent linkContent = ITContent.copy(content); + linkContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Task_Link")); + dealLinkDefinition(formulaInfos, linkContent, linkReportDefinition); + + } + } + } + + private void dealLinkDefinition(List formulaInfos, ITContent linkContent, VanGanttLinkReportDefinition linkReportDefinition) { + //起始任务id + dealFormulaObject(formulaInfos, linkContent, Toolkit.i18nText("Fine-Design_Chart_Start_Task_ID"), linkReportDefinition.getStartTaskID()); + //结束任务id + dealFormulaObject(formulaInfos, linkContent, Toolkit.i18nText("Fine-Design_Chart_End_Task_ID"), linkReportDefinition.getEndTaskID()); + //关联类型 + dealFormulaObject(formulaInfos, linkContent, Toolkit.i18nText("Fine-Design_Chart_Link_Type"), linkReportDefinition.getLinkType()); + } + + private void dealReportDefinition(List formulaInfos, ITContent reportContent, VanGanttReportDefinition reportDefinition) { + //系列名 + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_Series_Name"), reportDefinition.getSeriesName()); + //开始时间 + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_Start_Time"), reportDefinition.getStartTime()); + //结束时间 + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_End_Time"), reportDefinition.getEndTime()); + //里程碑时间 + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_Marker_Time"), reportDefinition.getMarkTime()); + //进度 + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_Process"), reportDefinition.getProgress()); + //任务ID + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_Task_ID"), reportDefinition.getLinkID()); + //项目名称 + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_Project_Name"), reportDefinition.getFirstProcess()); + //项目 + for (Object o : reportDefinition.getProcessList()) { + dealFormulaObject(formulaInfos, reportContent, Toolkit.i18nText("Fine-Design_Chart_Project"), o); + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartGanttDataFormulaAction getInstance() { + return SearchChartGanttDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartGanttDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartGanttDataFormulaAction instance; + + SearchChartGanttDataFormulaActionEnum() { + instance = new SearchChartGanttDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartGanttDataFormulaAction getInstance() { + return instance; + } + } +} + diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMapDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMapDataFormulaAction.java new file mode 100644 index 0000000000..b892e35c82 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMapDataFormulaAction.java @@ -0,0 +1,246 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.Formula; +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartdata.SeriesDefinition; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.info.base.SearchTag; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.map.data.VanMapDefinition; +import com.fr.plugin.chart.map.data.VanMapReportDefinition; + +import java.util.List; + +/** + * 地图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartMapDataFormulaAction implements SearchChartDataFormula { + private SearchChartMapDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof VanMapDefinition) { + VanMapDefinition mapDefinition = (VanMapDefinition) provider; + //区域地图 + ITContent areaContent = ITContent.copy(content); + areaContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Region_Map")); + dealAreaDefinition(formulaInfos, areaContent, mapDefinition.getAreaDefinition()); + //流向地图 + ITContent lineContent = ITContent.copy(content); + lineContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_LineMap")); + dealLineDefinition(formulaInfos, content, mapDefinition.getLineDefinition()); + //点地图 + ITContent pointContent = ITContent.copy(content); + pointContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_PointMap")); + dealPointDefinition(formulaInfos, content, mapDefinition.getPointDefinition()); + } + } + + /** + * 处理点地图 + * + * @param formulaInfos + * @param content + * @param pointDefinition + */ + public void dealPointDefinition(List formulaInfos, ITContent content, TopDefinitionProvider pointDefinition) { + if (pointDefinition instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) pointDefinition; + ITContent pointContent = ITContent.copy(content); + //系列名&值 + dealSeriesDefinition(formulaInfos, pointContent, definition.getSeriesList()); + //经纬度 + dealLongitudeAndLatitude(formulaInfos, pointContent, definition); + //区域名 + dealAreaName(formulaInfos, pointContent, definition.getCategoryName(), definition); + } + } + + private boolean isFormulaString(Object o) { + String formulaFlag = "="; + return o instanceof String && ((String) o).startsWith(formulaFlag); + } + + private void dealLineDefinition(List formulaInfos, ITContent content, TopDefinitionProvider lineDefinition) { + if (lineDefinition instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) lineDefinition; + ITContent lineContent = ITContent.copy(content); + //系列名&值 + dealSeriesDefinition(formulaInfos, lineContent, definition.getSeriesList()); + //经纬度 + dealLongitudeAndLatitude(formulaInfos, lineContent, definition); + //终点经纬度 + if (isFormulaString(definition.getEndLongitude())) { + ITContent longContent = ITContent.copy(lineContent); + longContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_End_Longitude")); + longContent.setReplaceObject(definition.getEndLongitude()); + longContent.setTag(SearchTag.CHART_DATA_END_LONGITUDE); + longContent.setHoldObject(definition); + formulaInfos.add(new FormulaInfo(longContent)); + } + if (isFormulaString(definition.getEndLatitude())) { + ITContent latitudeContent = ITContent.copy(lineContent); + latitudeContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_End_Latitude")); + latitudeContent.setReplaceObject(definition.getEndLatitude()); + latitudeContent.setTag(SearchTag.CHART_DATA_END_LATITUDE); + latitudeContent.setHoldObject(definition); + formulaInfos.add(new FormulaInfo(latitudeContent)); + } + if (isFormulaString(definition.getEndAreaName())) { + ITContent endAreaNameContent = ITContent.copy(lineContent); + endAreaNameContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_End_Area_Name")); + endAreaNameContent.setReplaceObject(definition.getEndAreaName()); + endAreaNameContent.setTag(SearchTag.CHART_AREA_END_NAME); + endAreaNameContent.setHoldObject(definition); + formulaInfos.add(new FormulaInfo(endAreaNameContent)); + } + //区域名 + dealAreaName(formulaInfos, lineContent, definition.getCategoryName(), definition); + } + } + + private void dealLongitudeAndLatitude(List formulaInfos, ITContent content, VanMapReportDefinition definition) { + if (isFormulaString(definition.getLongitude())) { + ITContent longContent = ITContent.copy(content); + longContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Longitude")); + longContent.setReplaceObject(definition.getLongitude()); + longContent.setTag(SearchTag.CHART_DATA_LONGITUDE); + longContent.setHoldObject(definition); + formulaInfos.add(new FormulaInfo(longContent)); + } + if (isFormulaString(definition.getLatitude())) { + ITContent latitudeContent = ITContent.copy(content); + latitudeContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Latitude")); + latitudeContent.setReplaceObject(definition.getLatitude()); + latitudeContent.setHoldObject(definition); + latitudeContent.setTag(SearchTag.CHART_DATA_LATITUDE); + formulaInfos.add(new FormulaInfo(latitudeContent)); + } + } + + /** + * 处理区域地图 + * + * @param formulaInfos + * @param content + * @param areaDefinition + */ + public void dealAreaDefinition(List formulaInfos, ITContent content, TopDefinitionProvider areaDefinition) { + if (areaDefinition instanceof VanMapReportDefinition) { + VanMapReportDefinition reportDefinition = (VanMapReportDefinition) areaDefinition; + ITContent mapContent = ITContent.copy(content); + //系列名&值 + dealSeriesDefinition(formulaInfos, mapContent, reportDefinition.getSeriesList()); + //区域名 + dealAreaName(formulaInfos, mapContent, reportDefinition.getCategoryName(), reportDefinition); + } + } + + + /** + * 处理点地图特有的 + * + * @param formulaInfos + * @param content + * @param pointDefinition + */ + public void dealPointDefinition4Special(List formulaInfos, ITContent content, TopDefinitionProvider pointDefinition) { + if (pointDefinition instanceof VanMapReportDefinition) { + VanMapReportDefinition definition = (VanMapReportDefinition) pointDefinition; + ITContent pointContent = ITContent.copy(content); + //经纬度 + dealLongitudeAndLatitude(formulaInfos, pointContent, definition); + } + } + + /** + * 处理区域名 + * @param formulaInfos + * @param content + * @param object + * @param definition + */ + public void dealAreaName(List formulaInfos, ITContent content, Object object, VanMapReportDefinition definition) { + if (object instanceof Formula) { + ITContent cateContent = ITContent.copy(content); + cateContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Area_Name") + ); + cateContent.setReplaceObject(object); + formulaInfos.add(new FormulaInfo(cateContent)); + } else if (isFormulaString(object)) { + ITContent strContent = ITContent.copy(content); + strContent.setHoldObject(definition); + strContent.setTag(SearchTag.CHART_AREA_NAME); + strContent.setReplaceObject(object); + strContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Area_Name")); + formulaInfos.add(new FormulaInfo(strContent)); + } + } + + + /** + * 处理系列名&值 + */ + public static void dealSeriesDefinition(List formulaInfos, ITContent content, List seriesDefinitions) { + for (SeriesDefinition seriesDefinition : seriesDefinitions) { + if (seriesDefinition.getValue() instanceof Formula) { + ITContent valueContent = ITContent.copy(content); + valueContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Series_Value") + ); + valueContent.setReplaceObject(seriesDefinition.getValue()); + formulaInfos.add(new FormulaInfo(valueContent)); + } + if (seriesDefinition.getSeriesName() instanceof Formula) { + ITContent nameContent = ITContent.copy(content); + nameContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Series_Name") + ); + nameContent.setReplaceObject(seriesDefinition.getSeriesName()); + formulaInfos.add(new FormulaInfo(nameContent)); + } + + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartMapDataFormulaAction getInstance() { + return SearchChartMapDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartMapDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartMapDataFormulaAction instance; + + SearchChartMapDataFormulaActionEnum() { + instance = new SearchChartMapDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartMapDataFormulaAction getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMeterDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMeterDataFormulaAction.java new file mode 100644 index 0000000000..6b635ebfda --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMeterDataFormulaAction.java @@ -0,0 +1,68 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.Formula; +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartdata.MeterReportDefinition; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; + +import java.util.List; + +/** + * 漏斗图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartMeterDataFormulaAction implements SearchChartDataFormula { + + private SearchChartMeterDataFormulaAction() { + } + + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof MeterReportDefinition) { + MeterReportDefinition definition = (MeterReportDefinition) provider; + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Series_Name"), definition.getName()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Series_Value"), definition.getValue()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Target_Value"), definition.getTarget()); + } + } + + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartMeterDataFormulaAction getInstance() { + return SearchChartMeterDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartMeterDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartMeterDataFormulaAction instance; + + SearchChartMeterDataFormulaActionEnum() { + instance = new SearchChartMeterDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartMeterDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMultiPieDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMultiPieDataFormulaAction.java new file mode 100644 index 0000000000..75f1147a98 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMultiPieDataFormulaAction.java @@ -0,0 +1,71 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.Formula; +import com.fr.base.chart.chartdata.TopDefinitionProvider; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.multilayer.data.MultiPieReportDataDefinition; + +import java.util.List; + +/** + * 层次图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartMultiPieDataFormulaAction implements SearchChartDataFormula { + private SearchChartMultiPieDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof MultiPieReportDataDefinition) { + //层次 + MultiPieReportDataDefinition definition = (MultiPieReportDataDefinition) provider; + for (int i = 0; i < definition.getLevelColumnNameList().size(); i++) { + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Level"), definition.getLevelColumnNameList().get(i)); + } + + //值字段 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Basic_Base_Value"), definition.getValue()); + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartMultiPieDataFormulaAction getInstance() { + return SearchChartMultiPieDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartMultiPieDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartMultiPieDataFormulaAction instance; + + SearchChartMultiPieDataFormulaActionEnum() { + instance = new SearchChartMultiPieDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartMultiPieDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartNormalReportDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartNormalReportDataFormulaAction.java new file mode 100644 index 0000000000..cfd3f0e68e --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartNormalReportDataFormulaAction.java @@ -0,0 +1,65 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartdata.NormalReportDataDefinition; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; + +import java.util.List; + +/** + * 组合图中的大部分类型 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-22 + */ +public class SearchChartNormalReportDataFormulaAction implements SearchChartDataFormula { + + private SearchChartNormalReportDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof NormalReportDataDefinition) { + NormalReportDataDefinition dataDefinition = (NormalReportDataDefinition) provider; + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Category_Name"), dataDefinition.getCategoryName()); + SearchChartMapDataFormulaAction.dealSeriesDefinition(formulaInfos, content, dataDefinition.getSeriesList()); + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartNormalReportDataFormulaAction getInstance() { + return SearchChartNormalReportDataFormulaActionEnum.SINGLETON.getInstance(); + } + + + /** + * 枚举实现单例 + */ + private enum SearchChartNormalReportDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartNormalReportDataFormulaAction instance; + + SearchChartNormalReportDataFormulaActionEnum() { + instance = new SearchChartNormalReportDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartNormalReportDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartStructureDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartStructureDataFormulaAction.java new file mode 100644 index 0000000000..266d1fe4a0 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartStructureDataFormulaAction.java @@ -0,0 +1,69 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.structure.data.StructureReportDefinition; + +import java.util.List; + +/** + * 框架图 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartStructureDataFormulaAction implements SearchChartDataFormula { + private SearchChartStructureDataFormulaAction() { + } + + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof StructureReportDefinition) { + StructureReportDefinition definition = (StructureReportDefinition) provider; + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Node_Name"), definition.getNodeName()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Node_Id"), definition.getNodeID()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Parent_Node_Id"), definition.getParentID()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Series_Value"), definition.getNodeValue()); + + + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartStructureDataFormulaAction getInstance() { + return SearchChartStructureDataFormulaActionEnum.SINGLETON.getInstance(); + } + + + /** + * 枚举实现单例 + */ + private enum SearchChartStructureDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartStructureDataFormulaAction instance; + + SearchChartStructureDataFormulaActionEnum() { + instance = new SearchChartStructureDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartStructureDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartVanNormalDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartVanNormalDataFormulaAction.java new file mode 100644 index 0000000000..65f4800d21 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartVanNormalDataFormulaAction.java @@ -0,0 +1,74 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.chart.chartdata.NormalReportDataDefinition; +import com.fr.chart.chartdata.SeriesDefinition; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; + +import java.util.List; + +/** + * 普通图表类型 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartVanNormalDataFormulaAction implements SearchChartDataFormula { + private SearchChartVanNormalDataFormulaAction() { + } + + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof NormalReportDataDefinition) { + NormalReportDataDefinition normalReportDataDefinition = (NormalReportDataDefinition) provider; + //分类名 + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Category_Name"), normalReportDataDefinition.getCategoryName()); + //系列名&值 + for (Object seriesDefinition : normalReportDataDefinition.getSeriesList()) { + if (seriesDefinition instanceof SeriesDefinition) { + SeriesDefinition definition = (SeriesDefinition) seriesDefinition; + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Series_Name"), definition.getSeriesName()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Series_Value"), definition.getValue()); + } + } + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartVanNormalDataFormulaAction getInstance() { + return SearchChartNormalDataFormulaActionEnum.SINGLETON.getInstance(); + } + + + /** + * 枚举实现单例 + */ + private enum SearchChartNormalDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartVanNormalDataFormulaAction instance; + + SearchChartNormalDataFormulaActionEnum() { + instance = new SearchChartVanNormalDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartVanNormalDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartWordCloudDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartWordCloudDataFormulaAction.java new file mode 100644 index 0000000000..d22eadaeab --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartWordCloudDataFormulaAction.java @@ -0,0 +1,63 @@ +package com.fr.design.actions.replace.action.content.formula.chart; + +import com.fr.base.chart.chartdata.TopDefinitionProvider; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.plugin.chart.wordcloud.data.WordCloudReportDefinition; + +import java.util.List; + +/** + * 词云 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchChartWordCloudDataFormulaAction implements SearchChartDataFormula { + private SearchChartWordCloudDataFormulaAction() { + } + + @Override + public void searchChartDataFormula(List formulaInfos, ITContent content, TopDefinitionProvider provider) { + if (provider instanceof WordCloudReportDefinition) { + WordCloudReportDefinition definition = (WordCloudReportDefinition) provider; + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Word_Name"), definition.getWordName()); + dealFormulaObject(formulaInfos, content, Toolkit.i18nText("Fine-Design_Chart_Word_Value"), definition.getWordValue()); + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchChartWordCloudDataFormulaAction getInstance() { + return SearchWordCloudDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchWordCloudDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartWordCloudDataFormulaAction instance; + + SearchWordCloudDataFormulaActionEnum() { + instance = new SearchChartWordCloudDataFormulaAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchChartWordCloudDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/DataType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/DataType.java new file mode 100644 index 0000000000..2c8fd93165 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/DataType.java @@ -0,0 +1,132 @@ +package com.fr.design.actions.replace.action.content.formula.data; + +import com.fr.base.Formula; +import com.fr.base.TableData; +import com.fr.data.impl.ConditionTableData; +import com.fr.data.impl.DBTableData; +import com.fr.data.impl.RecursionTableData; +import com.fr.data.impl.storeproc.StoreProcedure; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.stable.ParameterProvider; +import com.fr.stable.StringUtils; +import org.jetbrains.annotations.Nullable; + + +import java.util.List; + +/** + * 分别对不同类型的数据集进行获取公式处理 + * 暂不支持ClassTableData(用户自定义数据集)、FileTableData(用户自定义数据集),EmbeddedTableData(无公式) + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-26 + */ +public enum DataType { + /** + * 数据库查询 + */ + DB_TABLE_DATA("DBTableData") { + @Override + public void searchFormula(TableData tableData, ITContent content, List fomulaInfos) { + if (((DBTableData) tableData).getParameters() != null) { + for (ParameterProvider provider : ((DBTableData) tableData).getParameters()) { + dealProvider(provider, content, fomulaInfos); + } + } + } + + }, + /** + * 存储过程 + */ + STORE_PROCEDURE("StoreProcedure") { + @Override + public void searchFormula(TableData tableData, ITContent content, List fomulaInfos) { + if (((StoreProcedure) tableData).getParameters() != null) { + for (ParameterProvider provider : ((StoreProcedure) tableData).getParameters()) { + dealProvider(provider, content, fomulaInfos); + + } + } + } + }, + /** + * 关联数据集 + */ + CONDITION_TABLE_DATA("ConditionTableData") { + @Override + public void searchFormula(TableData tableData, ITContent content, List fomulaInfos) { + if (((ConditionTableData) tableData).getDefineParameters() != null) { + for (ParameterProvider provider : ((ConditionTableData) tableData).getDefineParameters()) { + dealProvider(provider, content, fomulaInfos); + } + } + } + }, + /** + * 树数据集 + */ + RECURSION_TABLE_DATA("RecursionTableData") { + @Override + public void searchFormula(TableData tableData, ITContent content, List fomulaInfos) { + if (((RecursionTableData) tableData).getParameters() != null) { + for (ParameterProvider provider : ((RecursionTableData) tableData).getParameters()) { + dealProvider(provider, content, fomulaInfos); + } + } + } + }; + + + String name; + + DataType(String name) { + this.name = name; + } + + /** + * 处理参数 + * + * @param provider + * @param content + * @param formulaInfos + */ + public void dealProvider(ParameterProvider provider, ITContent content, List formulaInfos) { + if (provider.getValue() instanceof Formula && StringUtils.isNotEmpty((((Formula) provider.getValue())).getContent())) { + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Parameter")); + newContent.setReplaceObject(provider); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + + /** + * 匹配 + * + * @param name + * @return + */ + @Nullable + public static DataType match(String name) { + DataType[] values = DataType.values(); + for (DataType value : values) { + if (value.name.equals(name)) { + return value; + } + } + return null; + } + + /** + * 从数据集中获取公式 + * + * @param tableData + * @param content + * @param formulaInfos + */ + abstract void searchFormula(TableData tableData, ITContent content, List formulaInfos); + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/SearchDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/SearchDataFormulaAction.java new file mode 100644 index 0000000000..3d4c66adc0 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/SearchDataFormulaAction.java @@ -0,0 +1,110 @@ +package com.fr.design.actions.replace.action.content.formula.data; + +import com.fr.data.TableDataSource; +import com.fr.design.actions.replace.action.content.formula.SearchFormula; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.data.tabledata.wrapper.TableDataFactory; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.TableDataConfig; + +import java.util.Iterator; +import java.util.List; + +/** + * 搜索数据集中的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-26 + */ +public class SearchDataFormulaAction implements SearchFormula { + + + private SearchDataFormulaAction() { + } + + + @Override + public void searchFormulaFromObject(JTemplate jTemplate, List formulaInfos) { + //模板数据集 + dealTemplateData(jTemplate, formulaInfos); + + ////服务器数据集二期再考虑 + //dealServerData(formulaInfos); + } + + private void dealServerData(List fomulaInfos) { + TableDataConfig tableDataConfig = TableDataConfig.getInstance(); + String[] nameArray = TableDataFactory.getSortOfChineseNameOfServerData(tableDataConfig); + for (String dataName : nameArray) { + ITContent content = new ITContent(); + content.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_DS_Server_TableData"), + dataName + ); + content.setJumpAble(false); + content.setShowObject(Toolkit.i18nText("Fine-Design_Basic_DS_Server_TableData")); + DataType dataType = DataType.match(tableDataConfig.getTableData(dataName).getClass().getSimpleName()); + if (dataType != null) { + dataType.searchFormula(tableDataConfig.getTableData(dataName), content, fomulaInfos); + } + } + } + + private void dealTemplateData(JTemplate jTemplate, List fomulaInfos) { + if (jTemplate.getTarget() instanceof TableDataSource) { + TableDataSource source = (TableDataSource) jTemplate.getTarget(); + Iterator dataIterator = source.getTableDataNameIterator(); + while (dataIterator.hasNext()) { + String dataName = (String) dataIterator.next(); + ITContent content = new ITContent(); + content.setTemplateName(jTemplate.getTemplateName()); + content.setJumpAble(false); + content.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_DS_Report_TableData"), + dataName + ); + content.setShowObject(Toolkit.i18nText("Fine-Design_Basic_DS_Report_TableData")); + DataType dataType = DataType.match(source.getTableData(dataName).getClass().getSimpleName()); + if (dataType != null) { + dataType.searchFormula(source.getTableData(dataName), content, fomulaInfos); + } + } + } + } + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchDataFormulaAction getInstance() { + return SearchDataFormulaAction.SearchDataFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchDataFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchDataFormulaAction instance; + + SearchDataFormulaActionEnum() { + instance = new SearchDataFormulaAction(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchDataFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/SearchFloatFormula.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/SearchFloatFormula.java new file mode 100644 index 0000000000..4a74e46b8f --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/SearchFloatFormula.java @@ -0,0 +1,33 @@ +package com.fr.design.actions.replace.action.content.formula.floatelement; + +import com.fr.design.actions.replace.action.content.formula.SearchFormula; +import com.fr.design.actions.replace.info.FloatInfo; +import com.fr.design.actions.replace.info.FormulaInfo; + +import java.util.List; + +/** + * 搜索悬浮元素的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-12 + */ +public interface SearchFloatFormula extends SearchFormula { + + /** + * 查找悬浮元素可能存在的共有的公式 + * + * @param floatInfo FloatInfo信息 + * @param formulaInfos 要存储对应信息列表的数据结构 + */ + void searchFormulaFromCommonFloat(List formulaInfos, FloatInfo floatInfo); + + /** + * 查找不同悬浮元素内容类型各自可能存在的公式 + * + * @param formulaInfos 要存储对应信息列表的数据结构 + * @param floatInfo FloatInfo信息 + */ + void searchFormulaFromFloatType(List formulaInfos, FloatInfo floatInfo); +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/SearchFloatFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/SearchFloatFormulaAction.java new file mode 100644 index 0000000000..e71fad6889 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/floatelement/SearchFloatFormulaAction.java @@ -0,0 +1,156 @@ +package com.fr.design.actions.replace.action.content.formula.floatelement; + +import com.fr.base.Formula; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.actions.replace.action.content.floatelement.SearchFloatAction; +import com.fr.design.actions.replace.action.content.formula.chart.SearchChartCollectionFormulaAction; +import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction; +import com.fr.design.actions.replace.info.FloatInfo; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.js.NameJavaScriptGroup; +import com.fr.report.cell.FloatElement; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +/** + * 搜索悬浮元素中的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-12 + */ +public class SearchFloatFormulaAction implements SearchFloatFormula { + + private SearchFloatFormulaAction() { + } + + + @Override + public void searchFormulaFromObject(JTemplate jTemplate, List formulaInfos) { + SearchFloatAction searchFloatAction = SearchFloatAction.getInstance(); + searchFloatAction.search4Infos(jTemplate); + for (FloatInfo floatInfo : searchFloatAction.getFloatInfos()) { + searchFormulaFromCommonFloat(formulaInfos, floatInfo); + searchFormulaFromFloatType(formulaInfos, floatInfo); + } + } + + @Override + public void searchFormulaFromCommonFloat(List formulaInfos, FloatInfo floatInfo) { + NameJavaScriptGroup nameJavaScriptGroup = ((FloatElement) floatInfo.getContent().getReplaceObject()).getNameHyperlinkGroup(); + if (nameJavaScriptGroup != null) { + for (int i = 0; i < nameJavaScriptGroup.size(); i++) { + SearchJSHighlightAction action = SearchJSHighlightAction.getInstance(); + action.searchJSFormulaFromOther(formulaInfos, floatInfo.getContent(), nameJavaScriptGroup.getNameHyperlink(i).getJavaScript()); + } + } + } + + + @Override + public void searchFormulaFromFloatType(List formulaInfos, FloatInfo floatInfo) { + Object value = ((FloatElement) floatInfo.getContent().getReplaceObject()).getValue(); + FloatFormulaType floatFormulaType = FloatFormulaType.match(value.getClass().getSimpleName()); + if (floatFormulaType != null) { + floatFormulaType.searchFormulaFromFloatElementType(formulaInfos, floatInfo); + } + } + + /** + * 悬浮元素的类型 + */ + public enum FloatFormulaType { + /** + * 公式 + */ + FORMULA("Formula") { + @Override + public void searchFormulaFromFloatElementType(List formulaInfos, FloatInfo floatInfo) { + ITContent content = ITContent.copy(floatInfo.getContent()); + Formula value = (Formula) ((FloatElement) floatInfo.getContent().getReplaceObject()).getValue(); + content.setReplaceObject(value); + formulaInfos.add(new FormulaInfo(content)); + } + }, + /** + * 图表 + */ + CHART_COLLECTION("ChartCollection") { + @Override + public void searchFormulaFromFloatElementType(List formulaInfos, FloatInfo floatInfo) { + ITContent content = ITContent.copy(floatInfo.getContent()); + ChartCollection chartCollection = (ChartCollection) ((FloatElement) floatInfo.getContent().getReplaceObject()).getValue(); + content.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Chart")); + SearchChartCollectionFormulaAction.getInstance().searchChartCollectionFormula(formulaInfos, content, chartCollection); + } + }; + String name; + + FloatFormulaType(String name) { + this.name = name; + } + + /** + * 匹配 + * + * @param name + * @return + */ + @Nullable + public static FloatFormulaType match(String name) { + FloatFormulaType[] values = FloatFormulaType.values(); + for (FloatFormulaType value : values) { + if (value.name.equals(name)) { + return value; + } + } + return null; + } + + /** + * 从特殊类型的悬浮元素值中获取到所需的公式 + * + * @param formulaInfos + * @param floatInfo + */ + abstract public void searchFormulaFromFloatElementType(List formulaInfos, FloatInfo floatInfo); + } + + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchFloatFormulaAction getInstance() { + return SearchFloatFormulaAction.SearchFloatFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 单例实现枚举 + */ + private enum SearchFloatFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchFloatFormulaAction instance; + + SearchFloatFormulaActionEnum() { + instance = new SearchFloatFormulaAction(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchFloatFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/SearchHighlightFormula.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/SearchHighlightFormula.java new file mode 100644 index 0000000000..d9dc0b5e31 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/SearchHighlightFormula.java @@ -0,0 +1,30 @@ +package com.fr.design.actions.replace.action.content.formula.highlight; + +import com.fr.design.actions.replace.action.content.formula.SearchFormula; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.report.cell.cellattr.highlight.HighlightAction; + +import java.util.List; + +/** + * 从条件属性中搜索公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-18 + */ +public interface SearchHighlightFormula extends SearchFormula { + + /** + * 处理条件属性中各种属性 + * + * @param content + * @param formulaInfos + * @param highlightAction + */ + default void dealWithHighlightAction(ITContent content, List formulaInfos, HighlightAction highlightAction) { + } + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/SearchHighlightFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/SearchHighlightFormulaAction.java new file mode 100644 index 0000000000..28e6cacb8b --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/SearchHighlightFormulaAction.java @@ -0,0 +1,65 @@ +package com.fr.design.actions.replace.action.content.formula.highlight; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.report.cell.cellattr.highlight.HighlightAction; + + +import java.util.List; +import java.util.Map; + +/** + * 处理条件属性中各种属性的公式(超级链接、控件...) + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-18 + */ +public class SearchHighlightFormulaAction implements SearchHighlightFormula { + + private SearchHighlightFormulaAction() { + } + + @Override + public void dealWithHighlightAction(ITContent content, List formulaInfos, HighlightAction highlightAction) { + Map highlightType = SearchHighlightFormulaManager.getInstance().getHighlightType(); + if (highlightType.containsKey(highlightAction.getClass().getSimpleName())) { + SearchHighlightFormula searchHighlight = highlightType.get(highlightAction.getClass().getSimpleName()); + searchHighlight.dealWithHighlightAction(content, formulaInfos, highlightAction); + } + + } + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchHighlightFormulaAction getInstance() { + return SearchHighlightFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchHighlightFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchHighlightFormulaAction instance; + + SearchHighlightFormulaActionEnum() { + instance = new SearchHighlightFormulaAction(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchHighlightFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/SearchHighlightFormulaManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/SearchHighlightFormulaManager.java new file mode 100644 index 0000000000..290731f8f6 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/SearchHighlightFormulaManager.java @@ -0,0 +1,109 @@ +package com.fr.design.actions.replace.action.content.formula.highlight; + +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.action.SearchManager; +import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction; +import com.fr.design.actions.replace.action.content.formula.highlight.present.SearchPresentHighlightAction; +import com.fr.design.actions.replace.action.content.formula.highlight.value.SearchValueHighlightAction; + +import java.util.HashMap; +import java.util.Map; + +/** + * 管理要搜索的条件属性类型(公式) + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-16 + */ +public class SearchHighlightFormulaManager implements SearchManager { + private Map highlightType = new HashMap<>(); + public static final String HYPERLINK_HIGHLIGHT_ACTION = "HyperlinkHighlightAction"; + public static final String PRESENT_HIGHLIGHT_ACTION = "PresentHighlightAction"; + public static final String VALUE_HIGHLIGHT_ACTION = "ValueHighlightAction"; + + private SearchHighlightFormulaManager() { + //这边控件类型不做处理,在SearchWidgetFormulaAction统一处理即可 + //条件属性-超级链接 + register(HYPERLINK_HIGHLIGHT_ACTION, SearchJSHighlightAction.getInstance()); + //条件属性-形态 + register(PRESENT_HIGHLIGHT_ACTION, SearchPresentHighlightAction.getInstance()); + //条件属性-新值 + register(VALUE_HIGHLIGHT_ACTION, SearchValueHighlightAction.getInstance()); + } + + + @Override + public void registerAction(String tag, SearchAction searchAction) { + if (searchAction instanceof SearchHighlightFormula) { + register(tag, (SearchHighlightFormula) searchAction); + } + } + + @Override + public void removeAction(String tag) { + remove(tag); + } + + /** + * 注册 + * + * @param tag 用于匹配的类型tag + * @param searchHighlightFormula 对应的实现类 + */ + private void register(String tag, SearchHighlightFormula searchHighlightFormula) { + highlightType.put(tag, searchHighlightFormula); + } + + /** + * 注销 + * + * @param tag 用于匹配的tag + */ + private void remove(String tag) { + highlightType.remove(tag); + } + + /** + * 获取单元格类型 + * + * @return + */ + public Map getHighlightType() { + return highlightType; + } + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchHighlightFormulaManager getInstance() { + return SearchHighlightFormulaManagerEnum.SINGLETON.getInstance(); + } + + + /** + * 枚举实现单例 + */ + private enum SearchHighlightFormulaManagerEnum { + /** + * 单例 + */ + SINGLETON; + private SearchHighlightFormulaManager instance; + + SearchHighlightFormulaManagerEnum() { + instance = new SearchHighlightFormulaManager(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchHighlightFormulaManager getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchCommonConditionAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchCommonConditionAction.java new file mode 100644 index 0000000000..ddcda65b02 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchCommonConditionAction.java @@ -0,0 +1,66 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.condition; + +import com.fr.base.Formula; +import com.fr.data.condition.CommonCondition; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.general.data.Condition; + +import java.util.List; + +/** + * 获取CommonCondition中的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-17 + */ +public class SearchCommonConditionAction implements SearchConditionFormula { + + private SearchCommonConditionAction() { + } + + @Override + public void searchFormulaFromCondition(List formulaInfos, ITContent content, Condition condition) { + if (((CommonCondition) condition).getCompare().getValue() instanceof Formula) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(((CommonCondition) condition).getCompare()); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + + + + /** + * 获取单例 + * + * @return + */ + public static SearchCommonConditionAction getInstance() { + return SearchCommonConditionActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchCommonConditionActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchCommonConditionAction instance; + + SearchCommonConditionActionEnum() { + instance = new SearchCommonConditionAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchCommonConditionAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchConditionFormula.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchConditionFormula.java new file mode 100644 index 0000000000..85f5a67dbb --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchConditionFormula.java @@ -0,0 +1,26 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.condition; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.general.data.Condition; + +import java.util.List; + +/** + * 从条件相关对象中拿公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-17 + */ +public interface SearchConditionFormula { + /** + * 从条件相关对象中获取公式 + * + * @param formulaInfos + * @param content + * @param condition + */ + void searchFormulaFromCondition(List formulaInfos, ITContent content, Condition condition); +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchConditionManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchConditionManager.java new file mode 100644 index 0000000000..6cebe52e76 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchConditionManager.java @@ -0,0 +1,106 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.condition; + + +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.action.SearchManager; + +import java.util.HashMap; +import java.util.Map; + +/** + * 管理条件类型的注册 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-16 + */ +public class SearchConditionManager implements SearchManager { + private Map conditionType = new HashMap<>(); + public static final String FORMULA_CONDITION = "FormulaCondition"; + public static final String OBJECT_CONDITION = "ObjectCondition"; + public static final String LIST_CONDITION = "ListCondition"; + public static final String COMMON_CONDITION = "CommonCondition"; + + private SearchConditionManager() { + register(FORMULA_CONDITION, SearchFormulaConditionAction.getInstance()); + register(OBJECT_CONDITION, SearchObjectConditionAction.getInstance()); + register(LIST_CONDITION, SearchListConditionAction.getInstance()); + register(COMMON_CONDITION, SearchCommonConditionAction.getInstance()); + } + + @Override + public void registerAction(String tag, SearchAction searchAction) { + if (searchAction instanceof SearchConditionFormula) { + register(tag, (SearchConditionFormula) searchAction); + } + } + + @Override + public void removeAction(String tag) { + remove(tag); + } + + + /** + * 注册 + * + * @param tag 用于匹配的类型tag + * @param searchConditionFormula 对应的实现类 + */ + private void register(String tag, SearchConditionFormula searchConditionFormula) { + conditionType.put(tag, searchConditionFormula); + } + + /** + * 注销 + * + * @param tag 用于匹配的tag + */ + private void remove(String tag) { + conditionType.remove(tag); + } + + /** + * 获取类型 + * + * @return + */ + public Map getConditionType() { + return conditionType; + } + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchConditionManager getInstance() { + return SearchConditionManagerEnum.SINGLETON.getInstance(); + } + + + /** + * 枚举实现单例 + */ + private enum SearchConditionManagerEnum { + /** + * 单例 + */ + SINGLETON; + private SearchConditionManager instance; + + SearchConditionManagerEnum() { + instance = new SearchConditionManager(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchConditionManager getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchFormulaConditionAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchFormulaConditionAction.java new file mode 100644 index 0000000000..44d495018b --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchFormulaConditionAction.java @@ -0,0 +1,65 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.condition; + +import com.fr.data.condition.FormulaCondition; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.general.data.Condition; + +import java.util.List; + +/** + * 获取FormulaCondition公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-17 + */ +public class SearchFormulaConditionAction implements SearchConditionFormula { + + private SearchFormulaConditionAction() { + } + + + @Override + public void searchFormulaFromCondition(List formulaInfos, ITContent content, Condition condition) { + if (((FormulaCondition) (condition)).getFormula() != null) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(condition); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + + /** + * 获取单例 + * + * @return + */ + public static SearchFormulaConditionAction getInstance() { + return SearchFormulaConditionActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchFormulaConditionActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchFormulaConditionAction instance; + + SearchFormulaConditionActionEnum() { + instance = new SearchFormulaConditionAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchFormulaConditionAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchListConditionAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchListConditionAction.java new file mode 100644 index 0000000000..374062c452 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchListConditionAction.java @@ -0,0 +1,76 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.condition; + +import com.fr.data.condition.CommonCondition; +import com.fr.data.condition.FormulaCondition; +import com.fr.data.condition.ListCondition; +import com.fr.data.condition.ObjectCondition; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.general.data.Condition; + +import java.util.List; + +/** + * 获取ListCondition公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-17 + */ +public class SearchListConditionAction implements SearchConditionFormula { + + private SearchListConditionAction() { + } + + @Override + public void searchFormulaFromCondition(List formulaInfos, ITContent content, Condition condition) { + for (int i = 0; i < ((ListCondition) condition).getJoinConditionCount(); i++) { + Condition joinCondition = ((ListCondition) condition).getJoinCondition(i).getCondition(); + if (joinCondition instanceof CommonCondition) { + SearchCommonConditionAction commonConditionAction = SearchCommonConditionAction.getInstance(); + commonConditionAction.searchFormulaFromCondition(formulaInfos, content, joinCondition); + } else if (joinCondition instanceof FormulaCondition) { + SearchFormulaConditionAction formulaConditionAction = SearchFormulaConditionAction.getInstance(); + formulaConditionAction.searchFormulaFromCondition(formulaInfos, content, joinCondition); + } else if (joinCondition instanceof ObjectCondition) { + SearchObjectConditionAction objectConditionAction = SearchObjectConditionAction.getInstance(); + objectConditionAction.searchFormulaFromCondition(formulaInfos, content, joinCondition); + } + } + } + + + /** + * 获取单例 + * + * @return + */ + public static SearchListConditionAction getInstance() { + return SearchListConditionActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchListConditionActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchListConditionAction instance; + + SearchListConditionActionEnum() { + instance = new SearchListConditionAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchListConditionAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchObjectConditionAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchObjectConditionAction.java new file mode 100644 index 0000000000..3d9752ef5b --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchObjectConditionAction.java @@ -0,0 +1,65 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.condition; + +import com.fr.base.Formula; +import com.fr.data.condition.ObjectCondition; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.general.data.Condition; + +import java.util.List; + +/** + * 获取ObjectCondition类型公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-18 + */ +public class SearchObjectConditionAction implements SearchConditionFormula { + + + private SearchObjectConditionAction() { + } + + @Override + public void searchFormulaFromCondition(List formulaInfos, ITContent content, Condition condition) { + if (((ObjectCondition) condition).getCompare().getValue() != null && ((ObjectCondition) condition).getCompare().getValue() instanceof Formula) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(((ObjectCondition) condition).getCompare()); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + + /** + * 获取单例 + * + * @return + */ + public static SearchObjectConditionAction getInstance() { + return SearchObjectConditionActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchObjectConditionActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchObjectConditionAction instance; + + SearchObjectConditionActionEnum() { + instance = new SearchObjectConditionAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchObjectConditionAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchChartHyperPopLinkAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchChartHyperPopLinkAction.java new file mode 100644 index 0000000000..4edd5b4f17 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchChartHyperPopLinkAction.java @@ -0,0 +1,68 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.javascript; + +import com.fr.base.chart.BaseChartCollection; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.web.ChartHyperPoplink; +import com.fr.design.actions.replace.action.content.formula.chart.SearchChartCollectionFormulaAction; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.js.JavaScript; + +import java.util.List; + +/** + * 图表超链-悬浮窗图表的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-20 + */ +public class SearchChartHyperPopLinkAction implements SearchJSFormula { + private SearchChartHyperPopLinkAction() { + } + + + @Override + public void searchJSFormulaFromOther(List formulaInfos, ITContent content, JavaScript javaScript) { + if (javaScript instanceof ChartHyperPoplink) { + ChartHyperPoplink chartHyperPoplink = (ChartHyperPoplink) javaScript; + if (chartHyperPoplink.getChartCollection() instanceof ChartCollection) { + SearchChartCollectionFormulaAction.getInstance().searchChartCollectionFormula(formulaInfos, content, (ChartCollection) chartHyperPoplink.getChartCollection()); + } + } + } + + /** + * 获取单例 + * + * @return + */ + public static SearchChartHyperPopLinkAction getInstance() { + return SearchChartHyperPopLinkActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartHyperPopLinkActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchChartHyperPopLinkAction instance; + + SearchChartHyperPopLinkActionEnum() { + instance = new SearchChartHyperPopLinkAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchChartHyperPopLinkAction getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchCommit2DBJSFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchCommit2DBJSFormulaAction.java new file mode 100644 index 0000000000..54e971ee3e --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchCommit2DBJSFormulaAction.java @@ -0,0 +1,152 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.javascript; + +import com.fr.base.Formula; +import com.fr.design.actions.replace.action.content.formula.highlight.condition.SearchConditionFormula; +import com.fr.design.actions.replace.action.content.formula.highlight.condition.SearchConditionManager; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.general.data.Condition; +import com.fr.js.Commit2DBJavaScript; +import com.fr.js.JavaScript; +import com.fr.write.DBManipulation; +import com.fr.write.DMLConfigJob; +import com.fr.write.NameSubmitJob; +import com.fr.write.config.ColumnConfig; +import com.fr.write.config.DMLConfig; + +import java.util.List; +import java.util.Map; + +/** + * 获取提交入库中的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-19 + */ +public class SearchCommit2DBJSFormulaAction implements SearchJSFormula { + + private SearchCommit2DBJSFormulaAction() { + } + + @Override + public void searchJSFormulaFromOther(List formulaInfos, ITContent content, JavaScript javaScript) { + if (!((Commit2DBJavaScript) javaScript).getDBManipulation().isEmpty()) { + //处理回调函数——这里单独摘出来是因为这边逻辑比较复杂,提交事件会再循环产生一个新的DBManipulation,后续统一处理 + dealWithCallBack(formulaInfos, content, ((Commit2DBJavaScript) javaScript)); + //处理DBManipulation + for (int i = 0; i < ((Commit2DBJavaScript) javaScript).getDBManipulation().size(); i++) { + dealWithDBManipulation(formulaInfos, content, (DBManipulation) ((Commit2DBJavaScript) javaScript).getDBManipulation().get(i)); + } + } + } + + /** + * 处理DBManipulation + * + * @param formulaInfos + * @param content + * @param dbManipulation + */ + public void dealWithDBManipulation(List formulaInfos, ITContent content, DBManipulation dbManipulation) { + DMLConfig dmlConfig = dbManipulation.getDmlConfig(); + //值中的公式 + dealWithColumnValue(formulaInfos, content, dmlConfig); + //处理提交条件中的公式 + dealWithCommit2DBCondition(formulaInfos, content, dmlConfig); + //处理DBManipulation + dealWithSubmitJob(formulaInfos, content, dmlConfig); + } + + private void dealWithColumnValue(List formulaInfos, ITContent content, DMLConfig dmlConfig) { + for (int i = 0, len = dmlConfig.getColumnConfigCount(); i < len; i++) { + ColumnConfig columnConfig = dmlConfig.getColumnConfig(i); + if (columnConfig.getColumnValue() instanceof Formula) { + ITContent configContent = ITContent.copy(content); + configContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Base_Value")); + configContent.setReplaceObject(columnConfig.getColumnValue()); + formulaInfos.add(new FormulaInfo(configContent)); + } + } + } + + private void dealWithSubmitJob(List formulaInfos, ITContent content, DMLConfig dmlConfig) { + for (int i = 0, len = dmlConfig.getSubmitJobCount(); i < len; i++) { + //这边自定义事件不需要处理,只处理提交事件 + NameSubmitJob job = dmlConfig.getNameSubmitJob(i); + if (job != null && job.getSubmitJob() instanceof DMLConfigJob) { + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Write_Submit_Event"), + job.getName() + ); + dealWithDBManipulation(formulaInfos, newContent, (((DMLConfigJob) job.getSubmitJob()).getDBManipulation())); + } + } + } + + private void dealWithCallBack(List formulaInfos, ITContent content, Commit2DBJavaScript javaScript) { + if (javaScript.getCallBack() != null) { + SearchJSHighlightAction jsHighlightAction = SearchJSHighlightAction.getInstance(); + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Set_Callback_Function") + ); + jsHighlightAction.searchJSFormulaFromOther(formulaInfos, newContent, javaScript.getCallBack()); + + } + } + + private void dealWithCommit2DBCondition(List formulaInfos, ITContent content, DMLConfig dmlConfig) { + if (dmlConfig.getCondition() != null) { + //这边condition有三种情况:FormulaCondition、CommonCondition、ListCondition,分别处理 + Condition condition = dmlConfig.getCondition(); + Map conditionType = SearchConditionManager.getInstance().getConditionType(); + if (conditionType.containsKey(condition.getClass().getSimpleName())) { + SearchConditionFormula searchCondition = conditionType.get(condition.getClass().getSimpleName()); + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Submit_Condition") + ); + searchCondition.searchFormulaFromCondition(formulaInfos, newContent, condition); + } + + } + } + + + /** + * 获取单例 + * + * @return + */ + public static SearchCommit2DBJSFormulaAction getInstance() { + return SearchCommit2DBJSFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchCommit2DBJSFormulaActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchCommit2DBJSFormulaAction instance; + + SearchCommit2DBJSFormulaActionEnum() { + instance = new SearchCommit2DBJSFormulaAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchCommit2DBJSFormulaAction getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchExportJSFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchExportJSFormulaAction.java new file mode 100644 index 0000000000..32b5721a52 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchExportJSFormulaAction.java @@ -0,0 +1,105 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.javascript; + +import com.fr.base.Formula; +import com.fr.base.Parameter; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.js.ExportJavaScript; +import com.fr.js.JavaScript; +import com.fr.js.SingleJavaScript; +import com.fr.stable.ParameterProvider; + + +import java.util.List; + +/** + * 获取导出事件的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-19 + */ +public class SearchExportJSFormulaAction implements SearchJSFormula { + + private SearchExportJSFormulaAction() { + } + + @Override + public void searchJSFormulaFromOther(List formulaInfos, ITContent content, JavaScript javaScript) { + //如果导出当前模板,可以存公式的地方就是命名方式-自定义、参数设置 + if (((ExportJavaScript) javaScript).isCurrentTemplate()) { + content.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")); + dealSingleJavaScript(formulaInfos, content, ((ExportJavaScript) javaScript).getCurrentTemplateJavaScript()); + } else { + content.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other")); + List list = ((ExportJavaScript) javaScript).getJsListForOtherTemplates(); + if (isListExist(list)) { + for (SingleJavaScript singleJavaScript : list) { + dealSingleJavaScript(formulaInfos, content, singleJavaScript); + } + } + } + } + + + + public boolean isListExist(List list) { + return list != null && list.size() > 0; + } + + private void dealSingleJavaScript(List formulaInfos, ITContent content, SingleJavaScript javaScript) { + if (!javaScript.isDefaultFileName()) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(javaScript); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Event"), + Toolkit.i18nText("Fine-Design_Basic_Export_JS_Filename") + ); + formulaInfos.add(new FormulaInfo(newContent)); + } + if (!javaScript.isExtendParameters()) { + for (ParameterProvider parameter : javaScript.getParameters()) { + ITContent paraContent = ITContent.copy(content); + if (parameter.getValue() instanceof Formula) { + paraContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Base_Value")); + paraContent.setReplaceObject(parameter.getValue()); + formulaInfos.add(new FormulaInfo(paraContent)); + } + } + } + } + + /** + * 获取单例 + * + * @return + */ + public static SearchExportJSFormulaAction getInstance() { + return SearchExportJSFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchExportJSFormulaActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchExportJSFormulaAction instance; + + SearchExportJSFormulaActionEnum() { + instance = new SearchExportJSFormulaAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchExportJSFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchJSFormula.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchJSFormula.java new file mode 100644 index 0000000000..553c55ba5c --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchJSFormula.java @@ -0,0 +1,43 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.javascript; + +import com.fr.design.actions.replace.action.content.formula.highlight.SearchHighlightFormula; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.js.JavaScript; + + +import java.util.List; + +/** + * 获取各种类型JS的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-18 + */ +public interface SearchJSFormula extends SearchHighlightFormula { + + /** + * 对各种类型的JS分别处理,获取各自其他地方的公式 + * + * @param formulaInfos + * @param content + * @param javaScript + */ + default void searchJSFormulaFromOther(List formulaInfos, ITContent content, JavaScript javaScript) { + } + + + + /** + * 从超链中的参数获取公式 + * + * @param formulaInfos + * @param content + * @param javaScript + */ + default void addFormulaInfosFromJSPara(List formulaInfos, ITContent content, JavaScript javaScript) { + } + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchJSFormulaManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchJSFormulaManager.java new file mode 100644 index 0000000000..e77e4c60ec --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchJSFormulaManager.java @@ -0,0 +1,121 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.javascript; + +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.action.SearchManager; + + +import java.util.HashMap; +import java.util.Map; + +/** + * 管理JS公式的注册 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-16 + */ +public class SearchJSFormulaManager implements SearchManager { + private static Map javaScriptType = new HashMap<>(); + + public static final String COMMIT_2_DB_JAVASCRIPT = "Commit2DBJavaScript"; + public static final String EXPORT_JAVASCRIPT = "ExportJavaScript"; + public static final String MOBILE_POPUP_HYPERLINK = "MobilePopupHyperlink"; + public static final String CHART_HYPER_POP_LINK = "ChartHyperPoplink"; + + private SearchJSFormulaManager() { + //控件事件里面需要特殊处理的类型 + //EmailJavaScript(这个暂时不做处理) + //ExportJavaScript + //MobilePopupHyperlink + //Commit2DBJavaScript + //单元格条件属性里面需要处理的类型 + //WebHyperlink——只有参数可以放公式,不需要特殊处理 + //ReportletHyperlink——只有参数可以放公式,不需要特殊处理 + //EmailJavaScript(这个暂时不做处理) + //ParameterJavaScript——只有参数可以放公式,不需要特殊处理 + //JavaScriptImpl——只有参数可以放公式,不需要特殊处理 + //MobilePopupHyperlink + //ChartHyperPoplink + //ChartHyperRelateCellLink——只有参数可以放公式,不需要特殊处理 + //ChartHyperRelateFloatLink——只有参数可以放公式,不需要特殊处理 + register(COMMIT_2_DB_JAVASCRIPT, SearchCommit2DBJSFormulaAction.getInstance()); + register(EXPORT_JAVASCRIPT, SearchExportJSFormulaAction.getInstance()); + register(MOBILE_POPUP_HYPERLINK, SearchMobileHyperlinkFormulaAction.getInstance()); + register(CHART_HYPER_POP_LINK, SearchChartHyperPopLinkAction.getInstance()); + } + + @Override + public void registerAction(String tag, SearchAction searchAction) { + if (searchAction instanceof SearchJSFormula) { + register(tag, (SearchJSFormula) searchAction); + } + } + + @Override + public void removeAction(String tag) { + remove(tag); + } + + /** + * 注册 + * + * @param tag 用于匹配的类型tag + * @param searchJSFormula 对应的实现类 + */ + private void register(String tag, SearchJSFormula searchJSFormula) { + javaScriptType.put(tag, searchJSFormula); + } + + /** + * 注销 + * + * @param tag 用于匹配的tag + */ + private void remove(String tag) { + javaScriptType.remove(tag); + } + + /** + * 获取类型 + * + * @return + */ + public Map getJSType() { + return javaScriptType; + } + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchJSFormulaManager getInstance() { + return SearchJSFormulaManagerEnum.SINGLETON.getInstance(); + } + + + /** + * 枚举实现单例 + */ + private enum SearchJSFormulaManagerEnum { + /** + * 单例 + */ + SINGLETON; + private SearchJSFormulaManager instance; + + SearchJSFormulaManagerEnum() { + instance = new SearchJSFormulaManager(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchJSFormulaManager getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchJSHighlightAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchJSHighlightAction.java new file mode 100644 index 0000000000..40c31abe9e --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchJSHighlightAction.java @@ -0,0 +1,116 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.javascript; + +import com.fr.base.Formula; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.js.JavaScript; +import com.fr.js.NameJavaScriptGroup; +import com.fr.report.cell.cellattr.highlight.HighlightAction; +import com.fr.report.cell.cellattr.highlight.HyperlinkHighlightAction; +import com.fr.stable.ParameterProvider; + +import java.util.List; +import java.util.Map; + +/** + * 处理条件属性中各种超级链接内的公式(也包括事件中的各种超链) + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-18 + */ +public class SearchJSHighlightAction implements SearchJSFormula { + + + private SearchJSHighlightAction() { + } + + @Override + public void dealWithHighlightAction(ITContent content, List formulaInfos, HighlightAction highlightAction) { + NameJavaScriptGroup nameJavaScriptGroup = ((HyperlinkHighlightAction) highlightAction).getHperlink(); + if (nameJavaScriptGroup != null) { + for (int i = 0; i < nameJavaScriptGroup.size(); i++) { + //单元格条件属性-属性-超级链接里面参数的公式统一判断获取一下 + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos(nameJavaScriptGroup.getNameHyperlink(i).getName()); + addFormulaInfosFromJSPara(formulaInfos, newContent, nameJavaScriptGroup.getNameHyperlink(i).getJavaScript()); + } + } + } + + /** + * 仅仅获取JS中的参数中的公式 + * + * @param formulaInfos + * @param content + * @param javaScript + */ + @Override + public void addFormulaInfosFromJSPara(List formulaInfos, ITContent content, JavaScript javaScript) { + if (javaScript.getParameters() != null) { + for (ParameterProvider provider : javaScript.getParameters()) { + if (provider.getValue() instanceof Formula) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(provider); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Parameters")); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + } + } + + /** + * 对各种类型的JS分别处理,获取公式 + * + * @param formulaInfos + * @param content + * @param javaScript + */ + @Override + public void searchJSFormulaFromOther(List formulaInfos, ITContent content, JavaScript javaScript) { + //获取JS中的参数中的公式 + addFormulaInfosFromJSPara(formulaInfos, content, javaScript); + Map javaScriptType = SearchJSFormulaManager.getInstance().getJSType(); + //这里面类型比较多,但是一部分不用处理——公式可能存在的地方只有参数,这部分在addFormulaInfosFromJSPara中就已经把公式拿完了 + if (javaScriptType.containsKey(javaScript.getClass().getSimpleName())) { + SearchJSFormula javaScriptFormula = javaScriptType.get(javaScript.getClass().getSimpleName()); + javaScriptFormula.searchJSFormulaFromOther(formulaInfos, content, javaScript); + } + } + + + /** + * 获取单例 + * + * @return + */ + public static SearchJSHighlightAction getInstance() { + return SearchJSHighlightActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchJSHighlightActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchJSHighlightAction instance; + + SearchJSHighlightActionEnum() { + instance = new SearchJSHighlightAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchJSHighlightAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchMobileHyperlinkFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchMobileHyperlinkFormulaAction.java new file mode 100644 index 0000000000..f30c1a7b08 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchMobileHyperlinkFormulaAction.java @@ -0,0 +1,69 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.javascript; + +import com.fr.base.Formula; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.js.JavaScript; +import com.fr.js.MobilePopupHyperlink; + +import java.util.List; + +/** + * 获取移动端弹窗相关公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-19 + */ +public class SearchMobileHyperlinkFormulaAction implements SearchJSFormula { + + private SearchMobileHyperlinkFormulaAction() { + } + + @Override + public void searchJSFormulaFromOther(List formulaInfos, ITContent content, JavaScript javaScript) { + if (((MobilePopupHyperlink) javaScript).getPopupText() instanceof Formula) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(((MobilePopupHyperlink) javaScript).getPopupText()); + newContent.addOtherPos( + Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup"), + Toolkit.i18nText("FR-Plugin-Designer_Mobile_Popup_Text") + ); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + + /** + * 获取单例 + * + * @return + */ + public static SearchMobileHyperlinkFormulaAction getInstance() { + return SearchMobileHyperlinkFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchMobileHyperlinkFormulaActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchMobileHyperlinkFormulaAction instance; + + SearchMobileHyperlinkFormulaActionEnum() { + instance = new SearchMobileHyperlinkFormulaAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchMobileHyperlinkFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/present/SearchPresentHighlightAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/present/SearchPresentHighlightAction.java new file mode 100644 index 0000000000..6826ff3fd1 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/present/SearchPresentHighlightAction.java @@ -0,0 +1,91 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.present; + +import com.fr.base.Formula; +import com.fr.base.present.DictPresent; +import com.fr.base.present.FormulaPresent; +import com.fr.design.actions.replace.action.content.formula.highlight.SearchHighlightFormula; +import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction; +import com.fr.design.actions.replace.action.content.formula.widget.DictionaryType; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.highlight.HighlightAction; +import com.fr.report.cell.cellattr.highlight.PresentHighlightAction; + +import java.util.List; + +/** + * 条件属性-属性-形态 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-27 + */ +public class SearchPresentHighlightAction implements SearchHighlightFormula { + + private SearchPresentHighlightAction() { + } + + + @Override + public void dealWithHighlightAction(ITContent content, List formulaInfos, HighlightAction highlightAction) { + if (highlightAction instanceof PresentHighlightAction) { + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Present")); + PresentHighlightAction action = (PresentHighlightAction) highlightAction; + //公式形态 + if (action.getPresent() instanceof FormulaPresent) { + newContent.setReplaceObject(action.getPresent()); + formulaInfos.add(new FormulaInfo(newContent)); + } else if (action.getPresent() instanceof DictPresent) { + //数据字典 + DictPresent present = (DictPresent) action.getPresent(); + if (present.getDictionary() != null) { + DictionaryType type = DictionaryType.match(present.getDictionary().getClass().getSimpleName()); + if (type != null) { + type.searchFormulaFromDictionary(newContent, formulaInfos, present.getDictionary()); + } + } + } else if (action.getValue() instanceof Formula) { + //普通 + newContent.setReplaceObject(action.getValue()); + formulaInfos.add(new FormulaInfo(newContent)); + + } + } + } + + /** + * 获取单例 + * + * @return + */ + public static SearchPresentHighlightAction getInstance() { + return SearchPresentHighlightActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchPresentHighlightActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchPresentHighlightAction instance; + + SearchPresentHighlightActionEnum() { + instance = new SearchPresentHighlightAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchPresentHighlightAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/value/SearchValueHighlightAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/value/SearchValueHighlightAction.java new file mode 100644 index 0000000000..1d692c197a --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/value/SearchValueHighlightAction.java @@ -0,0 +1,70 @@ +package com.fr.design.actions.replace.action.content.formula.highlight.value; + +import com.fr.base.Formula; +import com.fr.design.actions.replace.action.content.formula.highlight.SearchHighlightFormula; +import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchMobileHyperlinkFormulaAction; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.report.cell.cellattr.highlight.HighlightAction; +import com.fr.report.cell.cellattr.highlight.ValueHighlightAction; + +import java.util.List; + +/** + * 条件属性-新值-公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-27 + */ +public class SearchValueHighlightAction implements SearchHighlightFormula { + private SearchValueHighlightAction() { + } + + @Override + public void dealWithHighlightAction(ITContent content, List formulaInfos, HighlightAction highlightAction) { + if (highlightAction instanceof ValueHighlightAction) { + ValueHighlightAction action = (ValueHighlightAction) highlightAction; + if (action.getValue() instanceof Formula) { + ITContent valueContent = ITContent.copy(content); + valueContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_New_Value")); + valueContent.setReplaceObject(action.getValue()); + formulaInfos.add(new FormulaInfo(valueContent)); + } + } + } + + /** + * 获取单例 + * + * @return + */ + public static SearchValueHighlightAction getInstance() { + return SearchValueHighlightActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchValueHighlightActionEnum { + /** + * 单例实现 + */ + SINGLETON; + private SearchValueHighlightAction instance; + + SearchValueHighlightActionEnum() { + instance = new SearchValueHighlightAction(); + } + + /** + * 拿到对象 + * + * @return + */ + public SearchValueHighlightAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormula.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormula.java new file mode 100644 index 0000000000..8d9f9190c2 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormula.java @@ -0,0 +1,36 @@ +package com.fr.design.actions.replace.action.content.formula.template; + +import com.fr.design.actions.replace.action.content.formula.SearchFormula; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.mainframe.JTemplate; + +import java.util.List; + +/** + * 搜索模板全局内容 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-12 + */ +public interface SearchTemplateFormula extends SearchFormula { + + /** + * 搜索全局水印中的公式 + * + * @param jTemplate + * @param formulaInfos + * @param content + */ + void searchTemplateWaterMarkFormula(JTemplate jTemplate, List formulaInfos, ITContent content); + + /** + * 搜索全局参数中的公式 + * + * @param jTemplate + * @param formulaInfos + * @param content + */ + void searchTemplateParaFormula(JTemplate jTemplate, List formulaInfos, ITContent content); +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java new file mode 100644 index 0000000000..0dd6919558 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java @@ -0,0 +1,217 @@ +package com.fr.design.actions.replace.action.content.formula.template; + +import com.fr.base.Formula; +import com.fr.base.Parameter; +import com.fr.base.ParameterConfig; +import com.fr.base.io.AttrMark; +import com.fr.base.iofile.attr.WatermarkAttr; +import com.fr.data.Verifier; +import com.fr.data.VerifyItem; +import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchCommit2DBJSFormulaAction; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.info.base.SearchTag; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.HistoryTemplateListPane; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.ReportComponentComposite; +import com.fr.design.mainframe.SheetNameTabPane; +import com.fr.main.impl.WorkBook; +import com.fr.report.core.ReportUtils; +import com.fr.report.report.Report; +import com.fr.report.worksheet.WorkSheet; +import com.fr.report.write.BuiltInSQLSubmiter; +import com.fr.report.write.ReportWriteAttr; +import com.fr.report.write.SubmitVisitor; +import com.fr.report.write.ValueVerifier; +import com.fr.stable.CommonUtils; + + +import java.util.List; + +/** + * 搜索模板的全局相关内容 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-12 + */ +public class SearchTemplateFormulaAction implements SearchTemplateFormula { + + + private SearchTemplateFormulaAction() { + } + + + @Override + public void searchFormulaFromObject(JTemplate jTemplate, List formulaInfos) { + ITContent content = new ITContent(); + content.setTemplateName(jTemplate.getTemplateName()); + content.setJumpAble(false); + //参数 + searchTemplateParaFormula(jTemplate, formulaInfos, content); + //水印 + searchTemplateWaterMarkFormula(jTemplate, formulaInfos, content); + //报表填报属性 + searchTemplateWriteAttrFormula(jTemplate, formulaInfos, content); + //sheet名称 + searchTemplateSheetNameFormula(jTemplate, formulaInfos, content); + } + + private void searchTemplateSheetNameFormula(JTemplate jTemplate, List formulaInfos, ITContent content) { + if (jTemplate.getTarget() instanceof WorkBook) { + WorkBook workBook = (WorkBook) jTemplate.getTarget(); + for (int i = 0, len = workBook.getReportCount(); i < len; i++) { + String name = workBook.getReportName(i); + if (CommonUtils.canBeFormula(name)) { + ITContent sheetContent = ITContent.copy(content); + sheetContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Replace_Sheet"), + name + ); + sheetContent.setReplaceObject(name); + sheetContent.setHoldObject(workBook); + sheetContent.setTag(SearchTag.SHEET_NAME); + sheetContent.setSheetID(String.valueOf(i)); + formulaInfos.add(new FormulaInfo(sheetContent)); + } + } + } + } + + private void searchTemplateWriteAttrFormula(JTemplate jTemplate, List formulaInfos, ITContent content) { + if (jTemplate.getTarget() instanceof WorkBook) { + WorkBook workBook = (WorkBook) jTemplate.getTarget(); + for (int i = 0, len = workBook.getReportCount(); i < len; i++) { + Report report = workBook.getReport(i); + if (report instanceof WorkSheet) { + ITContent sheetContent = ITContent.copy(content); + sheetContent.setSheetName(workBook.getReportName(i)); + sheetContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Report_Write_Attributes")); + dealWorkSheetAttr(formulaInfos, sheetContent, (WorkSheet) report); + } + } + } + } + + private void dealWorkSheetAttr(List formulaInfos, ITContent sheetContent, WorkSheet report) { + ReportWriteAttr attr = report.getAttributeTarget(ReportWriteAttr.XML_TAG); + if (attr != null) { + //提交 + for (int i = 0, len = attr.getSubmitVisitorCount(); i < len; i++) { + SubmitVisitor visitor = attr.getSubmitVisitor(i); + ITContent submitContent = ITContent.copy(sheetContent); + submitContent.addOtherPos(Toolkit.i18nText("FIne-Design_Basic_Submit")); + dealBuiltSQLSubmiter4Formula(formulaInfos, submitContent, visitor); + } + + //数据校验 + for (int i = 0, len = attr.getVerifierCount(); i < len; i++) { + Verifier verifier = attr.getVerifier(i); + if (verifier instanceof ValueVerifier) { + ITContent content = ITContent.copy(sheetContent); + content.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Verify_Data_Verify")); + dealValueVerifier4Formula(formulaInfos, content, (ValueVerifier) verifier); + } + } + } + + } + + private void dealValueVerifier4Formula(List formulaInfos, ITContent content, ValueVerifier verifier) { + ITContent verifyContent = ITContent.copy(content); + verifyContent.addOtherPos(verifier.getName()); + for (int i = 0, len = verifier.getVerifyItemsCount(); i < len; i++) { + VerifyItem item = verifier.getVerifyItem(i); + if (item.getFormula() != null) { + ITContent formulaContent = ITContent.copy(verifyContent); + formulaContent.setReplaceObject(item.getFormula()); + formulaInfos.add(new FormulaInfo(formulaContent)); + } + if (CommonUtils.canBeFormula(item.getMessage())) { + ITContent messageContent = ITContent.copy(verifyContent); + messageContent.setReplaceObject(item.getMessage()); + messageContent.setHoldObject(item); + formulaInfos.add(new FormulaInfo(messageContent)); + } + } + } + + private void dealBuiltSQLSubmiter4Formula(List formulaInfos, ITContent submitContent, SubmitVisitor visitor) { + if (visitor instanceof BuiltInSQLSubmiter) { + BuiltInSQLSubmiter submiter = (BuiltInSQLSubmiter) visitor; + ITContent content = ITContent.copy(submitContent); + content.addOtherPos(submiter.getName()); + SearchCommit2DBJSFormulaAction.getInstance().dealWithDBManipulation(formulaInfos, content, submiter.getDBManipulation()); + } + } + + @Override + public void searchTemplateWaterMarkFormula(JTemplate jTemplate, List formulaInfos, ITContent content) { + WatermarkAttr watermarkAttr = ReportUtils.getWatermarkAttrFromTemplateAndGlobal((AttrMark) jTemplate.getTarget()); + if (watermarkAttr != null) { + ITContent waterMarkContent = ITContent.copy(content); + waterMarkContent.addOtherPos(Toolkit.i18nText("Fine-Design_Form_WaterMark")); + waterMarkContent.setReplaceObject(watermarkAttr); + formulaInfos.add(new FormulaInfo(waterMarkContent)); + } + } + + @Override + public void searchTemplateParaFormula(JTemplate jTemplate, List formulaInfos, ITContent content) { + Parameter[] parameters = jTemplate.getJTemplateParameters(); + for (Parameter parameter : parameters) { + if (parameter.getValue() instanceof Formula) { + ITContent paraContent = ITContent.copy(content); + paraContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Template_Parameter")); + paraContent.setReplaceObject(parameter); + formulaInfos.add(new FormulaInfo(paraContent)); + } + } + + ////全局类二期再做 + //Parameter[] globalParameters = ParameterConfig.getInstance().getGlobalParameters(); + //for (Parameter parameter : globalParameters) { + // if (parameter.getValue() instanceof Formula) { + // ITContent paraContent = ITContent.copy(content); + // paraContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Parameter_Source_Type_Server")); + // paraContent.setReplaceObject(parameter); + // formulaInfos.add(new FormulaInfo(paraContent)); + // } + //} + } + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchTemplateFormulaAction getInstance() { + return SearchTemplateFormulaAction.SearchTemplateFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 单例实现枚举 + */ + enum SearchTemplateFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchTemplateFormulaAction instance; + + SearchTemplateFormulaActionEnum() { + instance = new SearchTemplateFormulaAction(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchTemplateFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/AbstractSearchWidgetFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/AbstractSearchWidgetFormulaAction.java new file mode 100644 index 0000000000..d8ff30f79e --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/AbstractSearchWidgetFormulaAction.java @@ -0,0 +1,73 @@ +package com.fr.design.actions.replace.action.content.formula.widget; + +import com.fr.base.Formula; +import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.form.event.Listener; +import com.fr.form.ui.DataControl; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WScaleLayout; +import com.fr.form.ui.widget.CRBoundsWidget; + +import java.util.List; + +/** + * 处理共有控件内容 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-19 + */ +public abstract class AbstractSearchWidgetFormulaAction implements SearchWidgetFormula { + + /** + * 用于处理控件共有的事件以及控件值中的公式 + * + * @param content + * @param formulaInfos + */ + @Override + public void searchFormulaFromWidget(ITContent content, List formulaInfos) { + Widget widget = (Widget) content.getReplaceObject(); + //控件值中的公式 + searchFormulaFromWidgetValue(content, formulaInfos); + for (int i = 0; i < widget.getListenerSize(); i++) { + Listener listener = widget.getListener(i); + ITContent newContent = ITContent.copy(content); + //控件的事件可以使用的JS有五种,这边统一交给Highlight那边判断超级链接并进行处理 + SearchJSHighlightAction jsHighlightAction = SearchJSHighlightAction.getInstance(); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Event"),listener.getName()); + + jsHighlightAction.searchJSFormulaFromOther(formulaInfos, newContent, listener.getAction()); + } + } + + /** + * 判断一下控件有没有控件值接口,如果有再判断一下控件值是否已经设置并且是公式 + * + * @param content + * @param formulaInfos + */ + @Override + public void searchFormulaFromWidgetValue(ITContent content, List formulaInfos) { + Widget widget = (Widget) content.getReplaceObject(); + if (widget instanceof WScaleLayout){ + widget = ((CRBoundsWidget)((WScaleLayout)widget).getWidget(0)).getWidget(); + } + if (widget instanceof DataControl) { + if (isWidgetValueValid(((DataControl) widget))) { + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Widget_Value")); + newContent.setReplaceObject(((DataControl) widget).getWidgetValue().getValue()); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + } + + private boolean isWidgetValueValid(DataControl control){ + return control.getWidgetValue() != null + && control.getWidgetValue().getValue() instanceof Formula; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryAction.java new file mode 100644 index 0000000000..7ae47c80ef --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryAction.java @@ -0,0 +1,26 @@ +package com.fr.design.actions.replace.action.content.formula.widget; + +import com.fr.data.Dictionary; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; + +import java.util.List; + +/** + * 从数据字典中获取信息 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-22 + */ +public interface DictionaryAction { + + /** + * 从数据字典中获取公式 + * + * @param content + * @param formulaInfos + * @param dictionary + */ + void searchFormulaFromDictionary(ITContent content, List formulaInfos, Dictionary dictionary); +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java new file mode 100644 index 0000000000..6a55aebf9b --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java @@ -0,0 +1,122 @@ +package com.fr.design.actions.replace.action.content.formula.widget; + +import com.fr.data.Dictionary; +import com.fr.data.impl.DatabaseDictionary; +import com.fr.data.impl.FormulaDictionary; +import com.fr.data.impl.TableDataDictionary; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.info.base.SearchTag; +import com.fr.design.i18n.Toolkit; +import org.jetbrains.annotations.Nullable; + +import java.util.List; + +/** + * 数据字典处理 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-22 + */ +public enum DictionaryType implements DictionaryAction { + + /** + * 数据字典——公式 + */ + FORMULA_DICTIONARY("FormulaDictionary") { + @Override + public void searchFormulaFromDictionary(ITContent content, List formulaInfos, Dictionary dictionary) { + if (dictionary instanceof FormulaDictionary) { + FormulaDictionary formulaDictionary = (FormulaDictionary) dictionary; + + //显示值 + if (formulaDictionary.getExcuteFormula() != null) { + ITContent excuteContent = ITContent.copy(content); + excuteContent.setReplaceObject(formulaDictionary.getExcuteFormula()); + excuteContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary"), + Toolkit.i18nText("Fine-Design_Basic_Formula"), + Toolkit.i18nText("Fine-Design_Basic_Display_Value") + ); + excuteContent.setHoldObject(dictionary); + excuteContent.setTag(SearchTag.DICT_EXCUTE); + formulaInfos.add(new FormulaInfo(excuteContent)); + } + //实际值 + if (formulaDictionary.getProduceFormula() != null) { + ITContent produceContent = ITContent.copy(content); + produceContent.setReplaceObject(formulaDictionary.getProduceFormula()); + produceContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary"), + Toolkit.i18nText("Fine-Design_Basic_Formula"), + Toolkit.i18nText("Fine-Design_Basic_Actual_Value") + ); + produceContent.setHoldObject(dictionary); + produceContent.setTag(SearchTag.DICT_PRODUCE); + formulaInfos.add(new FormulaInfo(produceContent)); + } + } + } + }, + /** + * 数据查询 + */ + TABLE_DATA_DICTIONARY("TableDataDictionary") { + @Override + public void searchFormulaFromDictionary(ITContent content, List formulaInfos, Dictionary dictionary) { + if (((TableDataDictionary) dictionary).getFormula() != null) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(((TableDataDictionary) dictionary).getFormula()); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary"), + Toolkit.i18nText("Fine-Design_Basic_Dic_Data_Query"), + Toolkit.i18nText("Fine-Design_Basic_Display_Value") + ); + formulaInfos.add(new FormulaInfo(newContent)); + } + + } + }, + /** + * 数据库表 + */ + DATABASE_DICTIONARY("DatabaseDictionary") { + @Override + public void searchFormulaFromDictionary(ITContent content, List formulaInfos, Dictionary dictionary) { + if (((DatabaseDictionary) dictionary).getFormula() != null) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(((DatabaseDictionary) dictionary).getFormula()); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary"), + Toolkit.i18nText("Fine-Design_Basic_Datasource_From_Database"), + Toolkit.i18nText("Fine-Design_Basic_Display_Value") + ); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + }; + + String name; + + DictionaryType(String name) { + this.name = name; + } + + /** + * 匹配 + * + * @param name + * @return + */ + @Nullable + public static DictionaryType match(String name) { + DictionaryType[] values = DictionaryType.values(); + for (DictionaryType value : values) { + if (value.name.equals(name)) { + return value; + } + } + return null; + } +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchCommonWidgetFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchCommonWidgetFormulaAction.java new file mode 100644 index 0000000000..27d921a622 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchCommonWidgetFormulaAction.java @@ -0,0 +1,60 @@ +package com.fr.design.actions.replace.action.content.formula.widget; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; + +import java.util.List; + +/** + * 控件中的公式只会在事件、控件值 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-19 + */ +public class SearchCommonWidgetFormulaAction extends AbstractSearchWidgetFormulaAction { + + + private SearchCommonWidgetFormulaAction() { + } + + @Override + public void searchFormulaFromWidget(ITContent content, List formulaInfos) { + //每个事件的事件、控件值两部分的公式获取逻辑是一样的,直接调用即可,各自其他地方的公式就需要特殊处理 + super.searchFormulaFromWidget(content, formulaInfos); + } + + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchCommonWidgetFormulaAction getInstance() { + return SearchCommonWidgetFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchCommonWidgetFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchCommonWidgetFormulaAction instance; + + SearchCommonWidgetFormulaActionEnum() { + instance = new SearchCommonWidgetFormulaAction(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchCommonWidgetFormulaAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchDateEditorFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchDateEditorFormulaAction.java new file mode 100644 index 0000000000..28bd17c9b5 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchDateEditorFormulaAction.java @@ -0,0 +1,86 @@ +package com.fr.design.actions.replace.action.content.formula.widget; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.form.ui.DateEditor; +import com.fr.stable.StringUtils; + + +import java.util.List; + +/** + * 日期类型控件特殊处理 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-26 + */ +public class SearchDateEditorFormulaAction extends AbstractSearchWidgetFormulaAction { + + + private SearchDateEditorFormulaAction() { + } + + @Override + public void searchFormulaFromWidget(ITContent content, List formulaInfos) { + super.searchFormulaFromWidget(content, formulaInfos); + dealStratDateFormula(content, formulaInfos); + dealEndDateFormula(content, formulaInfos); + } + + private void dealEndDateFormula(ITContent content, List formulaInfos) { + DateEditor dateEditor = (DateEditor) content.getReplaceObject(); + if (dateEditor.getEndDateFM() != null && StringUtils.isNotEmpty(dateEditor.getEndDateFM().getContent())) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(dateEditor.getEndDateFM()); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_FS_End_Date")); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + + private void dealStratDateFormula(ITContent content, List formulaInfos) { + DateEditor dateEditor = (DateEditor) content.getReplaceObject(); + if (dateEditor.getStartDateFM() != null && StringUtils.isNotEmpty(dateEditor.getStartDateFM().getContent())) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(dateEditor.getStartDateFM()); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_FS_Start_Date")); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchDateEditorFormulaAction getInstance() { + return SearchDateEditorFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchDateEditorFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchDateEditorFormulaAction instance; + + SearchDateEditorFormulaActionEnum() { + instance = new SearchDateEditorFormulaAction(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchDateEditorFormulaAction getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchDictFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchDictFormulaAction.java new file mode 100644 index 0000000000..a89e5118e1 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchDictFormulaAction.java @@ -0,0 +1,77 @@ +package com.fr.design.actions.replace.action.content.formula.widget; + +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.form.ui.DictionaryContainer; + + +import java.util.List; + +/** + * 控件中的公式会存在: 控件值、 非树形结构数据字典、 事件 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-20 + */ +public class SearchDictFormulaAction extends AbstractSearchWidgetFormulaAction { + + private SearchDictFormulaAction() { + } + + @Override + public void searchFormulaFromWidget(ITContent content, List formulaInfos) { + //控件值、事件 + super.searchFormulaFromWidget(content, formulaInfos); + //数据字典 + searchFormulaFromDict(content, formulaInfos); + + } + + private void searchFormulaFromDict(ITContent content, List formulaInfos) { + if (content.getReplaceObject() instanceof DictionaryContainer) { + if (((DictionaryContainer) content.getReplaceObject()).getDictionary() != null) { + DictionaryType type = DictionaryType.match(((DictionaryContainer) content.getReplaceObject()).getDictionary().getClass().getSimpleName()); + if (type != null) { + type.searchFormulaFromDictionary(content, formulaInfos, ((DictionaryContainer) content.getReplaceObject()).getDictionary()); + } + } + } + } + + + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchDictFormulaAction getInstance() { + return SearchDictFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchDictFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchDictFormulaAction instance; + + SearchDictFormulaActionEnum() { + instance = new SearchDictFormulaAction(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchDictFormulaAction getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchTreeEditorFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchTreeEditorFormulaAction.java new file mode 100644 index 0000000000..3a36eb510c --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchTreeEditorFormulaAction.java @@ -0,0 +1,129 @@ +package com.fr.design.actions.replace.action.content.formula.widget; + +import com.fr.data.Dictionary; +import com.fr.data.impl.FormulaDictionary; +import com.fr.data.impl.FormulaDisplayDictionary; +import com.fr.data.impl.TableDataDictionary; +import com.fr.data.impl.TreeNodeAttr; +import com.fr.data.impl.TreeNodeWrapper; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.form.ui.DictionaryContainer; +import com.fr.form.ui.TreeEditor; +import com.fr.form.ui.tree.LayerConfig; +import com.fr.stable.StringUtils; + +import java.util.List; + +/** + * 搜索树形结构数据字典的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-22 + */ +public class SearchTreeEditorFormulaAction extends AbstractSearchWidgetFormulaAction { + private SearchTreeEditorFormulaAction() { + } + + @Override + public void searchFormulaFromWidget(ITContent content, List formulaInfos) { + //控件值、事件 + super.searchFormulaFromWidget(content, formulaInfos); + //树形结构数据字典 + SearchFormulaFromModelConfig(content, formulaInfos); + + } + + private void SearchFormulaFromModelConfig(ITContent content, List formulaInfos) { + if (content.getReplaceObject() instanceof TreeEditor) { + if (((TreeEditor) content.getReplaceObject()).getBuildModelConfig() != null) { + //LayerConfig[] 急速分层构建 + //TreeNodeWrapper 普通分层构建 + //TableDataDictionary 自动构建 + Object object = ((TreeEditor) content.getReplaceObject()).getBuildModelConfig(); + if (object instanceof LayerConfig[]) { + LayerConfig[] layerConfigs = (LayerConfig[]) object; + dealWithLayerConfigs(layerConfigs, content, formulaInfos); + } else if (object instanceof TreeNodeWrapper) { + TreeNodeWrapper wrapper = (TreeNodeWrapper) object; + dealWithTreeNodeWrapper(wrapper, content, formulaInfos); + } else if (object instanceof TableDataDictionary) { + TableDataDictionary tableDataDictionary = (TableDataDictionary) object; + if (tableDataDictionary.getFormula() != null) { + ITContent autoContent = ITContent.copy(content); + autoContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Auto_Build"), + Toolkit.i18nText("Fine-Design_Basic_Display_Value") + ); + autoContent.setReplaceObject(tableDataDictionary.getFormula()); + formulaInfos.add(new FormulaInfo(autoContent)); + } + } + + } + } + } + + private void dealWithTreeNodeWrapper(TreeNodeWrapper wrapper, ITContent content, List formulaInfos) { + for (TreeNodeAttr attr : wrapper.getTreeNodeAttrs()) { + if (attr.getDictionary() != null) { + DictionaryType type = DictionaryType.match(attr.getDictionary().getClass().getSimpleName()); + if (type != null) { + type.searchFormulaFromDictionary(content, formulaInfos, attr.getDictionary()); + } + } + } + } + + private void dealWithLayerConfigs(LayerConfig[] layerConfigs, ITContent content, List formulaInfos) { + for (LayerConfig layerConfig : layerConfigs) { + if (layerConfig.getDictionary().getFormula() != null + && StringUtils.isNotEmpty(layerConfig.getDictionary().getFormula().getContent())) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(layerConfig.getDictionary().getFormula()); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary"), + Toolkit.i18nText("Fine-Design_Basic_DataTable_Build") + ); + formulaInfos.add(new FormulaInfo(newContent)); + } + } + } + + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchTreeEditorFormulaAction getInstance() { + return SearchTreeEditorFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchTreeEditorFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchTreeEditorFormulaAction instance; + + SearchTreeEditorFormulaActionEnum() { + instance = new SearchTreeEditorFormulaAction(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchTreeEditorFormulaAction getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormula.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormula.java new file mode 100644 index 0000000000..166fd215ef --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormula.java @@ -0,0 +1,42 @@ +package com.fr.design.actions.replace.action.content.formula.widget; + +import com.fr.design.actions.replace.action.content.formula.SearchFormula; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.base.ITContent; + +import java.util.List; + +/** + * 搜索控件中的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-19 + */ +public interface SearchWidgetFormula extends SearchFormula { + + /** + * 从WidgetInfos列表中搜索所有公式 + * @param info 对应的Info信息列表 + * @param formulaInfos 要存储进去的公式信息列表 + */ + default void searchFormulaFromWidgetInfos(Info info, List formulaInfos){} + + /** + * 从控件的不同类型中获取公式 + * + * @param content 对应的ITContent数据结构 + * @param formulaInfos 要存储进去的公式信息列表 + */ + void searchFormulaFromWidget(ITContent content, List formulaInfos); + + /** + * 从控件值中获取公式 + * + * @param content 对应的ITContent数据结构 + * @param formulaInfos 要存储进去的公式信息列表 + */ + void searchFormulaFromWidgetValue(ITContent content, List formulaInfos); + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaAction.java new file mode 100644 index 0000000000..3e1f4a8bcf --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaAction.java @@ -0,0 +1,146 @@ +package com.fr.design.actions.replace.action.content.formula.widget; + + +import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.actions.replace.action.content.component.SearchComponentAction; +import com.fr.design.actions.replace.action.content.formula.chart.SearchChartCollectionFormulaAction; +import com.fr.design.actions.replace.action.content.widget.SearchWidgetAction; +import com.fr.design.actions.replace.info.ComponentInfo; +import com.fr.design.actions.replace.info.FormulaInfo; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.WidgetInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.design.mainframe.JTemplate; + +import com.fr.form.main.Form; +import com.fr.form.ui.ChartEditor; + + +import com.fr.form.ui.Label; +import com.fr.form.ui.Widget; + +import com.fr.form.ui.container.WBorderLayout; +import com.fr.form.ui.container.WScaleLayout; +import com.fr.form.ui.container.WTitleLayout; +import com.fr.form.ui.widget.CRBoundsWidget; +import com.fr.main.impl.WorkBook; + + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; + +/** + * 查找控件内的公式 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-19 + */ +public class SearchWidgetFormulaAction extends AbstractSearchWidgetFormulaAction { + private SearchWidgetFormulaAction() { + } + + @Override + public void searchFormulaFromObject(JTemplate jTemplate, List formulaInfos) { + List result = new ArrayList<>(); + if (jTemplate.getTarget() instanceof WorkBook) { + SearchWidgetAction searchWidgetAction = SearchWidgetAction.getInstance(); + searchWidgetAction.search4Infos(jTemplate); + if (!searchWidgetAction.isWidgetInfosEmpty()) { + for (WidgetInfo widgetInfo : searchWidgetAction.getWidgetInfos()) { + //由于控件类型比较多,各种控件也不大相同,可能存放公式的地方也都不一样,这边根据对应的类型进行处理 + searchFormulaFromWidgetInfos(widgetInfo, result); + } + } + } else if (jTemplate.getTarget() instanceof Form) { + SearchComponentAction searchComponentAction = SearchComponentAction.getInstance(); + searchComponentAction.search4Infos(jTemplate); + if (ShowValueUtils.isNotEmpty(searchComponentAction.getComponentInfos())) { + for (ComponentInfo componentInfo : searchComponentAction.getComponentInfos()) { + searchFormulaFromWidgetInfos(componentInfo, formulaInfos); + } + } + } + formulaInfos.addAll(result); + } + + @Override + public void searchFormulaFromWidgetInfos(Info info, List formulaInfos) { + if (isReplaceObjectExist(info)) { + searchFormulaFromWidgetValue(info, formulaInfos); + } + } + + private void searchFormulaFromWidgetValue(Info info, List formulaInfos) { + Widget widget = (Widget) info.getContent().getReplaceObject(); + if (widget instanceof WScaleLayout) { + widget = ((CRBoundsWidget) ((WScaleLayout) widget).getWidget(0)).getWidget(); + info.getContent().setReplaceObject(widget); + } + if (widget instanceof WTitleLayout) { + if (((WTitleLayout) widget).getTitleBoundsWidget() != null) { + CRBoundsWidget boundsWidget = ((WTitleLayout) widget).getTitleBoundsWidget(); + if (boundsWidget.getWidget() instanceof Label) { + ITContent titleContent = ITContent.copy(info.getContent()); + titleContent.setReplaceObject(((Label) boundsWidget.getWidget()).getWidgetValue().getValue()); + formulaInfos.add(new FormulaInfo(titleContent)); + } + } + Widget tempWidget = (((WTitleLayout) widget).getBodyBoundsWidget()).getWidget(); + if (isChartValid(tempWidget)) { + SearchChartCollectionFormulaAction.getInstance().searchChartCollectionFormula(formulaInfos, info.getContent(), (ChartCollection) ((ChartEditor) tempWidget).getChartCollection()); + } + } + Map widgetType = SearchWidgetFormulaManager.getInstance().getWidgetType(); + if (widgetType.containsKey(widget.getClass().getSimpleName())) { + SearchWidgetFormula searchWidgetFormula = widgetType.get(widget.getClass().getSimpleName()); + ITContent content = ITContent.copy(info.getContent()); + searchWidgetFormula.searchFormulaFromWidget(content, formulaInfos); + } + + } + + private boolean isChartValid(Widget tempWidget) { + return tempWidget instanceof ChartEditor && ((ChartEditor) tempWidget).getChartCollection() instanceof ChartCollection; + } + + public boolean isReplaceObjectExist(Info info) { + return info.getContent() != null && info.getContent().getReplaceObject() != null; + } + + /** + * 对外开放的获取对象的方法 + * + * @return + */ + public static SearchWidgetFormulaAction getInstance() { + return SearchWidgetFormulaAction.SearchWidgetFormulaActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchWidgetFormulaActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchWidgetFormulaAction instance; + + SearchWidgetFormulaActionEnum() { + instance = new SearchWidgetFormulaAction(); + } + + /** + * 获取对象 + * + * @return + */ + public SearchWidgetFormulaAction getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaManager.java new file mode 100644 index 0000000000..1d11046164 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchWidgetFormulaManager.java @@ -0,0 +1,147 @@ +package com.fr.design.actions.replace.action.content.formula.widget; + +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.action.SearchManager; + +import java.util.HashMap; +import java.util.Map; + +/** + * 管理要搜索的控件类型(公式) + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-16 + */ +public class SearchWidgetFormulaManager implements SearchManager { + private Map widgetType = new HashMap<>(); + private static final String FORM_SUBMIT_BUTTON = "FormSubmitButton"; + private static final String W_PARAMETER_LAYOUT = "WParameterLayout"; + private static final String TEXT_AREA = "TextArea"; + private static final String PASSWORD = "Password"; + private static final String CHECK_BOX = "CheckBox"; + private static final String LABEL = "Label"; + private static final String FREE_BUTTON = "FreeButton"; + private static final String NUMBER_EDITOR = "NumberEditor"; + private static final String TEXT_EDITOR = "TextEditor"; + private static final String DATE_EDITOR = "DateEditor"; + private static final String COMBO_BOX = "ComboBox"; + private static final String RADIO_GROUP = "RadioGroup"; + private static final String CHECK_BOX_GROUP = "CheckBoxGroup"; + private static final String COMBO_CHECK_BOX = "ComboCheckBox"; + private static final String PAGE_FIXED_ROW_COMBOBOX = "PageFixedRowComboBox"; + private static final String TREE_COMBO_BOX_EDITOR = "TreeComboBoxEditor"; + private static final String TREE_EDITOR = "TreeEditor"; + private static final String W_TITLE_LAYOUT = "WTitleLayout"; + private static final String W_BORDER_LAYOUT = "WBorderLayout"; + + private SearchWidgetFormulaManager() { + /** + * 可能有控件值、 有事件 + */ + register(FORM_SUBMIT_BUTTON, SearchCommonWidgetFormulaAction.getInstance()); + register(W_PARAMETER_LAYOUT, SearchCommonWidgetFormulaAction.getInstance()); + register(TEXT_AREA, SearchCommonWidgetFormulaAction.getInstance()); + register(PASSWORD, SearchCommonWidgetFormulaAction.getInstance()); + register(CHECK_BOX, SearchCommonWidgetFormulaAction.getInstance()); + register(LABEL, SearchCommonWidgetFormulaAction.getInstance()); + register(FREE_BUTTON, SearchCommonWidgetFormulaAction.getInstance()); + register(NUMBER_EDITOR, SearchCommonWidgetFormulaAction.getInstance()); + register(TEXT_EDITOR, SearchCommonWidgetFormulaAction.getInstance()); + register(W_TITLE_LAYOUT, SearchCommonWidgetFormulaAction.getInstance()); + register(W_BORDER_LAYOUT, SearchCommonWidgetFormulaAction.getInstance()); + /** + * 日期类型 + */ + register(DATE_EDITOR, SearchDateEditorFormulaAction.getInstance()); + + /** + * 控件值、事件、非树形数据字典 + */ + register(COMBO_BOX, SearchDictFormulaAction.getInstance()); + register(RADIO_GROUP, SearchDictFormulaAction.getInstance()); + register(CHECK_BOX_GROUP, SearchDictFormulaAction.getInstance()); + register(COMBO_CHECK_BOX, SearchDictFormulaAction.getInstance()); + register(PAGE_FIXED_ROW_COMBOBOX, SearchDictFormulaAction.getInstance()); + + /** + * 控件值、事件、树形数据字典 + */ + register(TREE_COMBO_BOX_EDITOR, SearchTreeEditorFormulaAction.getInstance()); + register(TREE_EDITOR, SearchTreeEditorFormulaAction.getInstance()); + } + + + @Override + public void registerAction(String tag, SearchAction searchAction) { + if (searchAction instanceof SearchWidgetFormula) { + register(tag, (SearchWidgetFormula) searchAction); + } + } + + @Override + public void removeAction(String tag) { + remove(tag); + } + + /** + * 注册 + * + * @param tag 用于匹配的类型tag + * @param searchWidgetFormula 对应的实现类 + */ + private void register(String tag, SearchWidgetFormula searchWidgetFormula) { + widgetType.put(tag, searchWidgetFormula); + } + + /** + * 注销 + * + * @param tag 用于匹配的tag + */ + private void remove(String tag) { + widgetType.remove(tag); + } + + /** + * 获取单元格类型 + * + * @return + */ + public Map getWidgetType() { + return widgetType; + } + + /** + * 对外开放的获取单例对象的方法 + * + * @return + */ + public static SearchWidgetFormulaManager getInstance() { + return SearchWidgetFormulaManagerEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchWidgetFormulaManagerEnum { + /** + * 单例 + */ + SINGLETON; + private SearchWidgetFormulaManager instance; + + SearchWidgetFormulaManagerEnum() { + instance = new SearchWidgetFormulaManager(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchWidgetFormulaManager getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchCellJSAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchCellJSAction.java new file mode 100644 index 0000000000..cff74e9e0a --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchCellJSAction.java @@ -0,0 +1,141 @@ +package com.fr.design.actions.replace.action.content.js; + +import com.fr.chart.chartattr.ChartCollection; + +import com.fr.design.actions.replace.action.content.cell.SearchCellAction; +import com.fr.design.actions.replace.info.CellInfo; +import com.fr.design.actions.replace.info.JSInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.utils.SearchJSUtils; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.js.JavaScriptImpl; + +import com.fr.js.NameJavaScriptGroup; + +import com.fr.report.cell.CellElement; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.highlight.DefaultHighlight; +import com.fr.report.cell.cellattr.highlight.HighlightAction; +import com.fr.report.cell.cellattr.highlight.HyperlinkHighlightAction; + +import java.util.ArrayList; +import java.util.List; + +/** + * 搜索单元格JS + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-13 + */ +public class SearchCellJSAction implements SearchJS { + + + private SearchCellJSAction() { + } + + @Override + public void searchJSFromObject(JTemplate jTemplate, List jsInfos) { + List CellJSInfos = new ArrayList<>(); + addJSInfos2ListFromCell(jTemplate, CellJSInfos); + jsInfos.addAll(CellJSInfos); + } + + private void addJSInfos2ListFromCell(JTemplate jTemplate, List jsInfos) { + SearchCellAction searchCellAction = SearchCellAction.getInstance(); + searchCellAction.search4Infos(jTemplate); + for (CellInfo cellInfo : searchCellAction.getCellInfos()) { + CellElement cell = (CellElement) cellInfo.getContent().getReplaceObject(); + ITContent newContent4Cell = ITContent.copy(cellInfo.getContent()); + ITContent newContent4CellCondition = ITContent.copy(cellInfo.getContent()); + ITContent newContent4CellWidgetCondition = ITContent.copy(cellInfo.getContent()); + //单元格的超级链接里面的JS + SearchJSUtils.addJSInfosFromHyperLink(cell, jsInfos, newContent4Cell); + + //单元格条件属性里的JS + newContent4CellCondition.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Condition_Attributes")); + searchCellConditionJS(cell, jsInfos, newContent4CellCondition); + + + //单元格如果是图表还需要额外处理 + if (cell.getValue() instanceof ChartCollection) { + SearchChartJSAction.getInstance().searchChartJS((ChartCollection) cell.getValue(), ITContent.copy(cellInfo.getContent()), jsInfos); + } + } + } + + private void searchCellConditionJS(CellElement cell, List jsInfos, ITContent content) { + if (((TemplateCellElement) cell).getHighlightGroup() != null) { + for (int i = 0; i < ((TemplateCellElement) cell).getHighlightGroup().size(); i++) { + NameJavaScriptGroup njsg = getJSFromAction(((DefaultHighlight) ((TemplateCellElement) cell).getHighlightGroup().getHighlight(i))); + getAllJSFromNameJavaScriptGroup(cell, jsInfos, njsg, content); + + } + } + } + + private void getAllJSFromNameJavaScriptGroup(CellElement cell, List jsInfos, NameJavaScriptGroup njsg, ITContent content) { + if (isJSExist(njsg)) { + for (int i = 0; i < njsg.size(); i++) { + if (njsg.getNameHyperlink(i).getJavaScript() instanceof JavaScriptImpl) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(njsg.getNameHyperlink(i)); + SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent)); + } + + } + } + } + + private boolean isJSExist(NameJavaScriptGroup njsg) { + return njsg != null; + } + + private NameJavaScriptGroup getJSFromAction(DefaultHighlight highlight) { + for (int i = 0; i < highlight.actionCount(); i++) { + if (isHighlightAction(highlight.getHighlightAction(i))) { + return ((HyperlinkHighlightAction) highlight.getHighlightAction(i)).getHperlink(); + } + } + return null; + } + + private boolean isHighlightAction(HighlightAction highlightAction) { + return highlightAction instanceof HyperlinkHighlightAction; + } + + + /** + * 开放对外的方法,用于获取SearchCellJSAction的单例 + * + * @return SearchCellJSAction的单例 + */ + public static SearchCellJSAction getInstance() { + return SearchCellJSActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchCellJSActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchCellJSAction instance; + + SearchCellJSActionEnum() { + instance = new SearchCellJSAction(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchCellJSAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java new file mode 100644 index 0000000000..ad97655263 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java @@ -0,0 +1,189 @@ +package com.fr.design.actions.replace.action.content.js; + +import com.fr.chart.chartattr.Axis; +import com.fr.chart.chartattr.Chart; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.actions.replace.info.JSInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.utils.SearchJSUtils; +import com.fr.design.i18n.Toolkit; +import com.fr.js.JavaScriptImpl; +import com.fr.js.NameJavaScript; + +import com.fr.js.NameJavaScriptGroup; +import com.fr.plugin.chart.attr.axis.VanChartAxis; +import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.base.RefreshMoreLabel; +import com.fr.plugin.chart.base.VanChartHtmlLabel; +import com.fr.plugin.chart.custom.CustomPlotFactory; +import com.fr.plugin.chart.custom.VanChartCustomPlot; +import com.fr.plugin.chart.vanchart.VanChart; +import com.fr.stable.collections.combination.Pair; + +import java.util.ArrayList; +import java.util.List; + +/** + * 获取图表的JS + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-15 + */ +public class SearchChartJSAction { + + + private SearchChartJSAction() { + } + + /** + * 寻找图表中的JS + * + * @param chartCollection + * @param content + * @param jsInfos + */ + public void searchChartJS(ChartCollection chartCollection, ITContent content, List jsInfos) { + List> htmlLabels = SearchJSUtils.getHtmlLabel(chartCollection); + List nameJavaScripts = SearchJSUtils.getNameJavaScript(chartCollection); + //图表-样式-标签以及图表-特效-条件显示 + ITContent htmlITContent = ITContent.copy(content); + htmlITContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Chart")); + SearchJSUtils.addJSInfosFromHtmlLabel(htmlITContent, htmlLabels, jsInfos); + //图表-特效-交互属性-超级链接 + ITContent conditionContent = ITContent.copy(content); + conditionContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Chart"), + Toolkit.i18nText("Fine-Design_Chart_Animation_Special"), + Toolkit.i18nText("Fine-Design_Chart_Interactive") + ); + SearchJSUtils.addJSInfosFromNameJS(conditionContent, nameJavaScripts, jsInfos); + + //图表-特效-交互属性-监控刷新 + dealMonitorRefreshJS(conditionContent, chartCollection, jsInfos); + for (int i = 0; i < chartCollection.getChartCount(); i++) { + ITContent chartContent = ITContent.copy(content); + chartContent.addOtherPos(chartCollection.getChart(i).getChartName()); + //坐标轴 + searchAxisJS(jsInfos, chartContent, chartCollection.getChart(i)); + //组合图表-条件属性-超链特判 + dealCustomPlot(jsInfos, conditionContent, chartCollection.getChart(i)); + } + } + + private void dealCustomPlot(List jsInfos, ITContent conditionContent, Chart chart) { + if (chart.getPlot() instanceof VanChartCustomPlot) { + VanChartCustomPlot customPlot = chart.getPlot(); + for (VanChartPlot plot : customPlot.getCustomPlotList()) { + NameJavaScriptGroup javaScriptGroup = plot.getHotHyperLink(); + if (javaScriptGroup != null) { + for (int i = 0; i < javaScriptGroup.size(); i++) { + if (javaScriptGroup.getNameHyperlink(i).getJavaScript() instanceof JavaScriptImpl) { + ITContent content = ITContent.copy(conditionContent); + content.addOtherPos( + CustomPlotFactory.getTitle(CustomPlotFactory.getCustomType(plot)), + javaScriptGroup.getNameHyperlink(i).getName() + ); + content.setReplaceObject(javaScriptGroup.getNameHyperlink(i)); + jsInfos.add(new JSInfo(content)); + } + } + } + } + } + } + + + private void dealMonitorRefreshJS(ITContent conditionContent, ChartCollection chartCollection, List jsInfos) { + for (int i = 0; i < chartCollection.getChartCount(); i++) { + if (chartCollection.getChart(i) instanceof VanChart) { + VanChart chart = (VanChart) chartCollection.getChart(i); + if (isMonitorValid(chart.getRefreshMoreLabel())) { + VanChartHtmlLabel htmlLabel = chart.getRefreshMoreLabel().getAttrTooltip().getContent().getHtmlLabel(); + if (htmlLabel != null) { + ITContent content = ITContent.copy(conditionContent); + content.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Moniter_refresh")); + content.setReplaceObject(htmlLabel); + jsInfos.add(new JSInfo(content)); + } + } + } + } + } + + private boolean isMonitorValid(RefreshMoreLabel moreLabel) { + return moreLabel.isMoreLabel() && moreLabel.getAttrTooltip() != null && moreLabel.getAttrTooltip().isEnable(); + } + + private void searchAxisJS(List jsInfos, ITContent chartContent, Chart chart) { + if (chart.getPlot() != null) { + Axis xAxis = chart.getPlot().getxAxis(); + Axis yAxis = chart.getPlot().getyAxis(); + if (xAxis instanceof VanChartAxis) { + ITContent xAxisContent = ITContent.copy(chartContent); + xAxisContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Axis"), + Toolkit.i18nText("Fine-Design_Chart_X_Axis"), + Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format") + ); + dealAxisHtmlLabelJS(jsInfos, ((VanChartAxis) xAxis).getHtmlLabel(), xAxisContent); + } + + if (yAxis instanceof VanChartAxis) { + ITContent yAxisContent = ITContent.copy(chartContent); + yAxisContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Chart_Axis"), + Toolkit.i18nText("Fine-Design_Chart_Y_Axis"), + Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format") + ); + dealAxisHtmlLabelJS(jsInfos, ((VanChartAxis) yAxis).getHtmlLabel(), yAxisContent); + } + } + + } + + private void dealAxisHtmlLabelJS(List jsInfos, VanChartHtmlLabel label, ITContent content) { + if (isHtmlLabelValid(label)) { + ITContent axisContent = ITContent.copy(content); + axisContent.setReplaceObject(label); + jsInfos.add(new JSInfo(axisContent)); + } + } + + private boolean isHtmlLabelValid(VanChartHtmlLabel label) { + return label != null && label.getCustomText() != null; + } + + /** + * 对外开放的获取单例的方法 + * + * @return + */ + public static SearchChartJSAction getInstance() { + return SearchChartJSAction.SearchChartJSActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchChartJSActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchChartJSAction instance; + + SearchChartJSActionEnum() { + instance = new SearchChartJSAction(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchChartJSAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchComponentJSAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchComponentJSAction.java new file mode 100644 index 0000000000..881b0d1663 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchComponentJSAction.java @@ -0,0 +1,87 @@ +package com.fr.design.actions.replace.action.content.js; + +import com.fr.base.chart.BaseChartCollection; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.design.actions.replace.action.content.component.SearchComponentAction; +import com.fr.design.actions.replace.info.ComponentInfo; +import com.fr.design.actions.replace.info.JSInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.mainframe.JTemplate; +import com.fr.form.ui.ChartEditor; +import com.fr.form.ui.container.WTitleLayout; + +import java.util.ArrayList; +import java.util.List; + +/** + * 决策报表的图表组件中特殊存在的JS + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-20 + */ +public class SearchComponentJSAction implements SearchJS { + private SearchComponentJSAction() { + } + + @Override + public void searchJSFromObject(JTemplate jTemplate, List jsInfos) { + List componentJSInfos = new ArrayList<>(); + addJSInfos2ListFromComponent(jTemplate, componentJSInfos); + jsInfos.addAll(componentJSInfos); + } + + private void addJSInfos2ListFromComponent(JTemplate jTemplate, List componentJSInfos) { + SearchComponentAction searchComponentAction = SearchComponentAction.getInstance(); + searchComponentAction.search4Infos(jTemplate); + List componentInfoList = searchComponentAction.getComponentInfos(); + for (ComponentInfo componentInfo : componentInfoList) { + Object o = componentInfo.getContent().getReplaceObject(); + if (o instanceof WTitleLayout) { + if (((WTitleLayout) o).getBodyBoundsWidget().getWidget() instanceof ChartEditor) { + ChartEditor chartEditor = (ChartEditor) ((WTitleLayout) o).getBodyBoundsWidget().getWidget(); + SearchChartJSAction searchChartJSAction = SearchChartJSAction.getInstance(); + for (BaseChartCollection chartCollection : chartEditor.getChartCollections()) { + if (chartCollection instanceof ChartCollection) { + searchChartJSAction.searchChartJS((ChartCollection) chartCollection, ITContent.copy(componentInfo.getContent()), componentJSInfos); + } + + } + } + } + } + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchComponentJSAction getInstance() { + return SearchComponentJSActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchComponentJSActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchComponentJSAction instance; + + SearchComponentJSActionEnum() { + instance = new SearchComponentJSAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchComponentJSAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchFloatJSAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchFloatJSAction.java new file mode 100644 index 0000000000..4270d5bbca --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchFloatJSAction.java @@ -0,0 +1,88 @@ +package com.fr.design.actions.replace.action.content.js; + +import com.fr.chart.chartattr.ChartCollection; + +import com.fr.design.actions.replace.action.content.floatelement.SearchFloatAction; +import com.fr.design.actions.replace.info.FloatInfo; +import com.fr.design.actions.replace.info.JSInfo; +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.design.actions.replace.utils.SearchJSUtils; + +import com.fr.design.mainframe.JTemplate; + +import com.fr.report.cell.FloatElement; + + + +import java.util.*; + +/** + * 搜索悬浮元素JS + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-15 + */ +public class SearchFloatJSAction implements SearchJS { + + private SearchFloatJSAction() { + } + + + @Override + public void searchJSFromObject(JTemplate jTemplate, List jsInfos) { + List floatJSInfos = new ArrayList<>(); + addJSInfos2ListFromFloat(jTemplate, floatJSInfos); + jsInfos.addAll(floatJSInfos); + } + + + private void addJSInfos2ListFromFloat(JTemplate jTemplate, List jsInfos) { + SearchFloatAction searchFloatAction = SearchFloatAction.getInstance(); + searchFloatAction.search4Infos(jTemplate); + for (FloatInfo floatInfo : searchFloatAction.getFloatInfos()) { + FloatElement floatElement = (FloatElement) floatInfo.getContent().getReplaceObject(); + ITContent content = ITContent.copy(floatInfo.getContent()); + //从超级链接搜索 + SearchJSUtils.addJSInfosFromHyperLink(floatElement, jsInfos, content); + if (floatElement.getValue() instanceof ChartCollection) { + SearchChartJSAction.getInstance().searchChartJS((ChartCollection) floatElement.getValue(), ITContent.copy(floatInfo.getContent()), jsInfos); + } + } + } + + + /** + * 对外开放的获取对象的方法 + * + * @return + */ + public static SearchFloatJSAction getInstance() { + return SearchFloatJSActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchFloatJSActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchFloatJSAction instance; + + SearchFloatJSActionEnum() { + instance = new SearchFloatJSAction(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchFloatJSAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJS.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJS.java new file mode 100644 index 0000000000..d543a4c2ea --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJS.java @@ -0,0 +1,26 @@ +package com.fr.design.actions.replace.action.content.js; + +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.info.JSInfo; +import com.fr.design.mainframe.JTemplate; + +import java.util.List; + +/** + * 搜索JS + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-15 + */ +public interface SearchJS extends SearchAction { + + /** + * 获取各个地方的JS + * + * @param jTemplate + * @param jsInfos + */ + default void searchJSFromObject(JTemplate jTemplate, List jsInfos) { + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJSManager.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJSManager.java new file mode 100644 index 0000000000..9bd972a1f1 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchJSManager.java @@ -0,0 +1,121 @@ +package com.fr.design.actions.replace.action.content.js; + +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.action.SearchManager; +import com.fr.design.actions.replace.info.JSInfo; + +import com.fr.design.mainframe.JTemplate; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + + +/** + * 管理搜索JS的注册销毁的管理类 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-12 + */ +public class SearchJSManager implements SearchAction, SearchManager { + private List jsInfos; + private Set searchJSSet = new HashSet<>(); + + private SearchJSManager() { + //从控件 + register(SearchWidgetJSAction.getInstance()); + //从单元格获取JS + register(SearchCellJSAction.getInstance()); + //从模板Web属性 + register(SearchWebJSAction.getInstance()); + //从悬浮元素 + register(SearchFloatJSAction.getInstance()); + //从决策报表图表组件 + register(SearchComponentJSAction.getInstance()); + } + + @Override + public void search4Infos(JTemplate jTemplate) { + List jsInfos = new ArrayList<>(); + for (SearchJS searchJS : searchJSSet) { + searchJS.searchJSFromObject(jTemplate, jsInfos); + } + setJsInfos(jsInfos); + } + + public List getJsInfos() { + return jsInfos; + } + + public void setJsInfos(List jsInfos) { + this.jsInfos = jsInfos; + } + + @Override + public void registerAction(String tag, SearchAction searchAction) { + if (searchAction instanceof SearchJS){ + register((SearchJS) searchAction); + } + } + + @Override + public void removeAction(SearchAction searchAction) { + if (searchAction instanceof SearchJS){ + remove((SearchJS) searchAction); + } + } + + /** + * 注册对象 + * + * @param searchJS + */ + private void register(SearchJS searchJS) { + searchJSSet.add(searchJS); + } + + /** + * 销毁对象 + */ + private void remove(SearchJS searchJS) { + searchJSSet.remove(searchJS); + } + + /** + * 对外开放的获取对象的方法 + * + * @return + */ + public static SearchJSManager getInstance() { + return SearchJSActionEnum.SINGLETON.getInstance(); + } + + + + /** + * 枚举实现单例 + */ + private enum SearchJSActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchJSManager instance; + + SearchJSActionEnum() { + instance = new SearchJSManager(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchJSManager getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java new file mode 100644 index 0000000000..725d1280db --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java @@ -0,0 +1,229 @@ +package com.fr.design.actions.replace.action.content.js; + +import com.fr.design.actions.replace.info.JSInfo; + +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.design.actions.replace.info.base.SearchTag; +import com.fr.design.actions.replace.utils.SearchJSUtils; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.form.event.Listener; +import com.fr.form.ui.CustomToolBarButton; +import com.fr.form.ui.Widget; + +import com.fr.js.JavaScriptImpl; +import com.fr.main.impl.WorkBook; +import com.fr.report.web.ToolBarManager; +import com.fr.report.web.WebContent; +import com.fr.report.web.util.ReportEngineEventMapping; +import com.fr.web.attr.ReportWebAttr; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 搜索模板Web属性里的JS + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-15 + */ +public class SearchWebJSAction implements SearchJS { + + private final static Map MAP = new HashMap<>(); + private final static Map SERVER_MAP = new HashMap<>(); + private List arrayList = new ArrayList<>(); + + private SearchWebJSAction() { + } + + static { + MAP.put("WebPage", Toolkit.i18nText("Fine-Design_Report_Pagination_Setting")); + MAP.put("WebWrite", Toolkit.i18nText("Fine-Design_Report_Write_Setting")); + MAP.put("WebView", Toolkit.i18nText("Fine-Design_Report_Data_Analysis_Settings")); + SERVER_MAP.put("WebPage", Toolkit.i18nText("Fine-Design_Report_ReportServerP_Report_Server_Parameter") + "-" + Toolkit.i18nText("Fine-Design_Report_Pagination_Setting")); + SERVER_MAP.put("WebWrite", Toolkit.i18nText("Fine-Design_Report_ReportServerP_Report_Server_Parameter") + "-" + Toolkit.i18nText("Fine-Design_Report_Write_Setting")); + SERVER_MAP.put("WebView", Toolkit.i18nText("Fine-Design_Report_ReportServerP_Report_Server_Parameter") + "-" + Toolkit.i18nText("Fine-Design_Report_Data_Analysis_Settings")); + } + + + @Override + public void searchJSFromObject(JTemplate jTemplate, List jsInfos) { + arrayList.clear(); + List webJSInfos = new ArrayList<>(); + addJSInfos2ListFromWeb(jTemplate, webJSInfos); + jsInfos.addAll(webJSInfos); + } + + + private void addJSInfos2ListFromWeb(JTemplate jTemplate, List jsInfos) { + ////服务器相关二期再做 + //dealServerWebAttr(jTemplate, jsInfos); + dealTemplateWebAttr(jTemplate, jsInfos); + } + + private void dealServerWebAttr(JTemplate jTemplate, List jsInfos) { + ReportWebAttr webReportAttr = ReportWebAttr.getInstance(); + if (webReportAttr != null) { + webReportAttr.getWebWrite(); + ITContent content = new ITContent(); + content.setTemplateName(jTemplate.getTemplateName()); + content.setJumpAble(false); + addWebContent2Array(webReportAttr); + for (int i = 0; i < arrayList.size(); i++) { + addJSInfos2ListFromServerWebAttr(content, jsInfos, arrayList.get(i)); + } + } + } + + private void dealTemplateWebAttr(JTemplate jTemplate, List jsInfos) { + if (jTemplate.getTarget() instanceof WorkBook) { + WorkBook workBook = (WorkBook) jTemplate.getTarget(); + ReportWebAttr webAttr = workBook.getReportWebAttr(); + ITContent content = new ITContent(); + content.setTemplateName(jTemplate.getTemplateName()); + content.setJumpAble(false); + addWebContent2Array(webAttr); + //处理引用JS + dealImportJS(content,jsInfos,webAttr); + for (int i = 0; i < arrayList.size(); i++) { + addJSInfos2ListFromArray(content, jsInfos, arrayList.get(i)); + } + } + } + + private void dealImportJS(ITContent content, List jsInfos, ReportWebAttr webAttr) { + if (webAttr != null){ + for (String jsStr : webAttr.getJSImport()){ + ITContent jsContent = ITContent.copy(content); + jsContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Report_Web_Attributes"), + Toolkit.i18nText("Fine-Design_Report_Import_JavaScript") + ); + jsContent.setReplaceObject(jsStr); + jsContent.setHoldObject(webAttr); + jsContent.setTag(SearchTag.IMPORT_JS); + jsInfos.add(new JSInfo(jsContent)); + } + } + } + + private void addJSInfos2ListFromServerWebAttr(ITContent content, List jsInfos, WebContent webContent) { + ITContent newContent = ITContent.copy(content); + if (SERVER_MAP.containsKey(webContent.getClass().getSimpleName())) { + newContent.addOtherPos(SERVER_MAP.get(webContent.getClass().getSimpleName())); + } + addJSInfos2ListFromWebButton(newContent, jsInfos, webContent); + addJSInfos2ListFromWebListener(newContent, jsInfos, webContent); + } + + private void addJSInfos2ListFromArray(ITContent content, List jsInfos, WebContent webContent) { + ITContent newContent = ITContent.copy(content); + if (MAP.containsKey(webContent.getClass().getSimpleName())) { + newContent.addOtherPos(MAP.get(webContent.getClass().getSimpleName())); + } + addJSInfos2ListFromWebButton(newContent, jsInfos, webContent); + addJSInfos2ListFromWebListener(newContent, jsInfos, webContent); + } + + private void addJSInfos2ListFromWebListener(ITContent content, List jsInfos, WebContent webContent) { + for (int i = 0; i < webContent.getListenerSize(); i++) { + Listener listener = webContent.getListener(i); + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(listener); + newContent.addOtherPos(Toolkit.i18nText(ReportEngineEventMapping.getLocaleName(listener.getEventName()))); + SearchJSUtils.searchJSFromListener(jsInfos, newContent); + } + } + + private void addJSInfos2ListFromWebButton(ITContent content, List jsInfos, WebContent webContent) { + if (hasToolBarManagers(webContent.getToolBarManagers())) { + for (ToolBarManager toolBarManager : webContent.getToolBarManagers()) { + dealWithCustonToolBarButtonImpl(content, jsInfos, toolBarManager); + } + } + } + + private void addWebContent2Array(ReportWebAttr webAttr) { + arrayList.clear(); + if (webAttr != null) { + addContent(arrayList, webAttr.getWebWrite()); + addContent(arrayList, webAttr.getWebPage()); + addContent(arrayList, webAttr.getWebView()); + } + + } + + private void addContent(List arrayList, WebContent webContent) { + if (webContent != null) { + arrayList.add(webContent); + } + } + + private void dealWithCustonToolBarButtonImpl(ITContent content, List jsInfos, ToolBarManager toolBarManager) { + for (int i = 0; i < toolBarManager.getToolBar().getWidgetSize(); i++) { + if (isWidgetIntanceofCustomToolBarButton(toolBarManager.getToolBar().getWidget(i))) { + ITContent newContent = ITContent.copy(content); + addJSInfos2ListFromButtonImpl(newContent, jsInfos, toolBarManager.getToolBar().getWidget(i)); + } + } + + } + + private void addJSInfos2ListFromButtonImpl(ITContent content, List jsInfos, Widget widget) { + + if (((CustomToolBarButton) widget).getJSImpl() != null + && ((CustomToolBarButton) widget).getJSImpl() instanceof JavaScriptImpl) { + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Custom_Form_Button")); + newContent.setReplaceObject(((CustomToolBarButton) widget).getJSImpl()); + SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent)); + } + + } + + private boolean hasToolBarManagers(ToolBarManager[] toolBarManagers) { + return toolBarManagers.length > 0; + } + + private boolean isWidgetIntanceofCustomToolBarButton(Widget widget) { + return widget instanceof CustomToolBarButton; + } + + /** + * 对外开放的获取单例的方法 + * + * @return + */ + public static SearchWebJSAction getInstance() { + return SearchWebJSActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchWebJSActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchWebJSAction instance; + + SearchWebJSActionEnum() { + instance = new SearchWebJSAction(); + } + + /** + * 获取单例对象 + * + * @return + */ + public SearchWebJSAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWidgetJSAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWidgetJSAction.java new file mode 100644 index 0000000000..967cf178c9 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWidgetJSAction.java @@ -0,0 +1,92 @@ +package com.fr.design.actions.replace.action.content.js; + +import com.fr.design.actions.replace.action.content.component.SearchComponentAction; +import com.fr.design.actions.replace.action.content.widget.SearchWidgetAction; +import com.fr.design.actions.replace.info.ComponentInfo; +import com.fr.design.actions.replace.info.JSInfo; + +import com.fr.design.actions.replace.info.WidgetInfo; +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.design.actions.replace.utils.SearchJSUtils; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.main.impl.WorkBook; + +import java.util.ArrayList; +import java.util.List; + +/** + * 搜索控件的JS + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-13 + */ +public class SearchWidgetJSAction implements SearchJS { + + private SearchWidgetJSAction() { + } + + @Override + public void searchJSFromObject(JTemplate jTemplate, List jsInfos) { + List widgetJSInfos = new ArrayList<>(); + addJSInfos2ListFromWidget(jTemplate, widgetJSInfos); + jsInfos.addAll(widgetJSInfos); + } + + private void addJSInfos2ListFromWidget(JTemplate jTemplate, List jsInfos) { + if (jTemplate.getTarget() instanceof WorkBook) { + SearchWidgetAction searchWidgetAction = SearchWidgetAction.getInstance(); + searchWidgetAction.search4Infos(jTemplate); + for (WidgetInfo widgetInfo : searchWidgetAction.getWidgetInfos()) { + ITContent content = ITContent.copy(widgetInfo.getContent()); + content.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Event")); + SearchJSUtils.selectJSAction(jsInfos, content); + } + } else { + SearchComponentAction searchComponentAction = SearchComponentAction.getInstance(); + searchComponentAction.search4Infos(jTemplate); + for (ComponentInfo componentInfo : searchComponentAction.getComponentInfos()) { + ITContent content = ITContent.copy(componentInfo.getContent()); + content.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Event")); + SearchJSUtils.selectJSAction(jsInfos, content); + } + } + + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchWidgetJSAction getInstance() { + return SearchWidgetJSActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchWidgetJSActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchWidgetJSAction instance; + + SearchWidgetJSActionEnum() { + instance = new SearchWidgetJSAction(); + } + + /** + * 获取单例的方法 + * + * @return + */ + public SearchWidgetJSAction getInstance() { + return instance; + } + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/sql/SearchSQLAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/sql/SearchSQLAction.java new file mode 100644 index 0000000000..f36e3afbeb --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/sql/SearchSQLAction.java @@ -0,0 +1,143 @@ +package com.fr.design.actions.replace.action.content.sql; + +import com.fr.data.TableDataSource; +import com.fr.data.impl.DBTableData; +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.info.SQLInfo; + +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.data.tabledata.wrapper.TableDataFactory; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.file.TableDataConfig; +import com.fr.stable.AssistUtils; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * 搜索SQL + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-16 + */ +public class SearchSQLAction implements SearchAction { + private List sqlInfos; + + private SearchSQLAction() { + } + + @Override + public void search4Infos(JTemplate jTemplate) { + List sqlInfos = new ArrayList<>(); + ITContent content = new ITContent(); + content.setTemplateName(jTemplate.getTemplateName()); + content.setJumpAble(false); + addModelDataInfos2Array(jTemplate, content, sqlInfos); + ////服务器的数据二期再查询 + //addServerDataInfos2Array(content, sqlInfos); + setSqlInfos(sqlInfos); + } + + + /** + * 服务器数据集 + * + * @param content + * @param sqlInfos + */ + private void addServerDataInfos2Array(ITContent content, List sqlInfos) { + TableDataConfig tableDataConfig = TableDataConfig.getInstance(); + String[] nameArray = TableDataFactory.getSortOfChineseNameOfServerData(tableDataConfig); + for (String dataName : nameArray) { + if (tableDataConfig.getTableData(dataName) instanceof DBTableData) { + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_DS_Server_TableData"), + dataName + ); + newContent.setShowObject(Toolkit.i18nText("Fine-Design_Basic_DS_Server_TableData")); + newContent.setReplaceObject(tableDataConfig.getTableData(dataName)); + sqlInfos.add(new SQLInfo(newContent)); + } + + } + } + + /** + * 模板数据集 + * + * @param jTemplate + * @param content + * @param sqlInfos + */ + private void addModelDataInfos2Array(JTemplate jTemplate, ITContent content, List sqlInfos) { + if (jTemplate.getTarget() instanceof TableDataSource) { + TableDataSource source = (TableDataSource) jTemplate.getTarget(); + Iterator dataIterator = source.getTableDataNameIterator(); + while (dataIterator.hasNext()) { + String dataName = (String) dataIterator.next(); + if (source.getTableData(dataName) instanceof DBTableData) { + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_DS_Report_TableData"), + dataName + ); + newContent.setShowObject(Toolkit.i18nText("Fine-Design_Basic_DS_Report_TableData")); + newContent.setReplaceObject(source.getTableData(dataName)); + sqlInfos.add(new SQLInfo(newContent)); + } + } + } + + } + + public List getSqlInfos() { + return sqlInfos; + } + + public void setSqlInfos(List sqlInfos) { + this.sqlInfos = sqlInfos; + } + + @Override + public String toString() { + return AssistUtils.toString(this); + } + + + /** + * 对外开放的获取单例对象方法 + * + * @return + */ + public static SearchSQLAction getInstance() { + return SearchSQLAction.SearchSQLActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchSQLActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchSQLAction instance; + + SearchSQLActionEnum() { + instance = new SearchSQLAction(); + } + + /** + * 获取对象 + * + * @return + */ + public SearchSQLAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java new file mode 100644 index 0000000000..98d2282f5d --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java @@ -0,0 +1,190 @@ +package com.fr.design.actions.replace.action.content.widget; + +import com.fr.design.actions.replace.action.content.component.ComponentType; +import com.fr.design.actions.replace.info.DealWithInfoValue; +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.WidgetInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.form.ui.WaterMark; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WScaleLayout; +import com.fr.form.ui.widget.CRBoundsWidget; +import com.fr.stable.collections.combination.Pair; +import org.jetbrains.annotations.Nullable; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 决策报表控件种类 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-29 + */ +public enum FrmWidgetType implements SearchFrmWidget, DealWithInfoValue { + /** + * 自适应布局 + */ + W_SCALE_LAYOUT("WScaleLayout") { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + WScaleLayout widget = (WScaleLayout) info.getContent().getReplaceObject(); + if (((WidgetInfo) info).isWaterMark()) { + FrmWidgetType frmWidgetType = FrmWidgetType.match(((CRBoundsWidget) widget.getWidget(0)).getWidget().getClass().getSimpleName()); + if (frmWidgetType != null) { + frmWidgetType.setValue(info, findStr, replaceStr, operatorArray); + } + } else { + ComponentType componentType = ComponentType.match(widget.getClass().getSimpleName()); + if (componentType != null) { + componentType.setValue(info, findStr, replaceStr, operatorArray); + } + } + + } + }, + /** + * 文本控件 + */ + TEXT_EDITOR("TextEditor"), + /** + * 标签控件 + */ + LABEL("Label"), + /** + * 按钮控件 + */ + FREE_BUTTON("FreeButton"), + /** + * 下拉框控件 + */ + COMBO_BOX("ComboBox"), + /** + * 下拉复选框控件 + */ + COMBO_CHECK_BOX("ComboCheckBox"), + /** + * 日期控件 + */ + DATE_EDITOR("DateEditor"), + /** + * 数字控件 + */ + NUMBER_EDITOR("NumberEditor"), + /** + * 下拉树控件 + */ + TREE_COMBO_BOX_EDITOR("TreeComboBoxEditor"), + /** + * 单选按钮组控件 + */ + RADIO_GROUP("RadioGroup"), + /** + * 复选按钮组控件 + */ + CHECK_BOX_GROUP("CheckBoxGroup"), + /** + * 查询按钮 + */ + FORM_SUBMIT_BUTTON("FormSubmitButton"), + /** + * 文本域控件 + */ + TEXT_AREA("TextArea"), + /** + * 密码控件 + */ + PASS_WORD("Password"), + /** + * 复选按钮控件 + */ + CHECK_BOX("CheckBox"), + /** + * 视图树 + */ + TREE_EDITOR("TreeEditor"), + /** + * 文件控件 + */ + MULTI_FILE_EDITOR("MultiFileEditor"); + + + String name; + + FrmWidgetType(String name) { + this.name = name; + } + + + /** + * 处理绝对布局或者已经是真正存储对象的控件 + * + * @param content + * @param widget + * @return + */ + public List dealAbsoluteWidget(ITContent content, Widget widget) { + ArrayList widgetInfos = new ArrayList<>(); + ITContent newContent = ITContent.copy(content); + widgetInfos.add(new WidgetInfo(newContent)); + return widgetInfos; + } + + + /** + * 匹配 + * + * @param name + * @return + */ + @Nullable + public static FrmWidgetType match(String name) { + FrmWidgetType[] values = FrmWidgetType.values(); + for (FrmWidgetType value : values) { + if (value.name.equals(name)) { + return value; + } + } + return null; + } + + + @Override + public Map getValue(Object... o) { + return new HashMap<>(); + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Widget widget = (Widget) info.getContent().getReplaceObject(); + if (widget instanceof WScaleLayout) { + widget = ((CRBoundsWidget) ((WScaleLayout) widget).getWidget(0)).getWidget(); + } + if (((WidgetInfo) info).isWaterMark()) { + WaterMark waterMark = (WaterMark) widget; + info.updateOldStr(waterMark.getWaterMark(), findStr); + waterMark.setWaterMark(ShowValueUtils.replaceAll(waterMark.getWaterMark(), findStr, replaceStr)); + } else { + info.updateOldStr(widget.getWidgetName(), findStr); + ComponentType componentType = ComponentType.match(widget.getClass().getSimpleName()); + if (componentType != null) { + componentType.setValue(info, findStr, replaceStr, operatorArray); + } + } + } + + @Override + public String getInfoShowStr(Info info) { + return info.getContent().getOldShowStr(); + } + + @Override + public List addFrmWidget2Array(ITContent content, Widget widget) { + return dealAbsoluteWidget(content, widget); + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/SearchFrmWidget.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/SearchFrmWidget.java new file mode 100644 index 0000000000..936d8ce6c8 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/SearchFrmWidget.java @@ -0,0 +1,26 @@ +package com.fr.design.actions.replace.action.content.widget; + +import com.fr.design.actions.replace.info.WidgetInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.form.ui.Widget; + +import java.util.List; + +/** + * 获取决策报表控件相关 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-29 + */ +public interface SearchFrmWidget { + + /** + * 将决策报表的控件加入数组中 + * + * @param content ITContent信息 + * @param widget 对应的控件 + * @return + */ + List addFrmWidget2Array(ITContent content, Widget widget); +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/SearchWidgetAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/SearchWidgetAction.java new file mode 100644 index 0000000000..32a21bee54 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/SearchWidgetAction.java @@ -0,0 +1,206 @@ +package com.fr.design.actions.replace.action.content.widget; + +import com.fr.base.parameter.ParameterUI; +import com.fr.design.actions.replace.action.SearchAction; +import com.fr.design.actions.replace.action.content.cell.SearchCellAction; +import com.fr.design.actions.replace.action.content.component.SearchComponentAction; +import com.fr.design.actions.replace.info.CellInfo; +import com.fr.design.actions.replace.info.ComponentInfo; +import com.fr.design.actions.replace.info.WidgetInfo; +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.JTemplate; +import com.fr.form.main.Form; +import com.fr.form.ui.Widget; +import com.fr.main.impl.WorkBook; +import com.fr.main.parameter.ReportParameterAttr; +import com.fr.report.cell.TemplateCellElement; +import com.fr.report.cell.cellattr.highlight.DefaultHighlight; +import com.fr.report.cell.cellattr.highlight.HighlightAction; +import com.fr.report.cell.cellattr.highlight.HighlightGroup; +import com.fr.report.cell.cellattr.highlight.WidgetHighlightAction; +import com.fr.stable.StringUtils; + +import java.util.ArrayList; +import java.util.List; + +/** + * 获取控件 + * 目前获取位置:单元格本身、单元格条件属性内超链控件、参数面板控件、决策报表的组件 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-16 + */ +public class SearchWidgetAction implements SearchAction { + List widgetInfos; + + private SearchWidgetAction() { + } + + @Override + public void search4Infos(JTemplate jTemplate) { + ArrayList widgetInfos = new ArrayList<>(); + ITContent content = new ITContent(); + content.setTemplateName(jTemplate.getTemplateName()); + content.setTemplatePath(jTemplate.getPath()); + //这边拿SearchCellAction里的CellInfo来查找,由于在SearchCellAction里面已经考虑了决策报表和普通报表两种情况了,这边就不用再做区分 + addCellWidget2Array(widgetInfos, jTemplate); + content.addTRL(jTemplate.getTemplateName()); + if (jTemplate.getTarget() instanceof WorkBook) { + addWorkBookParaWidget2Array(content, widgetInfos, jTemplate); + } else if (jTemplate.getTarget() instanceof Form) { + addFrmWidget2Array(content, widgetInfos, jTemplate); + } + setWidgetInfos(widgetInfos); + } + + private void addFrmWidget2Array(ITContent content, ArrayList widgetInfos, JTemplate jTemplate) { + SearchComponentAction searchComponentAction = SearchComponentAction.getInstance(); + searchComponentAction.search4Infos(jTemplate); + for (ComponentInfo componentInfo : searchComponentAction.getComponentInfos()) { + FrmWidgetType frmWidgetType = FrmWidgetType.match(componentInfo.getContent().getReplaceObject().getClass().getSimpleName()); + if (frmWidgetType != null) { + widgetInfos.addAll(frmWidgetType.addFrmWidget2Array(componentInfo.getContent(), (Widget) componentInfo.getContent().getReplaceObject())); + } + } + + } + + private void addCellWidget2Array(ArrayList widgetInfos, JTemplate jTemplate) { + SearchCellAction searchCellAction = SearchCellAction.getInstance(); + searchCellAction.search4Infos(jTemplate); + if (searchCellAction.getCellInfos().size() > 0) { + for (CellInfo cellInfo : searchCellAction.getCellInfos()) { + //单元格本身的控件 + addWidget2ArrayFromCell(widgetInfos, cellInfo); + //单元格条件属性中超链内的控件 + addWidget2ArrayFromCellHighlight(widgetInfos, cellInfo); + } + } + + } + + private void addWidget2ArrayFromCellHighlight(ArrayList widgetInfos, CellInfo cellInfo) { + if (cellInfo.getContent().getReplaceObject() instanceof TemplateCellElement) { + TemplateCellElement cell = (TemplateCellElement) cellInfo.getContent().getReplaceObject(); + if (cell.getHighlightGroup() != null) { + HighlightGroup highlightGroup = cell.getHighlightGroup(); + dealWithHighlightGroup4Widget(highlightGroup, widgetInfos, cellInfo); + } + } + } + + private void dealWithHighlightGroup4Widget(HighlightGroup highlightGroup, ArrayList widgetInfos, CellInfo cellInfo) { + for (int i = 0; i < highlightGroup.size(); i++) { + for (int j = 0; j < ((DefaultHighlight) highlightGroup.getHighlight(i)).actionCount(); j++) { + HighlightAction highlightAction = ((DefaultHighlight) highlightGroup.getHighlight(i)).getHighlightAction(j); + //处理HighlightAction + if (isHighlightWidgetExist(highlightAction)) { + ITContent content = ITContent.copy(cellInfo.getContent()); + content.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Condition_Attributes"), + Toolkit.i18nText("Fine-Design_Report_Hyperlink"), + Toolkit.i18nText("Fine-Design_Basic_Widget")); + content.setReplaceObject(((WidgetHighlightAction) highlightAction).getWidget()); + content.setShowObject(cellInfo.getContent().getReplaceObject()); + widgetInfos.add(new WidgetInfo(content)); + } + } + } + } + + private boolean isHighlightWidgetExist(HighlightAction highlightAction) { + return highlightAction instanceof WidgetHighlightAction && ((WidgetHighlightAction) highlightAction).getWidget() != null; + } + + private void addWidget2ArrayFromCell(ArrayList widgetInfos, CellInfo cellInfo) { + if (cellInfo.getContent().getReplaceObject() instanceof TemplateCellElement + && ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getWidget() != null) { + // 单元格内有控件 + ITContent newContent = ITContent.copy(cellInfo.getContent()); + + Widget widget = ((TemplateCellElement) cellInfo.getContent().getReplaceObject()).getWidget(); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Widget")); + if (StringUtils.isNotEmpty(widget.getWidgetName())) { + newContent.addOtherPos(widget.getWidgetName()); + } + newContent.setReplaceObject(widget); + newContent.setShowObject(cellInfo.getContent().getReplaceObject()); + widgetInfos.add(new WidgetInfo(newContent)); + + } + } + + private void addWorkBookParaWidget2Array(ITContent content, ArrayList widgetInfos, JTemplate jTemplate) { + WorkBook workBook = (WorkBook) jTemplate.getTarget(); + ReportParameterAttr reportParameterAttr = workBook.getReportParameterAttr(); + if (reportParameterAttr != null && reportParameterAttr.getParameterUI() != null) { + ParameterUI parameterUI = reportParameterAttr.getParameterUI(); + Widget[] widgets = parameterUI.getAllWidgets(); + for (Widget widget : widgets) { + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Parameter_Panel"), + Toolkit.i18nText("Fine-Design_Basic_Widget"), + widget.getWidgetName()); + newContent.setReplaceObject(widget); + newContent.setJumpAble(false); + newContent.setShowObject(Toolkit.i18nText("Fine-Design_Parameter_Panel")); + widgetInfos.add(new WidgetInfo(newContent)); + } + } + + } + + /** + * 是否为空 + * + * @return 为空返回true + */ + public boolean isWidgetInfosEmpty() { + return widgetInfos.isEmpty(); + } + + public List getWidgetInfos() { + return widgetInfos; + } + + public void setWidgetInfos(List widgetInfos) { + this.widgetInfos = widgetInfos; + } + + /** + * 对外开放获取对象的方法 + * + * @return + */ + public static SearchWidgetAction getInstance() { + return SearchWidgetAction.SearchWidgetActionEnum.SINGLETON.getInstance(); + } + + /** + * 枚举实现单例 + */ + private enum SearchWidgetActionEnum { + /** + * 单例 + */ + SINGLETON; + private SearchWidgetAction instance; + + SearchWidgetActionEnum() { + instance = new SearchWidgetAction(); + } + + /** + * 获取对象 + * + * @return + */ + public SearchWidgetAction getInstance() { + return instance; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java new file mode 100644 index 0000000000..e5a6ce4fa2 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java @@ -0,0 +1,338 @@ +package com.fr.design.actions.replace.info; + +import com.fr.base.Formula; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Title; +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.general.GeneralUtils; +import com.fr.main.impl.LinkWorkBookTemplate; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.cellattr.core.RichChar; +import com.fr.report.cell.cellattr.core.RichText; +import com.fr.report.cell.cellattr.core.SubReport; +import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.report.cell.painter.BiasTextPainter; +import com.fr.stable.AssistUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.combination.Pair; +import org.jetbrains.annotations.Nullable; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * 存储单元格信息的Info + * 返回:查找内容(匹配词高亮)、模板名称、所在sheet、分布组件、单元格位置、操作 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-11 + */ +public class CellInfo implements Info { + private ITContent content; + private int cellChartIndex = -1; + private boolean chartExist = false; + + public CellInfo(ITContent content) { + this.content = content; + } + + @Override + public ITContent getContent() { + return content; + } + + public void setContent(ITContent content) { + this.content = content; + } + + /** + * toString + * + * @return + */ + @Override + public String toString() { + return AssistUtils.toString(this); + } + + + /** + * 获取单元格的值(不对图表进行处理,如果是图表类型在展示阶段特殊处理) + * + * @param o 用于替换的replaceObject + * @return + */ + @Override + public Map getValue(Object... o) { + HashMap stringHashMap = new HashMap<>(); + CellElement cellElement = (((CellElement) (this.getContent().getReplaceObject()))); + if (cellElement.getValue() != null && !this.isChartExist()) { + CellValueType cellValueType = CellValueType.match(cellElement.getValue().getClass().getSimpleName()); + if (cellValueType != null) { + cellValueType.addValue2Map(cellElement.getValue(), stringHashMap); + } else { + stringHashMap.put("content", GeneralUtils.objectToString(cellElement.getValue())); + } + } + return stringHashMap; + } + + /** + * 对不同类型的值进行设置与替换 + * + * @param info 用于获取值和设置值 + * @param findStr 要被替换的字符串 + * @param replaceStr 用于替换的字符串 + * @param operatorArray 存储内容类替换所要操作的所有位置(Pair<起始位置,结束位置>) + */ + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + CellElement cellElement = (((CellElement) (this.getContent().getReplaceObject()))); + if (this.isChartExist() && this.getCellChartIndex() != -1) { + ChartCollection chartCollection = (ChartCollection) ((CellElement) this.getContent().getReplaceObject()).getValue(); + Title title = chartCollection.getChart(this.getCellChartIndex()).getTitle(); + if (title.getTextObject() instanceof Formula) { + Formula formula = (Formula) title.getTextObject(); + updateOldStr(formula.getContent(), findStr); + formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr)); + } else { + updateOldStr(GeneralUtils.objectToString(title.getTextObject()), findStr); + title.setTextObject(ShowValueUtils.replaceAll(GeneralUtils.objectToString(title.getTextObject()), findStr, replaceStr)); + } + } else { + CellValueType cellValueType = CellValueType.match(cellElement.getValue().getClass().getSimpleName()); + if (cellValueType != null) { + cellValueType.setValue(this, cellElement.getValue(), findStr, replaceStr); + } else { + updateOldStr(GeneralUtils.objectToString(cellElement.getValue()), findStr); + cellElement.setValue(ShowValueUtils.replaceAll(GeneralUtils.objectToString(cellElement.getValue()), findStr, replaceStr)); + } + + } + } + + public int getCellChartIndex() { + return cellChartIndex; + } + + public void setCellChartIndex(int cellChartIndex) { + this.cellChartIndex = cellChartIndex; + } + + /** + * 是否是图表 + * + * @return + */ + public boolean isChartExist() { + return chartExist; + } + + public void setChartExist(boolean chartExist) { + this.chartExist = chartExist; + } + + /** + * 复制一份CellInfo,防止引用传递问题 + * + * @return + */ + public CellInfo copy() { + ITContent content = ITContent.copy(this.getContent()); + CellInfo cellInfo = new CellInfo(content); + cellInfo.setCellChartIndex(this.getCellChartIndex()); + cellInfo.setChartExist(this.isChartExist()); + return cellInfo; + } + + /** + * 获取展示的字符串 + * + * @param info 信息 + * @return + */ + @Override + public String getInfoShowStr(Info info) { + return this.getContent().getOldShowStr(); + } + + /** + * 校验值有没有被修改 + * + * @return + */ + @Override + public Boolean checkValid() { + CellElement cellElement = (((CellElement) (this.getContent().getReplaceObject()))); + String newValue; + if (this.isChartExist() && this.getCellChartIndex() != -1) { + newValue = getChartCheckValue(); + } else { + CellValueType cellValueType = CellValueType.match(cellElement.getValue().getClass().getSimpleName()); + if (cellValueType != null) { + newValue = cellValueType.getCheckValue(this); + } else { + newValue = GeneralUtils.objectToString(cellElement.getValue()); + } + } + return StringUtils.equals(newValue, this.getContent().getOldShowStr()); + } + + private String getChartCheckValue() { + ChartCollection chartCollection = (ChartCollection) ((CellElement) this.getContent().getReplaceObject()).getValue(); + Title title = chartCollection.getChart(this.getCellChartIndex()).getTitle(); + if (title.getTextObject() instanceof Formula) { + Formula formula = (Formula) title.getTextObject(); + return formula.getContent(); + } else { + return GeneralUtils.objectToString(title.getTextObject()); + } + } + + /** + * 单元格的值的类型 + */ + public enum CellValueType { + /** + * 数据列类型(目前只对数据集的名称进行修改,对于其中的列名暂不支持修改) + */ + DS_COLUMN("DSColumn") { + @Override + public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) { + cellInfo.updateOldStr(GeneralUtils.objectToString(((DSColumn) o).getDSName()), findStr); + ((DSColumn) o).setDSName(ShowValueUtils.replaceAll(((DSColumn) o).getDSName(), findStr, replaceStr)); + } + + @Override + public void addValue2Map(Object o, HashMap map) { + map.put("content", ((DSColumn) o).getDSName()); + } + + @Override + public String getCheckValue(Info info) { + CellElement o = (CellElement) info.getContent().getReplaceObject(); + return ((DSColumn) o.getValue()).getDSName(); + } + }, + /** + * 公式类型 + */ + FORMULA("Formula") { + @Override + public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) { + cellInfo.updateOldStr(GeneralUtils.objectToString(o), findStr); + ((Formula) o).setContent(ShowValueUtils.replaceAll(((Formula) o).getContent(), findStr, replaceStr)); + } + + @Override + public String getCheckValue(Info info) { + CellElement o = (CellElement) info.getContent().getReplaceObject(); + return ((Formula) o.getValue()).getContent(); + } + }, + + /** + * 子报表类型(目前支持修改路径) + */ + SUB_REPORT("SubReport") { + @Override + public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) { + LinkWorkBookTemplate workBookTemplate = (LinkWorkBookTemplate) ((SubReport) o).getPackee(); + cellInfo.updateOldStr(workBookTemplate.getTemplatePath(), findStr); + workBookTemplate.setTemplatePath(ShowValueUtils.replaceAll(workBookTemplate.getTemplatePath(), findStr, replaceStr)); + } + + @Override + public void addValue2Map(Object o, HashMap map) { + LinkWorkBookTemplate workBookTemplate = (LinkWorkBookTemplate) ((SubReport) o).getPackee(); + map.put("content", GeneralUtils.objectToString(workBookTemplate.getTemplatePath())); + } + + @Override + public String getCheckValue(Info info) { + CellElement o = (CellElement) info.getContent().getReplaceObject(); + LinkWorkBookTemplate workBookTemplate = (LinkWorkBookTemplate) ((SubReport) o.getValue()).getPackee(); + return GeneralUtils.objectToString(workBookTemplate.getTemplatePath()); + } + }, + + /** + * 斜线类型 + */ + BIAS_TEXT_PAINTER("BiasTextPainter") { + @Override + public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) { + cellInfo.updateOldStr(((BiasTextPainter) o).getText(), findStr); + ((BiasTextPainter) o).setText(ShowValueUtils.replaceAll(((BiasTextPainter) o).getText(), findStr, replaceStr)); + } + + @Override + public void addValue2Map(Object o, HashMap map) { + map.put("content", ((BiasTextPainter) o).getText()); + } + + @Override + public String getCheckValue(Info info) { + CellElement o = (CellElement) info.getContent().getReplaceObject(); + return ((BiasTextPainter) o.getValue()).getText(); + } + }; + + + String name; + + CellValueType(String name) { + this.name = name; + } + + + /** + * 匹配 + * + * @param name + * @return + */ + @Nullable + public static CellValueType match(String name) { + CellValueType[] values = CellValueType.values(); + for (CellValueType value : values) { + if (value.name.equals(name)) { + return value; + } + } + return null; + } + + /** + * 设置值 + * + * @param cellInfo + * @param o + * @param findStr + * @param replaceStr + */ + public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) { + } + + /** + * 将值加到Map中 + * + * @param o + * @param map + */ + public void addValue2Map(Object o, HashMap map) { + map.put("content", GeneralUtils.objectToString(o)); + } + + public String getCheckValue(Info info) { + return StringUtils.EMPTY; + } + } + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java new file mode 100644 index 0000000000..b302376fb6 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java @@ -0,0 +1,82 @@ +package com.fr.design.actions.replace.info; + +import com.fr.design.actions.replace.action.content.component.ComponentType; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.form.ui.Widget; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.combination.Pair; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 存储组件的Info + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-29 + */ +public class ComponentInfo implements Info { + private ITContent content; + + public ComponentInfo(ITContent content) { + this.content = content; + } + + public void setContent(ITContent content) { + this.content = content; + } + + @Override + public Map getValue(Object... o) { + HashMap hashMap = new HashMap<>(); + if (this.content.getReplaceObject() != null && this.content.getReplaceObject() instanceof Widget) { + hashMap.put("content", ((Widget) this.content.getReplaceObject()).getWidgetName()); + } + return hashMap; + } + + @Override + public ITContent getContent() { + return content; + } + + + @Override + public Boolean checkValid() { + ComponentType componentType = ComponentType.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (componentType != null) { + return componentType.check(this); + } + return false; + } + + /** + * 这边设置值其实就是修改组件的名称,要注意的就是如果是layout的情况下有些需要对其外面封装的对象也进行名称的修改 + * + * @param info 用于获取值和设置值 + * @param findStr 要被替换的字符串 + * @param replaceStr 用于替换的字符串 + * @param operatorArray 存储内容类替换所要操作的所有位置(Pair<起始位置,结束位置>) + */ + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + ComponentType componentType = ComponentType.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (componentType != null) { + componentType.setValue(info, findStr, replaceStr, operatorArray); + } + } + + /** + * 获取展示的信息 + * + * @param info 信息 + * @return + */ + @Override + public String getInfoShowStr(Info info) { + return this.getContent().getOldShowStr(); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/DealWithInfoValue.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/DealWithInfoValue.java new file mode 100644 index 0000000000..2330fa5fdf --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/DealWithInfoValue.java @@ -0,0 +1,53 @@ +package com.fr.design.actions.replace.info; + + +import com.fr.stable.StringUtils; +import com.fr.stable.collections.combination.Pair; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 处理信息 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-23 + */ +public interface DealWithInfoValue { + + /** + * 获取存储的值 + * + * @param o 用于替换的replaceObject + * @return 返回便于处理的Map(不同类型可能会存在多个需要存储的数据,eg:控件名 & 水印) + */ + default Map getValue(Object... o) { + return new HashMap<>(); + } + + + /** + * 替换时调用的方法,设置值 + * + * @param info 用于获取值和设置值 + * @param findStr 要被替换的字符串 + * @param replaceStr 用于替换的字符串 + * @param operatorArray 存储内容类替换所要操作的所有位置(Pair<起始位置,结束位置>) + */ + default void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + } + + + /** + * 获取用于展示给用户的值 + * + * @param info 信息 + * @return 返回用于展示的字符串 + */ + default String getInfoShowStr(Info info) { + return StringUtils.EMPTY; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java new file mode 100644 index 0000000000..2bf794ab80 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java @@ -0,0 +1,153 @@ +package com.fr.design.actions.replace.info; + +import com.fr.base.Formula; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartattr.Title; +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.general.GeneralUtils; +import com.fr.report.cell.CellElement; +import com.fr.report.cell.FloatElement; +import com.fr.stable.AssistUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.combination.Pair; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 存储悬浮元素的Info + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-15 + */ +public class FloatInfo implements Info { + private ITContent content; + private int floatChartIndex = -1; + private boolean chartExist = false; + + public FloatInfo(ITContent content) { + this.content = content; + } + + @Override + public ITContent getContent() { + return content; + } + + public void setContent(ITContent content) { + this.content = content; + } + + /** + * toString + * + * @return + */ + @Override + public String toString() { + return AssistUtils.toString(this); + } + + public int getFloatChartIndex() { + return floatChartIndex; + } + + public void setFloatChartIndex(int charIndex) { + this.floatChartIndex = charIndex; + } + + /** + * 是否是图表 + * + * @return + */ + public boolean isChartExist() { + return chartExist; + } + + public void setChartExist(boolean chartExist) { + this.chartExist = chartExist; + } + + @Override + public Map getValue(Object... o) { + HashMap hashMap = new HashMap<>(); + FloatElement floatElement = (((FloatElement) (this.getContent().getReplaceObject()))); + if (!this.isChartExist()) { + hashMap.put("content", GeneralUtils.objectToString(floatElement.getValue())); + } + return hashMap; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (this.isChartExist() && this.getFloatChartIndex() != -1) { + ChartCollection chartCollection = (ChartCollection) ((FloatElement) this.getContent().getReplaceObject()).getValue(); + Title title = chartCollection.getChart(this.getFloatChartIndex()).getTitle(); + if (title.getTextObject() instanceof Formula) { + Formula formula = (Formula) title.getTextObject(); + updateOldStr(formula.getContent(), findStr); + formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr)); + } else { + updateOldStr(GeneralUtils.objectToString(title.getTextObject()), findStr); + title.setTextObject(ShowValueUtils.replaceAll(GeneralUtils.objectToString(title.getTextObject()), findStr, replaceStr)); + } + } else { + FloatElement floatElement = ((FloatElement) this.getContent().getReplaceObject()); + if (floatElement.getValue() instanceof Formula) { + Formula formula = (Formula) floatElement.getValue(); + updateOldStr(formula.getContent(), findStr); + formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr)); + } else { + updateOldStr(GeneralUtils.objectToString(floatElement.getValue()), findStr); + floatElement.setValue(ShowValueUtils.replaceAll(GeneralUtils.objectToString(floatElement.getValue()), findStr, replaceStr)); + } + } + } + + @Override + public Boolean checkValid() { + FloatElement floatElement = (((FloatElement) (this.getContent().getReplaceObject()))); + String newValue; + if (this.isChartExist() && this.getFloatChartIndex() != -1) { + newValue = getChartCheckValue(); + } else { + newValue = GeneralUtils.objectToString(floatElement.getValue()); + } + return StringUtils.equals(newValue, this.getContent().getOldShowStr()); + } + + private String getChartCheckValue() { + ChartCollection chartCollection = (ChartCollection) ((FloatElement) this.getContent().getReplaceObject()).getValue(); + Title title = chartCollection.getChart(this.getFloatChartIndex()).getTitle(); + if (title.getTextObject() instanceof Formula) { + Formula formula = (Formula) title.getTextObject(); + return formula.getContent(); + } else { + return GeneralUtils.objectToString(title.getTextObject()); + } + } + + @Override + public String getInfoShowStr(Info info) { + return this.getContent().getOldShowStr(); + } + + /** + * 复制 + * + * @return + */ + public FloatInfo copy() { + ITContent content = ITContent.copy(this.getContent()); + FloatInfo floatInfo = new FloatInfo(content); + floatInfo.setFloatChartIndex(this.getFloatChartIndex()); + floatInfo.setChartExist(this.isChartExist()); + return floatInfo; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java new file mode 100644 index 0000000000..ce2ecd36c6 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java @@ -0,0 +1,79 @@ +package com.fr.design.actions.replace.info; + + +import com.fr.data.impl.FormulaDictionary; +import com.fr.design.actions.replace.action.content.formula.FormulaReplaceObject; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.combination.Pair; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 存储公式类型的Info + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-17 + */ +public class FormulaInfo implements Info { + private ITContent content; + private static final String DISPLAY = Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary") + "-" + Toolkit.i18nText("Fine-Design_Chart_Formula") + "-" + Toolkit.i18nText("Fine-Design_Basic_Display_Value"); + private static final String ACTUAL = Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary") + "-" + Toolkit.i18nText("Fine-Design_Chart_Formula") + "-" + Toolkit.i18nText("Fine-Design_Basic_Actual_Value"); + + public FormulaInfo(ITContent content) { + this.content = content; + } + + @Override + public ITContent getContent() { + return content; + } + + public void setContent(ITContent content) { + this.content = content; + } + + @Override + public Map getValue(Object... o) { + Map map = new HashMap<>(); + map = getCommonValue(); + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + FormulaReplaceObject formulaReplaceObject = FormulaReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (formulaReplaceObject != null) { + formulaReplaceObject.setValue(this, findStr, replaceStr, operatorArray); + } + } + + @Override + public String getInfoShowStr(Info info) { + FormulaReplaceObject formulaReplaceObject = FormulaReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (formulaReplaceObject != null) { + return formulaReplaceObject.getInfoShowStr(info); + } + return StringUtils.EMPTY; + } + + @Override + public Boolean checkValid() { + //校验二期才完善,目前都给过 + return true; + } + + private Map getCommonValue() { + Map map = new HashMap(); + FormulaReplaceObject o = FormulaReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (o != null) { + return o.getValue(this.content.getReplaceObject()); + } + return map; + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/Info.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/Info.java new file mode 100644 index 0000000000..3f5a30d860 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/Info.java @@ -0,0 +1,45 @@ +package com.fr.design.actions.replace.info; + +import com.fr.design.actions.replace.info.base.ITContent; + + +/** + * 主要的数据结构 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-17 + */ +public interface Info extends DealWithInfoValue { + + /** + * 获取ITContent + * + * @return + */ + ITContent getContent(); + + + /** + * 更新旧值 + * + * @param oldShowStr + * @param lastSearchStr + */ + default void updateOldStr(String oldShowStr, String lastSearchStr) { + this.getContent().setOldShowStr(oldShowStr); + this.getContent().setLastSearchStr(lastSearchStr); + } + + /** + * 校验正确性(是否被修改) + * + * @return + */ + default Boolean checkValid() { + //todo 完善所有类型的校验 + return true; + } + + ; +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java new file mode 100644 index 0000000000..3f0632fe84 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/JSInfo.java @@ -0,0 +1,108 @@ +package com.fr.design.actions.replace.info; + + +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.stable.AssistUtils; +import com.fr.stable.collections.combination.Pair; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + + +/** + * 存储JS信息的Info + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-11 + */ +public class JSInfo implements Info { + private ITContent content; + private boolean contentFlag = true; + + public JSInfo(ITContent content) { + this.content = content; + } + + @Override + public ITContent getContent() { + return content; + } + + public void setContent(ITContent content) { + this.content = content; + } + + @Override + public Map getValue(Object... object) { + ReplaceObject o = ReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (o != null) { + return o.getValue(this.content.getReplaceObject()); + } + return new HashMap<>(); + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + ReplaceObject o = ReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (o != null) { + o.setValue(this, findStr, replaceStr, this.getContent().getOperatorArray()); + } + + } + + @Override + public String getInfoShowStr(Info info) { + return info.getContent().getOldShowStr(); + } + + + @Override + public Boolean checkValid() { + ReplaceObject o = ReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (o != null) { + return o.check(this); + } + return false; + } + + /** + * toString + * + * @return + */ + @Override + public String toString() { + return AssistUtils.toString(this); + } + + /** + * 复制 + * + * @return + */ + public JSInfo copy() { + ITContent content = ITContent.copy(this.getContent()); + JSInfo jsInfo = new JSInfo(content); + jsInfo.setContentFlag(this.isContent()); + return jsInfo; + } + + /** + * 是否属于存储内容 + * + * @return + */ + public boolean isContent() { + return contentFlag; + } + + public void setContentFlag(boolean contentFlag) { + this.contentFlag = contentFlag; + } + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java new file mode 100644 index 0000000000..48a4dbf644 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java @@ -0,0 +1,307 @@ +package com.fr.design.actions.replace.info; + +import com.fr.data.impl.DBTableData; +import com.fr.design.DesignModelAdapter; +import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.design.data.DesignTableDataManager; +import com.fr.design.data.datapane.TableDataTreePane; +import com.fr.form.event.Listener; +import com.fr.general.GeneralUtils; +import com.fr.js.JavaScriptImpl; +import com.fr.js.NameJavaScript; +import com.fr.plugin.chart.base.VanChartHtmlLabel; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.combination.Pair; +import com.fr.web.attr.ReportWebAttr; +import org.jetbrains.annotations.Nullable; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 处理所存储的不同类型的对象(除了Formula外的其他对象) + * 此处对象是ITContent中用于直接查找内容与替换内容的操作对象 + * Formula要处理的对象太多而且会和其他类型有重叠,所以单独开一个类放 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-23 + */ +public enum ReplaceObject implements DealWithInfoValue { + /** + * NameJavaScript——JS + */ + NAME_JAVA_SCRIPT("NameJavaScript") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + addValue2Map(nameKey, ((NameJavaScript) o[0]).getName(), map); + addValue2Map(contentKey, ((JavaScriptImpl) (((NameJavaScript) o[0]).getJavaScript())).getContent(), map); + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (((JSInfo) info).isContent()) { + JavaScriptImpl javaScript = (JavaScriptImpl) ((NameJavaScript) (info.getContent().getReplaceObject())).getJavaScript(); + info.updateOldStr(javaScript.getContent(), findStr); + javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr)); + } else { + NameJavaScript javaScript = ((NameJavaScript) (info.getContent().getReplaceObject())); + info.updateOldStr(javaScript.getName(), findStr); + javaScript.setName(ShowValueUtils.replaceAll(javaScript.getName(), findStr, replaceStr)); + } + } + + @Override + public String getInfoShowStr(Info info) { + if (((JSInfo) info).isContent()) { + JavaScriptImpl javaScript = (JavaScriptImpl) ((NameJavaScript) (info.getContent().getReplaceObject())).getJavaScript(); + return javaScript.getContent(); + } else { + NameJavaScript javaScript = ((NameJavaScript) (info.getContent().getReplaceObject())); + return javaScript.getName(); + } + } + + @Override + boolean check(Info info) { + if (((JSInfo) info).isContent()) { + JavaScriptImpl javaScript = (JavaScriptImpl) ((NameJavaScript) (info.getContent().getReplaceObject())).getJavaScript(); + return StringUtils.equals(javaScript.getContent(), info.getContent().getOldShowStr()); + } else { + NameJavaScript javaScript = ((NameJavaScript) (info.getContent().getReplaceObject())); + return StringUtils.equals(javaScript.getName(), info.getContent().getOldShowStr()); + } + } + }, + /** + * Listener——JS + */ + LISTENER("Listener") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + addValue2Map(nameKey, ((Listener) o[0]).getName(), map); + addValue2Map(contentKey, ((JavaScriptImpl) (((Listener) o[0]).getAction())).getContent(), map); + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (((JSInfo) info).isContent()) { + JavaScriptImpl javaScript = (JavaScriptImpl) ((Listener) (info.getContent().getReplaceObject())).getAction(); + info.updateOldStr(javaScript.getContent(), findStr); + javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr)); + } else { + Listener listener = ((Listener) ((info.getContent().getReplaceObject()))); + info.updateOldStr(listener.getName(), findStr); + listener.setName(ShowValueUtils.replaceAll(listener.getName(), findStr, replaceStr)); + } + } + + @Override + public String getInfoShowStr(Info info) { + if (((JSInfo) info).isContent()) { + JavaScriptImpl javaScript = (JavaScriptImpl) ((Listener) (info.getContent().getReplaceObject())).getAction(); + return javaScript.getContent(); + } else { + Listener listener = ((Listener) (info.getContent().getReplaceObject())); + return listener.getName(); + } + } + + @Override + boolean check(Info info) { + if (((JSInfo) info).isContent()) { + JavaScriptImpl javaScript = (JavaScriptImpl) ((Listener) (info.getContent().getReplaceObject())).getAction(); + return StringUtils.equals(javaScript.getContent(), info.getContent().getOldShowStr()); + } else { + Listener listener = ((Listener) (info.getContent().getReplaceObject())); + return StringUtils.equals(listener.getName(), info.getContent().getOldShowStr()); + } + } + }, + /** + * VanChartHtmlLabel——JS + */ + VAN_CHART_HTML_LABEL("VanChartHtmlLabel") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + addValue2Map(contentKey, ((VanChartHtmlLabel) o[0]).getCustomText(), map); + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (((JSInfo) info).isContent()) { + VanChartHtmlLabel htmlLabel = ((VanChartHtmlLabel) (info.getContent().getReplaceObject())); + StringBuilder stringBuilder = new StringBuilder(htmlLabel.getCustomText()); + info.updateOldStr(htmlLabel.getCustomText(), findStr); + htmlLabel.setCustomText(ShowValueUtils.replaceAll(htmlLabel.getCustomText(), findStr, replaceStr)); + } + } + + @Override + public String getInfoShowStr(Info info) { + VanChartHtmlLabel htmlLabel = ((VanChartHtmlLabel) (info.getContent().getReplaceObject())); + return htmlLabel.getCustomText(); + } + + @Override + boolean check(Info info) { + if (((JSInfo) info).isContent()) { + VanChartHtmlLabel htmlLabel = ((VanChartHtmlLabel) (info.getContent().getReplaceObject())); + return StringUtils.equals(htmlLabel.getCustomText(), info.getContent().getOldShowStr()); + } + return false; + } + }, + /** + * JavaScriptImpl——JS + */ + JAVA_SCRIPT_IMPL("JavaScriptImpl") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + addValue2Map(contentKey, ((JavaScriptImpl) o[0]).getContent(), map); + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + JavaScriptImpl javaScript = (JavaScriptImpl) (info.getContent().getReplaceObject()); + info.updateOldStr(javaScript.getContent(), findStr); + javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr)); + } + + @Override + public String getInfoShowStr(Info info) { + JavaScriptImpl javaScript = (JavaScriptImpl) (info.getContent().getReplaceObject()); + return javaScript.getContent(); + } + + @Override + boolean check(Info info) { + JavaScriptImpl javaScript = (JavaScriptImpl) (info.getContent().getReplaceObject()); + return StringUtils.equals(javaScript.getContent(), info.getContent().getOldShowStr()); + } + }, + /** + * 模板Web属性——引用JS + */ + IMPORT_JS("String") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + addValue2Map(contentKey, GeneralUtils.objectToString(o[0]), map); + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof ReportWebAttr) { + ReportWebAttr attr = (ReportWebAttr) info.getContent().getHoldObject(); + List jsImports = Arrays.asList(attr.getJSImport()); + String jsName = GeneralUtils.objectToString(info.getContent().getReplaceObject()); + for (int i = 0, len = jsImports.size(); i < len; i++) { + if (StringUtils.equals(jsImports.get(i), jsName)) { + jsImports.set(i, ShowValueUtils.replaceAll(jsName, findStr, replaceStr)); + } + } + attr.clearJSImportList(); + for (int i = 0, len = jsImports.size(); i < len; i++) { + attr.addJSImport(jsImports.get(i)); + } + } + } + + @Override + public String getInfoShowStr(Info info) { + return GeneralUtils.objectToString(info.getContent().getReplaceObject()); + } + + @Override + boolean check(Info info) { + return true; + } + }, + /** + * DBTableData——SQL + */ + DB_TABLE_DATA("DBTableData") { + @Override + boolean check (Info info){ + DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); + return StringUtils.equals(dbTableData.getQuery(), info.getContent().getOldShowStr()); + } + + @Override + public Map getValue (Object...o){ + HashMap map = new HashMap<>(); + addValue2Map(contentKey, ((DBTableData) o[0]).getQuery(), map); + return map; + } + + @Override + public void setValue (Info info, String findStr, String replaceStr, List < Pair < Integer, Integer >> operatorArray){ + DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); + info.updateOldStr(dbTableData.getQuery(), findStr); + dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr)); + //清除缓存 + DesignTableDataManager.removeSelectedColumnNames(dbTableData.getName()); + //收缩菜单 + TableDataTreePane.getInstance(DesignModelAdapter.getCurrentModelAdapter()).refreshDockingView(); + } + + @Override + public String getInfoShowStr (Info info){ + return info.getInfoShowStr(info); + } + }; + + + String name; + String nameKey = "name"; + String contentKey = "content"; + + ReplaceObject(String name) { + this.name = name; + } + + /** + * 匹配 + * + * @param name + * @return + */ + @Nullable + public static ReplaceObject match(String name) { + ReplaceObject[] values = ReplaceObject.values(); + for (ReplaceObject value : values) { + if (value.name.equals(name)) { + return value; + } + } + return null; + } + + /** + * 将键值放入Map中 + * + * @param flag + * @param content + * @param map + */ + public void addValue2Map(String flag, String content, Map map) { + if (StringUtils.isNotEmpty(content)) { + map.put(flag, content); + } + } + + + abstract boolean check(Info info); + } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java new file mode 100644 index 0000000000..6006c83754 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java @@ -0,0 +1,71 @@ +package com.fr.design.actions.replace.info; + +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.stable.AssistUtils; +import com.fr.stable.collections.combination.Pair; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 存储SQL信息的Info + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-16 + */ +public class SQLInfo implements Info { + private ITContent content; + + public SQLInfo(ITContent content) { + this.content = content; + } + + @Override + public ITContent getContent() { + return content; + } + + public void setContent(ITContent content) { + this.content = content; + } + + @Override + public Map getValue(Object... objects) { + ReplaceObject o = ReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (o != null) { + return o.getValue(this.content.getReplaceObject()); + } + return new HashMap<>(); + } + + /** + * 复制 + * @return + */ + public SQLInfo copy() { + ITContent content = ITContent.copy(this.getContent()); + return new SQLInfo(content); + } + + @Override + public String toString() { + return AssistUtils.toString(this); + } + + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + ReplaceObject o = ReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (o != null) { + o.setValue(this, findStr, replaceStr, operatorArray); + } + } + + @Override + public String getInfoShowStr(Info info) { + return this.getContent().getOldShowStr(); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java new file mode 100644 index 0000000000..8f44967a9c --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java @@ -0,0 +1,128 @@ +package com.fr.design.actions.replace.info; + +import com.fr.design.actions.replace.action.content.widget.FrmWidgetType; +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.form.ui.WaterMark; +import com.fr.form.ui.Widget; +import com.fr.form.ui.container.WScaleLayout; +import com.fr.form.ui.widget.CRBoundsWidget; +import com.fr.stable.AssistUtils; +import com.fr.stable.collections.combination.Pair; + + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * 存储控件信息的Info + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-16 + */ +public class WidgetInfo implements Info, DealWithInfoValue { + private ITContent content; + private boolean waterMarkFlag = true; + + public WidgetInfo(ITContent content) { + this.content = content; + } + + @Override + public ITContent getContent() { + return content; + } + + public void setContent(ITContent content) { + this.content = content; + } + + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + Widget widget = (Widget) this.content.getReplaceObject(); + if (widget instanceof WScaleLayout) { + widget = ((CRBoundsWidget) ((WScaleLayout) widget).getWidget(0)).getWidget(); + } + if (widget.getWidgetName() != null) { + map.put("name", widget.getWidgetName()); + } + if (widget instanceof WaterMark && (((WaterMark) widget).getWaterMark() != null)) { + map.put("waterMark", ((WaterMark) widget).getWaterMark()); + } + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + Widget widget = ((Widget) (this.content.getReplaceObject())); + if (this.getContent().isFrm()) { + FrmWidgetType widgetType = FrmWidgetType.match(widget.getClass().getSimpleName()); + if (widgetType != null) { + widgetType.setValue(info, findStr, replaceStr, this.getContent().getOperatorArray()); + } + } else { + if (isWaterMark()) { + updateOldStr(((WaterMark) widget).getWaterMark(), findStr); + ((WaterMark) widget).setWaterMark(ShowValueUtils.replaceAll(((WaterMark) widget).getWaterMark(), findStr, replaceStr)); + } else { + updateOldStr(widget.getWidgetName(), findStr); + widget.setWidgetName(ShowValueUtils.replaceAll(widget.getWidgetName(), findStr, replaceStr)); + } + } + + } + + @Override + public String getInfoShowStr(Info info) { + return this.getContent().getOldShowStr(); + } + + /** + * 复制 + * + * @param widgetInfo + * @return + */ + public WidgetInfo copy(WidgetInfo widgetInfo) { + ITContent content = ITContent.copy(widgetInfo.getContent()); + return new WidgetInfo(content); + } + + /** + * 是否存储水印 + * + * @return + */ + public boolean isWaterMark() { + return waterMarkFlag; + } + + public void setWaterMarkFlag(boolean waterMarkFlag) { + this.waterMarkFlag = waterMarkFlag; + } + + /** + * ReplaceObject是否存在 + * + * @return + */ + public boolean isReplaceObjectExist() { + return content != null && content.getReplaceObject() != null; + } + + /** + * toString + * + * @return + */ + @Override + public String toString() { + return AssistUtils.toString(this); + } + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java new file mode 100644 index 0000000000..ee83e77534 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java @@ -0,0 +1,327 @@ +package com.fr.design.actions.replace.info.base; + + +import com.fr.stable.AssistUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.combination.Pair; + +import java.util.ArrayList; +import java.util.List; + +/** + * 主要的存储信息的数据结构 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-11 + */ +public class ITContent implements Cloneable { + private String sheetID; + private String sheetName; + private String templateName; + private String templatePath; + private String blockName; + /** + * 一些不好定位的位置先用字符串展示出来就好 + */ + private String otherPos; + /** + * 用于操作替换相关的对象(通过此属性获取所需的对象) + */ + private Object replaceObject; + /** + * 用于展示给用户的位置 + */ + private Object showObject; + /** + * 用于展示内容 + */ + private String showStr; + /** + * 存储展示前的旧值 + */ + private String oldShowStr; + /** + * 存储上一次搜索的string + */ + private String lastSearchStr; + /** + * 由于我们TRL是一次性的,这边存字符串到时候new一个即可 + */ + private String trlString; + /** + * 为操作字符串提供操作位置的定位信息,Pair中存储的是开始操作的索引以及结束操作的索引 + */ + private List> operatorArray; + /** + * 是否是决策报表——用于判断一些决策报表的特殊操作(比如决策报表控件在设置值时要多设置几个地方,一层套一层) + */ + private boolean frmFlag = false; + /** + * 是否被选中 + */ + private boolean selected = true; + + /** + * 是否可跳转 + */ + private boolean jumpAble = true; + + /** + * 持有公式的对象 + */ + private Object holdObject; + + /** + * 与SearchTag对应的标签,用于后续校验处理 + */ + private int tag = -1; + + public ITContent() { + this.sheetID = StringUtils.EMPTY; + this.sheetName = StringUtils.EMPTY; + this.blockName = StringUtils.EMPTY; + this.templateName = StringUtils.EMPTY; + this.otherPos = StringUtils.EMPTY; + this.replaceObject = StringUtils.EMPTY; + this.showObject = StringUtils.EMPTY; + this.showStr = StringUtils.EMPTY; + this.oldShowStr = StringUtils.EMPTY; + this.lastSearchStr = StringUtils.EMPTY; + this.trlString = StringUtils.EMPTY; + this.operatorArray = new ArrayList<>(); + this.holdObject = new Object(); + this.templatePath = StringUtils.EMPTY; + } + + + /** + * 复制 + * + * @return + */ + public static ITContent copy(ITContent content) { + ITContent result = new ITContent(); + if (content != null){ + result.setSheetID(content.getSheetID()); + result.setSheetName(content.getSheetName()); + result.setTemplateName(content.getTemplateName()); + result.setBlockName(content.getBlockName()); + result.addOtherPos(content.getOtherPos()); + result.setReplaceObject(content.getReplaceObject()); + result.setShowObject(content.getShowObject()); + result.setTrlString(content.getTrlString()); + result.setShowStr(content.getShowStr()); + result.setOldShowStr(content.getOldShowStr()); + result.setLastSearchStr(content.getLastSearchStr()); + result.setOperatorArray(content.getOperatorArray()); + result.setFrmFlag(content.isFrm()); + result.setJumpAble(content.isJumpAble()); + result.setHoldObject(content.getHoldObject()); + result.setTag(content.getTag()); + result.setTemplatePath(content.getTemplatePath()); + } + return result; + } + + public int getTag() { + return tag; + } + + public void setTag(int tag) { + this.tag = tag; + } + + public Object getHoldObject() { + return holdObject; + } + + public void setHoldObject(Object holdObject) { + this.holdObject = holdObject; + } + + public Object getReplaceObject() { + return replaceObject; + } + + public void setReplaceObject(Object replaceObject) { + this.replaceObject = replaceObject; + } + + public String getSheetID() { + return sheetID; + } + + public void setSheetID(String sheetID) { + this.sheetID = sheetID; + } + + public String getSheetName() { + return sheetName; + } + + public void setSheetName(String sheetName) { + this.sheetName = sheetName; + } + + public String getTemplateName() { + return templateName; + } + + public void setTemplateName(String templateName) { + this.templateName = templateName; + } + + public String getBlockName() { + return blockName; + } + + public void setBlockName(String blockName) { + this.blockName = blockName; + } + + public String getOtherPos() { + return otherPos; + } + + public Object getShowObject() { + return showObject; + } + + public String getShowStr() { + return showStr; + } + + public void setShowStr(String showStr) { + this.showStr = showStr; + } + + public String getTrlString() { + return trlString; + } + + public void setTrlString(String trlString) { + this.trlString = trlString; + } + + public void setShowObject(Object showObject) { + this.showObject = showObject; + } + + public String getTemplatePath() { + return templatePath; + } + + public void setTemplatePath(String templatePath) { + this.templatePath = templatePath; + } + + /** + * 添加位置信息 + * + * @param otherPoses + */ + public void addOtherPos(String... otherPoses) { + for (String otherPos : otherPoses) { + if (StringUtils.isNotEmpty(this.otherPos)) { + this.otherPos = this.otherPos + "-" + otherPos; + } else { + this.otherPos = otherPos; + } + } + } + + /** + * 添加跳转路径 + * + * @param trlString + */ + public void addTRL(String trlString) { + if (StringUtils.isNotEmpty(trlString)) { + if (StringUtils.isNotEmpty(this.trlString)) { + this.trlString = this.trlString + ":" + trlString; + } else { + this.trlString = trlString; + } + } + + } + + public List> getOperatorArray() { + return operatorArray; + } + + public void setOperatorArray(List> operatorArray) { + this.operatorArray = operatorArray; + } + + public void setOtherPos(String otherPos) { + this.otherPos = otherPos; + } + + /** + * 是否选中 + * + * @return + */ + public boolean isSelected() { + return selected; + } + + /** + * 设置选中 + * + * @param selected + */ + public void setSelected(boolean selected) { + this.selected = selected; + } + + /** + * 是否是决策报表 + * + * @return + */ + public boolean isFrm() { + return frmFlag; + } + + public void setFrmFlag(boolean frmFlag) { + this.frmFlag = frmFlag; + } + + public String getOldShowStr() { + return oldShowStr; + } + + public void setOldShowStr(String oldShowStr) { + this.oldShowStr = oldShowStr; + } + + public String getLastSearchStr() { + return lastSearchStr; + } + + public void setLastSearchStr(String lastSearchStr) { + this.lastSearchStr = lastSearchStr; + } + + public boolean isJumpAble() { + return jumpAble; + } + + public void setJumpAble(boolean jumpAble) { + this.jumpAble = jumpAble; + } + + public boolean isFrmFlag() { + return frmFlag; + } + + @Override + public String toString() { + return AssistUtils.toString(this); + } + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java new file mode 100644 index 0000000000..b5e202bcb1 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java @@ -0,0 +1,62 @@ +package com.fr.design.actions.replace.info.base; + +/** + * 用于校验的标签 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-21 + */ +public class SearchTag { + /** + * 经度 + */ + public static final int CHART_DATA_LONGITUDE = 0; + /** + * 纬度 + */ + public static final int CHART_DATA_LATITUDE = 1; + /** + * 区域名 + */ + public static final int CHART_AREA_NAME = 2; + /** + * 终点经度 + */ + public static final int CHART_DATA_END_LONGITUDE = 3; + /** + * 终点纬度 + */ + public static final int CHART_DATA_END_LATITUDE = 4; + /** + * 终点区域名 + */ + public static final int CHART_AREA_END_NAME = 5; + /** + * 模板填报属性数据校验提示 + */ + public static final int WRITE_ATTR_MESSAGE = 6; + /** + * sheet名称 + */ + public static final int SHEET_NAME = 7; + /** + * 单元格属性-其他-内容提示 + */ + public static final int CELL_TOOL_TIP = 8; + /** + * 数据字典-公式-显示值 + */ + public static final int DICT_EXCUTE = 9; + /** + * 数据字典-公式-实际值 + */ + public static final int DICT_PRODUCE = 10; + /** + * 引用JS + */ + public static final int IMPORT_JS = 11; + + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITComboBoxEditor.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITComboBoxEditor.java new file mode 100644 index 0000000000..cb0d343e82 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITComboBoxEditor.java @@ -0,0 +1,118 @@ +package com.fr.design.actions.replace.ui; + +import com.fr.design.gui.itextfield.UITextField; +import com.fr.general.ComparatorUtils; +import com.fr.stable.Constants; +import com.fr.stable.StringUtils; + +import javax.swing.plaf.basic.BasicComboBoxEditor; +import java.awt.Component; +import java.awt.Insets; +import java.awt.event.ActionListener; +import java.lang.reflect.Method; + +/** + * 渲染带有默认值的ComboBox + * UIComboBox中设置默认值会整体上移,需要自己重新实现一个 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-02 + */ +public class ITComboBoxEditor extends BasicComboBoxEditor { + protected UITextField textField; + private Object oldValue; + + /** + * 构造时重新设置一下TextField的上边距 + */ + public ITComboBoxEditor() { + textField = new UITextField() { + @Override + public Insets getInsets() { + return new Insets(4, 4, 0, 4); + } + }; + textField.setRectDirection(Constants.RIGHT); + } + + @Override + public Component getEditorComponent() { + return textField; + } + + /** + * 设置选项 + * + * @param anObject 选项 + */ + @Override + public void setItem(Object anObject) { + if (anObject != null) { + + textField.setText(anObject.toString()); + oldValue = anObject; + } else { + textField.setText(StringUtils.EMPTY); + } + + } + + /** + * 获取选项 + * + * @return 选项 + */ + @Override + public Object getItem() { + Object newValue = textField.getText(); + if (oldValue != null && !(oldValue instanceof String)) { + // The original value is not a string. Should return the value in it's + // original type. + if (ComparatorUtils.equals(newValue, oldValue.toString())) { + return oldValue; + } else { + // Must take the value from the textField and get the value and cast it to the new type. + Class cls = oldValue.getClass(); + try { + Method method = cls.getMethod("valueOf", new Class[]{String.class}); + newValue = method.invoke(oldValue, new Object[]{textField.getText()}); + } catch (Exception ignored) { + // Fail silently and return the newValue (a String object) + } + } + } + return newValue; + + } + + /** + * 选择所有 + */ + @Override + public void selectAll() { + textField.selectAll(); + textField.requestFocus(); + } + + /** + * 添加监听 + * + * @param l 监听 + */ + @Override + public void addActionListener(ActionListener l) { + textField.addActionListener(l); + } + + /** + * 移除监听 + * + * @param l 监听 + */ + @Override + public void removeActionListener(ActionListener l) { + textField.removeActionListener(l); + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java new file mode 100644 index 0000000000..54e6a3bff4 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -0,0 +1,355 @@ +package com.fr.design.actions.replace.ui; + + +import com.fr.design.actions.replace.action.ShowSearchResultAction; + +import com.fr.design.actions.replace.info.Info; + +import com.fr.design.actions.replace.utils.ShowValueUtils; +import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.dialog.UIDialog; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.design.mainframe.JTemplate; + +import com.fr.general.GeneralUtils; + +import com.fr.stable.StringUtils; + + +import javax.swing.JOptionPane; +import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Point; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; + +import java.util.List; +import java.util.regex.Pattern; + +import static com.fr.design.actions.replace.ui.ITTableEditorPane.getEditTable; + +/** + * 主面板 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-10 + */ +public class ITReplaceMainDialog extends UIDialog { + List searchResultList = new ArrayList<>(); + private static boolean ITReplaceFlag = false; + private static boolean matched = false; + private static volatile ITReplaceMainDialog instance = null; + private static String templateID; + private static String templateName; + private ITReplaceNorthPanel northPane; + private ITReplaceSouthPanel southPanel; + private ITReplaceWestPanel westPanel; + private boolean searchFlag; + private String searchStr; + private static final int FIRST_ROW = 0; + public static int selectCount = 0; + + public ITReplaceMainDialog() { + super(DesignerContext.getDesignerFrame()); + init(); + } + + /** + * 初始化 + */ + public void init() { + setTitle(Toolkit.i18nText("Fine-Design_Replace_Title")); + initFrame(); + fitScreen(); + ITReplaceFlag = true; + } + + /** + * DCL + * + * @return 面板 + */ + public static ITReplaceMainDialog getInstance() { + if (instance == null) { + synchronized (ITReplaceMainDialog.class) { + if (instance == null) { + instance = new ITReplaceMainDialog(); + } + } + } + return instance; + } + + + /** + * 适配屏幕 + */ + public void fitScreen() { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + int height = 385; + int width = jTemplate.getWidth(); + Point point = jTemplate.getLocationOnScreen(); + setModal(false); + setMaximumSize(new Dimension(jTemplate.getWidth(), jTemplate.getHeight())); + setMinimumSize(new Dimension(jTemplate.getWidth(), 240)); + setSize(width, height); + setLocation(new Point(point.x, point.y + jTemplate.getHeight() / 2 + jTemplate.getHeight() / 2 - 385)); + + northPane.fitScreen(0, 0, width); + } + + + /** + * 创建面板 + */ + public void initFrame() { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + northPane = new ITReplaceNorthPanel(); + southPanel = new ITReplaceSouthPanel(); + westPanel = new ITReplaceWestPanel(); + + northPane.fitScreen(0, 0, jTemplate.getWidth()); + + JPanel center = new JPanel(new BorderLayout()); + + UIComboBox replaceComboBox = northPane.getReplaceInputCombobox(); + northPane.getFindInputCombobox().setEditable(true); + replaceComboBox.setEnabled(false); + replaceComboBox.setEditable(true); + northPane.getReplaceButton().setEnabled(false); + + ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Search_Input")); + ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Input")); + ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + search(); + } + }); + + northPane.getSearchButton().addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + search(); + + } + }); + + northPane.getReplaceButton().addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (isSearchFlag()) { + replace(); + } + } + }); + center.add(northPane.getScrollPane(), BorderLayout.NORTH); + center.add(southPanel.getTableEditorPane(), BorderLayout.CENTER); + add(westPanel.getLeftJpanel(), BorderLayout.WEST); + //主体部分 + add(center, BorderLayout.CENTER); + center.setVisible(true); + } + + /** + * 替换 + */ + private void replace() { + String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); + String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText(); + //替换内容为空需要触发搜索 + if (isITReplaceValid() && checkTemplateChanged(searchResultList)) { + if (StringUtils.equals(getSearchStr(), searchStr) && StringUtils.isNotEmpty(replaceStr)) { + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); + for (Info info : searchResultList) { + if (info.getContent().isSelected()) { + info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray()); + } + } + southPanel.getTableEditorPane().update(); + northPane.refreshReplaceInputComboBoxItems(); + ITTableEditorPane.getEditTable().repaint(); + setSearchFlag(false); + } + search(); + } else { + Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")}; + int optionSelected = FineJOptionPane.showOptionDialog( + ITReplaceMainDialog.this, + Toolkit.i18nText("Fine-Design_Replace_Message"), + Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), + JOptionPane.YES_NO_CANCEL_OPTION, + JOptionPane.ERROR_MESSAGE, + null, + // 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框) + options, + options[0] + ); + //如果选择了重新查找,则再查找一遍 + if (optionSelected == 0) { + search(); + } + } + + + } + + private Boolean checkTemplateChanged(List searchResultList) { + for (Info info : searchResultList) { + if (!info.checkValid()) { + return false; + } + } + return true; + } + + + /** + * 可行性判定(模板是否可用、是否是同个模板) + * + * @return 检查无误则返回true + */ + public boolean isITReplaceValid() { + if (JTemplate.isValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) { + return StringUtils.equals(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID(), templateID) + && StringUtils.equals(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateName(), templateName); + } else { + return false; + } + + } + + + /** + * 是否选择过 + * + * @return + */ + public boolean isSearchFlag() { + return searchFlag; + } + + public void setSearchFlag(boolean searchFlag) { + this.searchFlag = searchFlag; + } + + public String getSearchStr() { + return searchStr; + } + + public void setSearchStr(String searchStr) { + this.searchStr = searchStr; + } + + /** + * 是否使用通配符 + * + * @return + */ + public static boolean isMatched() { + return matched; + } + + public static void setMatched(boolean matched) { + ITReplaceMainDialog.matched = matched; + } + + /** + * 设置标签 + * + * @param ITReplaceFlag + */ + public static void setITReplaceFlag(boolean ITReplaceFlag) { + ITReplaceMainDialog.ITReplaceFlag = ITReplaceFlag; + } + + /** + * 定位执行标签 + * + * @return + */ + public static boolean isITReplaceFlag() { + return ITReplaceFlag; + } + + /** + * 搜索 + */ + public void search() { + ITTableEditor itTableEditor = southPanel.getItTableEditor(); + if (JTemplate.isValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) { + JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); + templateID = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID(); + templateName = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateName(); + itTableEditor.clear(); + String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); + //更新搜索内容 + setSearchStr(searchStr); + //处理通配符的regexStr + ShowValueUtils.containPattern = Pattern.compile(ShowValueUtils.changeRegex(searchStr)); + //获取搜索目标 + ShowSearchResultAction searchAction = ShowSearchResultAction.match(GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem())); + //搜索 + if (searchAction != null) { + searchResultList = searchAction.addMatchResult(searchStr, searchAction.showSearchValue(jTemplate)); + itTableEditor.add(searchResultList); + northPane.getResultLabel().setText("" + Toolkit.i18nText("Fine-Design_Replace_Search_Finish") + "" + searchResultList.size() + "" + Toolkit.i18nText("Fine-Design_Replace_Result")); + } + ITTableEditorPane.ITHeaderRenderer renderer = (ITTableEditorPane.ITHeaderRenderer) getEditTable().getTableHeader().getDefaultRenderer(); + //刷新表头,并且重新勾选中表头全选框 + renderer.refreshHeader(getEditTable(), true); + itTableEditor.fireTableDataChanged(); + northPane.refreshFindInputComboBoxItems(); + setSearchFlag(true); + selectCount = searchResultList.size(); + //如果有结果,默认选中第一行 + if (searchResultList.size() > 0) { + getEditTable().addRowSelectionInterval(FIRST_ROW, FIRST_ROW); + } + + //更新替换按钮可用性 + if (StringUtils.isEmpty(searchStr) || searchResultList.size() == 0) { + northPane.getReplaceButton().setEnabled(false); + } else { + northPane.getReplaceButton().setEnabled(true); + } + + //设置替换输入框的可用性 + northPane.getReplaceInputCombobox().setEnabled(StringUtils.isNotEmpty(searchStr)); + } else { + //todo + } + } + + + public ITReplaceSouthPanel getSouthPanel() { + return southPanel; + } + + public void setSouthPanel(ITReplaceSouthPanel southPanel) { + this.southPanel = southPanel; + } + + public ITReplaceNorthPanel getNorthPane() { + return northPane; + } + + public void setNorthPane(ITReplaceNorthPanel northPane) { + this.northPane = northPane; + } + + /** + * 检测结果是否合法 + */ + @Override + public void checkValid() throws Exception { + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java new file mode 100644 index 0000000000..a4fe1fef0f --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -0,0 +1,388 @@ +package com.fr.design.actions.replace.ui; + +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.gui.icombobox.UIComboBox; +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; +import com.fr.stable.StringUtils; + + +import javax.swing.ComboBoxEditor; +import javax.swing.JCheckBox; +import javax.swing.JPanel; +import javax.swing.ScrollPaneConstants; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.ArrayList; +import java.util.Collections; + +/** + * 上面板 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-01 + */ +public class ITReplaceNorthPanel { + private JPanel upPanel; + private UILabel findLabel; + private UILabel rangeLabel; + private UILabel resultLabel; + private UIComboBox findCombobox; + private UIComboBox rangeCombobox; + private JCheckBox matchRadioButton; + + private UIComboBox findInputCombobox; + private UIComboBox replaceInputCombobox; + private UIScrollPane scrollPane; + private UIButton replaceButton; + private UIButton searchButton; + + //存储的5次最近输入 + private int maxItemCount = 5; + private static final int LIMIT_WIDTH = 1250; + private static final int HEIGHT = 161; + private static final int BUTTON_WIDTH = 60; + private static final int BUTTON_GAP = 20; + private static final int MATCH_WIDTH = 70; + + + private int findLabelX, findLabelY, findLabelWidth, findLabelHeight; + private int findComboBoxX, findComboBoxY, findComboBoxWidth, findComboBoxHeight; + private int rangeLabelX, rangeLabelY, rangeLabelWidth, rangeLabelHeight; + private int rangeComboBoxX, rangeComboBoxY, rangeComboBoxWidth, rangeComboBoxHeight; + private int matchX, matchY, matchWidth, matchHeight; + private int resultLabelX, resultLabelY, resultLabelWidth, resultLabelHeight; + private int findInputComboBoxX, findInputComboBoxY, findInputComboBoxWidth, findInputComboBoxHeight; + private int replaceInputComboBoxX, replaceInputComboBoxY, replaceInputComboBoxWidth, replaceInputComboBoxHeight; + private int replaceButtonX, replaceButtonY, replaceButtonHeight; + private int searchButtonX, searchButtonY, searchButtonHeight; + + + public static ArrayList findItems = new ArrayList<>(); + public static ArrayList findInputItems = new ArrayList<>(); + public static ArrayList replaceInputItems = new ArrayList<>(); + + static { + findItems.add(Toolkit.i18nText("Fine-Design_Basic_Cell")); + findItems.add(Toolkit.i18nText("Fine-Design_Replace_JS")); + findItems.add("SQL"); + findItems.add(Toolkit.i18nText("Fine-Design_Basic_Float_Element")); + findItems.add(Toolkit.i18nText("Fine-Design_Replace_Component")); + findItems.add(Toolkit.i18nText("Fine-Design_Basic_Widget")); + findItems.add(Toolkit.i18nText("Fine-Design_Basic_Formula")); + } + + public ITReplaceNorthPanel() { + upPanel = new JPanel(null); + + findLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Element")); + rangeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Range")); + resultLabel = new UILabel(); + + String[] rangeItems = new String[]{Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")}; + String[] replaceInputItems = new String[]{StringUtils.EMPTY}; + findCombobox = new UIComboBox(findItems.toArray()); + rangeCombobox = new UIComboBox(rangeItems); + findInputCombobox = new UIComboBox(findInputItems.toArray()) { + @Override + public void setEditor(ComboBoxEditor comboBoxEditor) { + super.setEditor(new ITComboBoxEditor()); + } + }; + replaceInputCombobox = new UIComboBox(replaceInputItems) { + @Override + public void setEditor(ComboBoxEditor comboBoxEditor) { + super.setEditor(new ITComboBoxEditor()); + } + }; + matchRadioButton = new JCheckBox(Toolkit.i18nText("Fine-Design_Replace_WildCard")); + matchRadioButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ITReplaceMainDialog.setMatched(matchRadioButton.isSelected()); + } + }); + + replaceButton = new UIButton(Toolkit.i18nText("Fine-Design_Replace_Button")); + searchButton = new UIButton(Toolkit.i18nText("Fine-Design_Search_Button")); + upPanel.setPreferredSize(new Dimension(LIMIT_WIDTH, HEIGHT)); + scrollPane = new UIScrollPane(upPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); + upPanel.add(findLabel); + upPanel.add(rangeLabel); + upPanel.add(resultLabel); + upPanel.add(findCombobox); + upPanel.add(rangeCombobox); + upPanel.add(findInputCombobox); + upPanel.add(replaceInputCombobox); + upPanel.add(matchRadioButton); + upPanel.add(replaceButton); + upPanel.add(searchButton); + } + + /** + * 限制尺寸 + * + * @param width + */ + public void setLimitSize(int width) { + width = Math.max(LIMIT_WIDTH, width); + upPanel.setMaximumSize(new Dimension(width, 161)); + upPanel.setPreferredSize(new Dimension(width, 161)); + } + + + /** + * 适配屏幕 + * + * @param x + * @param y + * @param templateWidth + */ + public void fitScreen(int x, int y, int templateWidth) { + + templateWidth = Math.max(templateWidth, LIMIT_WIDTH); + + setFindLabelBounds(x, y, templateWidth); + setRangeLabelBounds(x, y, templateWidth); + setResultLabelBounds(x, y, templateWidth); + + setFindComboboxBounds(x, y, templateWidth); + setRangeComboboxBounds(x, y, templateWidth); + setFindInputComboboxBounds(x, y, templateWidth); + setReplaceInputComboboxBounds(x, y, templateWidth); + + setUIRadioButtonBounds(x, y, templateWidth); + setReplaceButtonBounds(x, y, templateWidth); + setSearchButtonBounds(x, y, templateWidth); + + + } + + + /** + * 刷新输入框 + */ + public void refreshFindInputComboBoxItems() { + String text = ((UITextField) (this.getFindInputCombobox().getEditor().getEditorComponent())).getText(); + if (StringUtils.isNotEmpty(text)) { + if (findInputItems.contains(text)) { + Collections.swap(findInputItems, 0, findInputItems.indexOf(text)); + } else { + if (findInputItems.size() >= maxItemCount) { + findInputItems.remove(maxItemCount - 1); + findInputItems.add(0, text); + } else { + findInputItems.add(0, text); + } + } + this.getFindInputCombobox().refreshBoxItems(ITReplaceNorthPanel.findInputItems); + ((UITextField) (this.getFindInputCombobox().getEditor().getEditorComponent())).setText(text); + } + } + + /** + * 刷新替换框 + */ + public void refreshReplaceInputComboBoxItems() { + String text = ((UITextField) (this.getReplaceInputCombobox().getEditor().getEditorComponent())).getText(); + if (StringUtils.isNotEmpty(text)) { + if (replaceInputItems.contains(text)) { + Collections.swap(replaceInputItems, 0, replaceInputItems.indexOf(text)); + } else { + if (replaceInputItems.size() >= maxItemCount) { + replaceInputItems.remove(maxItemCount - 1); + replaceInputItems.add(0, text); + } else { + replaceInputItems.add(0, text); + } + } + this.getReplaceInputCombobox().refreshBoxItems(ITReplaceNorthPanel.replaceInputItems); + ((UITextField) (this.getReplaceInputCombobox().getEditor().getEditorComponent())).setText(text); + } + } + + + public UIScrollPane getScrollPane() { + return scrollPane; + } + + public void setScrollPane(UIScrollPane scrollPane) { + this.scrollPane = scrollPane; + } + + + private void setSearchButtonBounds(int x, int y, int templateWidth) { + searchButtonHeight = 25; + searchButtonY = resultLabelY; + searchButtonX = replaceInputComboBoxX + replaceInputComboBoxWidth - BUTTON_WIDTH * 2 - BUTTON_GAP; + searchButton.setBounds(searchButtonX, searchButtonY, BUTTON_WIDTH, searchButtonHeight); + } + + private void setReplaceButtonBounds(int x, int y, int templateWidth) { + replaceButtonHeight = 25; + replaceButtonY = resultLabelY; + replaceButtonX = replaceInputComboBoxX + replaceInputComboBoxWidth - BUTTON_WIDTH; + replaceButton.setBounds(replaceButtonX, replaceButtonY, BUTTON_WIDTH, replaceButtonHeight); + } + + private void setReplaceInputComboboxBounds(int x, int y, int templateWidth) { + replaceInputComboBoxX = x + templateWidth / 2 + templateWidth / 60; + replaceInputComboBoxY = y + 55; + replaceInputComboBoxWidth = templateWidth / 3 + templateWidth / 30 * 2; + replaceInputComboBoxHeight = 25; + replaceInputCombobox.setBounds(replaceInputComboBoxX, replaceInputComboBoxY, replaceInputComboBoxWidth, replaceInputComboBoxHeight); + } + + private void setFindInputComboboxBounds(int x, int y, int templateWidth) { + findInputComboBoxX = x + templateWidth / 60; + findInputComboBoxY = y + 55; + findInputComboBoxWidth = templateWidth / 3 + templateWidth / 30 * 2; + findInputComboBoxHeight = 25; + findInputCombobox.setBounds(findInputComboBoxX, findInputComboBoxY, findInputComboBoxWidth, findInputComboBoxHeight); + } + + private void setUIRadioButtonBounds(int x, int y, int templateWidth) { + matchX = x + templateWidth / 60; + matchY = y + 90; + matchWidth = MATCH_WIDTH; + matchHeight = 25; + matchRadioButton.setBounds(matchX, matchY, matchWidth, matchHeight); + } + + + private void setRangeComboboxBounds(int x, int y, int templateWidth) { + rangeComboBoxX = x + templateWidth / 2 + templateWidth / 15; + rangeComboBoxY = y + 20; + rangeComboBoxWidth = templateWidth / 3 + templateWidth / 60; + rangeComboBoxHeight = 25; + rangeCombobox.setBounds(rangeComboBoxX, rangeComboBoxY, rangeComboBoxWidth, rangeComboBoxHeight); + } + + + private void setFindComboboxBounds(int x, int y, int templateWidth) { + findComboBoxX = x + templateWidth / 30 * 2; + findComboBoxY = y + 20; + findComboBoxWidth = templateWidth / 3 + templateWidth / 60; + findComboBoxHeight = 25; + findCombobox.setBounds(findComboBoxX, findComboBoxY, findComboBoxWidth, findComboBoxHeight); + } + + + private void setResultLabelBounds(int x, int y, int templateWidth) { + resultLabelX = findLabelX; + resultLabelY = y + 125; + resultLabelWidth = templateWidth; + resultLabelHeight = 25; + resultLabel.setBounds(resultLabelX, resultLabelY, resultLabelWidth, resultLabelHeight); + + } + + private void setRangeLabelBounds(int x, int y, int templateWidth) { + rangeLabelX = x + templateWidth / 2 + templateWidth / 60; + rangeLabelY = y + 20; + rangeLabelWidth = findLabelWidth; + rangeLabelHeight = 25; + rangeLabel.setBounds(rangeLabelX, rangeLabelY, rangeLabelWidth, rangeLabelHeight); + + } + + private void setFindLabelBounds(int x, int y, int templateWidth) { + findLabelX = x + templateWidth / 60; + findLabelY = y + 20; + findLabelWidth = templateWidth / 20; + findLabelHeight = 25; + findLabel.setBounds(findLabelX, findLabelY, findLabelWidth, findLabelHeight); + } + + public JPanel getUpPanel() { + return upPanel; + } + + public void setUpPanel(JPanel upPanel) { + this.upPanel = upPanel; + } + + public UILabel getFindLabel() { + return findLabel; + } + + public void setFindLabel(UILabel findLabel) { + this.findLabel = findLabel; + } + + public UILabel getRangeLabel() { + return rangeLabel; + } + + public void setRangeLabel(UILabel rangeLabel) { + this.rangeLabel = rangeLabel; + } + + public UILabel getResultLabel() { + return resultLabel; + } + + public void setResultLabel(UILabel resultLabel) { + this.resultLabel = resultLabel; + } + + public UIComboBox getFindCombobox() { + return findCombobox; + } + + public void setFindCombobox(UIComboBox findCombobox) { + this.findCombobox = findCombobox; + } + + public UIComboBox getRangeCombobox() { + return rangeCombobox; + } + + public void setRangeCombobox(UIComboBox rangeCombobox) { + this.rangeCombobox = rangeCombobox; + } + + public JCheckBox getMatchRadioButton() { + return matchRadioButton; + } + + public void setMatchRadioButton(JCheckBox checkBox) { + this.matchRadioButton = checkBox; + } + + public UIComboBox getFindInputCombobox() { + return findInputCombobox; + } + + public void setFindInputCombobox(UIComboBox findInputCombobox) { + this.findInputCombobox = findInputCombobox; + } + + public UIComboBox getReplaceInputCombobox() { + return replaceInputCombobox; + } + + public void setReplaceInputCombobox(UIComboBox replaceInputCombobox) { + this.replaceInputCombobox = replaceInputCombobox; + } + + public UIButton getReplaceButton() { + return replaceButton; + } + + public void setReplaceButton(UIButton replaceButton) { + this.replaceButton = replaceButton; + } + + public UIButton getSearchButton() { + return searchButton; + } + + public void setSearchButton(UIButton searchButton) { + this.searchButton = searchButton; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java new file mode 100644 index 0000000000..a240eba967 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java @@ -0,0 +1,52 @@ +package com.fr.design.actions.replace.ui; + +import javax.swing.RowSorter; +import javax.swing.table.TableRowSorter; +import java.awt.Color; + +/** + * 下面板 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-05 + */ +public class ITReplaceSouthPanel { + ITTableEditorPane tableEditorPane; + ITTableEditor itTableEditor; + //勾选框索引 + public static final int CHECKBOX_INDEX = 0; + //ITContent在表格的列索引 + public static final int CONTENT_INDEX = 6; + + public ITReplaceSouthPanel() { + itTableEditor = new ITTableEditor(); + tableEditorPane = new ITTableEditorPane<>(itTableEditor); + RowSorter sorter = new TableRowSorter(itTableEditor){ + @Override + public boolean isSortable(int column) { + return column != CHECKBOX_INDEX || column != CONTENT_INDEX; + } + }; + tableEditorPane.getEditTable().setRowSorter(sorter); + tableEditorPane.getEditTable().setSelectionBackground(new Color(217, 235, 254)); + tableEditorPane.getEditTable().setRowHeight(tableEditorPane.getEditTable().getRowHeight() / 2 + tableEditorPane.getEditTable().getRowHeight()); + tableEditorPane.makeFace(tableEditorPane.getEditTable()); + } + + public ITTableEditorPane getTableEditorPane() { + return tableEditorPane; + } + + public void setTableEditorPane(ITTableEditorPane tableEditorPane) { + this.tableEditorPane = tableEditorPane; + } + + public ITTableEditor getItTableEditor() { + return itTableEditor; + } + + public void setItTableEditor(ITTableEditor itTableEditor) { + this.itTableEditor = itTableEditor; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java new file mode 100644 index 0000000000..9295baf655 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java @@ -0,0 +1,45 @@ +package com.fr.design.actions.replace.ui; + +import com.fr.design.gui.ibutton.UIToggleButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.stable.StringUtils; + +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.Color; +import java.awt.GridLayout; + +/** + * 左侧面板 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-05 + */ +public class ITReplaceWestPanel { + JPanel leftJpanel; + + public ITReplaceWestPanel() { + + leftJpanel = new JPanel(new GridLayout(15, 1, 0, 0)); + UIToggleButton contentButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); + contentButton.setSelected(true); + contentButton.setBorderPainted(false); + leftJpanel.add(contentButton); + leftJpanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, new Color(218, 218, 221))); + //填充一下面板 + int labelNum = 14; + for (int i = 0; i < labelNum; i++) { + leftJpanel.add(new UILabel(StringUtils.EMPTY)); + } + } + + public JPanel getLeftJpanel() { + return leftJpanel; + } + + public void setLeftJpanel(JPanel leftJpanel) { + this.leftJpanel = leftJpanel; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java new file mode 100644 index 0000000000..1a73d3fcb3 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java @@ -0,0 +1,104 @@ +package com.fr.design.actions.replace.ui; + +import com.fr.base.TRL; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.ibutton.UIButton; +import com.fr.design.i18n.Toolkit; +import com.fr.design.mainframe.DesignerContext; +import com.fr.file.FILEFactory; +import com.fr.general.GeneralUtils; +import com.fr.stable.StringUtils; +import com.fr.stable.project.ProjectConstants; + + +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.table.TableCellEditor; +import javax.swing.table.TableCellRenderer; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import static com.fr.design.actions.replace.ui.ITTableEditorPane.getEditTable; + +/** + * 放进表格中的定位按钮 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-23 + */ +public class ITTableButton extends AbstractCellEditor implements TableCellEditor, TableCellRenderer { + + private UIButton paraButton; + + public ITTableButton() { + paraButton = new UIButton("" + Toolkit.i18nText("Fine-Design_Chart_Location") + " "); + paraButton.setVisible(true); + paraButton.setBorderPainted(false); + paraButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + ITContent content = (ITContent) getEditTable().getValueAt(getEditTable().getEditingRow(), 6); + if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) { + ITReplaceMainDialog.setITReplaceFlag(true); + TRL trl = new TRL(GeneralUtils.objectToString(content.getTrlString())); + DesignerContext.getDesignerFrame().openTemplate(FILEFactory.createFILE(content.getTemplatePath())); + HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(trl); + } + ITReplaceMainDialog.setITReplaceFlag(false); + } + }); + + + } + + /** + * 获取Editor的Component(编辑状态下) + * + * @param table 表格 + * @param value 传递的值 + * @param isSelected 是否选中 + * @param row 行 + * @param column 列 + * @return paraButton + */ + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + ITContent content = (ITContent) table.getValueAt(row, 6); + paraButton.setEnabled(content.isJumpAble()); + return paraButton; + } + + + /** + * 获取Renderer的Component(正常状态下) + * + * @param table 表格 + * @param value 传递的值 + * @param isSelected 是否选中 + * @param row 行 + * @param column 列 + * @return paraButton + */ + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + ITContent content = (ITContent) table.getValueAt(row, 6); + paraButton.setEnabled(content.isJumpAble()); + return paraButton; + } + + @Override + public Object getCellEditorValue() { + return null; + } + + public UIButton getParaButton() { + return paraButton; + } + + public void setParaButton(UIButton paraButton) { + this.paraButton = paraButton; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java new file mode 100644 index 0000000000..5c57e6d6a1 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java @@ -0,0 +1,212 @@ +package com.fr.design.actions.replace.ui; + +import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.base.ITContent; + +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itableeditorpane.UITableEditAction; +import com.fr.design.gui.itableeditorpane.UITableModelAdapter; +import com.fr.design.i18n.Toolkit; + +import com.fr.stable.StringUtils; +import org.jetbrains.annotations.Nullable; + + +import java.util.List; + +/** + * 表格的Editor,对应每列放的内容,用来处理表格的model + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-22 + */ + +public class ITTableEditor extends UITableModelAdapter { + + public ITTableEditor() { + super(new String[]{ + StringUtils.BLANK, + Toolkit.i18nText("Fine-Design_Replace_Search_Content"), + Toolkit.i18nText("Fine-Design_Replace_Template_Name"), + Toolkit.i18nText("Fine-Design_Replace_Sheet_Name"), + Toolkit.i18nText("Fine-Design_Replace_Block_Name"), + Toolkit.i18nText("Fine-Design_Replace_Location_Info"), + Toolkit.i18nText("Fine-Design_Replace_Operator"), + }); + + this.setColumnClass(new Class[]{ + Boolean.class, + UILabel.class, + UILabel.class, + UILabel.class, + UILabel.class, + UILabel.class, + ITTableButton.class, + + }); + this.setDefaultEditor(ITTableButton.class, new ITTableButton()); + this.setDefaultRenderer(ITTableButton.class, new ITTableButton()); + + this.createTable().getColumnModel().getColumn(ITReplaceSouthPanel.CONTENT_INDEX).setMaxWidth(50); + this.createTable().getColumnModel().getColumn(ITReplaceSouthPanel.CHECKBOX_INDEX).setMaxWidth(50); + + } + + /** + * 获取指定单元格的值 + * + * @param rowIndex + * @param columnIndex + * @return + */ + @Nullable + @Override + public Object getValueAt(int rowIndex, int columnIndex) { + ITContent content = (ITContent) this.getList().get(rowIndex); + ChooseIndex chooseIndex = ChooseIndex.match(columnIndex); + if (chooseIndex != null) { + return chooseIndex.returnContentObject(content); + } + return null; + + } + + /** + * 设置单元格能否编辑 + * + * @param row 行 + * @param col 列 + * @return + */ + @Override + public boolean isCellEditable(int row, int col) { + return col == ITReplaceSouthPanel.CONTENT_INDEX || col == ITReplaceSouthPanel.CHECKBOX_INDEX; + } + + /** + * 创建Action + * + * @return UITableEditAction + */ + @Override + public UITableEditAction[] createAction() { + return new UITableEditAction[0]; + } + + /** + * 添加数据 + * + * @param list + */ + public void add(List list) { + for (Info info : list) { + addRow(info.getContent()); + fireTableDataChanged(); + } + } + + public enum ChooseIndex { + /** + * 第一列,返回选中情况 + */ + INDEX_0(0) { + @Override + public Object returnContentObject(ITContent content) { + return content.isSelected(); + } + }, + + /** + * 第二列,展示内容 + */ + INDEX_1(1) { + @Override + public Object returnContentObject(ITContent content) { + return content.getShowStr(); + } + }, + /** + * 第三列,展示模板名 + */ + INDEX_2(2) { + @Override + public Object returnContentObject(ITContent content) { + return " " + content.getTemplateName(); + } + }, + + /** + * 第四列,展示Sheet + */ + INDEX_3(3) { + @Override + public Object returnContentObject(ITContent content) { + return " " + content.getSheetName(); + } + }, + + /** + * 第五列,展示块名、组件名 + */ + INDEX_4(4) { + @Override + public Object returnContentObject(ITContent content) { + return " " + content.getBlockName(); + } + }, + /** + * 第六列,展示路径 + */ + INDEX_5(5) { + @Override + public Object returnContentObject(ITContent content) { + return " " + content.getOtherPos(); + } + }, + + /** + * 第七列,展示定位按钮 + */ + INDEX_6(6) { + @Override + public Object returnContentObject(ITContent content) { + return content; + } + }; + + int index; + + ChooseIndex(int index) { + this.index = index; + } + + /** + * 匹配列 + * + * @param index 列序号 + * @return 选中的列 + */ + @Nullable + public static ChooseIndex match(int index) { + ChooseIndex[] values = ChooseIndex.values(); + for (ChooseIndex value : values) { + if (value.index == index) { + return value; + } + } + return null; + } + + /** + * 返回对应列的对应内容 + * + * @param content 存储信息的数据结构 + * @return Object + */ + @Nullable + public Object returnContentObject(ITContent content) { + return null; + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java new file mode 100644 index 0000000000..0a743d34eb --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java @@ -0,0 +1,319 @@ +package com.fr.design.actions.replace.ui; + +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.border.UIRoundedBorder; +import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.BasicPane; + +import com.fr.design.gui.icontainer.UIScrollPane; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itableeditorpane.UITableEditAction; +import com.fr.design.gui.itableeditorpane.UITableModelAdapter; +import com.fr.design.layout.FRGUIPaneFactory; +import com.fr.design.mainframe.share.ui.base.MouseClickListener; +import com.fr.stable.StringUtils; + + +import javax.swing.JCheckBox; +import javax.swing.JComponent; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JTable; +import javax.swing.SwingConstants; +import javax.swing.UIManager; +import javax.swing.table.JTableHeader; +import javax.swing.table.TableCellRenderer; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; + +/** + * 表格面板 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-22 + */ +public class ITTableEditorPane extends BasicPane { + + public static JTable editTable; + private UITableModelAdapter tableModel; + private String leftLabelName; + private JPanel buttonPane; + + public ITTableEditorPane(UITableModelAdapter model) { + this.tableModel = model; + this.initComponent(model.createAction()); + editTable.setGridColor(new Color(218, 218, 221)); + + } + + + /** + * 初始化 + * + * @param action + */ + private void initComponent(UITableEditAction[] action) { + this.setLayout(FRGUIPaneFactory.createBorderLayout()); + JPanel pane = new JPanel(new BorderLayout(4, 4)); + this.add(pane, BorderLayout.CENTER); + UILabel l = new UILabel(leftLabelName); + editTable = tableModel.createTable(); + editTable.getTableHeader().setBackground(UIConstants.DEFAULT_BG_RULER); + editTable.addMouseListener(new MouseClickListener() { + @Override + public void mouseClicked(MouseEvent e) { + int row = ((JTable) e.getSource()).rowAtPoint(e.getPoint()); + int col = ((JTable) e.getSource()).columnAtPoint(e.getPoint()); + if (col == ITReplaceSouthPanel.CHECKBOX_INDEX) { + ITContent content = (ITContent) editTable.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX); + //改变面板的各个状态 + changeComponentStatus(content, row, col); + } + + } + }); + UIScrollPane scrollPane = new UIScrollPane(editTable); + scrollPane.setBorder(new UIRoundedBorder(UIConstants.TITLED_BORDER_COLOR, 1, UIConstants.ARC)); + pane.add(scrollPane, BorderLayout.CENTER); + } + + /** + * 改变面板的各个状态(替换按钮、表头勾选框) + * @param content + * @param row + * @param col + */ + public void changeComponentStatus(ITContent content, int row, int col) { + if (content.isSelected()) { + content.setSelected(false); + editTable.setValueAt(content.isSelected(), row, col); + ITReplaceMainDialog.selectCount--; + //如果没有选中,替换按钮需要置灰 + ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(ITReplaceMainDialog.selectCount > 0); + } else { + content.setSelected(true); + editTable.setValueAt(content.isSelected(), row, col); + ITReplaceMainDialog.selectCount++; + ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(true); + } + //更新表头的勾选框状态 + if (editTable.getTableHeader().getDefaultRenderer() instanceof ITHeaderRenderer) { + ITHeaderRenderer renderer = (ITHeaderRenderer) editTable.getTableHeader().getDefaultRenderer(); + renderer.refreshHeader(editTable, ITReplaceMainDialog.selectCount >= editTable.getRowCount()); + } + } + + + public UITableModelAdapter getTableModel() { + return tableModel; + } + + @Override + protected String title4PopupWindow() { + return StringUtils.EMPTY; + } + + + /** + * 表头渲染 + */ + public static class ITHeaderRenderer implements TableCellRenderer { + JTableHeader tableHeader; + final JCheckBox selectBox; + + public ITHeaderRenderer(JTable table) { + this.tableHeader = table.getTableHeader(); + selectBox = new JCheckBox(); + selectBox.setSelected(true); + tableHeader.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if (e.getClickCount() > 0) { + //获得选中列 + int selectColumn = tableHeader.columnAtPoint(e.getPoint()); + if (selectColumn == ITReplaceSouthPanel.CHECKBOX_INDEX) { + boolean value = !selectBox.isSelected(); + selectBox.setSelected(value); + selectAllOrNull(value); + if (value) { + ITReplaceMainDialog.selectCount = getEditTable().getRowCount(); + } else { + ITReplaceMainDialog.selectCount = 0; + } + tableHeader.repaint(); + table.repaint(); + } + } + } + }); + } + + /** + * 刷新表头 + * + * @param table + */ + public void refreshHeader(JTable table, boolean value) { + selectBox.setSelected(value); + int rowHeight = table.getRowHeight(); + table.updateUI(); + table.setRowHeight(rowHeight); + } + + @Override + public Component getTableCellRendererComponent(JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, int column) { + tableHeader = table.getTableHeader(); + tableHeader.setReorderingAllowed(false); + String valueStr = (String) value; + JLabel label = new JLabel(valueStr); + label.setHorizontalAlignment(SwingConstants.LEFT); + selectBox.setHorizontalAlignment(SwingConstants.CENTER); + selectBox.setBorderPainted(true); + JComponent component = (column == ITReplaceSouthPanel.CHECKBOX_INDEX) ? selectBox : label; + component.setForeground(tableHeader.getForeground()); + component.setBackground(tableHeader.getBackground()); + component.setFont(tableHeader.getFont()); + component.setBorder(UIManager.getBorder("TableHeader.cellBorder")); + return component; + } + + + } + + + /** + * 设置表头属性 + * + * @param table + */ + public static void makeFace(JTable table) { + Dimension size = table.getTableHeader().getPreferredSize(); + size.height = 26;//设置新的表头高度 + + table.getTableHeader().setBackground(new Color(232, 232, 233)); + + table.getTableHeader().setPreferredSize(size); + + table.getTableHeader().setDefaultRenderer(new ITHeaderRenderer(table)); + } + + /** + * 选中全部 + * + * @param value + */ + public static void selectAllOrNull(Boolean value) { + int len = getEditTable().getRowCount(); + if (len > 0) { + ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(value); + } + for (int i = 0; i < len; i++) { + ((ITContent) (getEditTable().getValueAt(i, ITReplaceSouthPanel.CONTENT_INDEX))).setSelected(value); + } + } + + /** + * 填充数据 + * + * @param objs + */ + public void populate(T[] objs) { + tableModel.clear(); + if (objs == null) { + return; + } + for (T obj : objs) { + tableModel.addRow(obj); + } + this.tableModel.fireTableDataChanged(); + if (objs.length > 0) { + this.editTable.getSelectionModel().setSelectionInterval(0, 0); + } + } + + /** + * 更新列表内的数据 + * + * @return + */ + public java.util.List update() { + tableModel.stopCellEditing(); + return tableModel.getList(); + } + + /** + * 更新数据来源 + * + * @param list + */ + public void update(List list) { + tableModel.stopCellEditing(); + tableModel.setList(list); + } + + /** + * 获取选中行号 + * + * @return + */ + public int getSelectedRow() { + return this.editTable.getSelectedRow(); + } + + /** + * 获取选中列号 + * + * @return + */ + public int getSelectedColumn() { + return this.editTable.getSelectedColumn(); + } + + /** + * 获取面板 + * + * @return + */ + public JPanel getbuttonPane() { + return buttonPane; + } + + /** + * 停止编辑 + */ + public void stopEditing() { + tableModel.stopCellEditing(); + } + + + /** + * 设置表头是否可以改变大小 + */ + public void setHeaderResizing(boolean resizingAllowed) { + editTable.getTableHeader().setResizingAllowed(resizingAllowed); + } + + /** + * 获取表格 + * + * @return + */ + public static JTable getEditTable() { + return editTable; + } + + public void setEditTable(JTable editTable) { + this.editTable = editTable; + } + + +} \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceOperator.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceOperator.java new file mode 100644 index 0000000000..be6dc6eb1d --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceOperator.java @@ -0,0 +1,25 @@ +package com.fr.design.actions.replace.utils; + +import com.fr.design.actions.help.replace.ITReplaceOperator; +import com.fr.design.actions.replace.ui.ITReplaceMainDialog; + +/** + * 操作面板 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-27 + */ +public class ReplaceOperator implements ITReplaceOperator { + + /** + * 关闭面板 + * (当前关闭时机:进入权限编辑状态&开发者调试) + */ + @Override + public void close(){ + ITReplaceMainDialog.getInstance().dispose(); + } + + +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java new file mode 100644 index 0000000000..d04b02aa26 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java @@ -0,0 +1,335 @@ +package com.fr.design.actions.replace.utils; + +import com.fr.chart.base.DataSeriesCondition; +import com.fr.chart.chartattr.ChartCollection; +import com.fr.chart.chartglyph.ConditionAttr; +import com.fr.chart.chartglyph.ConditionCollection; +import com.fr.chart.web.ChartHyperPoplink; +import com.fr.design.actions.replace.action.content.js.SearchChartJSAction; +import com.fr.design.actions.replace.info.JSInfo; +import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.i18n.Toolkit; +import com.fr.form.event.Listener; +import com.fr.form.ui.Widget; +import com.fr.general.GeneralUtils; +import com.fr.js.Commit2DBJavaScript; +import com.fr.js.JavaScript; +import com.fr.js.JavaScriptImpl; +import com.fr.js.NameJavaScript; +import com.fr.js.NameJavaScriptGroup; +import com.fr.plugin.chart.attr.plot.VanChartPlot; +import com.fr.plugin.chart.base.AttrLabel; +import com.fr.plugin.chart.base.AttrTooltip; +import com.fr.plugin.chart.base.VanChartHtmlLabel; +import com.fr.plugin.chart.vanchart.VanChart; +import com.fr.report.cell.Elem; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.combination.Pair; + + +import java.util.ArrayList; +import java.util.List; + +/** + * 用来获取JS相关的工具类 + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-11 + */ +public class SearchJSUtils { + + /** + * 从Listener中获取JS + */ + public static void searchJSFromListener(List jsInfos, ITContent content) { + if (content.getReplaceObject() instanceof Listener) { + Listener listener = (Listener) (content.getReplaceObject()); + JavaScript javaScript = listener.getAction(); + if (javaScript instanceof JavaScriptImpl) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(listener); + SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent)); + } else if (javaScript instanceof Commit2DBJavaScript){ + dealCommit2DBJS(jsInfos, content, (Commit2DBJavaScript) javaScript); + } + } + } + + private static void dealCommit2DBJS(List jsInfos, ITContent content, Commit2DBJavaScript javaScript) { + if (!javaScript.getDBManipulation().isEmpty()) { + //处理回调函数 + dealWithCallBack(jsInfos, content, javaScript); + } + } + + private static void dealWithCallBack(List jsInfos, ITContent content, Commit2DBJavaScript commit2DBJavaScript) { + JavaScript javaScript = commit2DBJavaScript.getCallBack(); + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Set_Callback_Function") + ); + if (javaScript instanceof JavaScriptImpl) { + newContent.setReplaceObject(javaScript); + jsInfos.add(new JSInfo(newContent)); + } else if (javaScript instanceof Commit2DBJavaScript){ + dealCommit2DBJS(jsInfos, newContent, (Commit2DBJavaScript) javaScript); + } + } + + + /** + * 获取HtmlLabel数组 + * + * @param collection + * @return + */ + public static List> getHtmlLabel(ChartCollection collection) { + ArrayList> arrayList = new ArrayList<>(); + addHtmlLabel2Array(arrayList, collection); + return arrayList; + } + + /** + * 获取图表-样式-标签、图表-样式-提示以及图表-特效-条件显示中的HtmlLabel并加入数组 + * + * @param arrayList + * @param collection + */ + private static void addHtmlLabel2Array(List> arrayList, ChartCollection collection) { + for (int i = 0; i < collection.getChartCount(); i++) { + if (collection.getChart(i) instanceof VanChart) { + VanChart chart = ((VanChart) collection.getChart(i)); + int size = chart.getPlot().getConditionCollection().getConditionAttrSize(); + ConditionCollection conditionCollection = chart.getPlot().getConditionCollection(); + addAttrLabelHtmlLabel(chart, arrayList); + for (int j = 0; j < size; j++) { + searchConditionCollection(arrayList, conditionCollection.getConditionAttr(j)); + } + } + } + } + + /** + * 将图表-样式-标签以及图表-样式-提示中的HtmlLabel加入数组 + * + * @param chart + * @param arrayList + */ + private static void addAttrLabelHtmlLabel(VanChart chart, List> arrayList) { + VanChartPlot plot = chart.getPlot(); + addAttrToolTipCondition2Array(plot, arrayList); + if (isAttrLabelExist(plot)) { + addAttrLabelDetail2Array(plot, arrayList); + addAttrSecondLabelDetail2Array(plot, arrayList); + + } + + } + + private static void addAttrToolTipCondition2Array(VanChartPlot plot, List> arrayList) { + if (isToolTipValid(plot)) { + arrayList.add(new Pair<>(((AttrTooltip) plot.getAttrTooltipFromConditionCollection()).getContent().getHtmlLabel(), + Toolkit.i18nText("Fine-Design_Chart_Tooltip") + "-" + Toolkit.i18nText("Fine-Design_Basic_Custom"))); + } + } + + private static boolean isToolTipValid(VanChartPlot plot) { + return plot.getAttrTooltipFromConditionCollection() != null && ((AttrTooltip) plot.getAttrTooltipFromConditionCollection()).isEnable() && plot.getAttrTooltipFromConditionCollection() instanceof AttrTooltip; + } + + private static void addAttrLabelDetail2Array(VanChartPlot plot, List> arrayList) { + if (isLabelDetailValid(plot)) { + arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel(), Toolkit.i18nText("Fine-Design_Chart_Value_Label"))); + } + } + + private static boolean isLabelDetailValid(VanChartPlot plot) { + return plot.getAttrLabelFromConditionCollection() != null + && plot.getAttrLabelFromConditionCollection().getAttrLabelDetail() != null + && plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel() != null; + } + + private static void addAttrSecondLabelDetail2Array(VanChartPlot plot, List> arrayList) { + if (isSecondLabelDetailValid(plot)) { + arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getSecondLabelDetail().getContent().getHtmlLabel(), Toolkit.i18nText("Fine-Design_Chart_Category_Label"))); + } + } + + private static boolean isSecondLabelDetailValid(VanChartPlot plot) { + return plot.getAttrLabelFromConditionCollection() != null + && plot.getAttrLabelFromConditionCollection().getSecondLabelDetail() != null + && plot.getAttrLabelFromConditionCollection().getSecondLabelDetail().getContent().getHtmlLabel() != null; + } + + private static boolean isAttrLabelExist(VanChartPlot plot) { + return plot.getAttrLabelFromConditionCollection() != null && plot.getAttrLabelFromConditionCollection().isEnable(); + } + + /** + * 将图表-特效-条件显示中的HtmlLabel加入数组 + * + * @param arrayList + * @param conditionAttr + */ + private static void searchConditionCollection(List> arrayList, ConditionAttr conditionAttr) { + int conditionSize = conditionAttr.getDataSeriesConditionCount(); + for (int t = 0; t < conditionSize; t++) { + DataSeriesCondition condition = conditionAttr.getDataSeriesCondition(t); + String str = Toolkit.i18nText("Fine-Design_Chart_Animation_Special") + "-" + Toolkit.i18nText("Fine-Design_Chart_Condition_Display"); + if (StringUtils.isNotEmpty(conditionAttr.getName())) { + str += "-" + conditionAttr.getName(); + } + if (condition instanceof AttrTooltip) { + arrayList.add(new Pair<>(((AttrTooltip) condition).getContent().getHtmlLabel(), str + "-" + Toolkit.i18nText("Fine-Design_Chart_Data_Point_Tooltip"))); + } + if (condition instanceof AttrLabel) { + AttrLabel label = (AttrLabel) condition; + if (isAttrLabelValid(label)) { + arrayList.add(new Pair<>(label.getContent().getHtmlLabel(), str + "-" + Toolkit.i18nText("Fine-Design_Chart_Label"))); + } + } + + } + } + + private static boolean isAttrLabelValid(AttrLabel label) { + return label.isEnable() && label.getContent() != null && label.getContent().getHtmlLabel() != null; + } + + /** + * 获取图表-特效-交互属性中的JS + * + * @param chartCollection + * @return + */ + public static List getNameJavaScript(ChartCollection chartCollection) { + ArrayList nameJavaScriptArrayList = new ArrayList<>(); + for (int i = 0; i < chartCollection.getChartCount(); i++) { + if (chartCollection.getChart(i) instanceof VanChart) { + VanChart chart = ((VanChart) chartCollection.getChart(i)); + NameJavaScriptGroup nameJavaScriptGroup = chart.getPlot().getHotHyperLink(); + addNameJavaScript2Array(nameJavaScriptArrayList, nameJavaScriptGroup); + } + } + return nameJavaScriptArrayList; + } + + private static void addNameJavaScript2Array(List nameJavaScriptArrayList, NameJavaScriptGroup nameJavaScriptGroup) { + if (isNameJavaScriptGroupExist(nameJavaScriptGroup)) { + for (int j = 0; j < nameJavaScriptGroup.size(); j++) { + if (nameJavaScriptGroup.getNameHyperlink(j).getJavaScript() instanceof JavaScriptImpl) { + nameJavaScriptArrayList.add(nameJavaScriptGroup.getNameHyperlink(j)); + } + } + } + } + + private static boolean isNameJavaScriptGroupExist(NameJavaScriptGroup nameJavaScriptGroup) { + return nameJavaScriptGroup != null; + } + + /** + * 添加JSInfo到列表 + * + * @param jsInfos + * @param jsInfo + */ + public static void addJSInfos(List jsInfos, JSInfo jsInfo) { + jsInfo.setContent(ITContent.copy(jsInfo.getContent())); + jsInfos.add(jsInfo); + } + + + /** + * 从HtmlLabel去获取JS + * 从图表-样式-标签以及图表-特效-条件显示获取JSInfo + * + * @param content + * @param htmlLabels + * @param jsInfos + */ + public static void addJSInfosFromHtmlLabel(ITContent content, List> htmlLabels, List jsInfos) { + if (ShowValueUtils.isNotEmpty(htmlLabels)) { + for (Pair pair : htmlLabels) { + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos(GeneralUtils.objectToString(pair.getSecond())); + newContent.setReplaceObject(pair.getFirst()); + SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent)); + } + } + } + + /** + * 从NameJS类型里面拿JS + * + * @param content + * @param nameJavaScripts + * @param jsInfos + */ + public static void addJSInfosFromNameJS(ITContent content, List nameJavaScripts, List jsInfos) { + if (ShowValueUtils.isNotEmpty(nameJavaScripts)) { + for (NameJavaScript nameJS : nameJavaScripts) { + ITContent newContent = ITContent.copy(content); + newContent.setReplaceObject(nameJS); + newContent.addOtherPos(nameJS.getName()); + SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent)); + + } + } + } + + /** + * 从超级链接里面拿JS + * + * @param elem + * @param jsInfos + * @param content + */ + public static void addJSInfosFromHyperLink(Elem elem, List jsInfos, ITContent content) { + if (elem.getNameHyperlinkGroup() != null) { + for (int j = 0; j < elem.getNameHyperlinkGroup().size(); j++) { + NameJavaScript nameJavaScript = elem.getNameHyperlinkGroup().getNameHyperlink(j); + JavaScript javaScript = nameJavaScript.getJavaScript(); + if (javaScript instanceof JavaScriptImpl) { + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Hyperlink")); + newContent.setReplaceObject(nameJavaScript); + newContent.addOtherPos(nameJavaScript.getName()); + SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent)); + } else if (isChartHyperPopLinkValid(javaScript)) { + ITContent chartContent = ITContent.copy(content); + chartContent.addOtherPos(nameJavaScript.getName()); + ChartCollection chartCollection = (ChartCollection) ((ChartHyperPoplink) javaScript).getChartCollection(); + SearchChartJSAction.getInstance().searchChartJS(chartCollection, chartContent, jsInfos); + } + } + } + } + + /** + * 是否图表悬浮超链且内部图表是否可用 + * + * @param javaScript + * @return + */ + private static boolean isChartHyperPopLinkValid(JavaScript javaScript) { + return javaScript instanceof ChartHyperPoplink && ((ChartHyperPoplink) javaScript).getChartCollection() instanceof ChartCollection; + } + + /** + * 从Action中拿JS + * + * @param jsInfos + * @param content + */ + public static void selectJSAction(List jsInfos, ITContent content) { + for (int i = 0; i < ((Widget) (content.getReplaceObject())).getListenerSize(); i++) { + Listener listener = ((Widget) (content.getReplaceObject())).getListener(i); + ITContent newContent = ITContent.copy(content); + newContent.addOtherPos(listener.getName()); + newContent.setReplaceObject(listener); + SearchJSUtils.searchJSFromListener(jsInfos, newContent); + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java new file mode 100644 index 0000000000..b7b46539b3 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java @@ -0,0 +1,304 @@ +package com.fr.design.actions.replace.utils; + + +import com.fr.design.actions.replace.ui.ITReplaceMainDialog; +import com.fr.stable.StringUtils; +import com.fr.stable.collections.combination.Pair; + + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + + +/** + * 用来处理展示内容的工具类(截取、高亮) + * + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-08-23 + */ +public class ShowValueUtils { + + public static final String ANY_THING = "?"; + public static final String NUMBER = "#"; + public static final String ENGLISH = "$"; + public static final String ANY_THING_REGEX = "."; + public static final String NUMBER_REGEX = "[0-9]"; + public static final String ENGLISH_REGEX = "[a-zA-Z]"; + public static final char LEFT_HTML_CHAR = '<'; + public static final char RIGHT_HTML_CHAR = '>'; + public static final String HEAD = ""; + public static final String TAIL = ""; + public static final String FONT_HEAD = ""; + public static final String FONT_TAIL = ""; + public static final String HTML = ""; + public static final String NOBR = ""; + public static final String HTML_TAIL = ""; + public static final String NOBR_TAIL = ""; + public static final int HEAD_LEN = HEAD.length(); + public static final int TAIL_LEN = TAIL.length(); + public static final int FONT_HEAD_LEN = FONT_HEAD.length(); + public static final int FONT_TAIL_LEN = FONT_TAIL.length(); + public static final int HTML_LEN = HTML.length(); + public static final int HTML_TAIL_LEN = HTML_TAIL.length(); + public static final int NOBR_LEN = NOBR.length(); + public static final int NOBR_TAIL_LEN = NOBR_TAIL.length(); + /** + * <转变为<的长度差 + */ + public static final int LEFT_DIFFERENT = 3; + /** + * >转变为>的长度差 + */ + public static final int RIGHT_DIFFERENT = 2; + + public static Pattern containPattern; + private static List specialCharList = new ArrayList<>(); + + static { + //正则特殊字符:? * () [] {} ^ $ . \ + | + //如果是? 并采用通配符 ,会自动转成“.” 所以 ? 不用处理 + //$同理 + specialCharList.add("\\"); + specialCharList.add("/"); + specialCharList.add("*"); + specialCharList.add("("); + specialCharList.add(")"); + specialCharList.add("["); + specialCharList.add("]"); + specialCharList.add("{"); + specialCharList.add("}"); + specialCharList.add("^"); + specialCharList.add("."); + specialCharList.add("+"); + specialCharList.add("|"); + specialCharList.add("!"); + + } + + /** + * 获取除内容外其他一次性展示所有的内容(名称、水印...) + * + * @param str + * @param searchStr + * @return + */ + public static String getCommonString(String str, String searchStr) { + if (StringUtils.isEmpty(searchStr)) { + return str; + } else { + return updateHighlight(str, searchStr); + } + } + + /** + * 替换策略 + * + * @param str 原字符串 + * @param regex 要被替换的内容 + * @param replacement 要用来替换进去的内容 + * @return 替换后的字符串 + */ + public static String replaceAll(String str, String regex, String replacement) { + if (ITReplaceMainDialog.isMatched()) { + return str.replaceAll(changeRegex(regex), replacement); + } else { + return str.replace(regex, replacement); + } + } + + /** + * 转换正则表达式 + * + * @param regexStr + * @return + */ + public static String changeRegex(String regexStr) { + String change = "\\"; + for (int i = 0; i < specialCharList.size(); i++) { + regexStr = regexStr.replace(specialCharList.get(i), change + specialCharList.get(i)); + } + regexStr = regexStr.replace(NUMBER, NUMBER_REGEX); + regexStr = regexStr.replace(ENGLISH, ENGLISH_REGEX); + regexStr = regexStr.replace(ANY_THING, ANY_THING_REGEX); + return regexStr; + } + + /** + * 获取匹配的字符串的位置(开始位置,结束位置) + * + * @param str 原字符串 + * @param find 要查找的内容 + * @return 存储匹配的字符串的位置的列表 + */ + public static List> getStringStartAndEndIndex(String str, String find) { + List> pairs = new ArrayList<>(); + //定义该变量用于记录匹配元素前面的长度 + int frontLength = 0; + StringBuffer result = new StringBuffer(); + if (StringUtils.isEmpty(find)) { + return pairs; + } + //只要该str字符串中有匹配的元素,才进行以下操作 + while (str.contains(find)) { + //定义该变量用于记录匹配的元素在当前字符串的位置 + int index = str.indexOf(find); + pairs.add(new Pair<>(index + frontLength, index + frontLength + find.length())); + frontLength += (index + find.length()); + //将字符串中匹配元素的前面部分及其本身截取,留下后面的部分 + str = str.substring(index + find.length()); + + } + return pairs; + } + + + /** + * 更新高亮 + * + * @param str + * @param searchStr + * @return + */ + public static String updateHighlight(String str, String searchStr) { + if (ITReplaceMainDialog.isMatched()) { + String result = str; + Pattern pattern = containPattern; + Matcher matcher = pattern.matcher(str); + int size = FONT_HEAD.length() + FONT_TAIL.length(); + int index = 0; + StringBuilder builder = new StringBuilder(str); + while (matcher.find()) { + builder.replace(matcher.start() + index, matcher.end() + index, FONT_HEAD + changeHtmlStr(matcher.group()) + FONT_TAIL); + index += size; + index += getIncreaseCount(matcher.group()); + } + + return changeOriginHtmlStr(HEAD + builder.toString() + TAIL); + } else { + String ans = HEAD + replaceAll(str, searchStr, FONT_HEAD + changeHtmlStr(searchStr) + FONT_TAIL) + TAIL; + return changeOriginHtmlStr(ans); + } + } + + /** + * 用于处理原字符串中的尖括号 + */ + private static String changeOriginHtmlStr(String str) { + int count = 0; + StringBuilder builder = new StringBuilder(str); + for (int i = 0; i < str.length(); i++) { + char c = str.charAt(i); + if (c == LEFT_HTML_CHAR) { + if (!checkValid(str, i)) { + builder.replace(i + count, i + count + 1, "<"); + count += LEFT_DIFFERENT; + } + } + } + return builder.toString(); + } + + private static boolean checkValid(String str, int i) { + int leftLen = str.length() - (i + 1); + return checkStrValid(str, i, leftLen, HTML_LEN, HTML) || + checkStrValid(str, i, leftLen, HTML_TAIL_LEN, HTML_TAIL) || + checkStrValid(str, i, leftLen, FONT_HEAD_LEN, FONT_HEAD) || + checkStrValid(str, i, leftLen, FONT_TAIL_LEN, FONT_TAIL) || + checkStrValid(str, i, leftLen, NOBR_LEN, NOBR) || + checkStrValid(str, i, leftLen, NOBR_TAIL_LEN, NOBR_TAIL); + } + + /** + * 是否是所指定的字符串 + * + * @param str + * @param i + * @param leftLen + * @return + */ + private static boolean checkStrValid(String str, int i, int leftLen, int len, String checkStr) { + if (leftLen < len - 1) { + return false; + } else { + return StringUtils.equals(str.substring(i, i + len), checkStr); + } + } + + + /** + * 用于处理搜索的字符中的尖括号 + * + * @param searchStr + * @return + */ + private static String changeHtmlStr(String searchStr) { + String showStr = searchStr; + showStr = showStr.replace("<", "<"); + showStr = showStr.replace(">", ">"); + return showStr; + } + + private static int getIncreaseCount(String str) { + int count = 0; + for (int i = 0; i < str.length(); i++) { + if (str.charAt(i) == LEFT_HTML_CHAR) { + count += LEFT_DIFFERENT; + } + if (str.charAt(i) == RIGHT_HTML_CHAR) { + count += RIGHT_DIFFERENT; + } + } + return count; + } + + /** + * 集合是否不为空 + * + * @param collection + * @return + */ + public static boolean isNotEmpty(Collection collection) { + return collection != null && collection.size() > 0; + } + + + /** + * 支持正则表达式的indexOf + * + * @param str + * @param regexStr + * @return + */ + public static int indexOf(String str, String regexStr) { + CharSequence inputStr = str; + int failReturn = -1; + Pattern pattern = containPattern; + Matcher matcher = pattern.matcher(inputStr); + if (matcher.find()) { + return matcher.start(); + } + return failReturn; + } + + /** + * 支持通配符的contains + * + * @param originStr + * @param matchStr + * @return + */ + public static boolean contains(String originStr, String matchStr) { + if (ITReplaceMainDialog.isMatched()) { + Pattern pattern = containPattern; + Matcher matcher = pattern.matcher(originStr); + return matcher.find(); + } else { + return originStr.contains(matchStr); + } + + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java index d0f6a114d8..a14573c6e4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/ReportComponentComposite.java @@ -2,6 +2,7 @@ package com.fr.design.mainframe; import com.fr.base.ScreenResolution; import com.fr.base.TRL; +import com.fr.design.actions.replace.ui.ITReplaceMainDialog; import com.fr.design.base.mode.DesignModeContext; import com.fr.design.designer.EditingState; import com.fr.design.event.RemoveListener; @@ -140,8 +141,8 @@ public class ReportComponentComposite extends JComponent implements RemoveListen Grid grid = centerCardPane.editingComponet.elementCasePane.getGrid(); this.centerCardPane.editingComponet.elementCasePane.getGrid().addMouseWheelListener(new ReportComponentCompositeMouseWheelHandler(this)); - - if (!grid.hasFocus() && grid.isRequestFocusEnabled()) { + //!ITReplaceMainDialog.isITReplaceFlag()用于解决查找替换面板闪烁问题 + if (!grid.hasFocus() && grid.isRequestFocusEnabled() && !ITReplaceMainDialog.isITReplaceFlag()) { grid.requestFocus(); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java b/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java index 0529cf82a3..629f71b6bb 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/WorkSheetDesigner.java @@ -217,9 +217,9 @@ public class WorkSheetDesigner extends ReportComponent selectedLabelList = new ArrayList<>(); AlphaFineConfigManager alphaFineConfigManager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager(); if (alphaFineConfigManager.isProductDynamics()) { - selectedLabelList.add(new SelectedLabel(PRODUCT_NEWS, CellType.PRODUCT_NEWS)); + selectedLabelList.add(new SelectedLabel(AlphaFineConstants.PRODUCT_NEWS, CellType.PRODUCT_NEWS)); } if (alphaFineConfigManager.hasTemplateShop()) { - selectedLabelList.add(new SelectedLabel(TEMPLATE_SHOP, CellType.TEMPLATE_SHOP)); + selectedLabelList.add(new SelectedLabel(AlphaFineConstants.TEMPLATE_SHOP, CellType.TEMPLATE_SHOP)); } if (alphaFineConfigManager.isContainDocument()) { - selectedLabelList.add(new SelectedLabel(HELP, CellType.DOCUMENT)); + selectedLabelList.add(new SelectedLabel(AlphaFineConstants.HELP, CellType.DOCUMENT)); } if (alphaFineConfigManager.isContainPlugin()) { - selectedLabelList.add(new SelectedLabel(PLUGIN, CellType.PLUGIN)); + selectedLabelList.add(new SelectedLabel(AlphaFineConstants.PLUGIN, CellType.PLUGIN)); } if (alphaFineConfigManager.isContainAction()) { - selectedLabelList.add(new SelectedLabel(FUNCTION, CellType.ACTION)); + selectedLabelList.add(new SelectedLabel(AlphaFineConstants.FUNCTION, CellType.ACTION)); } if (alphaFineConfigManager.isContainMyTemplate()) { - selectedLabelList.add(new SelectedLabel(MY_TEMPLATES, CellType.FILE)); + selectedLabelList.add(new SelectedLabel(AlphaFineConstants.MY_TEMPLATES, CellType.FILE)); } + // 根据设置排序 + sortList(selectedLabelList); // 默认选中第一个tab if (!selectedLabelList.isEmpty()) { selectedLabelList.get(0).setSelected(true); @@ -627,6 +622,19 @@ public class AlphaFineFrame extends JFrame { return selectedLabelList; } + /** + * 根据用户自定义的顺序排序 + * */ + private void sortList(List list) { + AlphaFineConfigManager alphaFineConfigManager = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager(); + String[] tabOrder = alphaFineConfigManager.getTabOrder(); + Map orderMap = new HashMap<>(); + for (int i = 0; i < tabOrder.length; i++) { + orderMap.put(tabOrder[i], i); + } + list.sort(Comparator.comparingInt(tab -> orderMap.get(tab.getText()))); + } + private void fireOneClickRead() { List productNewsList = ProductNewsSearchManager.getInstance().getCachedProductNewsList(); Set readSet = DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().getReadSet(); @@ -907,11 +915,12 @@ public class AlphaFineFrame extends JFrame { if (StringUtils.isEmpty(text)) { return; } - searchLoadingPane = new SearchLoadingPane(); + initSearchLoadingPane(); SearchTextBean searchTextBean = new SearchTextBean(text, segmentationResult); this.productNewsSearchWorkerManager.doSearch(searchTextBean); this.documentWorkerManager.doSearch(searchTextBean); this.pluginSearchWorkerManager.doSearch(searchTextBean); + this.templateResourceSearchWorkerManager.doSearch(searchTextBean); } /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineList.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineList.java index f4ffe50e39..6cad0e2e26 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineList.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineList.java @@ -1,15 +1,16 @@ package com.fr.design.mainframe.alphafine.component; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.DocumentModel; import com.fr.design.mainframe.alphafine.preview.ResultShowPane; + +import javax.swing.JList; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import javax.swing.JList; /** * @author hades diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java index b745b0de96..ccf6e6d5f0 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineTextField.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.alphafine.component; import com.fr.design.gui.itextfield.UITextField; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.RenderingHints; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipContentCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipContentCellRender.java index 1b439f1a83..395dec800f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipContentCellRender.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipContentCellRender.java @@ -1,20 +1,21 @@ package com.fr.design.mainframe.alphafine.component; import com.fr.base.svg.IconUtils; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineUtil; import com.fr.general.ComparatorUtils; import com.fr.stable.StringUtils; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; + import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.ListCellRenderer; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; /** * @author hades diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipList.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipList.java index 3d33337724..7f9edfaffc 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipList.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineToolTipList.java @@ -1,13 +1,14 @@ package com.fr.design.mainframe.alphafine.component; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.general.ComparatorUtils; + +import javax.swing.JList; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import javax.swing.JList; /** * @author hades diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaSearchTooltipPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaSearchTooltipPane.java index b07d506b8d..6682618766 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaSearchTooltipPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaSearchTooltipPane.java @@ -1,14 +1,14 @@ package com.fr.design.mainframe.alphafine.component; import com.fr.design.DesignerEnvManager; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.gui.icontainer.UIScrollPane; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; -import com.fr.stable.StringUtils; + +import javax.swing.DefaultListModel; +import javax.swing.JPanel; import java.awt.Color; import java.awt.Dimension; import java.util.Stack; -import javax.swing.DefaultListModel; -import javax.swing.JPanel; /** * @author hades diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsContentCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsContentCellRender.java index c6b5983d68..a8f51641c6 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsContentCellRender.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsContentCellRender.java @@ -1,21 +1,22 @@ package com.fr.design.mainframe.alphafine.component; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineUtil; import com.fr.design.mainframe.alphafine.model.ProductNews; import com.fr.design.utils.DesignUtils; + +import javax.swing.BorderFactory; +import javax.swing.JList; +import javax.swing.JPanel; +import javax.swing.ListCellRenderer; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Component; import java.awt.Dimension; import java.awt.Graphics; import java.text.SimpleDateFormat; -import javax.swing.BorderFactory; -import javax.swing.JList; -import javax.swing.JPanel; -import javax.swing.ListCellRenderer; /** * @author hades diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsList.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsList.java index 48dfa4b865..10921ff114 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsList.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsList.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.alphafine.component; import com.fr.design.DesignerEnvManager; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.model.ProductNews; import com.fr.design.utils.BrowseUtils; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsSearchResultPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsSearchResultPane.java index b3fd4dc958..5e29eed073 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsSearchResultPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/ProductNewsSearchResultPane.java @@ -1,13 +1,12 @@ package com.fr.design.mainframe.alphafine.component; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.gui.icontainer.UIScrollPane; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; import javax.swing.BorderFactory; import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; /** * @author hades diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchLabel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchLabel.java new file mode 100644 index 0000000000..f7e017024f --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchLabel.java @@ -0,0 +1,57 @@ +package com.fr.design.mainframe.alphafine.component; + +import com.fr.design.mainframe.alphafine.AlphaFineHelper; +import org.jetbrains.annotations.NotNull; + +import javax.swing.JLabel; +import javax.swing.JPanel; +import java.awt.Color; +import java.awt.FlowLayout; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.List; + +/** + * alphaFine - 推荐搜索词标签 + * + * @author Link + * @version 11.0 + * Created by Link on 2022/9/19 + */ +public class RecommendSearchLabel extends JPanel { + + private static final Color RECOMMEND_SEARCH_KEY_BLUE = new Color(0x419bf9); + + public RecommendSearchLabel(String title, @NotNull List tips) { + this.setLayout(new FlowLayout(FlowLayout.CENTER)); + this.setBackground(Color.WHITE); + JLabel recommend = new JLabel(title); + this.add(recommend); + + for (String key : tips) { + JLabel keyLabel = new SearchKeyLabel(key); + this.add(keyLabel); + } + } + + + /** + * 推荐搜索词,绑定alphaFine搜索事件 + */ + public class SearchKeyLabel extends JLabel { + String searchKey; + + SearchKeyLabel(String searchKey) { + this.searchKey = searchKey; + setText(searchKey); + setBackground(Color.WHITE); + setForeground(RECOMMEND_SEARCH_KEY_BLUE); + addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + AlphaFineHelper.getAlphaFineDialog().fireSearch(searchKey); + } + }); + } + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchPane.java index 41d4881605..8082d8e762 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchPane.java @@ -1,23 +1,16 @@ package com.fr.design.mainframe.alphafine.component; import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.model.TemplateResource; import javax.swing.BorderFactory; -import javax.swing.JLabel; -import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Color; -import java.awt.FlowLayout; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; import java.util.List; public class RecommendSearchPane extends TemplateResourcePanel { private static final Color BORDER_WHITE = new Color(0xe8e8e9); - private static final Color RECOMMEND_SEARCH_KEY_BLUE = new Color(0x419bf9); public RecommendSearchPane(TemplateResource templateResource) { super(); @@ -37,37 +30,11 @@ public class RecommendSearchPane extends TemplateResourcePanel { private void createCenterPane() { - setCenterPane(new JPanel(new FlowLayout(FlowLayout.LEFT))); - JPanel centerPane = getCenterPane(); - centerPane.setBackground(Color.WHITE); - JLabel recommend = new JLabel(Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Resource_Recommend_For_You")); - centerPane.add(recommend); + String recommend = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Resource_Recommend_For_You"); List searchKeys = getTemplateResource().getRecommendSearchKey(); - for (String key : searchKeys) { - JLabel keyLabel = new SearchKeyLabel(key); - centerPane.add(keyLabel); - } - } - - - class SearchKeyLabel extends JLabel { - String searchKey; - - SearchKeyLabel(String searchKey) { - this.searchKey = searchKey; - setText(searchKey); - setBackground(Color.WHITE); - setForeground(RECOMMEND_SEARCH_KEY_BLUE); - addMouseListener(new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - AlphaFineHelper.getAlphaFineDialog().fireSearch(searchKey); - } - }); - } - + setCenterPane(new RecommendSearchLabel(recommend, searchKeys)); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchHintPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchHintPane.java new file mode 100644 index 0000000000..83a2fdffcd --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchHintPane.java @@ -0,0 +1,80 @@ +package com.fr.design.mainframe.alphafine.component; + +import com.fr.base.svg.IconUtils; +import com.fr.common.util.Collections; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.i18n.Toolkit; +import com.fr.design.utils.DesignUtils; + +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.SwingConstants; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.util.ArrayList; +import java.util.List; + +/** + * alphafine - 搜索提示面板 + * + * @author Link + * @version 11.0 + * Created by Link on 2022/9/18 + */ +public class SearchHintPane extends JPanel { + + private static final String TITLE = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Search_Title"); + private static final String RECOMMEND = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Recommend_Search"); + private static final Icon ICON = IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/search_hint.svg"); + private static final int HEIGHT = 200; + private static final int WIDTH = 300; + private static final int TITLE_LABEL_HEIGHT = 30; + private static final int TITLE_FONT_SIZE = 14; + + public SearchHintPane() { + this(new ArrayList<>()); + } + + public SearchHintPane(List hints) { + this(hints, ICON, TITLE); + } + + public SearchHintPane(List hints, Icon icon, String title) { + setLayout(new BorderLayout()); + setBorder(BorderFactory.createEmptyBorder(40,0,0,0)); + setBackground(Color.white); + setPreferredSize(new Dimension(WIDTH, HEIGHT)); + setAlignmentY(SwingConstants.CENTER); + UILabel image = new UILabel(); + image.setPreferredSize(new Dimension(150, 111)); + image.setHorizontalAlignment(SwingConstants.CENTER); + image.setIcon(icon); + image.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + add(image, BorderLayout.NORTH); + add(generateDescription(title), BorderLayout.CENTER); + add(generateHintsLabel(hints), BorderLayout.SOUTH); + } + + protected Component generateDescription(String title) { + JLabel description = new JLabel(title); + description.setForeground(AlphaFineConstants.MEDIUM_GRAY); + description.setFont(DesignUtils.getDefaultGUIFont().applySize(TITLE_FONT_SIZE)); + description.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0)); + description.setHorizontalAlignment(SwingConstants.CENTER); + description.setPreferredSize(new Dimension(WIDTH, TITLE_LABEL_HEIGHT)); + return description; + } + + private Component generateHintsLabel(List hints) { + if (Collections.isEmpty(hints)) { + return new JLabel(); + } + return new RecommendSearchLabel(RECOMMEND, hints); + } + +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultContentCellRender.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultContentCellRender.java index dd65d36a2f..b3fe2dc5b7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultContentCellRender.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultContentCellRender.java @@ -1,19 +1,20 @@ package com.fr.design.mainframe.alphafine.component; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineUtil; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.general.IOUtils; import com.fr.stable.StringUtils; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; + import javax.swing.BorderFactory; import javax.swing.JList; import javax.swing.JPanel; import javax.swing.ListCellRenderer; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; /** * @author hades diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultPane.java index d4f6c18027..642a0da2b2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SearchResultPane.java @@ -1,13 +1,14 @@ package com.fr.design.mainframe.alphafine.component; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.gui.icontainer.UIScrollPane; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.design.mainframe.alphafine.preview.ResultShowPane; + +import javax.swing.JPanel; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; -import javax.swing.JPanel; /** * @author hades diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SelectedLabel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SelectedLabel.java index 9bf151adc9..4bc59fd935 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SelectedLabel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/SelectedLabel.java @@ -2,7 +2,7 @@ package com.fr.design.mainframe.alphafine.component; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineUtil; import com.fr.design.mainframe.alphafine.CellType; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePanel.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePanel.java index 967f0a41ff..31652c405d 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePanel.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePanel.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.alphafine.component; +import com.fr.common.util.Strings; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.alphafine.model.TemplateResource; import com.fr.design.mainframe.alphafine.preview.TemplateShopPane; @@ -93,11 +94,8 @@ public class TemplateResourcePanel extends JPanel { } private void createCenterPane() { - JLabel nameLabel = new JLabel(templateResource.getName()); - nameLabel.setFont(RESOURCE_NAME_FONT); - nameLabel.setForeground(RESOURCE_NAME_COLOR); - nameLabel.setBackground(Color.WHITE); - nameLabel.setBorder(BorderFactory.createEmptyBorder()); + JLabel nameLabel = createHtmlNameLabel(); + JLabel demoLabel = new JLabel(); if (templateResource.hasDemoUrl()) { @@ -121,6 +119,26 @@ public class TemplateResourcePanel extends JPanel { centerPane.add(demoLabel, BorderLayout.EAST); } + + private static final String SEARCH_WORD_FORMAT = "%s"; + private static final String HTML_JLABEL_FORMAT = "%s"; + + private JLabel createHtmlNameLabel() { + JLabel label = new JLabel(); + String htmlText = templateResource.getName(); + String searchWord = templateResource.getSearchWord(); + if (!Strings.isEmpty(searchWord) && htmlText.contains(searchWord)) { + htmlText = htmlText.replace(searchWord, String.format(SEARCH_WORD_FORMAT, searchWord)); + } + htmlText = String.format(HTML_JLABEL_FORMAT, htmlText); + label.setText(htmlText); + label.setFont(RESOURCE_NAME_FONT); + label.setForeground(RESOURCE_NAME_COLOR); + label.setBackground(Color.WHITE); + label.setBorder(BorderFactory.createEmptyBorder()); + return label; + } + @Override public Dimension getPreferredSize() { return new Dimension(180, 90); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketConstants.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketConstants.java index f17095b093..f9d80238b5 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketConstants.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketConstants.java @@ -7,4 +7,5 @@ public class FineMarketConstants { public static final String RAR = ".rar"; public static final String CPT = ".cpt"; public static final String FRM = ".frm"; + public static final String FVS = ".fvs"; } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketDownloadManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketDownloadManager.java index c95ee8bde8..bc195865ac 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketDownloadManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketDownloadManager.java @@ -11,8 +11,9 @@ import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.model.TemplateResource; import com.fr.design.mainframe.alphafine.search.helper.FineMarketClientHelper; import com.fr.design.mainframe.toast.SimpleToast; +import com.fr.file.FileCommonUtils; +import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; -import com.fr.third.jodd.io.ZipUtil; import javax.swing.SwingUtilities; import javax.swing.filechooser.FileSystemView; @@ -80,7 +81,8 @@ public class FineMarketDownloadManager { if (fileName.endsWith(FineMarketConstants.ZIP)) { File file = new File(fileName); File parentDir = file.getParentFile(); - ZipUtil.unzip(file, parentDir); + // TODO:之前用的gbk解码太容易乱码了。这里应该自动识别编码,然后解压,但是要添加1个三方包,可能会赶不上发布。所以先暂时用utf8顶着。 + IOUtils.unzip(file, FileCommonUtils.getAbsolutePath(parentDir), "UTF-8"); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResource.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResource.java index b7ace8a3fc..9d55feb892 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResource.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResource.java @@ -65,6 +65,12 @@ public class TemplateResource { private List recommendSearchKey; private boolean embed; + + + /// 其他属性 + // 当前搜索词 + private String searchWord; + public static List createByJson(JSONArray jsonArray) { List list = new ArrayList<>(); if (jsonArray != null) { @@ -219,4 +225,12 @@ public class TemplateResource { this.uuid = uuid; return this; } + + public String getSearchWord() { + return searchWord; + } + + public void setSearchWord(String searchWord) { + this.searchWord = searchWord; + } } \ No newline at end of file diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResourceDetail.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResourceDetail.java index 5065f6a2b4..0a1d98449c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResourceDetail.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResourceDetail.java @@ -8,9 +8,10 @@ import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; -import java.util.ArrayList; import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -169,7 +170,7 @@ public class TemplateResourceDetail { JSONObject resource = embedResources.getJSONObject(i); if (resourceId.equals(resource.getString(ID))) { detail.setInfo(resource.getString(INFO)); - detail.setHtmlText(resource.getString(DETAIL_INFO)); + detail.setHtmlText(reformat(resource.getString(DETAIL_INFO))); detail.setVendor(resource.getString(VENDOR)); detail.setPrice(resource.getDouble(PRICE)); detail.setResourceUrl(resource.getString(URL)); @@ -191,7 +192,7 @@ public class TemplateResourceDetail { // 1请求详细信息 JSONObject info = helper.getTemplateInfoById(resourceId); detail.setInfo(info.getString(INFO)); - detail.setHtmlText(info.getString(DETAIL_INFO)); + detail.setHtmlText(reformat(info.getString(DETAIL_INFO))); detail.setVendor(info.getString(VENDOR)); detail.setTagsId(info.getString(TAGS_ID).split(",")); detail.setPrice(info.getDouble(PRICE)); @@ -214,25 +215,36 @@ public class TemplateResourceDetail { return null; } + + static final String A_TAG_FORMAT = "%s"; + static final String HTML_TAG_REGX="<[^>]+>"; + static final Pattern A_TAG_PATTERN = Pattern.compile("]*href=(\\\"([^\\\"]*)\\\"|\\'([^\\']*)\\'|([^\\\\s>]*))[^>]*>(.*?)"); + static final Pattern HTML_TAG_PATTERN = Pattern.compile(HTML_TAG_REGX); + /** - * 这里做下数据转换 - * 原始数据是html标签写的,如下 - * "

  1. 该模板需用10.0及以上版本设计器预览

  2. 该模板为库存场景解决方案的部分内容,全部内容可下载库存场景解决方案查看

  3. 为保障模板预览效果,建议安装新自适应插件(FR11.0版本插件已内置,无需手动安装),有使用需求或疑问,请联系帆软技术支持咨询

", - * - * 转换的后的数据 是原始数据中所有

标签内的(包括标签)的字符串(List),如上字符串会转为如下 - * List [

该模板需用10.0及以上版本设计器预览

, - *

该模板为库存场景解决方案的部分内容,全部内容可下载库存场景解决方案查看

, - *

为保障模板预览效果,建议安装新自适应插件(FR11.0版本插件已内置,无需手动安装),有使用需求或疑问,请联系帆软技术支持咨询

- * ] + * 数据格式转换 + * 原始数据的格式不统一,纯文本、html都有; 统一转为纯文本,如果有a标签则保留 * */ - static final Pattern htmlPattern = Pattern.compile("

(.+?)

"); - static List parseDetailInfo(String htmlDetailInfo) { - List infos = new ArrayList<>(); - Matcher matcher = htmlPattern.matcher(htmlDetailInfo); + static String reformat(String htmlDetailInfo) { + String result = HTML_TAG_PATTERN.matcher(htmlDetailInfo).replaceAll(""); + Map aMap = getLink(htmlDetailInfo); + for (Map.Entry entry : aMap.entrySet()) { + String aTag = String.format(A_TAG_FORMAT, entry.getValue(), entry.getKey()); + result = result.replace(entry.getKey(), aTag); + } + return result; + } + + /** + * 读取dom中的a标签,转换为map + */ + static Map getLink(String html) { + Map map = new HashMap<>(); + Matcher matcher = A_TAG_PATTERN.matcher(html); while (matcher.find()) { - infos.add(matcher.group()); + map.put(matcher.group(5), matcher.group(1)); } - return infos; + return map; } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultContentPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultContentPane.java new file mode 100644 index 0000000000..99c312e882 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultContentPane.java @@ -0,0 +1,57 @@ +package com.fr.design.mainframe.alphafine.preview; + +import com.fr.design.actions.help.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.CellType; +import com.fr.design.mainframe.alphafine.component.AlphaFineFrame; +import com.fr.design.mainframe.alphafine.component.SearchHintPane; +import com.fr.design.mainframe.alphafine.search.SearchWorkerManager; +import com.fr.design.mainframe.alphafine.search.manager.SearchProviderRegistry; + +import javax.swing.JPanel; +import java.awt.BorderLayout; + +/** + * alphaFine - 默认展示页面 + * + * @author Link + * @version 11.0 + * Created by Link on 2022/9/18 + */ +public class DefaultContentPane extends JPanel { + + // 左边展示内容,右边展示搜索提示 + private SearchWorkerManager searchWorkerManager; + private CellType cellType; + + public DefaultContentPane(CellType cellType, AlphaFineFrame parentWindow) { + this.setLayout(new BorderLayout()); + this.setPreferredSize(AlphaFineConstants.PREVIEW_SIZE); + this.searchWorkerManager = new SearchWorkerManager( + cellType, + searchTextBean -> SearchProviderRegistry.getSearchProvider(cellType).getDefaultResult(), + parentWindow, + new SimpleRightSearchResultPane(new SearchHintPane()) + ); + this.searchWorkerManager.showDefault(this); + } + + /** + * 显示搜索结果 + */ + public void showResult(JPanel result) { + add(result); + repaint(); + } + + public DefaultContentPane() { + + } + + public CellType getCellType() { + return cellType; + } + + public void setCellType(CellType cellType) { + this.cellType = cellType; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultPluginContentPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultPluginContentPane.java new file mode 100644 index 0000000000..9ed5003d36 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultPluginContentPane.java @@ -0,0 +1,120 @@ +package com.fr.design.mainframe.alphafine.preview; + +import com.fr.design.actions.help.alphafine.AlphaFineConstants; +import com.fr.design.mainframe.alphafine.AlphaFineHelper; +import com.fr.design.mainframe.alphafine.CellType; +import com.fr.design.mainframe.alphafine.component.AlphaFineFrame; +import com.fr.design.mainframe.alphafine.component.SearchHintPane; +import com.fr.design.mainframe.alphafine.search.SearchWorkerManager; +import com.fr.design.mainframe.alphafine.search.manager.SearchProviderRegistry; +import com.fr.general.CloudCenter; +import com.fr.log.FineLoggerFactory; + +import javax.swing.JPanel; +import javax.swing.SwingWorker; +import java.awt.CardLayout; +import java.util.ArrayList; +import java.util.List; + +/** + * alphafine插件默认页 + * + * @author Link + * @version 11.0 + * Created by Link on 2022/9/18 + */ +public class DefaultPluginContentPane extends DefaultContentPane { + + private static final String[] HINTS = CloudCenter.getInstance().acquireConf("alphafine.plugin.recommend", "JS,API,JSON").split(","); + private static final String LOADING_PANE = "loading"; + private static final String NETWORK_ERROR = "networkError"; + private static final String RESULT_PANE = "result"; + private SearchWorkerManager searchWorkerManager; + private CellType cellType; + private AlphaFineFrame parentWindow; + private CardLayout cardLayout; + private SearchLoadingPane searchLoadingPane; + private NetWorkFailedPane netWorkFailedPane; + private SwingWorker worker; + + + public DefaultPluginContentPane(CellType cellType, AlphaFineFrame parentWindow) { + super(); + this.cellType = cellType; + this.parentWindow = parentWindow; + this.cardLayout = new CardLayout(); + this.setLayout(cardLayout); + this.setPreferredSize(AlphaFineConstants.PREVIEW_SIZE); + initPanel(); + add(searchLoadingPane, LOADING_PANE); + add(netWorkFailedPane, NETWORK_ERROR); + worker = createWorker(); + worker.execute(); + } + + private void initPanel() { + this.searchLoadingPane = new SearchLoadingPane(); + this.netWorkFailedPane = new NetWorkFailedPane(()-> reload()); + } + + private void switchPane(String tag) { + cardLayout.show(this, tag); + } + + private SwingWorker createWorker() { + return new SwingWorker() { + @Override + protected Boolean doInBackground() throws Exception { + switchPane(LOADING_PANE); + return AlphaFineHelper.isNetworkOk(); + } + + @Override + protected void done() { + super.done(); + try { + boolean networkOk = get(); + if (!networkOk) { + switchPane(NETWORK_ERROR); + } else { + List searchKeys = new ArrayList<>(); + for (String s : HINTS) { + searchKeys.add(s); + } + searchWorkerManager = new SearchWorkerManager( + cellType, + searchTextBean -> SearchProviderRegistry.getSearchProvider(cellType).getDefaultResult(), + parentWindow, + new SimpleRightSearchResultPane(new SearchHintPane(searchKeys)) + ); + searchWorkerManager.showDefault(DefaultPluginContentPane.this); + } + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + } + }; + } + + @Override + public void showResult(JPanel result) { + add(result, RESULT_PANE); + switchPane(RESULT_PANE); + } + + /** + * 网络异常时,重新加载 + */ + public void reload() { + worker = createWorker(); + worker.execute(); + } + + public CellType getCellType() { + return cellType; + } + + public void setCellType(CellType cellType) { + this.cellType = cellType; + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultProductNewsPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultProductNewsPane.java index d70e37ec04..e32e6dd249 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultProductNewsPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DefaultProductNewsPane.java @@ -1,9 +1,9 @@ package com.fr.design.mainframe.alphafine.preview; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.component.ProductNewsContentCellRender; import com.fr.design.mainframe.alphafine.component.ProductNewsList; @@ -12,14 +12,15 @@ import com.fr.design.mainframe.alphafine.model.ProductNews; import com.fr.design.mainframe.alphafine.search.manager.impl.ProductNewsSearchManager; import com.fr.design.utils.DesignUtils; import com.fr.log.FineLoggerFactory; -import java.awt.BorderLayout; -import java.awt.Color; -import java.util.List; + import javax.swing.BorderFactory; import javax.swing.DefaultListModel; import javax.swing.ImageIcon; import javax.swing.JPanel; import javax.swing.SwingWorker; +import java.awt.BorderLayout; +import java.awt.Color; +import java.util.List; /** * @author hades diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java index 6aa46f1a63..70e69f57f2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/DocumentPreviewPane.java @@ -2,7 +2,7 @@ package com.fr.design.mainframe.alphafine.preview; import com.fr.design.gui.itextarea.UITextArea; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import javax.swing.*; import java.awt.*; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java index 1ba7a5b915..1548aeb7b9 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/FilePreviewPane.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.alphafine.preview; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import javax.swing.*; import java.awt.*; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java index 961d490e58..bee71f5859 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/HelpDocumentNoResultPane.java @@ -1,9 +1,9 @@ package com.fr.design.mainframe.alphafine.preview; +import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants; import com.fr.design.constants.UIConstants; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.utils.BrowseUtils; import com.fr.design.utils.DesignUtils; @@ -13,6 +13,12 @@ import com.fr.json.JSONFactory; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; +import javax.swing.BorderFactory; +import javax.swing.Icon; +import javax.swing.JPanel; +import javax.swing.JSeparator; +import javax.swing.SwingConstants; +import javax.swing.SwingWorker; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Cursor; @@ -22,12 +28,6 @@ import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.LinkedHashMap; import java.util.Map; -import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.JPanel; -import javax.swing.JSeparator; -import javax.swing.SwingConstants; -import javax.swing.SwingWorker; /** * @author hades @@ -98,7 +98,7 @@ public class HelpDocumentNoResultPane extends JPanel { private Map generateMap() { - JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY, AlphaFineConstants.ALPHA_HELP_RECOMMEND); + JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY, AlphaFineCloudConstants.getAlphaHelpRecommend()); Map linkMap = new LinkedHashMap<>(); for (int i = 0, len = jsonArray.size(); i < len; i++) { JSONObject json = jsonArray.getJSONObject(i); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/LoadingRightSearchResultPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/LoadingRightSearchResultPane.java index 6201c25e58..916c7307a6 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/LoadingRightSearchResultPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/LoadingRightSearchResultPane.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.alphafine.preview; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.FileModel; @@ -11,6 +11,11 @@ import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; import com.fr.workspace.server.exporter.LocalExportOperator; import com.fr.workspace.server.exporter.TemplateExportOperator; + +import javax.imageio.ImageIO; +import javax.swing.BorderFactory; +import javax.swing.ImageIcon; +import javax.swing.SwingWorker; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; @@ -18,10 +23,6 @@ import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; import java.util.concurrent.ExecutionException; -import javax.imageio.ImageIO; -import javax.swing.BorderFactory; -import javax.swing.ImageIcon; -import javax.swing.SwingWorker; /** * @author hades diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NetWorkFailedPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NetWorkFailedPane.java index eb4c107c46..1dda65942c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NetWorkFailedPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NetWorkFailedPane.java @@ -3,7 +3,7 @@ package com.fr.design.mainframe.alphafine.preview; import com.fr.design.gui.ilable.UILabel; import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.share.ui.base.MouseClickListener; import com.fr.general.IOUtils; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultPane.java index db92821186..33fb600f1a 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultPane.java @@ -1,17 +1,16 @@ package com.fr.design.mainframe.alphafine.preview; -import com.bulenkov.iconloader.IconLoader; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.utils.DesignUtils; -import java.awt.Component; import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.JPanel; import javax.swing.SwingConstants; import java.awt.BorderLayout; import java.awt.Color; +import java.awt.Component; import java.awt.Dimension; /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java index 3dc4a44b2a..0159959de2 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/NoResultWithLinkPane.java @@ -1,15 +1,17 @@ package com.fr.design.mainframe.alphafine.preview; +import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.dialog.link.MessageWithLink; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.utils.BrowseUtils; import com.fr.design.utils.DesignUtils; -import java.awt.Color; -import java.awt.Component; + import javax.swing.BorderFactory; import javax.swing.Icon; import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkListener; +import java.awt.Color; +import java.awt.Component; /** * 带跳转链接的无结果面板 @@ -32,7 +34,7 @@ public class NoResultWithLinkPane extends NoResultPane { String[] para1 = title.split(TAG_A_START); String[] para2 = para1[1].split(TAG_A_END); - MessageWithLink messageWithLink = new MessageWithLink(para1[0], para2[0], AlphaFineConstants.ALPHA_GO_TO_FORUM, para2[1], Color.WHITE, DesignUtils.getDefaultGUIFont().applySize(14), AlphaFineConstants.MEDIUM_GRAY) { + MessageWithLink messageWithLink = new MessageWithLink(para1[0], para2[0], AlphaFineCloudConstants.getAlphaGoToForum(), para2[1], Color.WHITE, DesignUtils.getDefaultGUIFont().applySize(14), AlphaFineConstants.MEDIUM_GRAY) { @Override protected void initListener(String link) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java index 6f659055e4..dbe3126647 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/PluginPreviewPane.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.alphafine.preview; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.CellType; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java index f6a9f70767..2340766925 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/RobotPreviewPane.java @@ -1,9 +1,10 @@ package com.fr.design.mainframe.alphafine.preview; +import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.itextarea.UITextArea; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; import com.fr.design.mainframe.alphafine.cell.model.RobotModel; import com.fr.log.FineLoggerFactory; @@ -60,7 +61,7 @@ public class RobotPreviewPane extends JPanel { .replaceAll("\\('", StringUtils.EMPTY) .replaceAll("'\\)", StringUtils.EMPTY); try { - Desktop.getDesktop().browse(new URI(AlphaFineConstants.ALPHA_PREVIEW + URLEncoder.encode(s, EncodeConstants.ENCODING_UTF_8))); + Desktop.getDesktop().browse(new URI(AlphaFineCloudConstants.getAlphaPreview() + URLEncoder.encode(s, EncodeConstants.ENCODING_UTF_8))); } catch (IOException | URISyntaxException e1) { FineLoggerFactory.getLogger().error(e1.getMessage()); } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SearchLoadingPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SearchLoadingPane.java index e694708e88..17c2289794 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SearchLoadingPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SearchLoadingPane.java @@ -1,13 +1,12 @@ package com.fr.design.mainframe.alphafine.preview; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; import javax.swing.ImageIcon; import javax.swing.JPanel; +import java.awt.BorderLayout; +import java.awt.Color; /** * @author hades diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SimpleRightSearchResultPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SimpleRightSearchResultPane.java index 6d94bd9ed8..656e80b6ec 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SimpleRightSearchResultPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/SimpleRightSearchResultPane.java @@ -1,11 +1,12 @@ package com.fr.design.mainframe.alphafine.preview; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; + +import javax.swing.JPanel; import java.awt.Color; import java.awt.Dimension; -import javax.swing.JPanel; /** * @author hades diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java index f43d16e63c..a4b47dd8ee 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java @@ -1,10 +1,10 @@ package com.fr.design.mainframe.alphafine.preview; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.constants.UIConstants; import com.fr.design.dialog.link.MessageWithLink; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.i18n.Toolkit; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.action.StartUseAction; import com.fr.design.mainframe.alphafine.component.TemplateResourceImagePanel; import com.fr.design.mainframe.alphafine.model.TemplateResourceDetail; @@ -70,8 +70,8 @@ public class TemplateResourceDetailPane extends JPanel { private static final Font HTML_FONT = DesignUtils.getDefaultGUIFont().applySize(12); private static final Color HTML_COLOR = new Color(0x5c5c5d); - private static final String HTML_FORMAT = "%s"; - private static final String DETAIL_INFO_HTML_FORMAT = "

" + DETAIL_INFO + "

%s"; + private static final String HTML_FORMAT = "%s"; + private static final String DETAIL_INFO_HTML_FORMAT = "

" + DETAIL_INFO + "

%s"; private static final String HTML_P_TAG_FORMAT = "

%s

"; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateShopPane.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateShopPane.java index 00e7c4495c..3ce5f8caf8 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateShopPane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateShopPane.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.alphafine.preview; import com.fr.design.gui.ilable.UILabel; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.component.TemplateResourcePageGridPane; import com.fr.design.mainframe.alphafine.model.TemplateResource; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java index 40161e9baa..b701abdf8b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/ProductNewsSearchWorkerManager.java @@ -1,16 +1,17 @@ package com.fr.design.mainframe.alphafine.search; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.component.AlphaFineFrame; import com.fr.design.mainframe.alphafine.component.ProductNewsSearchResultPane; import com.fr.design.mainframe.alphafine.model.ProductNews; import com.fr.log.FineLoggerFactory; -import java.util.List; -import java.util.function.Function; + import javax.swing.DefaultListModel; import javax.swing.SwingWorker; +import java.util.List; +import java.util.function.Function; /** * @author hades diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchManager.java index f9f7893955..d8132c6871 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchManager.java @@ -1,5 +1,7 @@ package com.fr.design.mainframe.alphafine.search; +import com.fr.design.mainframe.alphafine.preview.DefaultContentPane; + /** * @author hades * @version 11.0 @@ -7,7 +9,17 @@ package com.fr.design.mainframe.alphafine.search; */ public interface SearchManager { - void doSearch(SearchTextBean searchTextBean); + /** + * 搜索 + * */ + void doSearch(SearchTextBean searchTextBean); + + /** + * 展示默认内容 + * */ + default void showDefault(DefaultContentPane defaultContentPane) { + + }; boolean hasSearchResult(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchTextBean.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchTextBean.java index f7148363c2..25fb64f9c6 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchTextBean.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchTextBean.java @@ -7,6 +7,8 @@ package com.fr.design.mainframe.alphafine.search; */ public class SearchTextBean { + public static SearchTextBean EMPTY = new SearchTextBean("", new String[0]); + private String searchText; /** diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java index 0b25c3ca1e..cdacd681d7 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/SearchWorkerManager.java @@ -1,6 +1,6 @@ package com.fr.design.mainframe.alphafine.search; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.model.AlphaCellModel; @@ -9,12 +9,15 @@ import com.fr.design.mainframe.alphafine.component.AlphaFineList; import com.fr.design.mainframe.alphafine.component.SearchListModel; import com.fr.design.mainframe.alphafine.component.SearchResultPane; import com.fr.design.mainframe.alphafine.model.SearchResult; +import com.fr.design.mainframe.alphafine.preview.DefaultContentPane; import com.fr.design.mainframe.alphafine.preview.ResultShowPane; import com.fr.log.FineLoggerFactory; -import java.util.function.Function; -import javax.swing.SwingWorker; import org.jetbrains.annotations.Nullable; +import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; +import java.util.function.Function; + /** * @author hades * @version 11.0 @@ -120,6 +123,21 @@ public class SearchWorkerManager implements SearchManager { this.searchWorker.execute(); } + @Override + public void showDefault(DefaultContentPane defaultContentPane) { + searchResultPane = new SearchResultPane(SearchTextBean.EMPTY.getSegmentation(), resultShowPane); + SearchListModel searchListModel = new SearchListModel(new SearchResult(), searchResultPane.getSearchResultList(), searchResultPane.getLeftSearchResultPane()); + SearchResult searchResult = searchResultFunction.apply(SearchTextBean.EMPTY); + for (AlphaCellModel object : searchResult) { + AlphaFineHelper.checkCancel(); + searchListModel.addElement(object); + } + searchResultPane.getSearchResultList().setModel(searchListModel); + searchResultPane.getSearchResultList().setSelectedIndex(0); + searchResultPane.getSearchResultList().requestFocus(); + SwingUtilities.invokeLater(()->defaultContentPane.showResult(searchResultPane)); + } + @Override public boolean hasSearchResult() { return hasSearchResult; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/TemplateResourceSearchWorkerManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/TemplateResourceSearchWorkerManager.java index 613f0f57a8..620fee8993 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/TemplateResourceSearchWorkerManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/TemplateResourceSearchWorkerManager.java @@ -1,6 +1,6 @@ package com.fr.design.mainframe.alphafine.search; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.component.AlphaFineFrame; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java index f4add755e5..817a47cca4 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.alphafine.search.helper; +import com.fr.base.login.ClientHelper; import com.fr.design.DesignerEnvManager; import com.fr.design.extra.PluginConstants; import com.fr.design.mainframe.alphafine.download.FineMarketDownloadManager; @@ -12,6 +13,7 @@ import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.market.key.FineMarketPublicKeyHolder; import com.fr.security.SecurityToolbox; +import com.fr.stable.EncodeConstants; import com.fr.stable.StableUtils; import com.fr.third.org.apache.http.HttpEntity; import com.fr.third.org.apache.http.HttpException; @@ -267,8 +269,11 @@ public class FineMarketClientHelper { } } + /** + * 通过名字搜索模板信息 + */ public @Nullable JSONArray getTemplateInfoByName(String name) throws IOException { - String url = FINE_MARKET_TEMPLATE_INFO + NAME_SEARCH + name; + String url = FINE_MARKET_TEMPLATE_INFO + NAME_SEARCH + ClientHelper.urlEncode(name, EncodeConstants.ENCODING_UTF_8); String jsonString = HttpToolbox.get(url); JSONObject jsonObject = new JSONObject(jsonString); String responseState = (String) jsonObject.get(RESPONSE_STATE); @@ -323,7 +328,7 @@ public class FineMarketClientHelper { * */ private void initTags() throws IOException { tags = new HashMap<>(); - String url = FINE_MARKET_TEMPLATE_INFO + TEMPLATES_TAGS; + String url = FINE_MARKET_TEMPLATE_INFO + ClientHelper.urlEncode(TEMPLATES_TAGS, EncodeConstants.ENCODING_UTF_8); String jsonString = HttpToolbox.get(url); JSONObject jsonObject = new JSONObject(jsonString); String responseState = (String) jsonObject.get(RESPONSE_STATE); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/SearchProviderRegistry.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/SearchProviderRegistry.java new file mode 100644 index 0000000000..02d1fc35c2 --- /dev/null +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/SearchProviderRegistry.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.alphafine.search.manager; + +import com.fr.design.mainframe.alphafine.CellType; +import com.fr.design.mainframe.alphafine.search.manager.fun.AlphaFineSearchProvider; +import com.fr.design.mainframe.alphafine.search.manager.impl.ActionSearchManager; +import com.fr.design.mainframe.alphafine.search.manager.impl.FileSearchManager; +import com.fr.design.mainframe.alphafine.search.manager.impl.PluginSearchManager; + +import java.util.HashMap; +import java.util.Map; + +/** + * alphafine搜索提供者注册到这里 + * + * @author Link + * @version 11.0 + * Created by Link on 2022/9/18 + */ +public class SearchProviderRegistry { + private static Map map; + + static { + map = new HashMap<>(); + map.put(CellType.PLUGIN, PluginSearchManager.getInstance()); + map.put(CellType.ACTION, ActionSearchManager.getInstance()); + map.put(CellType.FILE, FileSearchManager.getInstance()); + } + + /** + * 根据celltype获得对应searchProvider + */ + public static AlphaFineSearchProvider getSearchProvider(CellType cellType) { + return map.get(cellType); + } +} diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java index 631fce88ea..420762b87a 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/fun/AlphaFineSearchProvider.java @@ -22,6 +22,12 @@ public interface AlphaFineSearchProvider { */ SearchResult getMoreSearchResult(String searchText); + /** + * 不搜索的情况下,获取显示结果 + * */ + default SearchResult getDefaultResult() { + return new SearchResult(); + } /** * 获取所有搜索结果 取决于具体实现 diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java index 54d6d14025..c6b02160f8 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ActionSearchManager.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; import com.fr.design.DesignerEnvManager; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.model.ActionModel; @@ -29,6 +29,7 @@ public class ActionSearchManager implements AlphaFineSearchProvider { private SearchResult filterModelList; private SearchResult lessModelList; private SearchResult moreModelList; + private SearchResult defaultModelList; public static ActionSearchManager getInstance() { if (instance == null) { @@ -41,6 +42,17 @@ public class ActionSearchManager implements AlphaFineSearchProvider { return instance; } + /** + * 初始化的时候初始化默认功能列表 + * */ + private ActionSearchManager() { + defaultModelList = new SearchResult(); + List updateActions = UpdateActionManager.getUpdateActionManager().getUpdateActions(); + for (UpdateActionModel updateActionModel : updateActions) { + defaultModelList.add(new ActionModel(updateActionModel.getActionName(), updateActionModel.getParentName(), updateActionModel.getAction())); + } + } + /** * 根据类名获取对象 * @@ -115,4 +127,12 @@ public class ActionSearchManager implements AlphaFineSearchProvider { getLessSearchResult(searchTextBean.getSegmentation()); return filterModelList; } + + @Override + public SearchResult getDefaultResult() { + return defaultModelList; + } + + + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java index aa3690cb68..dbe810c8ea 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ComplementAdviceManager.java @@ -1,11 +1,14 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; +import com.fr.base.login.ClientHelper; import com.fr.design.DesignerEnvManager; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.model.SearchResult; import com.fr.general.http.HttpToolbox; import com.fr.log.FineLoggerFactory; +import com.fr.stable.EncodeConstants; import com.fr.third.org.apache.commons.codec.digest.DigestUtils; @@ -39,8 +42,9 @@ public class ComplementAdviceManager { if (DesignerEnvManager.getEnvManager().getAlphaFineConfigManager().isNeedIntelligentCustomerService()) { SearchResult searchResult = new SearchResult(); for (int j = 0; j < searchText.length; j++) { + String msg = ClientHelper.urlEncode(searchText[j], EncodeConstants.ENCODING_UTF_8); String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + searchText[j]); - String url = AlphaFineConstants.COMPLEMENT_ADVICE_SEARCH_URL_PREFIX + "msg=" + searchText[j] + "&token=" + token; + String url = AlphaFineCloudConstants.getComplementAdviceSearchUrlPrefix() + "msg=" + msg + "&token=" + ClientHelper.urlEncode(token, EncodeConstants.ENCODING_UTF_8); try { String result = HttpToolbox.get(url); AlphaFineHelper.checkCancel(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java index 3ea1f2db2f..69c34ba61c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/DocumentSearchManager.java @@ -1,7 +1,8 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; import com.fr.design.DesignerEnvManager; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.model.DocumentModel; @@ -15,6 +16,7 @@ import com.fr.json.JSONException; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; + import java.util.concurrent.TimeUnit; @@ -69,7 +71,7 @@ public class DocumentSearchManager implements AlphaFineSearchProvider { searchResult = new SearchResult(); for (int j = 0; j < searchText.length; j++) { long start = System.currentTimeMillis(); - String url = AlphaFineConstants.DOCUMENT_SEARCH_URL + searchText[j]; + String url = AlphaFineCloudConstants.getDocumentSearchUrl() + searchText[j]; try { String result = HttpToolbox.get(url); AlphaFineHelper.checkCancel(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java index 744b5a8399..5f358bbb5e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/FileSearchManager.java @@ -3,7 +3,7 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; import com.fr.base.FRContext; import com.fr.base.extension.FileExtension; import com.fr.design.DesignerEnvManager; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.model.FileModel; @@ -21,6 +21,8 @@ import com.fr.stable.StringUtils; import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; +import java.util.List; + /** * Created by XiaXiang on 2017/3/27. @@ -33,9 +35,11 @@ public class FileSearchManager implements AlphaFineSearchProvider { private static volatile FileSearchManager instance; private SearchResult filterModelList; private SearchResult lessModelList; + private SearchResult defaultModelList; private SearchResult moreModelList; private String searchText; private FileNode[] fileNodes = null; + private static final int DEFAULT_LIST_SIZE = 10; //停止搜索 //隐藏的搜索功能,可根据特殊的字符标记判断搜索分类 @@ -137,6 +141,19 @@ public class FileSearchManager implements AlphaFineSearchProvider { } } + @Override + public SearchResult getDefaultResult() { + List list = DesignerEnvManager.getEnvManager().getRecentOpenedFilePathList(); + defaultModelList = new SearchResult(); + for (int i = 0; i < Math.min(DEFAULT_LIST_SIZE, list.size()); i++) { + String name = list.get(i).toLowerCase(); + name = name.replaceAll(StringUtils.BLANK, StringUtils.EMPTY); + FileModel model = new FileModel(name, name); + defaultModelList.add(model); + } + return defaultModelList; + } + /** * 搜索模板内容 * diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java index 749a0a611f..a0815c2e3b 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/HotIssuesManager.java @@ -1,6 +1,6 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; import com.fr.design.mainframe.alphafine.cell.model.RobotModel; @@ -11,16 +11,15 @@ import com.fr.json.JSONArray; import com.fr.json.JSONException; import com.fr.json.JSONFactory; import com.fr.json.JSONObject; -import com.fr.json.JSONUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; +import org.jetbrains.annotations.Nullable; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; -import org.jetbrains.annotations.Nullable; /** @@ -76,7 +75,7 @@ public class HotIssuesManager { public String[][] getHotIssues() { try { - String result = HttpToolbox.get(AlphaFineConstants.ALPHA_HOT_SEARCH); + String result = HttpToolbox.get(AlphaFineCloudConstants.getAlphaHotSearch()); JSONArray jsonArray = JSONFactory.createJSON(JSON.ARRAY, result); if(jsonArray != null){ for (int i = 0; i < HOT_ITEM_NUM; i++) { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java index 56f7078b41..babf9f4865 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/PluginSearchManager.java @@ -1,7 +1,9 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; +import com.fr.common.util.Collections; import com.fr.design.DesignerEnvManager; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; @@ -15,13 +17,19 @@ import com.fr.json.JSONArray; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.plugin.basic.version.Version; -import com.fr.plugin.basic.version.VersionIntervalType; import com.fr.plugin.basic.version.VersionIntervalFactory; import com.fr.stable.ArrayUtils; import com.fr.stable.EncodeConstants; import java.io.UnsupportedEncodingException; import java.net.URLEncoder; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Comparator; +import java.util.List; +import java.util.Map; +import java.util.function.ToLongFunction; /** * Created by XiaXiang on 2017/3/27. @@ -30,6 +38,12 @@ public class PluginSearchManager implements AlphaFineSearchProvider { private SearchResult lessModelList; private SearchResult moreModelList; private SearchResult searchResult; + private SearchResult defaultModelList; + + private static final int DEFAULT_LIST_SIZE = 10; + private static final String TIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"; + + private static final String UPLOAD_TIME = "uploadTime"; private PluginSearchManager() { @@ -60,7 +74,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { int searchCount = object.optInt("searchCount"); String imageUrl = null; try { - imageUrl = isFromCloud ? AlphaFineConstants.PLUGIN_IMAGE_URL + URLEncoder.encode(object.optString("pic").toString().substring(AlphaFineConstants.PLUGIN_IMAGE_URL.length()), "utf8") : object.optString("pic"); + imageUrl = isFromCloud ? AlphaFineCloudConstants.getPluginImageUrl() + URLEncoder.encode(object.optString("pic").toString().substring(AlphaFineCloudConstants.getPluginImageUrl().length()), "utf8") : object.optString("pic"); } catch (UnsupportedEncodingException e) { FineLoggerFactory.getLogger().error("plugin icon error: " + e.getMessage()); } @@ -112,7 +126,7 @@ public class PluginSearchManager implements AlphaFineSearchProvider { for (int j = 0; j < searchText.length; j++) { try { String encodedKey = URLEncoder.encode(searchText[j], EncodeConstants.ENCODING_UTF_8); - String url = AlphaFineConstants.PLUGIN_SEARCH_URL + "?keyword=" + encodedKey; + String url = AlphaFineCloudConstants.getPluginSearchUrl() + "?keyword=" + encodedKey; String result = HttpToolbox.get(url); AlphaFineHelper.checkCancel(); JSONObject jsonObject = new JSONObject(result); @@ -155,4 +169,60 @@ public class PluginSearchManager implements AlphaFineSearchProvider { getLessSearchResult(searchTextBean.getSegmentation()); return searchResult; } + + @Override + public SearchResult getDefaultResult() { + this.defaultModelList = new SearchResult(); + try { + String url = AlphaFineCloudConstants.getSearchAllPluginUrl(); + String result = HttpToolbox.get(url); + AlphaFineHelper.checkCancel(); + JSONObject jsonObject = new JSONObject(result); + JSONArray jsonArray = jsonObject.optJSONArray("result"); + List plugins = jsonArray.getList(); + + List pluginModels = new ArrayList<>(); + pluginModels.addAll(parseDefaultPluginModel(plugins)); + + pluginModels.forEach(m->this.defaultModelList.add(m)); + + } catch (Exception e) { + FineLoggerFactory.getLogger().error("plugin search error :" + e.getMessage()); + } + + return this.defaultModelList; + } + + + /** + * 将jsonobject转化为PluginModel + * 并按照更新时间排序,取最新的10个 + * */ + List parseDefaultPluginModel(List jsonObjects) { + List pluginModels = new ArrayList<>(); + if (!Collections.isEmpty(jsonObjects)) { + SimpleDateFormat format = new SimpleDateFormat(TIME_FORMAT); + try { + jsonObjects.sort(Comparator.comparingLong(new ToLongFunction() { + @Override + public long applyAsLong(Map value) { + long time = 0L; + try { + time = format.parse((String) value.get(UPLOAD_TIME)).getTime(); + } catch (ParseException e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + return time; + } + })); + } catch (Exception e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + for (int i = 0; i < DEFAULT_LIST_SIZE; i++) { + pluginModels.add(getPluginModel(new JSONObject(jsonObjects.get(i)), false)); + } + } + return pluginModels; + } + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java index 9611217589..f4299fc7e3 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java @@ -2,7 +2,8 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; import com.fr.concurrent.NamedThreadFactory; import com.fr.design.DesignerEnvManager; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.model.ProductNews; import com.fr.general.http.HttpToolbox; @@ -82,7 +83,7 @@ public class ProductNewsSearchManager { public List getProductNewsList() throws Exception { productNewsList = new ArrayList<>(); idSet = new HashSet<>(); - String jsonStr = HttpToolbox.get(AlphaFineConstants.ALPHA_CID); + String jsonStr = HttpToolbox.get(AlphaFineCloudConstants.getAlphaCid()); AlphaFineHelper.checkCancel(); JSONObject cidJSON = JSONFactory.createJSON(JSON.OBJECT, jsonStr); JSONArray jsonArray = cidJSON.getJSONArray("data"); @@ -150,7 +151,7 @@ public class ProductNewsSearchManager { * 根据用户组id,查询用户组信息(改用户组中的所有设计器id) * */ private Set searchUserGroupInfo(String userGroupId) { - String url = AlphaFineConstants.ALPHA_CID_USER_GROUP_INFO + AlphaFineConstants.SEARCH_BY_ID + userGroupId; + String url = AlphaFineCloudConstants.getAlphaCidUserGroupInfo() + AlphaFineConstants.SEARCH_BY_ID + userGroupId; Set idSet = new HashSet<>(); try { String jsonStr = HttpToolbox.get(url); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java index d9b93fb556..992b429406 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecentSearchManager.java @@ -1,7 +1,7 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; import com.fr.design.actions.UpdateAction; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.CellModelHelper; import com.fr.design.mainframe.alphafine.cell.model.ActionModel; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java index ce0d987767..d0fcbd3b0c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/RecommendSearchManager.java @@ -1,7 +1,8 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; import com.fr.design.DesignerEnvManager; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.CellModelHelper; @@ -59,7 +60,7 @@ public class RecommendSearchManager implements AlphaFineSearchProvider { for (int j = 0; j < searchText.length; j++) { searchText[j] = searchText[j].replaceAll(StringUtils.BLANK, StringUtils.EMPTY); try { - String url = AlphaFineConstants.SEARCH_API + CodeUtils.cjkEncode(searchText[j]); + String url = AlphaFineCloudConstants.getSearchApi() + CodeUtils.cjkEncode(searchText[j]); String result = HttpToolbox.get(url); AlphaFineHelper.checkCancel(); JSONObject jsonObject = new JSONObject(result); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java index a953b70fe6..9e3d4bb679 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SegmentationManager.java @@ -1,6 +1,6 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.stable.StringUtils; import com.fr.third.ibm.icu.text.BreakIterator; diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java index f353573b49..dc7866301e 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/SimilarSearchManager.java @@ -1,7 +1,9 @@ package com.fr.design.mainframe.alphafine.search.manager.impl; +import com.fr.base.login.ClientHelper; import com.fr.design.DesignerEnvManager; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants; +import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.mainframe.alphafine.AlphaFineHelper; import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.cell.model.MoreModel; @@ -12,6 +14,7 @@ import com.fr.general.http.HttpToolbox; import com.fr.json.JSONObject; import com.fr.log.FineLoggerFactory; import com.fr.stable.ArrayUtils; +import com.fr.stable.EncodeConstants; import com.fr.third.org.apache.commons.codec.digest.DigestUtils; /** @@ -46,8 +49,9 @@ public class SimilarSearchManager implements AlphaFineSearchProvider { } SearchResult allModelList = new SearchResult(); for (int j = 0; j < searchText.length; j++) { + String msg = ClientHelper.urlEncode(searchText[j], EncodeConstants.ENCODING_UTF_8); String token = DigestUtils.md5Hex(AlphaFineConstants.ALPHA_ROBOT_SEARCH_TOKEN + searchText[j]); - String url = AlphaFineConstants.SIMILAR_SEARCH_URL_PREFIX + "msg=" + searchText[j] + "&token=" + token; + String url = AlphaFineCloudConstants.getSimilarSearchUrlPrefix() + "msg=" + msg + "&token=" + ClientHelper.urlEncode(token, EncodeConstants.ENCODING_UTF_8); try { String result = HttpToolbox.get(url); AlphaFineHelper.checkCancel(); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/TemplateResourceSearchManager.java b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/TemplateResourceSearchManager.java index 61dceaa008..c7b4babec1 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/TemplateResourceSearchManager.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/TemplateResourceSearchManager.java @@ -29,7 +29,19 @@ public class TemplateResourceSearchManager { public List getSearchResult(String searchText) { List resourceList = new ArrayList<>(); - // 联网搜索 + resourceList.addAll(searchOnline(searchText)); + resourceList.addAll(searchLocal(searchText)); + + resourceList.stream().forEach(resource -> {resource.setSearchWord(searchText);}); + + return resourceList; + } + + /** + * 联网搜索 + * */ + private List searchOnline(String searchText) { + List resourceList = new ArrayList<>(); try { JSONArray jsonArray = helper.getTemplateInfoByName(searchText); if (jsonArray != null && !jsonArray.isEmpty()) { @@ -38,8 +50,14 @@ public class TemplateResourceSearchManager { } catch (Exception e) { } + return resourceList; + } - // 本地搜索 + /** + * 本地搜索 + * */ + private List searchLocal(String searchText) { + List resourceList = new ArrayList<>(); if (resourceList.isEmpty()) { List localResource = getEmbedResourceList(); localResource.stream().forEach(resource->{ diff --git a/designer-realize/src/main/java/com/fr/design/report/ExcelExportPane.java b/designer-realize/src/main/java/com/fr/design/report/ExcelExportPane.java index f829616c7a..e00b5e22a4 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ExcelExportPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ExcelExportPane.java @@ -1,29 +1,47 @@ package com.fr.design.report; +import com.fr.design.constants.UIConstants; import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.io.attr.ExcelExportAttr; import com.fr.stable.StringUtils; +import javax.swing.AbstractButton; import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; import javax.swing.JPanel; +import java.awt.Color; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class ExcelExportPane extends BasicPane { private UICheckBox isExportHidedRow; private UICheckBox isExportHidenColumn; - private UICheckBox isNeedPassword; + // 文件密码 private UITextField passwordField; - private UICheckBox protectedWord; + // 工作表密码 private UITextField protectedField; + // 文件保护 + private UICheckBox fileProtect; + // 编辑保护 + private UICheckBox writeProtect; + // 工作表密码 + private UIRadioButton workbookPassword; + // 仅限预览 + private UIRadioButton onlyForPreview; + // 导出水印 + private UICheckBox exportWaterMark; private JPanel passwordWritePane; - private JPanel wordPane; + private JPanel writeProtectPane; public ExcelExportPane() { this.initComponents(); @@ -32,33 +50,35 @@ public class ExcelExportPane extends BasicPane { protected void initComponents() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - JPanel outnorthPane =FRGUIPaneFactory.createTitledBorderPane("Excel" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Excel_Export")); - JPanel northPane=FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); - this.add(outnorthPane); - outnorthPane.add(northPane); - JPanel rowAndColumnPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - northPane.add(rowAndColumnPane); + JPanel outPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane("Excel" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Excel_Export")); + JPanel outNorthPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Export_Setting")); + outNorthPane.setPreferredSize(new Dimension(580, 85)); + this.add(outPane); + outPane.add(outNorthPane); isExportHidedRow = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Export_Hided_Row")); isExportHidedRow.setSelected(false); - rowAndColumnPane.add(isExportHidedRow); + outNorthPane.add(isExportHidedRow); isExportHidenColumn = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Export_Hided_Column")); isExportHidenColumn.setSelected(false); - rowAndColumnPane.add(isExportHidenColumn); - - JPanel passwordPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - isNeedPassword = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_IS_Need_Password"), false); - passwordPane.add(isNeedPassword); - northPane.add(passwordPane); - passwordWritePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - passwordPane.add(passwordWritePane); - UILabel passwordLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_File_Password") + ":"); - passwordWritePane.add(passwordLabel); + outNorthPane.add(isExportHidenColumn); + // 内容保护 + JPanel outSouthPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Export_Content_Protect")); + outSouthPane.setPreferredSize(new Dimension(580, 280)); + outPane.add(outSouthPane); + // 文件保护 + fileProtect = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Export_File_Protect"), false); + outSouthPane.add(fileProtect); + // 文件密码和密码框 + passwordWritePane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); + JPanel passwordWriteFlowPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); + UILabel filePassword = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_File_Password")); + passwordWriteFlowPane.add(filePassword); passwordField = new UITextField(11); - passwordWritePane.add(passwordField); -// UIButton displayPasswordButton = new UIButton("..."); - isNeedPassword.addActionListener(new ActionListener() { + passwordWriteFlowPane.add(passwordField); + passwordWritePane.add(passwordWriteFlowPane); + fileProtect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - if (isNeedPassword.isSelected()) { + if (fileProtect.isSelected()) { passwordWritePane.setVisible(true); } else { passwordWritePane.setVisible(false); @@ -66,28 +86,57 @@ public class ExcelExportPane extends BasicPane { } }); - - + outSouthPane.add(passwordWritePane); + // 编辑保护 + writeProtect = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Export_Write_Protect"), false); + outSouthPane.add(writeProtect); + // 编辑保护勾选后展示的内容 + writeProtectPane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); + outSouthPane.add(writeProtectPane); + // 工作表密码 + workbookPassword = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sheet_Password"), true); JPanel protectedWordPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - protectedWord = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Protected_Password")); - wordPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); - wordPane.add(new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sheet_Password") + ":")); protectedField = new UITextField(11); - wordPane.add(protectedField); - protectedWordPane.add(protectedWord); - protectedWordPane.add(wordPane); - northPane.add(protectedWordPane); - protectedWord.addActionListener(new ActionListener() { + protectedWordPane.add(workbookPassword); + protectedWordPane.add(protectedField); + // 仅限预览 + onlyForPreview = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Export_Only_For_Preview")); + JPanel onlyForPreviewPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); + onlyForPreviewPane.add(onlyForPreview); + wrapButtonsInButtonGroup(workbookPassword, onlyForPreview); + writeProtectPane.add(protectedWordPane); + writeProtectPane.add(onlyForPreviewPane); + writeProtect.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { - if (protectedWord.isSelected()) { - wordPane.setVisible(true); + if (writeProtect.isSelected()) { + writeProtectPane.setVisible(true); } else { - wordPane.setVisible(false); - protectedField.setText(null); + writeProtectPane.setVisible(false); } } }); + // 导出水印 + exportWaterMark = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Export_WaterMark"), false); + outSouthPane.add(exportWaterMark); + + JPanel tips = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(5, 5, 0); + UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Export_WaterMark_Tips")); + uiLabel.setForeground(Color.GRAY); + ActionLabel actionLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Report_Export_WaterMark_Use"), UIConstants.FLESH_BLUE); + actionLabel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + writeProtect.setSelected(true); + writeProtectPane.setVisible(true); + onlyForPreview.setSelected(true); + exportWaterMark.setSelected(true); + } + }); + tips.add(uiLabel); + tips.add(actionLabel); + outSouthPane.add(tips); + } @Override @@ -102,20 +151,33 @@ public class ExcelExportPane extends BasicPane { isExportHidedRow.setSelected(excelExportAttr.isExportHidedRow()); isExportHidenColumn.setSelected(excelExportAttr.isExportHidedColumn()); if (StringUtils.isEmpty(excelExportAttr.getPassword())) { - isNeedPassword.setSelected(false); + fileProtect.setSelected(false); passwordWritePane.setVisible(false); } else { - isNeedPassword.setSelected(true); - passwordField.setText(excelExportAttr.getPassword()); + fileProtect.setSelected(true); passwordWritePane.setVisible(true); + passwordField.setText(excelExportAttr.getPassword()); } - if (StringUtils.isEmpty(excelExportAttr.getProtectedWord())) { - this.protectedWord.setSelected(false); - this.wordPane.setVisible(false); + if (excelExportAttr.isWriteProtect()) { + if (excelExportAttr.isUseProtectedWord() && StringUtils.isNotEmpty(excelExportAttr.getProtectedWord())) { + writeProtect.setSelected(true); + writeProtectPane.setVisible(true); + workbookPassword.setSelected(true); + protectedField.setText(excelExportAttr.getProtectedWord()); + } else if (!excelExportAttr.isUseProtectedWord()) { + writeProtect.setSelected(true); + writeProtectPane.setVisible(true); + onlyForPreview.setSelected(true); + } else { + this.writeProtect.setSelected(false); + this.writeProtectPane.setVisible(false); + } } else { - this.protectedWord.setSelected(true); - this.wordPane.setVisible(true); - this.protectedField.setText(excelExportAttr.getProtectedWord()); + this.writeProtect.setSelected(false); + this.writeProtectPane.setVisible(false); + } + if (excelExportAttr.isExportWaterMark()) { + this.exportWaterMark.setSelected(true); } } @@ -125,11 +187,28 @@ public class ExcelExportPane extends BasicPane { excelExportAttr.setExportHidedColumn(isExportHidenColumn.isSelected()); excelExportAttr.setExportHidedRow(isExportHidedRow.isSelected()); - if (!isNeedPassword.isSelected()) { - passwordField.setText(null); + if (fileProtect.isSelected()) { + excelExportAttr.setPassword(passwordField.getText()); + } + if (writeProtect.isSelected()) { + excelExportAttr.setWriteProtect(true); + if (workbookPassword.isSelected()) { + excelExportAttr.setProtectedWord(protectedField.getText()); + } + excelExportAttr.setUseProtectedWord(workbookPassword.isSelected()); + } + if (exportWaterMark.isSelected()) { + excelExportAttr.setExportWaterMark(true); } - excelExportAttr.setPassword(passwordField.getText()); - excelExportAttr.setProtectedWord(this.protectedField.getText()); return excelExportAttr; } + + private void wrapButtonsInButtonGroup(AbstractButton... buttons) { + if (buttons != null) { + ButtonGroup buttonGroup = new ButtonGroup(); + for (AbstractButton button : buttons) { + buttonGroup.add(button); + } + } + } } diff --git a/designer-realize/src/main/java/com/fr/design/report/ImageExportPane.java b/designer-realize/src/main/java/com/fr/design/report/ImageExportPane.java index b8d6167335..08d1a213c3 100644 --- a/designer-realize/src/main/java/com/fr/design/report/ImageExportPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/ImageExportPane.java @@ -10,13 +10,14 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.io.attr.ImageExportAttr; import com.fr.io.attr.ReportExportAttr; -import java.awt.Color; import javax.swing.AbstractButton; import javax.swing.BorderFactory; import javax.swing.ButtonGroup; import javax.swing.JComponent; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; /** * 导出图片配置 @@ -51,11 +52,16 @@ public class ImageExportPane extends AbstractExportPane { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); JPanel globalTitlePane = FRGUIPaneFactory.createTitledBorderPane(GLOBAL_CONF); - JPanel tipsTitlePane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Advice")); + JPanel outNorthPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Export_Setting")); + outNorthPane.setPreferredSize(new Dimension(580, 230)); UILabel tipLabel = new UILabel(Toolkit.i18nText("Fine-Design_Image_Export_Tips")); - tipLabel.setForeground(Color.RED); + tipLabel.setForeground(Color.GRAY); + JPanel tipsTitlePane = new JPanel(); + tipsTitlePane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); + tipsTitlePane.setLayout(FRGUIPaneFactory.createBorderLayout()); tipsTitlePane.add(tipLabel); - this.add(globalTitlePane, BorderLayout.NORTH); + this.add(globalTitlePane); + globalTitlePane.add(outNorthPane); initGlobalSettings(); JPanel centerPane = FRGUIPaneFactory.createBorderLayout_S_Pane(); @@ -73,7 +79,7 @@ public class ImageExportPane extends AbstractExportPane { GAP), BorderLayout.CENTER); centerPane.add(tipsTitlePane,BorderLayout.SOUTH); - globalTitlePane.add(centerPane, BorderLayout.CENTER); + outNorthPane.add(centerPane, BorderLayout.CENTER); } diff --git a/designer-realize/src/main/java/com/fr/design/report/PDFExportPane.java b/designer-realize/src/main/java/com/fr/design/report/PDFExportPane.java index 7fa71fe950..f8e5767478 100644 --- a/designer-realize/src/main/java/com/fr/design/report/PDFExportPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/PDFExportPane.java @@ -1,20 +1,20 @@ package com.fr.design.report; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - -import javax.swing.*; - +import com.fr.design.dialog.BasicPane; import com.fr.design.gui.icheckbox.UICheckBox; -import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.dialog.BasicPane; - import com.fr.io.attr.PDFExportAttr; import com.fr.stable.StringUtils; +import javax.swing.BorderFactory; +import javax.swing.JPanel; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + public class PDFExportPane extends BasicPane { private UICheckBox isNeedPassword; private UITextField passwordField; @@ -27,21 +27,18 @@ public class PDFExportPane extends BasicPane { protected void initComponents() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - JPanel outnorthPane =FRGUIPaneFactory.createTitledBorderPane("PDF" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Excel_Export")); - JPanel northPane=FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); - this.add(outnorthPane); - outnorthPane.add(northPane); - JPanel rowAndColumnPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - northPane.add(rowAndColumnPane); - - JPanel passwordPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - isNeedPassword = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_IS_Need_Password"), false); + JPanel outPane =FRGUIPaneFactory.createTopVerticalTitledBorderPane("PDF" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Excel_Export")); + this.add(outPane); + // 内容保护 + JPanel outNorthPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Export_Content_Protect")); + outNorthPane.setPreferredSize(new Dimension(580, 100)); + outPane.add(outNorthPane); + + isNeedPassword = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_File_Password"), false); + JPanel passwordPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); passwordPane.add(isNeedPassword); - northPane.add(passwordPane); passwordWritePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); passwordPane.add(passwordWritePane); - UILabel passwordLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_File_Password") + ":"); - passwordWritePane.add(passwordLabel); passwordField = new UITextField(11); passwordWritePane.add(passwordField); isNeedPassword.addActionListener(new ActionListener() { @@ -49,7 +46,7 @@ public class PDFExportPane extends BasicPane { passwordWritePane.setVisible(isNeedPassword.isSelected()); } }); - + outNorthPane.add(passwordPane); } @Override diff --git a/designer-realize/src/main/java/com/fr/design/report/WordExportPane.java b/designer-realize/src/main/java/com/fr/design/report/WordExportPane.java index df808c1bcb..c252a4e627 100644 --- a/designer-realize/src/main/java/com/fr/design/report/WordExportPane.java +++ b/designer-realize/src/main/java/com/fr/design/report/WordExportPane.java @@ -1,21 +1,42 @@ package com.fr.design.report; -import java.awt.Color; -import java.awt.Dimension; - -import javax.swing.*; - +import com.fr.design.constants.UIConstants; +import com.fr.design.dialog.BasicPane; +import com.fr.design.gui.ibutton.UIRadioButton; import com.fr.design.gui.icheckbox.UICheckBox; +import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.MultilineLabel; +import com.fr.design.gui.ilable.UILabel; +import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; -import com.fr.design.dialog.BasicPane; - import com.fr.io.attr.WordExportAttr; +import com.fr.stable.StringUtils; + +import javax.swing.AbstractButton; +import javax.swing.BorderFactory; +import javax.swing.ButtonGroup; +import javax.swing.JPanel; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; public class WordExportPane extends BasicPane { private UICheckBox isExportAsTable; - private JPanel southPane; + // 编辑保护 + private UICheckBox writeProtect; + // 工作表密码 + private UITextField protectedField; + // 工作表密码 + private UIRadioButton workbookPassword; + // 仅限预览 + private UIRadioButton onlyForPreview; + // 导出水印 + private UICheckBox exportWaterMark; + + private JPanel writeProtectPane; public WordExportPane() { this.initComponents(); @@ -24,31 +45,74 @@ public class WordExportPane extends BasicPane { protected void initComponents() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - JPanel outnorthPane =FRGUIPaneFactory.createTitledBorderPane("Word" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Excel_Export")); - this.add(outnorthPane); - - JPanel northPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); - outnorthPane.add(northPane); - - JPanel checkBoxPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); + JPanel outPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane("Word" + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_ReportD_Excel_Export")); + JPanel outNorthPane =FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Export_Setting")); + outNorthPane.setPreferredSize(new Dimension(580, 110)); + this.add(outPane); + outPane.add(outNorthPane); + isExportAsTable = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Is_Need_Word_Adjust"), false); - checkBoxPane.add(isExportAsTable); - - southPane = FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); - JPanel innerAlertBorderPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Attention")); - JPanel alertPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); - - MultilineLabel wordLineLabel = new MultilineLabel(); - wordLineLabel.setPreferredSize(new Dimension(250, 100)); + + MultilineLabel wordLineLabel = new MultilineLabel(); + wordLineLabel.setPreferredSize(new Dimension(560, 50)); wordLineLabel.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Alert_Word")); - wordLineLabel.setForeground(Color.RED); - alertPane.add(wordLineLabel); - - southPane.add(innerAlertBorderPane); - innerAlertBorderPane.add(alertPane); - - northPane.add(checkBoxPane); - northPane.add(southPane); + wordLineLabel.setForeground(Color.GRAY); + + outNorthPane.add(isExportAsTable); + outNorthPane.add(wordLineLabel); + // 内容保护 + JPanel outSouthPane = FRGUIPaneFactory.createTopVerticalTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Export_Content_Protect")); + outSouthPane.setPreferredSize(new Dimension(580, 250)); + outPane.add(outSouthPane); + // 编辑保护 + writeProtect = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Export_Write_Protect"), false); + outSouthPane.add(writeProtect); + // 编辑保护勾选后展示的内容 + writeProtectPane = FRGUIPaneFactory.createVerticalFlowLayout_S_Pane(true); + outSouthPane.add(writeProtectPane); + // 工作表密码 + workbookPassword = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sheet_Password"), true); + JPanel protectedWordPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); + protectedField = new UITextField(11); + protectedWordPane.add(workbookPassword); + protectedWordPane.add(protectedField); + // 仅限预览 + onlyForPreview = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Export_Only_For_Preview")); + JPanel onlyForPreviewPane =FRGUIPaneFactory.createNormalFlowInnerContainer_M_Pane(); + onlyForPreviewPane.add(onlyForPreview); + wrapButtonsInButtonGroup(workbookPassword, onlyForPreview); + writeProtectPane.add(protectedWordPane); + writeProtectPane.add(onlyForPreviewPane); + writeProtect.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (writeProtect.isSelected()) { + writeProtectPane.setVisible(true); + } else { + writeProtectPane.setVisible(false); + } + } + + }); + // 导出水印 + exportWaterMark = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Export_WaterMark"), false); + outSouthPane.add(exportWaterMark); + + JPanel tips = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(5, 5, 0); + UILabel uiLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Export_WaterMark_Tips")); + uiLabel.setForeground(Color.GRAY); + ActionLabel actionLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Report_Export_WaterMark_Use"), UIConstants.FLESH_BLUE); + actionLabel.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + writeProtect.setSelected(true); + writeProtectPane.setVisible(true); + onlyForPreview.setSelected(true); + exportWaterMark.setSelected(true); + } + }); + tips.add(uiLabel); + tips.add(actionLabel); + outSouthPane.add(tips); } @Override @@ -65,11 +129,51 @@ public class WordExportPane extends BasicPane { isExportAsTable.setSelected(true); // southPane.setVisible(true); } + if (wordExportAttr.isWriteProtect()) { + if (wordExportAttr.isUseProtectedWord() && StringUtils.isNotEmpty(wordExportAttr.getProtectedWord())) { + writeProtect.setSelected(true); + writeProtectPane.setVisible(true); + workbookPassword.setSelected(true); + protectedField.setText(wordExportAttr.getProtectedWord()); + } else if (!wordExportAttr.isUseProtectedWord()) { + writeProtect.setSelected(true); + writeProtectPane.setVisible(true); + onlyForPreview.setSelected(true); + } else { + this.writeProtect.setSelected(false); + this.writeProtectPane.setVisible(false); + } + } else { + this.writeProtect.setSelected(false); + this.writeProtectPane.setVisible(false); + } + if (wordExportAttr.isExportWaterMark()) { + this.exportWaterMark.setSelected(true); + } } public WordExportAttr update() { WordExportAttr wordExportAttr = new WordExportAttr(); wordExportAttr.setExportAsTable(isExportAsTable.isSelected()); + if (writeProtect.isSelected()) { + wordExportAttr.setWriteProtect(true); + if (workbookPassword.isSelected()) { + wordExportAttr.setProtectedWord(protectedField.getText()); + } + wordExportAttr.setUseProtectedWord(workbookPassword.isSelected()); + } + if (exportWaterMark.isSelected()) { + wordExportAttr.setExportWaterMark(true); + } return wordExportAttr; } + + private void wrapButtonsInButtonGroup(AbstractButton... buttons) { + if (buttons != null) { + ButtonGroup buttonGroup = new ButtonGroup(); + for (AbstractButton button : buttons) { + buttonGroup.add(button); + } + } + } } diff --git a/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java b/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java index d9d5cbe53b..2927f74d69 100644 --- a/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java +++ b/designer-realize/src/main/java/com/fr/grid/AbstractGridHeaderMouseHandler.java @@ -38,6 +38,8 @@ import java.lang.reflect.Method; public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { protected static final int FUZZY_EDGE = 10; protected static final int SEPARATOR_GAP = 5; + //只选中一个 + private static final int ONLY_SELECT_ONE = 1; protected GridHeader gHeader; private int dragType = GridUtils.DRAG_NONE; @@ -109,7 +111,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { if (between(evt, tmpSize1, tmpSize2)) { if (index >= dragIndex) { try { - if(method != null) { + if (method != null) { method.invoke(report, dragIndex, FU.valueOfPix(evtOffset(evt, oldEndValueSize), resolution)); } } catch (Exception e) { @@ -118,7 +120,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { //sizeList.set(dragIndex, FU.valueOfPix(evtOffset(evt, oldEndValueSize), resolution)); } else { try { - if(method != null) { + if (method != null) { method.invoke(report, index, FU.valueOfPix(evtOffset(evt, (int) tmpSize1), resolution)); } } catch (Exception e) { @@ -128,7 +130,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { // from all to do. for (int h = (dragIndex - 1); h > index; h--) { try { - if(method != null) { + if (method != null) { method.invoke(report, h, UNIT.ZERO); } } catch (Exception e) { @@ -219,7 +221,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { ePane.getGrid().stopEditing();// james 停止当前的所有编辑 // peter:选中格子位置. - ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(ePane, evt.getX(), evt.getY(),resolution); + ColumnRow selectedCellPoint = GridUtils.getAdjustEventColumnRow_withresolution(ePane, evt.getX(), evt.getY(), resolution); iterateScrollBar(ePane, evt, PRESS_ACTION); @@ -227,7 +229,7 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { if (SwingUtilities.isRightMouseButton(evt)) { Selection cs = ePane.getSelection(); resetSelectionByRightButton(selectedCellPoint, cs, ePane); - + checkEndMultiSelectIndex(cs); UIPopupMenu popupMenu = createPopupMenu(ePane, evt, Math.max(dragIndex, Math.max(this.startMultiSelectIndex, this.endMultiSelectIndex))); if (popupMenu != null) { GUICoreUtils.showPopupMenu(popupMenu, gHeader, evt.getX() + 1, evt.getY() + 1); @@ -246,6 +248,16 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { ePane.repaint(); } + /** + * 如果行列中有只选中一个的情况,更新下endIndex,防止列宽或行宽不匹配 + * @param selection 与ElementCasePane绑定的选择对象 + */ + private void checkEndMultiSelectIndex(Selection selection) { + if (selection.getSelectedColumns().length == ONLY_SELECT_ONE || selection.getSelectedRows().length == ONLY_SELECT_ONE) { + this.endMultiSelectIndex = this.startMultiSelectIndex; + } + } + protected abstract void resetSelectionByRightButton(ColumnRow mouseSelectedColumnRow, Selection cs, ElementCasePane ePane); @@ -305,11 +317,14 @@ public abstract class AbstractGridHeaderMouseHandler extends MouseInputAdapter { StringBuilder sb = new StringBuilder(); sb.append(String.format("%.2f", new Double(len))) .append('/').append(String.format("%.2f", new Double(tlen))) - .append(unit).append('(') - .append((int)(unitValue.toPixD(resolution))).append('/') - .append((int)(totalUnitValue.toPixD(resolution))) - .append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Px")) - .append(')'); + .append(unit); + if(!DesignerUIModeConfig.getInstance().simulateWebUIMode()){ + sb.append('(') + .append((int)(unitValue.toPixD(resolution))).append('/') + .append((int)(totalUnitValue.toPixD(resolution))) + .append(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Px")) + .append(')'); + } return sb.toString(); } diff --git a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java index 9787a12158..66fb549e69 100644 --- a/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java +++ b/designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java @@ -31,6 +31,8 @@ import com.fr.design.actions.insert.flot.ChartFloatAction; import com.fr.design.actions.insert.flot.FormulaFloatAction; import com.fr.design.actions.insert.flot.ImageFloatAction; import com.fr.design.actions.insert.flot.TextBoxFloatAction; +import com.fr.design.actions.replace.ITReplaceAction; +import com.fr.design.actions.replace.utils.ReplaceOperator; import com.fr.design.bridge.DesignToolbarProvider; import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.env.DesignerWorkspaceLoader; @@ -40,6 +42,7 @@ import com.fr.design.form.parameter.FormParaDesigner; import com.fr.design.fun.ElementUIProvider; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; +import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider; import com.fr.design.hyperlink.ReportletHyperlinkPane; import com.fr.design.hyperlink.WebHyperlinkPane; import com.fr.design.hyperlink.popup.MobilePopupPane; @@ -54,6 +57,7 @@ import com.fr.design.login.message.DesignerMessageHelper; import com.fr.design.login.socketio.LoginAuthServer; import com.fr.design.mainframe.BaseJForm; import com.fr.design.mainframe.FormHierarchyTreePane; +import com.fr.design.mainframe.HyperlinkGroupPaneActionImpl; import com.fr.design.mainframe.InformationCollector; import com.fr.design.mainframe.JTemplateEvent; import com.fr.design.mainframe.WidgetPropertyPane; @@ -142,14 +146,13 @@ import com.fr.start.common.DesignerStartupPool; import com.fr.task.Once; import com.fr.workspace.WorkContext; import com.fr.xml.ReportXMLUtils; - -import javax.swing.SwingWorker; import java.awt.Image; import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.List; import java.util.Set; import java.util.concurrent.CompletableFuture; +import javax.swing.SwingWorker; /** * Created by juhaoyu on 2018/1/31. @@ -402,6 +405,7 @@ public class DesignerActivator extends Activator implements Prepare { private static void registerOtherPane() { StableFactory.registerMarkedClass(BBSGuestPaneProvider.XML_TAG, BBSGuestPane.class); + StableFactory.registerMarkedObject(HyperlinkGroupPaneActionProvider.XML_TAG, HyperlinkGroupPaneActionImpl.getInstance()); } /** @@ -463,11 +467,14 @@ public class DesignerActivator extends Activator implements Prepare { StableFactory.registerMarkedObject(DesignToolbarProvider.STRING_MARKED, WidgetToolBarPane.getInstance()); DesignModuleFactory.registerNewFormActionClass(NewFormAction.class); + DesignModuleFactory.registerReplaceActionClass(ITReplaceAction.class); DesignModuleFactory.registerFormParaDesignerClass(FormParaDesigner.class); DesignModuleFactory.registerParaPropertyPaneClass(ParameterPropertyPane.class); DesignModuleFactory.registerFormHierarchyPaneClass(FormHierarchyTreePane.class); DesignModuleFactory.registerWidgetPropertyPaneClass(WidgetPropertyPane.class); DesignModuleFactory.registerButtonDetailPaneClass(FormSubmitButtonDetailPane.class); + + DesignModuleFactory.registerReplace(new ReplaceOperator()); DesignModuleFactory.registerParameterReader(new FormParameterReader()); StableFactory.registerMarkedClass(BaseJForm.XML_TAG, NewJForm.class); diff --git a/designer-realize/src/main/java/com/fr/start/preload/ImagePreLoader.java b/designer-realize/src/main/java/com/fr/start/preload/ImagePreLoader.java index 24d23565c0..aad478348f 100644 --- a/designer-realize/src/main/java/com/fr/start/preload/ImagePreLoader.java +++ b/designer-realize/src/main/java/com/fr/start/preload/ImagePreLoader.java @@ -242,6 +242,7 @@ public class ImagePreLoader { "com/fr/design/images/buttonicon/widget/label_16_normal.svg", "com/fr/web/images/form/resources/button_16.png", "com/fr/design/images/buttonicon/widget/button_16.png", + "com/fr/web/images/form/resources/picture_widget_16.png", "com/fr/design/images/buttonicon/widget/button_16_normal.svg", "com/fr/design/images/buttonicon/widget/files_up.png", "com/fr/design/images/buttonicon/widget/files_up_normal.svg", diff --git a/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/search_hint.svg b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/search_hint.svg new file mode 100644 index 0000000000..767729dad5 --- /dev/null +++ b/designer-realize/src/main/resources/com/fr/design/mainframe/alphafine/images/search_hint.svg @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java index 5d32b85bbd..8c62b827ee 100644 --- a/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java +++ b/designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java @@ -1,6 +1,6 @@ package com.fr.design.mainframe.alphafine.cell.model; -import com.fr.design.mainframe.alphafine.AlphaFineConstants; +import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants; import com.fr.design.mainframe.alphafine.CellType; import com.fr.json.JSONException; import com.fr.json.JSONObject; @@ -14,8 +14,8 @@ public class ModelTest { Assert.assertEquals("name", documentModel.getName()); Assert.assertEquals("content", documentModel.getContent()); Assert.assertEquals(1, documentModel.getDocumentId()); - Assert.assertEquals(AlphaFineConstants.DOCUMENT_DOC_URL + documentModel.getDocumentId() + ".html", documentModel.getDocumentUrl()); - Assert.assertEquals(AlphaFineConstants.DOCUMENT_INFORMATION_URL + documentModel.getDocumentId(), documentModel.getInformationUrl()); + Assert.assertEquals(AlphaFineCloudConstants.getDocumentDocUrl() + documentModel.getDocumentId() + ".html", documentModel.getDocumentUrl()); + Assert.assertEquals(AlphaFineCloudConstants.getDocumentInformationUrl() + documentModel.getDocumentId(), documentModel.getInformationUrl()); Assert.assertEquals(documentModel.getStoreInformation(), documentModel.getInformationUrl()); Assert.assertEquals(CellType.DOCUMENT, documentModel.getType()); Assert.assertEquals(true, documentModel.hasAction()); diff --git a/designer-realize/src/test/java/com/fr/design/actions/replace/utils/ShowValueUtilsTest.java b/designer-realize/src/test/java/com/fr/design/actions/replace/utils/ShowValueUtilsTest.java new file mode 100644 index 0000000000..d31511bddc --- /dev/null +++ b/designer-realize/src/test/java/com/fr/design/actions/replace/utils/ShowValueUtilsTest.java @@ -0,0 +1,107 @@ +package com.fr.design.actions.replace.utils; + +import junit.framework.TestCase; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * @author Destiny.Lin + * @version 11.0 + * created by Destiny.Lin on 2022-09-30 + */ +public class ShowValueUtilsTest extends TestCase { + + + public void testChangeRegex() { + + /** + * 字符"." + */ + String regex = "."; + String str = "=\"通配符:我(){}[]是*cu/r?y+单!^个字|+符串/?\\?.\""; + Pattern pattern = Pattern.compile(ShowValueUtils.changeRegex(regex)); + Matcher matcher = pattern.matcher(str); + assertTrue(matcher.find()); + while (matcher.find()){ + assertEquals(".", matcher.group()); + } + + /** + * 字符"?" + */ + regex = "??."; + pattern =Pattern.compile(ShowValueUtils.changeRegex(regex)); + Matcher matcher1 = pattern.matcher(str); + assertTrue(matcher1.find()); + while (matcher1.find()){ + assertEquals("\\?.", matcher1.group()); + } + + /** + * 字符"\" + */ + regex = "?\\"; + pattern =Pattern.compile(ShowValueUtils.changeRegex(regex)); + Matcher matcher2 = pattern.matcher(str); + assertTrue(matcher2.find()); + while (matcher2.find()){ + assertEquals("?\\", matcher2.group()); + } + + /** + * 字符"/" + */ + regex = "/"; + pattern =Pattern.compile(ShowValueUtils.changeRegex(regex)); + Matcher matcher3 = pattern.matcher(str); + assertTrue(matcher3.find()); + while (matcher3.find()){ + assertEquals("/", matcher3.group()); + } + + /** + * 字符"*" + */ + regex = "*"; + pattern =Pattern.compile(ShowValueUtils.changeRegex(regex)); + Matcher matcher4 = pattern.matcher(str); + assertTrue(matcher4.find()); + while (matcher4.find()){ + assertEquals("*", matcher4.group()); + } + + /** + * 字符"(){}[]" + */ + regex = "(){}[]"; + pattern =Pattern.compile(ShowValueUtils.changeRegex(regex)); + Matcher matcher5 = pattern.matcher(str); + assertTrue(matcher5.find()); + while (matcher5.find()){ + assertEquals("(){}[]", matcher5.group()); + } + + /** + * 字符"^" + */ + regex = "!^"; + pattern =Pattern.compile(ShowValueUtils.changeRegex(regex)); + Matcher matcher6 = pattern.matcher(str); + assertTrue(matcher6.find()); + while (matcher6.find()){ + assertEquals("!^", matcher6.group()); + } + + /** + * 字符"|+" + */ + regex = "|+"; + pattern =Pattern.compile(ShowValueUtils.changeRegex(regex)); + Matcher matcher7 = pattern.matcher(str); + assertTrue(matcher7.find()); + while (matcher7.find()){ + assertEquals("|+", matcher7.group()); + } + } +} \ No newline at end of file