Browse Source
* commit 'a97b9f7f9be88c46ef1deba432ba3a69003b26d6': (93 commits) REPORT-81307 补充注释 REPORT-81307 A列列宽概率显示为B列列宽值 REPORT-81307 A列列宽概率显示为B列列宽值 REPORT-75998 完善正则表达式匹配,增加单元测试、增加控件事件中的回调函数中的JS REPORT-75998 修复多级菜单下无法跳转的错误 REPORT-81222【运营产品化二期】自定义排序先点击首个再点击最后一个,上下箭头置灰显示有问题 REPORT-81222【运营产品化二期】自定义排序先点击首个再点击最后一个,上下箭头置灰显示有问题 REPORT-81416 设计器闪退 REPORT-81483【运营产品化二期】11.0设计器需要支持搜索10.0&11.0的模板 1、修改了请求参数 2、修改了参数编码方式 3、修改了重载事件,添加重载动画 REPORT-75998 修复数据集面板不更新的bug、优化魔术数 REPORT-75998 修复查找完成后打开新模板无查找内容不符的提示,修复输入img返回结果不正确的bug REPORT-81241【运营产品化二期】插件中心断网后的重新加载无反应 删除json字符串,用jsonarry写 REPORT-81241【运营产品化二期】插件中心断网后的重新加载无反应 修改一些url编码 给一些常量加注释 REPORT-75998 修复数据校验计数错误 REPORT-75998 修改部分格式 REPORT-75998 增加搜索模板Web属性引用JS REPORT-75998 更改数据字典-公式的处理逻辑、增加勾选框的刷新逻辑、查找框无内容时替换框禁用 REPORT-75998 增加搜索模板Web属性引用JS REPORT-75998 更改数据字典-公式的处理逻辑、增加勾选框的刷新逻辑、查找框无内容时替换框禁用 REPORT-81241【运营产品化二期】插件中心断网后的重新加载无反应 添加url编码 提取常量 REPORT-81241【运营产品化二期】插件中心断网后的重新加载无反应 修改pr ...newui
superman
2 years ago
221 changed files with 16340 additions and 482 deletions
@ -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<String, String> 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()); |
||||||
|
} |
||||||
|
} |
@ -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<UICheckBox> sortItems; |
||||||
|
private MenuLabel selectedLabel; |
||||||
|
private AlphaFineConfigPane parentPane; |
||||||
|
|
||||||
|
public CustomSortPane(List<UICheckBox> 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<String, Integer> sortMap = new HashMap<>(); |
||||||
|
for (int i = 0; i < currentTabOrder.length; i++) { |
||||||
|
sortMap.put(currentTabOrder[i], i); |
||||||
|
} |
||||||
|
List<MenuLabel> sortLabels = new ArrayList<>(); |
||||||
|
for (UICheckBox item : sortItems) { |
||||||
|
MenuLabel label = new MenuLabel(item.getText(), (Function<MenuLabel, Object>) 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<String> selectedTab = new HashSet<>(); |
||||||
|
for (UICheckBox item : sortItems) { |
||||||
|
selectedTab.add(item.getText()); |
||||||
|
} |
||||||
|
|
||||||
|
// 未选中的tab,保持原排序不变
|
||||||
|
Map<String, Integer> 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); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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); |
||||||
|
} |
||||||
|
} |
||||||
|
}; |
||||||
|
} |
||||||
|
} |
@ -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<MenuLabel> labels; |
||||||
|
|
||||||
|
public MenuLabelPane(List<MenuLabel> 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); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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(); |
||||||
|
|
||||||
|
} |
After Width: | Height: | Size: 1.0 KiB |
After Width: | Height: | Size: 4.8 KiB |
@ -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; |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* <p>图片控件的creator</p> |
||||||
|
* |
||||||
|
* @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; |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* <p>图片控件中的已选图片展示面板</p> |
||||||
|
* |
||||||
|
* @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: |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* <p>图片控件的图片选择、编辑器</p> |
||||||
|
* |
||||||
|
* @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); |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p>表单图片控件的链接编辑器</p> |
||||||
|
* @author Jimmy |
||||||
|
*/ |
||||||
|
public class AccessibleUrlLinkModelEditor extends UneditableAccessibleEditor { |
||||||
|
private FormHyperlinkGroupPane hyperlinkPane; |
||||||
|
|
||||||
|
public AccessibleUrlLinkModelEditor() { |
||||||
|
super(new UrlLinkModelWrapper()); |
||||||
|
} |
||||||
|
/** |
||||||
|
* 原插件使用 |
||||||
|
* <p>DesignerContext.getDesignerFrame().getSelectedJTemplate().getHyperLinkPaneNoPop( |
||||||
|
* HyperlinkGroupPaneActionImpl.getInstance()));</p>获取{@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(); |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
/** |
||||||
|
* |
||||||
|
* <p>图片控件的图片选择、编辑器</p> |
||||||
|
* |
||||||
|
* @author Jimmy.Zheng created on 2022/8/11 21:15 |
||||||
|
**/ |
||||||
|
public class PictureEditor extends AccessiblePropertyEditor { |
||||||
|
|
||||||
|
public PictureEditor(Object o) { |
||||||
|
super(new AccessiblePictureModelEditor((PictureWidget) o)); |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
|
||||||
|
/** |
||||||
|
* |
||||||
|
* <p><p>图片控件的链接编辑器</p></p> |
||||||
|
* |
||||||
|
* @author Jimmy.Zheng created on 2022/8/11 21:19 |
||||||
|
**/ |
||||||
|
public class UrlLinkEditor extends AccessiblePropertyEditor { |
||||||
|
|
||||||
|
public UrlLinkEditor() { |
||||||
|
super(new AccessibleUrlLinkModelEditor()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,15 @@ |
|||||||
|
package com.fr.design.mainframe.widget.renderer; |
||||||
|
|
||||||
|
import com.fr.design.mainframe.widget.wrappers.PictureModelWrapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p>图片控件的图片编辑器的EncoderCellRenderer</p> |
||||||
|
* |
||||||
|
* @author Jimmy.Zheng created on 2022/8/11 21:29 |
||||||
|
**/ |
||||||
|
public class PictureRenderer extends EncoderCellRenderer { |
||||||
|
|
||||||
|
public PictureRenderer() { |
||||||
|
super(new PictureModelWrapper()); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,16 @@ |
|||||||
|
package com.fr.design.mainframe.widget.renderer; |
||||||
|
|
||||||
|
|
||||||
|
import com.fr.design.mainframe.widget.wrappers.UrlLinkModelWrapper; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p>图片控件的链接编辑器的EncoderCellRenderer</p> |
||||||
|
* |
||||||
|
* @author Jimmy.Zheng created on 2022/8/11 21:29 |
||||||
|
**/ |
||||||
|
public class UrlLinkRenderer extends EncoderCellRenderer { |
||||||
|
|
||||||
|
public UrlLinkRenderer() { |
||||||
|
super(new UrlLinkModelWrapper()); |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p>图片选择器 {@link com.fr.design.mainframe.widget.accessibles.AccessiblePictureModelEditor}的 Wrapper</p> |
||||||
|
* <p>插件中直接移入,未作改动</p> |
||||||
|
* |
||||||
|
* @author Jimmy.Zheng created on 2022/8/11 21:25 |
||||||
|
**/ |
||||||
|
public class PictureModelWrapper implements Encoder<FloatElement>, Decoder<FloatElement> { |
||||||
|
|
||||||
|
@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; |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
|
||||||
|
/** |
||||||
|
* <p>链接选择器 {@link com.fr.design.mainframe.widget.accessibles.AccessibleUrlLinkModelEditor}的 Wrapper</p> |
||||||
|
* <p>插件中直接移入,未作改动</p> |
||||||
|
* |
||||||
|
* @author Jimmy.Zheng created on 2022/8/11 21:28 |
||||||
|
**/ |
||||||
|
public class UrlLinkModelWrapper implements Encoder<NameJavaScriptGroup>, Decoder<NameJavaScriptGroup> { |
||||||
|
|
||||||
|
@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; |
||||||
|
} |
||||||
|
} |
@ -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); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
@ -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) { |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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){}; |
||||||
|
} |
@ -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; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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<? extends Info> showSearchValue(JTemplate jTemplate) { |
||||||
|
SearchCellAction.getInstance().search4Infos(jTemplate); |
||||||
|
return SearchCellAction.getInstance().getCellInfos(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<? extends Info> addMatchResult(String str, List<? extends Info> list) { |
||||||
|
List<CellInfo> 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<String, String> 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<? extends Info> showSearchValue(JTemplate jTemplate) { |
||||||
|
SearchJSManager.getInstance().search4Infos(jTemplate); |
||||||
|
return SearchJSManager.getInstance().getJsInfos(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<? extends Info> addMatchResult(String str, List<? extends Info> list) { |
||||||
|
List<JSInfo> jsInfos = new ArrayList<>(); |
||||||
|
Map<String, String> 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<String, String> map, List<JSInfo> 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<? extends Info> showSearchValue(JTemplate jTemplate) { |
||||||
|
SearchSQLAction.getInstance().search4Infos(jTemplate); |
||||||
|
return SearchSQLAction.getInstance().getSqlInfos(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<? extends Info> addMatchResult(String str, List<? extends Info> list) { |
||||||
|
List<SQLInfo> sqlInfos = new ArrayList<>(); |
||||||
|
Map<String, String> 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<String, String> map, List<SQLInfo> 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<Pair<Integer, Integer>> 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<? extends Info> showSearchValue(JTemplate jTemplate) { |
||||||
|
SearchFloatAction.getInstance().search4Infos(jTemplate); |
||||||
|
return SearchFloatAction.getInstance().getFloatInfos(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<? extends Info> addMatchResult(String str, List<? extends Info> list) { |
||||||
|
List<FloatInfo> 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<? extends Info> showSearchValue(JTemplate jTemplate) { |
||||||
|
SearchComponentAction.getInstance().search4Infos(jTemplate); |
||||||
|
return SearchComponentAction.getInstance().getComponentInfos(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<? extends Info> addMatchResult(String str, List<? extends Info> list) { |
||||||
|
ArrayList<ComponentInfo> componentInfos = new ArrayList<>(); |
||||||
|
Map<String, String> 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<String, String> stringHashMap, ArrayList<ComponentInfo> 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<? extends Info> showSearchValue(JTemplate jTemplate) { |
||||||
|
SearchWidgetAction.getInstance().search4Infos(jTemplate); |
||||||
|
return SearchWidgetAction.getInstance().getWidgetInfos(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<? extends Info> addMatchResult(String str, List<? extends Info> list) { |
||||||
|
ArrayList<WidgetInfo> widgetInfos = new ArrayList<>(); |
||||||
|
Map<String, String> stringHashMap = new HashMap<>(); |
||||||
|
for (Info info : list) { |
||||||
|
stringHashMap = info.getValue(); |
||||||
|
searchMap4Widget(stringHashMap, widgetInfos, ((WidgetInfo) info), str); |
||||||
|
} |
||||||
|
return widgetInfos; |
||||||
|
} |
||||||
|
|
||||||
|
private void searchMap4Widget(Map<String, String> map, List<WidgetInfo> 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<? extends Info> showSearchValue(JTemplate jTemplate) { |
||||||
|
SearchFormulaManager.getInstance().search4Infos(jTemplate); |
||||||
|
return SearchFormulaManager.getInstance().getFormulaInfos(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public List<? extends Info> addMatchResult(String str, List<? extends Info> list) { |
||||||
|
List<FormulaInfo> formulaInfos = new ArrayList<>(); |
||||||
|
Map<String, String> stringHashMap = new HashMap<>(); |
||||||
|
for (Info info : list) { |
||||||
|
stringHashMap = info.getValue(); |
||||||
|
searchMap4Formula(stringHashMap, formulaInfos, ((FormulaInfo) info), str); |
||||||
|
} |
||||||
|
return formulaInfos; |
||||||
|
} |
||||||
|
|
||||||
|
private void searchMap4Formula(Map<String, String> stringHashMap, List<FormulaInfo> 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())); |
||||||
|
} |
||||||
|
} |
@ -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<? extends Info> showSearchValue(JTemplate jTemplate); |
||||||
|
|
||||||
|
/** |
||||||
|
* 对搜索结果进行过滤 |
||||||
|
* |
||||||
|
* @param str |
||||||
|
* @param list |
||||||
|
* @return |
||||||
|
*/ |
||||||
|
List<? extends Info> addMatchResult(String str, List<? extends Info> list); |
||||||
|
|
||||||
|
} |
@ -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; |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取有内容的单元格相关信息 |
||||||
|
* <p> |
||||||
|
* 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<CellInfo> cellInfos; |
||||||
|
|
||||||
|
private SearchCellAction() { |
||||||
|
} |
||||||
|
|
||||||
|
public List<CellInfo> getCellInfos() { |
||||||
|
return cellInfos; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCellInfos(List<CellInfo> 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<CellInfo> dealForm(JTemplate jTemplate) { |
||||||
|
ArrayList<CellInfo> 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<CellInfo> 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<CellInfo> dealWorkBook(WorkBook workBook, ITContent workBookContent) { |
||||||
|
ArrayList<CellInfo> 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<CellInfo> 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<CellInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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<ComponentInfo> 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<ComponentInfo> componentInfos, ITContent bodyContent, Widget widget) { |
||||||
|
searchLayout4Component(componentInfos, bodyContent, (WCardTitleLayout) widget); |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* 对于WCardLayout 里面就是放的WTabFitLayout——tab00、tab10 |
||||||
|
* 处理该类型时不用对该对象进行处理,直接对其包含的内容进行递归处理即可 |
||||||
|
*/ |
||||||
|
W_CARD_LAYOUT("WCardLayout") { |
||||||
|
@Override |
||||||
|
public void addComponent2Array(List<ComponentInfo> componentInfos, ITContent bodyContent, Widget widget) { |
||||||
|
searchLayout4Component(componentInfos, bodyContent, (WCardLayout) widget); |
||||||
|
} |
||||||
|
}, |
||||||
|
/** |
||||||
|
* WCardTagLayout——默认命名方式为tabpane0的类型 |
||||||
|
* TIP:该类型对其设置组件名时直接setWidgetName即可,设计器右侧上方和右侧下方面板中的组件名称会同步更改 |
||||||
|
*/ |
||||||
|
W_CARD_TAG_LAYOUT("WCardTagLayout") { |
||||||
|
@Override |
||||||
|
public void addComponent2Array(List<ComponentInfo> 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<ComponentInfo> 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<ComponentInfo> 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<Pair<Integer, Integer>> 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<Pair<Integer, Integer>> 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<ComponentInfo> 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<ComponentInfo> 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<ComponentInfo> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -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<ComponentInfo> componentInfos; |
||||||
|
|
||||||
|
|
||||||
|
public List<ComponentInfo> getComponentInfos() { |
||||||
|
return componentInfos; |
||||||
|
} |
||||||
|
|
||||||
|
public void setComponentInfos(List<ComponentInfo> componentInfos) { |
||||||
|
this.componentInfos = componentInfos; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 搜索决策报表参数面板以及body面板两个地方的组件 |
||||||
|
* |
||||||
|
* @param jTemplate 要搜索的模板 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void search4Infos(JTemplate jTemplate) { |
||||||
|
List<ComponentInfo> 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<ComponentInfo> 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<ComponentInfo> 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<ComponentInfo> 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<ComponentInfo> 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<ComponentInfo> 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<ComponentInfo> 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<ComponentInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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; |
||||||
|
|
||||||
|
/** |
||||||
|
* 查找悬浮元素的信息 |
||||||
|
* <p> |
||||||
|
* 由于决策报表没有悬浮元素,因此不用考虑决策报表,只需要考虑普通报表即可 |
||||||
|
* |
||||||
|
* @author Destiny.Lin |
||||||
|
* @version 11.0 |
||||||
|
* created by Destiny.Lin on 2022-08-16 |
||||||
|
*/ |
||||||
|
public class SearchFloatAction implements SearchAction { |
||||||
|
private List<FloatInfo> floatInfos; |
||||||
|
|
||||||
|
/** |
||||||
|
* 查找悬浮元素信息,只需要考虑普通报表 |
||||||
|
* |
||||||
|
* @param jTemplate 指定搜索模板 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void search4Infos(JTemplate jTemplate) { |
||||||
|
List<FloatInfo> 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<FloatInfo> 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<FloatInfo> 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<FloatInfo> getFloatInfos() { |
||||||
|
return floatInfos; |
||||||
|
} |
||||||
|
|
||||||
|
public void setFloatInfos(List<FloatInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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<String, String> getValue(Object... o) { |
||||||
|
HashMap<String, String> 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<Pair<Integer, Integer>> 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(); |
||||||
|
} |
||||||
|
} |
@ -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<Pair<Integer, Integer>> 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<Pair<Integer, Integer>> 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<Pair<Integer, Integer>> 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<Pair<Integer, Integer>> 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<Pair<Integer, Integer>> 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<Pair<Integer, Integer>> 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<Pair<Integer, Integer>> 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<Pair<Integer, Integer>> 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<Pair<Integer, Integer>> 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<Pair<Integer, Integer>> 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<Pair<Integer, Integer>> 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<Pair<Integer, Integer>> operatorArray); |
||||||
|
|
||||||
|
@Override |
||||||
|
public String getInfoShowStr(Info info) { |
||||||
|
return info.getContent().getOldShowStr(); |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> formulaInfos, ITContent content) { |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 获取各个地方的公式 |
||||||
|
* |
||||||
|
* @param jTemplate |
||||||
|
* @param formulaInfos |
||||||
|
*/ |
||||||
|
default void searchFormulaFromObject(JTemplate jTemplate, List<FormulaInfo> formulaInfos) { |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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<FormulaInfo> formulaInfos; |
||||||
|
private Set<SearchFormula> 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<FormulaInfo> 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<FormulaInfo> getFormulaInfos() { |
||||||
|
return formulaInfos; |
||||||
|
} |
||||||
|
|
||||||
|
public void setFormulaInfos(List<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> formulaInfos) { |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 查找不同单元格内容类型各自可能存在的公式 |
||||||
|
* |
||||||
|
* @param formulaInfos |
||||||
|
* @param content |
||||||
|
*/ |
||||||
|
default void searchFormulaFromCellType(List<FormulaInfo> formulaInfos, ITContent content) { |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -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<FormulaInfo> formulaInfos) { |
||||||
|
searchFormulaFromCell(jTemplate, formulaInfos); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* 从单元格中寻找公式 |
||||||
|
* |
||||||
|
* @param jTemplate 指定搜索模板 |
||||||
|
* @param formulaInfos 指定添加信息的数组 |
||||||
|
*/ |
||||||
|
@Override |
||||||
|
public void searchFormulaFromCell(JTemplate jTemplate, List<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<String, SearchConditionFormula> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> formulaInfos) { |
||||||
|
Map<String, SearchCellFormula> 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<String, SearchCellFormula> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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<String, SearchCellFormula> 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<String, SearchCellFormula> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> formulaInfos) { |
||||||
|
//这边condition有三种情况:FormulaCondition、CommonCondition、ListCondition,分别处理
|
||||||
|
Map<String, SearchConditionFormula> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> formulaInfos, ITContent content) { |
||||||
|
RichText richText = ((RichText) ((CellElement) (content.getReplaceObject())).getValue()); |
||||||
|
Iterator<RichChar> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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<String, SearchChartDataFormula> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> formulaInfos, ITContent content, TopDefinitionProvider provider) { |
||||||
|
searchPresent4Formula(provider.getCategoryPresent(), content, formulaInfos); |
||||||
|
searchPresent4Formula(provider.getSeriesPresent(), content, formulaInfos); |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void searchPresent4Formula(Present present, ITContent content, List<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> formulaInfos, ITContent chartContent, Chart chart) { |
||||||
|
//样式-标题
|
||||||
|
searchChartPatternFormulaFromTitle(formulaInfos, chartContent, chart); |
||||||
|
|
||||||
|
//样式-坐标轴-值定义&样式-坐标轴-轴标题
|
||||||
|
searchChartPatternFormulaFromAxisValue(formulaInfos, chartContent, chart); |
||||||
|
|
||||||
|
//样式-背景-警戒线
|
||||||
|
searchChartPatternFormulaFromAlertLine(formulaInfos, chartContent, chart); |
||||||
|
} |
||||||
|
|
||||||
|
private void searchChartPatternFormulaFromAlertLine(List<FormulaInfo> 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<VanChartAlertValue> list = ((VanChartAxis) xAxis).getAlertValues(); |
||||||
|
for (VanChartAlertValue alertValue : list) { |
||||||
|
//警戒线设置
|
||||||
|
dealAlertValue(formulaInfos, content, alertValue); |
||||||
|
//提示文字
|
||||||
|
dealAlertContent(formulaInfos, content, alertValue); |
||||||
|
} |
||||||
|
} |
||||||
|
if (yAxis instanceof VanChartAxis) { |
||||||
|
List<VanChartAlertValue> list = ((VanChartAxis) yAxis).getAlertValues(); |
||||||
|
for (VanChartAlertValue alertValue : list) { |
||||||
|
//警戒线设置
|
||||||
|
dealAlertValue(formulaInfos, content, alertValue); |
||||||
|
//提示文字
|
||||||
|
dealAlertContent(formulaInfos, content, alertValue); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
private void dealAlertContent(List<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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<FormulaInfo> formulaInfos, ITContent content, TopDefinitionProvider provider) { |
||||||
|
if (provider instanceof CustomDefinition) { |
||||||
|
CustomDefinition definition = (CustomDefinition) provider; |
||||||
|
Map<String, SearchChartDataFormula> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> formulaInfos, ITContent content, TopDefinitionProvider provider); |
||||||
|
|
||||||
|
/** |
||||||
|
* 快速处理Formula |
||||||
|
* |
||||||
|
* @param formulaInfos |
||||||
|
* @param reportContent |
||||||
|
* @param otherPos |
||||||
|
* @param o |
||||||
|
*/ |
||||||
|
default void dealFormulaObject(List<FormulaInfo> 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)); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<String, SearchChartDataFormula> 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<String, SearchChartDataFormula> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
@ -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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> formulaInfos, ITContent content, List<SeriesDefinition> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> formulaInfos); |
||||||
|
|
||||||
|
} |
@ -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<FormulaInfo> formulaInfos) { |
||||||
|
//模板数据集
|
||||||
|
dealTemplateData(jTemplate, formulaInfos); |
||||||
|
|
||||||
|
////服务器数据集二期再考虑
|
||||||
|
//dealServerData(formulaInfos);
|
||||||
|
} |
||||||
|
|
||||||
|
private void dealServerData(List<FormulaInfo> 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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> formulaInfos, FloatInfo floatInfo); |
||||||
|
|
||||||
|
/** |
||||||
|
* 查找不同悬浮元素内容类型各自可能存在的公式 |
||||||
|
* |
||||||
|
* @param formulaInfos 要存储对应信息列表的数据结构 |
||||||
|
* @param floatInfo FloatInfo信息 |
||||||
|
*/ |
||||||
|
void searchFormulaFromFloatType(List<FormulaInfo> formulaInfos, FloatInfo floatInfo); |
||||||
|
} |
@ -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<FormulaInfo> formulaInfos) { |
||||||
|
SearchFloatAction searchFloatAction = SearchFloatAction.getInstance(); |
||||||
|
searchFloatAction.search4Infos(jTemplate); |
||||||
|
for (FloatInfo floatInfo : searchFloatAction.getFloatInfos()) { |
||||||
|
searchFormulaFromCommonFloat(formulaInfos, floatInfo); |
||||||
|
searchFormulaFromFloatType(formulaInfos, floatInfo); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
@Override |
||||||
|
public void searchFormulaFromCommonFloat(List<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> formulaInfos, HighlightAction highlightAction) { |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -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<FormulaInfo> formulaInfos, HighlightAction highlightAction) { |
||||||
|
Map<String, SearchHighlightFormula> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<String, SearchHighlightFormula> 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<String, SearchHighlightFormula> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> formulaInfos, ITContent content, Condition condition); |
||||||
|
} |
@ -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<String, SearchConditionFormula> 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<String, SearchConditionFormula> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> formulaInfos, ITContent content, DMLConfig dmlConfig) { |
||||||
|
if (dmlConfig.getCondition() != null) { |
||||||
|
//这边condition有三种情况:FormulaCondition、CommonCondition、ListCondition,分别处理
|
||||||
|
Condition condition = dmlConfig.getCondition(); |
||||||
|
Map<String, SearchConditionFormula> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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<FormulaInfo> 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<SingleJavaScript> list = ((ExportJavaScript) javaScript).getJsListForOtherTemplates(); |
||||||
|
if (isListExist(list)) { |
||||||
|
for (SingleJavaScript singleJavaScript : list) { |
||||||
|
dealSingleJavaScript(formulaInfos, content, singleJavaScript); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isListExist(List<SingleJavaScript> list) { |
||||||
|
return list != null && list.size() > 0; |
||||||
|
} |
||||||
|
|
||||||
|
private void dealSingleJavaScript(List<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> formulaInfos, ITContent content, JavaScript javaScript) { |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/** |
||||||
|
* 从超链中的参数获取公式 |
||||||
|
* |
||||||
|
* @param formulaInfos |
||||||
|
* @param content |
||||||
|
* @param javaScript |
||||||
|
*/ |
||||||
|
default void addFormulaInfosFromJSPara(List<FormulaInfo> formulaInfos, ITContent content, JavaScript javaScript) { |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
@ -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<String, SearchJSFormula> 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<String, SearchJSFormula> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> formulaInfos, ITContent content, JavaScript javaScript) { |
||||||
|
//获取JS中的参数中的公式
|
||||||
|
addFormulaInfosFromJSPara(formulaInfos, content, javaScript); |
||||||
|
Map<String, SearchJSFormula> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> formulaInfos, ITContent content); |
||||||
|
|
||||||
|
/** |
||||||
|
* 搜索全局参数中的公式 |
||||||
|
* |
||||||
|
* @param jTemplate |
||||||
|
* @param formulaInfos |
||||||
|
* @param content |
||||||
|
*/ |
||||||
|
void searchTemplateParaFormula(JTemplate jTemplate, List<FormulaInfo> formulaInfos, ITContent content); |
||||||
|
} |
@ -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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> 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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
@ -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<FormulaInfo> formulaInfos, Dictionary dictionary); |
||||||
|
} |
@ -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<FormulaInfo> 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<FormulaInfo> 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<FormulaInfo> 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; |
||||||
|
} |
||||||
|
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue