Browse Source

Merge remote-tracking branch 'origin/feature/x' into feature/x

feature/x
Jimmy.Zheng 2 years ago
parent
commit
42a4eb898e
  1. 4
      designer-base/src/main/java/com/fr/design/actions/AllowAuthorityEditAction.java
  2. 12
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java
  3. 31
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java
  4. 4
      designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java
  5. 19
      designer-base/src/main/java/com/fr/design/actions/help/replace/ITReplaceHelper.java
  6. 12
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java
  7. 18
      designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java
  8. 3
      designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java
  9. 1
      designer-realize/src/main/java/com/fr/design/actions/replace/ITReplaceAction.java
  10. 2
      designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchManagerCenter.java
  11. 27
      designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java
  12. 3
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/floatelement/SearchFloatAction.java
  13. 64
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java
  14. 2
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaManager.java
  15. 120
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java
  16. 1
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchFormulaConditionAction.java
  17. 18
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchCommit2DBJSFormulaAction.java
  18. 15
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchExportJSFormulaAction.java
  19. 4
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchDateEditorFormulaAction.java
  20. 40
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchTreeEditorFormulaAction.java
  21. 31
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java
  22. 35
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java
  23. 28
      designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java
  24. 10
      designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java
  25. 19
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java
  26. 5
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java
  27. 11
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java
  28. 9
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java
  29. 25
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java
  30. 22
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java
  31. 25
      designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceOperator.java
  32. 111
      designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java
  33. 48
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResourceDetail.java
  34. 3
      designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java
  35. 6
      designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java

4
designer-base/src/main/java/com/fr/design/actions/AllowAuthorityEditAction.java

@ -1,9 +1,9 @@
package com.fr.design.actions; package com.fr.design.actions;
import com.fr.base.svg.IconUtils;
import com.fr.base.vcs.DesignerMode; import com.fr.base.vcs.DesignerMode;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.roleAuthority.ReportAndFSManagePane; import com.fr.design.roleAuthority.ReportAndFSManagePane;
import com.fr.design.roleAuthority.RolesAlreadyEditedPane; import com.fr.design.roleAuthority.RolesAlreadyEditedPane;
import com.fr.design.designer.TargetComponent; import com.fr.design.designer.TargetComponent;
@ -61,6 +61,8 @@ public class AllowAuthorityEditAction extends TemplateComponentAction {
DesignerContext.getDesignerFrame().refreshDottedLine(); DesignerContext.getDesignerFrame().refreshDottedLine();
EastRegionContainerPane.getInstance().replaceConfiguredRolesPane(RolesAlreadyEditedPane.getInstance()); EastRegionContainerPane.getInstance().replaceConfiguredRolesPane(RolesAlreadyEditedPane.getInstance());
EastRegionContainerPane.getInstance().removeParameterPane(); EastRegionContainerPane.getInstance().removeParameterPane();
//进入时要关闭查找替换面板
DesignModuleFactory.getReplaceOperator().close();
//画虚线 //画虚线
return true; return true;

12
designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java

@ -114,7 +114,9 @@ public class AlphaFineConfigPane extends BasicPane {
customSortLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Config_Custom_Sort"), false); customSortLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Config_Custom_Sort"), false);
customSortLabel.setForeground(UIConstants.NORMAL_BLUE); customSortLabel.setForeground(UIConstants.NORMAL_BLUE);
customSortLabel.addActionListener((event)->{ customSortLabel.addActionListener((event)->{
if (customSortLabel.isEnabled()) {
openCustomSortMenu(); openCustomSortMenu();
}
}); });
customSortWrapperPane.add(customSortLabel); customSortWrapperPane.add(customSortLabel);
if (!hasSelectedSearchRangeCheckBox()) { if (!hasSelectedSearchRangeCheckBox()) {
@ -178,12 +180,13 @@ public class AlphaFineConfigPane extends BasicPane {
return res; return res;
} }
// 搜索范围-我的模板 /**
* 搜索范围-我的模板
*/
private void initMyTemplateSearchPane() { private void initMyTemplateSearchPane() {
containMyTemplatePane = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 5)); containMyTemplatePane = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 5));
containMyTemplateCheckbox.setBorder(BorderFactory.createEmptyBorder()); containMyTemplateCheckbox.setBorder(BorderFactory.createEmptyBorder());
containMyTemplateCheckbox.addActionListener( containMyTemplateCheckbox.addActionListener(new ActionListener() {
new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (containMyTemplateCheckbox.isSelected()) { if (containMyTemplateCheckbox.isSelected()) {
@ -192,8 +195,7 @@ public class AlphaFineConfigPane extends BasicPane {
myTemplateSearchConfigButton.setVisible(false); myTemplateSearchConfigButton.setVisible(false);
} }
} }
} });
);
myTemplateSearchConfigButton = new JButton(); myTemplateSearchConfigButton = new JButton();
myTemplateSearchConfigButton.setBorder(BorderFactory.createEmptyBorder()); myTemplateSearchConfigButton.setBorder(BorderFactory.createEmptyBorder());
myTemplateSearchConfigButton.setMargin(new Insets(0, 0, 0, 0)); myTemplateSearchConfigButton.setMargin(new Insets(0, 0, 0, 0));

31
designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java

@ -74,10 +74,14 @@ public class CustomSortPane extends JPanel {
} }
private void createToolbarPane() { private void createToolbarPane() {
top = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/top.svg")); 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")); 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")); 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")); 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 -> { top.addActionListener(e -> {
SwingUtilities.invokeLater(() -> { SwingUtilities.invokeLater(() -> {
sortItemPane.setComponentZOrder(selectedLabel, 0); sortItemPane.setComponentZOrder(selectedLabel, 0);
@ -132,6 +136,7 @@ public class CustomSortPane extends JPanel {
for (UICheckBox item : sortItems) { for (UICheckBox item : sortItems) {
MenuLabel label = new MenuLabel(item.getText(), (Function<MenuLabel, Object>) o -> { MenuLabel label = new MenuLabel(item.getText(), (Function<MenuLabel, Object>) o -> {
selectedLabel = o; selectedLabel = o;
disableButton();
return null; return null;
}); });
sortLabels.add(label); sortLabels.add(label);
@ -140,6 +145,24 @@ public class CustomSortPane extends JPanel {
sortItemPane = new MenuLabelPane(sortLabels); sortItemPane = new MenuLabelPane(sortLabels);
} }
/**
* 如果选中第一个和最后一个则置灰向上和向下的按钮
*/
private void disableButton() {
int order = sortItemPane.getComponentZOrder(selectedLabel);
if (order == 0) {
top.setEnabled(false);
up.setEnabled(false);
} else if (order == sortItemPane.getComponentCount() - 1) {
down.setEnabled(false);
bottom.setEnabled(false);
} else {
up.setEnabled(true);
top.setEnabled(true);
down.setEnabled(true);
bottom.setEnabled(true);
}
}
private void refreshCurrentOrder() { private void refreshCurrentOrder() {
String[] currentTabOrder = parentPane.getCurrentOrder(); String[] currentTabOrder = parentPane.getCurrentOrder();

4
designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java

@ -61,10 +61,10 @@ public class MenuLabel extends UILabel {
parentMenu.setNoneSelected(); parentMenu.setNoneSelected();
setBackground(SELECTED_COLOR); setBackground(SELECTED_COLOR);
function.apply(this); function.apply(this);
selected = true; this.selected = true;
} else { } else {
setBackground(BACKGROUND_COLOR); setBackground(BACKGROUND_COLOR);
selected = false; this.selected = false;
} }
} }

19
designer-base/src/main/java/com/fr/design/actions/help/replace/ITReplaceHelper.java

@ -0,0 +1,19 @@
package com.fr.design.actions.help.replace;
/**
* 定义一些底层操作
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-09-27
*/
public interface ITReplaceHelper {
/**
* 关闭面板
*/
void close();
}

12
designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java

@ -61,6 +61,14 @@ public class UIButton extends JButton implements UIObserver, UITextComponent {
init(); init();
} }
public UIButton(Icon icon, boolean decorate) {
this(icon);
if (!decorate) {
setContentAreaFilled(false);
setFocusPainted(false);
setBorderPainted(false);
}
}
public UIButton(Icon icon) { public UIButton(Icon icon) {
super(icon); super(icon);
@ -397,4 +405,8 @@ public class UIButton extends JButton implements UIObserver, UITextComponent {
public boolean shouldResponseChangeListener() { public boolean shouldResponseChangeListener() {
return true; return true;
} }
} }

18
designer-base/src/main/java/com/fr/design/module/DesignModuleFactory.java

@ -1,6 +1,7 @@
package com.fr.design.module; package com.fr.design.module;
import com.fr.base.chart.BaseChartCollection; import com.fr.base.chart.BaseChartCollection;
import com.fr.design.actions.help.replace.ITReplaceHelper;
import com.fr.design.gui.chart.BaseChartPropertyPane; import com.fr.design.gui.chart.BaseChartPropertyPane;
import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.gui.chart.MiddleChartDialog; import com.fr.design.gui.chart.MiddleChartDialog;
@ -50,6 +51,7 @@ public class DesignModuleFactory {
private Class ITReplaceAction; private Class ITReplaceAction;
private Class formParaDesigner; private Class formParaDesigner;
private Class paraPropertyPane; private Class paraPropertyPane;
private static ITReplaceHelper replaceHelper;
private Class<? extends HierarchyTreePane> formHierarchyPaneCls; private Class<? extends HierarchyTreePane> formHierarchyPaneCls;
private Class<? extends BaseWidgetPropertyPane> widgetPropertyPane; private Class<? extends BaseWidgetPropertyPane> widgetPropertyPane;
private Class buttonDetailPaneClass; private Class buttonDetailPaneClass;
@ -131,6 +133,22 @@ public class DesignModuleFactory {
return instance.ITReplaceAction; return instance.ITReplaceAction;
} }
/**
* 注册一下查找替换面板
* @param
*/
public static void registerReplace(ITReplaceHelper replace) {
replaceHelper = replace;
}
/**
* 获取查找替换面板的操作类
* @return
*/
public static ITReplaceHelper getReplaceOperator() {
return replaceHelper;
}
public static void registerParaPropertyPaneClass(Class p) { public static void registerParaPropertyPaneClass(Class p) {
instance.paraPropertyPane = p; instance.paraPropertyPane = p;
} }

3
designer-form/src/main/java/com/fr/design/preview/DeveloperPreview.java

@ -6,6 +6,7 @@ import com.fr.design.fun.impl.AbstractPreviewProvider;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JForm; import com.fr.design.mainframe.JForm;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.module.DesignModuleFactory;
import com.fr.design.worker.WorkerManager; import com.fr.design.worker.WorkerManager;
import com.fr.design.worker.save.CallbackSaveWorker; import com.fr.design.worker.save.CallbackSaveWorker;
import com.fr.general.web.ParameterConstants; import com.fr.general.web.ParameterConstants;
@ -47,6 +48,8 @@ public class DeveloperPreview extends AbstractPreviewProvider {
@Override @Override
public void onClick(JTemplate<?, ?> jt) { public void onClick(JTemplate<?, ?> jt) {
super.onClick(jt); super.onClick(jt);
//进入时要关闭查找替换面板
DesignModuleFactory.getReplaceOperator().close();
SwingWorker worker = WorkerManager.getInstance().getWorker(jt.getRuntimeId()); SwingWorker worker = WorkerManager.getInstance().getWorker(jt.getRuntimeId());
if (worker instanceof CallbackSaveWorker) { if (worker instanceof CallbackSaveWorker) {
CallbackSaveWorker callbackSaveWorker = (CallbackSaveWorker) worker; CallbackSaveWorker callbackSaveWorker = (CallbackSaveWorker) worker;

1
designer-realize/src/main/java/com/fr/design/actions/replace/ITReplaceAction.java

@ -55,6 +55,7 @@ public class ITReplaceAction extends UpdateAction {
*/ */
public void actionPerformed(ActionEvent event) { public void actionPerformed(ActionEvent event) {
ITReplaceMainDialog mainFrame = ITReplaceMainDialog.getInstance(); ITReplaceMainDialog mainFrame = ITReplaceMainDialog.getInstance();
mainFrame.fitScreen();
mainFrame.setVisible(true); mainFrame.setVisible(true);
} }

2
designer-realize/src/main/java/com/fr/design/actions/replace/action/SearchManagerCenter.java

@ -61,7 +61,7 @@ public class SearchManagerCenter {
*/ */
public enum ManagerType implements SearchManager { public enum ManagerType implements SearchManager {
/** /**
* 注册单元格不同值类型中自己特有的公式数据列子报表公式富文本可自己添加 * 注册单元格不同值类型中自己特有的公式数据列子报表公式可自己添加
*/ */
CELL_FORMULA(0) { CELL_FORMULA(0) {
@Override @Override

27
designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowSearchResultAction.java

@ -24,6 +24,7 @@ import com.fr.design.mainframe.JTemplate;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.FloatElement; import com.fr.report.cell.FloatElement;
import com.fr.report.cell.cellattr.core.RichText;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.collections.combination.Pair; import com.fr.stable.collections.combination.Pair;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -75,7 +76,7 @@ public enum ShowSearchResultAction implements ShowValue {
} else { } else {
Map<String, String> stringHashMap = info.getValue(); Map<String, String> stringHashMap = info.getValue();
String content = stringHashMap.getOrDefault(objectContentKey, StringUtils.EMPTY); String content = stringHashMap.getOrDefault(objectContentKey, StringUtils.EMPTY);
if (content.contains(str) && StringUtils.isNotEmpty(content)) { if (isValueValid(content, str, info)) {
info.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); info.getContent().setShowStr(ShowValueUtils.getCommonString(content, str));
info.getContent().setOldShowStr(content); info.getContent().setOldShowStr(content);
info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str));
@ -94,6 +95,11 @@ public enum ShowSearchResultAction implements ShowValue {
cellInfo.getContent().setSelected(true); 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事件
@ -139,7 +145,7 @@ public enum ShowSearchResultAction implements ShowValue {
private void searchMap4JS(Map<String, String> map, List<JSInfo> jsInfos, JSInfo info, String str) { private void searchMap4JS(Map<String, String> map, List<JSInfo> jsInfos, JSInfo info, String str) {
if (map.containsKey(objectNameKey) && StringUtils.isNotEmpty(map.get(objectNameKey))) { if (map.containsKey(objectNameKey) && StringUtils.isNotEmpty(map.get(objectNameKey))) {
String name = map.get(objectNameKey); String name = map.get(objectNameKey);
if (name.contains(str)) { if (ShowValueUtils.contains(name,str)) {
JSInfo nameJSInfo = info.copy(); JSInfo nameJSInfo = info.copy();
nameJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); nameJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(name, str));
nameJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(name, str)); nameJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(name, str));
@ -151,7 +157,7 @@ public enum ShowSearchResultAction implements ShowValue {
} }
if (map.containsKey(objectContentKey) && StringUtils.isNotEmpty(map.get(objectContentKey))) { if (map.containsKey(objectContentKey) && StringUtils.isNotEmpty(map.get(objectContentKey))) {
String content = map.get(objectContentKey); String content = map.get(objectContentKey);
if (content.contains(str)) { if (ShowValueUtils.contains(content,str)) {
JSInfo contentJSInfo = info.copy(); JSInfo contentJSInfo = info.copy();
contentJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); contentJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(content, str));
contentJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); contentJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str));
@ -195,7 +201,7 @@ public enum ShowSearchResultAction implements ShowValue {
private void searchMap4SQLContent(Map<String, String> map, List<SQLInfo> sqlInfos, SQLInfo info, String str) { private void searchMap4SQLContent(Map<String, String> map, List<SQLInfo> sqlInfos, SQLInfo info, String str) {
if (map.containsKey(objectContentKey) && StringUtils.isNotEmpty(map.get(objectContentKey))) { if (map.containsKey(objectContentKey) && StringUtils.isNotEmpty(map.get(objectContentKey))) {
String content = map.get(objectContentKey); String content = map.get(objectContentKey);
if (content.contains(str)) { if (ShowValueUtils.contains(content,str)) {
SQLInfo contentJSInfo = info.copy(); SQLInfo contentJSInfo = info.copy();
contentJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); contentJSInfo.getContent().setShowStr(ShowValueUtils.getCommonString(content, str));
contentJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); contentJSInfo.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str));
@ -244,7 +250,7 @@ public enum ShowSearchResultAction implements ShowValue {
} }
} }
} else { } else {
if (GeneralUtils.objectToString(floatElement.getValue()).contains(str)) { if (ShowValueUtils.contains(GeneralUtils.objectToString(floatElement.getValue()), str)) {
FloatInfo floatInfo = ((FloatInfo) info).copy(); FloatInfo floatInfo = ((FloatInfo) info).copy();
setShowInfo(floatInfo, GeneralUtils.objectToString(floatElement.getValue()), str); setShowInfo(floatInfo, GeneralUtils.objectToString(floatElement.getValue()), str);
floatInfos.add(floatInfo); floatInfos.add(floatInfo);
@ -285,7 +291,7 @@ public enum ShowSearchResultAction implements ShowValue {
private void searchMap4Component(Map<String, String> stringHashMap, ArrayList<ComponentInfo> componentInfos, ComponentInfo info, String str) { private void searchMap4Component(Map<String, String> stringHashMap, ArrayList<ComponentInfo> componentInfos, ComponentInfo info, String str) {
if (stringHashMap.containsKey(objectContentKey)) { if (stringHashMap.containsKey(objectContentKey)) {
String content = stringHashMap.get(objectContentKey); String content = stringHashMap.get(objectContentKey);
if (content.contains(str)) { if (ShowValueUtils.contains(content,str)) {
info.getContent().setShowStr(ShowValueUtils.getCommonString(content, str)); info.getContent().setShowStr(ShowValueUtils.getCommonString(content, str));
info.getContent().setOldShowStr(stringHashMap.get(objectContentKey)); info.getContent().setOldShowStr(stringHashMap.get(objectContentKey));
info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str)); info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(content, str));
@ -319,7 +325,7 @@ public enum ShowSearchResultAction implements ShowValue {
private void searchMap4Widget(Map<String, String> map, List<WidgetInfo> widgetInfos, WidgetInfo info, String str) { private void searchMap4Widget(Map<String, String> map, List<WidgetInfo> widgetInfos, WidgetInfo info, String str) {
if (map.containsKey(objectNameKey)) { if (map.containsKey(objectNameKey)) {
String name = map.get(objectNameKey); String name = map.get(objectNameKey);
if (StringUtils.isNotEmpty(name) && name.contains(str)) { if (StringUtils.isNotEmpty(name) && ShowValueUtils.contains(name,str)) {
WidgetInfo nameInfo = info.copy(info); WidgetInfo nameInfo = info.copy(info);
nameInfo.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); nameInfo.getContent().setShowStr(ShowValueUtils.getCommonString(name, str));
nameInfo.getContent().setOldShowStr(map.get(objectNameKey)); nameInfo.getContent().setOldShowStr(map.get(objectNameKey));
@ -331,7 +337,7 @@ public enum ShowSearchResultAction implements ShowValue {
} }
if (map.containsKey(objectWaterMarkKey)) { if (map.containsKey(objectWaterMarkKey)) {
String waterMark = map.get(objectWaterMarkKey); String waterMark = map.get(objectWaterMarkKey);
if (StringUtils.isNotEmpty(waterMark) && waterMark.contains(str)) { if (StringUtils.isNotEmpty(waterMark) && ShowValueUtils.contains(waterMark,str)) {
WidgetInfo widgetInfo = info.copy(info); WidgetInfo widgetInfo = info.copy(info);
widgetInfo.getContent().setShowStr(ShowValueUtils.getCommonString(waterMark, str)); widgetInfo.getContent().setShowStr(ShowValueUtils.getCommonString(waterMark, str));
widgetInfo.getContent().setOldShowStr(map.get(objectWaterMarkKey)); widgetInfo.getContent().setOldShowStr(map.get(objectWaterMarkKey));
@ -368,7 +374,7 @@ public enum ShowSearchResultAction implements ShowValue {
private void searchMap4Formula(Map<String, String> stringHashMap, List<FormulaInfo> formulaInfos, FormulaInfo info, String str) { private void searchMap4Formula(Map<String, String> stringHashMap, List<FormulaInfo> formulaInfos, FormulaInfo info, String str) {
if (stringHashMap.containsKey(objectContentKey)) { if (stringHashMap.containsKey(objectContentKey)) {
String name = stringHashMap.get(objectContentKey); String name = stringHashMap.get(objectContentKey);
if (name.contains(str)) { if (ShowValueUtils.contains(name,str)) {
info.getContent().setShowStr(ShowValueUtils.getCommonString(name, str)); info.getContent().setShowStr(ShowValueUtils.getCommonString(name, str));
info.getContent().setOldShowStr(stringHashMap.get(objectContentKey)); info.getContent().setOldShowStr(stringHashMap.get(objectContentKey));
info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(name, str)); info.getContent().setOperatorArray(ShowValueUtils.getStringStartAndEndIndex(name, str));
@ -411,11 +417,12 @@ public enum ShowSearchResultAction implements ShowValue {
/** /**
* 标题是否可用 * 标题是否可用
*
* @param title * @param title
* @param str * @param str
* @return * @return
*/ */
public boolean isTitleNameValid(Title title, String str) { public boolean isTitleNameValid(Title title, String str) {
return title != null && GeneralUtils.objectToString(title.getTextObject()).contains(str) && StringUtils.isNotEmpty(GeneralUtils.objectToString(title.getTextObject())); return title != null && ShowValueUtils.contains(GeneralUtils.objectToString(title.getTextObject()), str) && StringUtils.isNotEmpty(GeneralUtils.objectToString(title.getTextObject()));
} }
} }

3
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/floatelement/SearchFloatAction.java

@ -7,6 +7,7 @@ import com.fr.design.actions.replace.info.FloatInfo;
import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.general.ImageWithSuffix;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.report.cell.FloatElement; import com.fr.report.cell.FloatElement;
import com.fr.report.elementcase.ElementCase; import com.fr.report.elementcase.ElementCase;
@ -84,9 +85,11 @@ public class SearchFloatAction implements SearchAction {
if (floatElement.getValue() instanceof ChartCollection) { if (floatElement.getValue() instanceof ChartCollection) {
floatInfo.setChartExist(true); floatInfo.setChartExist(true);
} }
if (!(floatElement.getValue() instanceof ImageWithSuffix)) {
result.add(floatInfo); result.add(floatInfo);
} }
} }
}
public List<FloatInfo> getFloatInfos() { public List<FloatInfo> getFloatInfos() {

64
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java

@ -22,6 +22,7 @@ import com.fr.main.impl.WorkBook;
import com.fr.report.cell.cellattr.CellInsertPolicyAttr; import com.fr.report.cell.cellattr.CellInsertPolicyAttr;
import com.fr.report.cell.cellattr.core.RichChar; import com.fr.report.cell.cellattr.core.RichChar;
import com.fr.report.cell.cellattr.core.group.DSColumn; 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.FormulaProvider;
import com.fr.stable.ParameterProvider; import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -133,40 +134,6 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
return false; return false;
} }
}, },
/**
* 富文本
*/
RICH_CHAR("RichChar") {
@Override
public Map<String, String> getValue(Object... o) {
HashMap<String, String> map = new HashMap<>();
if (o[0] instanceof RichChar) {
if (StringUtils.isNotEmpty(((RichChar) o[0]).getText())) {
map.put("content", (((RichChar) o[0]).getText()));
}
}
return map;
}
@Override
public void setValue(Info info, String findStr, String replaceStr, List<Pair<Integer, Integer>> operatorArray) {
Object replaceObject = info.getContent().getReplaceObject();
if (replaceObject instanceof RichChar) {
RichChar richChar = (RichChar) replaceObject;
info.updateOldStr(richChar.getText(), findStr);
richChar.setText(ShowValueUtils.replaceAll(richChar.getText(), findStr, replaceStr));
}
}
@Override
public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof RichChar){
RichChar richChar = (RichChar) info.getContent().getReplaceObject();
return StringUtils.equals(richChar.getText(), info.getContent().getOldShowStr());
}
return false;
}
},
/** /**
* KV * KV
*/ */
@ -529,6 +496,35 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
public boolean check(Info info) { public boolean check(Info info) {
return true; 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;
}
} }
; ;

2
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/cell/SearchCellFormulaManager.java

@ -25,8 +25,6 @@ public class SearchCellFormulaManager implements SearchManager {
register(DS_COLUMN, SearchDSColumnFormulaAction.getInstance()); register(DS_COLUMN, SearchDSColumnFormulaAction.getInstance());
//公式 //公式
register(FORMULA, SearchCellFormulaTypeAction.getInstance()); register(FORMULA, SearchCellFormulaTypeAction.getInstance());
//富文本
register(RICH_TEXT, SearchRichFormulaAction.getInstance());
//子报表 //子报表
register(SUB_REPORT, SearchSubReportFormulaAction.getInstance()); register(SUB_REPORT, SearchSubReportFormulaAction.getInstance());

120
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java

@ -2,21 +2,38 @@ package com.fr.design.actions.replace.action.content.formula.chart;
import com.fr.base.Formula; import com.fr.base.Formula;
import com.fr.base.chart.chartdata.TopDefinitionProvider; 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.Axis;
import com.fr.chart.chartattr.Chart; import com.fr.chart.chartattr.Chart;
import com.fr.chart.chartattr.ChartCollection; 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.chartattr.Title;
import com.fr.chart.chartdata.NormalReportDataDefinition; import com.fr.chart.chartdata.NormalReportDataDefinition;
import com.fr.chart.chartdata.SeriesDefinition; 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.FormulaInfo;
import com.fr.design.actions.replace.info.JSInfo;
import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.i18n.Toolkit; 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.VanChartAlertValue;
import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.axis.VanChartValueAxis; 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.List;
import java.util.Map; import java.util.Map;
@ -44,7 +61,12 @@ public class SearchChartCollectionFormulaAction {
for (int i = 0; i < chartCollection.getChartCount(); i++) { for (int i = 0; i < chartCollection.getChartCount(); i++) {
ITContent chartContent = ITContent.copy(content); ITContent chartContent = ITContent.copy(content);
searchChartPatternFormula(formulaInfos, chartContent, chartCollection.getChart(i)); 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(); SearchChartDataFormulaManager searchChartDataFormulaManager = SearchChartDataFormulaManager.getInstance();
Map<String, SearchChartDataFormula> type = searchChartDataFormulaManager.getChartDataType(); Map<String, SearchChartDataFormula> type = searchChartDataFormulaManager.getChartDataType();
@ -56,7 +78,103 @@ public class SearchChartCollectionFormulaAction {
dataContent.addOtherPos(chartCollection.getChart(i).getChartName(), Toolkit.i18nText("Fine-Design_Basic_Data")); dataContent.addOtherPos(chartCollection.getChart(i).getChartName(), Toolkit.i18nText("Fine-Design_Basic_Data"));
searchChartDataFormula.searchChartDataFormula(formulaInfos, dataContent, provider); 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) { private boolean isDefinitionValid(TopDefinitionProvider provider) {

1
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/condition/SearchFormulaConditionAction.java

@ -21,7 +21,6 @@ public class SearchFormulaConditionAction implements SearchConditionFormula {
} }
@Override @Override
public void searchFormulaFromCondition(List<FormulaInfo> formulaInfos, ITContent content, Condition condition) { public void searchFormulaFromCondition(List<FormulaInfo> formulaInfos, ITContent content, Condition condition) {
if (((FormulaCondition) (condition)).getFormula() != null) { if (((FormulaCondition) (condition)).getFormula() != null) {

18
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchCommit2DBJSFormulaAction.java

@ -1,5 +1,6 @@
package com.fr.design.actions.replace.action.content.formula.highlight.javascript; 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.SearchConditionFormula;
import com.fr.design.actions.replace.action.content.formula.highlight.condition.SearchConditionManager; 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.FormulaInfo;
@ -10,6 +11,7 @@ import com.fr.js.Commit2DBJavaScript;
import com.fr.js.JavaScript; import com.fr.js.JavaScript;
import com.fr.write.DBManipulation; import com.fr.write.DBManipulation;
import com.fr.write.DMLConfigJob; import com.fr.write.DMLConfigJob;
import com.fr.write.config.ColumnConfig;
import com.fr.write.config.DMLConfig; import com.fr.write.config.DMLConfig;
import java.util.List; import java.util.List;
@ -41,14 +43,28 @@ public class SearchCommit2DBJSFormulaAction implements SearchJSFormula {
private void dealWithDBManipulation(List<FormulaInfo> formulaInfos, ITContent content, DBManipulation dbManipulation) { private void dealWithDBManipulation(List<FormulaInfo> formulaInfos, ITContent content, DBManipulation dbManipulation) {
DMLConfig dmlConfig = dbManipulation.getDmlConfig(); DMLConfig dmlConfig = dbManipulation.getDmlConfig();
//值中的公式
dealWithColumnValue(formulaInfos, content, dmlConfig);
//处理提交条件中的公式 //处理提交条件中的公式
dealWithCommit2DBCondition(formulaInfos, content, dmlConfig); dealWithCommit2DBCondition(formulaInfos, content, dmlConfig);
//处理DBManipulation //处理DBManipulation
dealWithSubmitJob(formulaInfos, content, dmlConfig); 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) { private void dealWithSubmitJob(List<FormulaInfo> formulaInfos, ITContent content, DMLConfig dmlConfig) {
for (int i = 0; i < dmlConfig.getSubmitJobCount(); i++) { for (int i = 0, len = dmlConfig.getSubmitJobCount(); i < len; i++) {
//这边自定义事件不需要处理,只处理提交事件 //这边自定义事件不需要处理,只处理提交事件
if (dmlConfig.getSubmitJob(i) instanceof DMLConfigJob) { if (dmlConfig.getSubmitJob(i) instanceof DMLConfigJob) {
ITContent newContent = ITContent.copy(content); ITContent newContent = ITContent.copy(content);

15
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchExportJSFormulaAction.java

@ -1,11 +1,14 @@
package com.fr.design.actions.replace.action.content.formula.highlight.javascript; 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.FormulaInfo;
import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.js.ExportJavaScript; import com.fr.js.ExportJavaScript;
import com.fr.js.JavaScript; import com.fr.js.JavaScript;
import com.fr.js.SingleJavaScript; import com.fr.js.SingleJavaScript;
import com.fr.stable.ParameterProvider;
import java.util.List; import java.util.List;
@ -26,8 +29,10 @@ public class SearchExportJSFormulaAction implements SearchJSFormula {
public void searchJSFormulaFromOther(List<FormulaInfo> formulaInfos, ITContent content, JavaScript javaScript) { public void searchJSFormulaFromOther(List<FormulaInfo> formulaInfos, ITContent content, JavaScript javaScript) {
//如果导出当前模板,可以存公式的地方就是命名方式-自定义 //如果导出当前模板,可以存公式的地方就是命名方式-自定义
if (((ExportJavaScript) javaScript).isCurrentTemplate()) { if (((ExportJavaScript) javaScript).isCurrentTemplate()) {
content.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current"));
dealSingleJavaScript(formulaInfos, content, ((ExportJavaScript) javaScript).getCurrentTemplateJavaScript()); dealSingleJavaScript(formulaInfos, content, ((ExportJavaScript) javaScript).getCurrentTemplateJavaScript());
} else { } else {
content.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Other"));
List<SingleJavaScript> list = ((ExportJavaScript) javaScript).getJsListForOtherTemplates(); List<SingleJavaScript> list = ((ExportJavaScript) javaScript).getJsListForOtherTemplates();
if (isListExist(list)) { if (isListExist(list)) {
for (SingleJavaScript singleJavaScript : list) { for (SingleJavaScript singleJavaScript : list) {
@ -51,6 +56,16 @@ public class SearchExportJSFormulaAction implements SearchJSFormula {
); );
formulaInfos.add(new FormulaInfo(newContent)); formulaInfos.add(new FormulaInfo(newContent));
} }
if (!javaScript.isExtendParameters()) {
ITContent paraContent = ITContent.copy(content);
for (ParameterProvider parameter : javaScript.getParameters()) {
if (parameter.getValue() instanceof Formula) {
paraContent.addOtherPos(Toolkit.i18nText("Fine-Design_Basic_Base_Value"));
paraContent.setReplaceObject(parameter.getValue());
formulaInfos.add(new FormulaInfo(paraContent));
}
}
}
} }
/** /**

4
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchDateEditorFormulaAction.java

@ -34,7 +34,7 @@ public class SearchDateEditorFormulaAction extends AbstractSearchWidgetFormulaAc
if (dateEditor.getEndDateFM() != null && StringUtils.isNotEmpty(dateEditor.getEndDateFM().getContent())) { if (dateEditor.getEndDateFM() != null && StringUtils.isNotEmpty(dateEditor.getEndDateFM().getContent())) {
ITContent newContent = ITContent.copy(content); ITContent newContent = ITContent.copy(content);
newContent.setReplaceObject(dateEditor.getEndDateFM()); newContent.setReplaceObject(dateEditor.getEndDateFM());
newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_End_Time")); newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_FS_End_Date"));
formulaInfos.add(new FormulaInfo(newContent)); formulaInfos.add(new FormulaInfo(newContent));
} }
} }
@ -44,7 +44,7 @@ public class SearchDateEditorFormulaAction extends AbstractSearchWidgetFormulaAc
if (dateEditor.getStartDateFM() != null && StringUtils.isNotEmpty(dateEditor.getStartDateFM().getContent())) { if (dateEditor.getStartDateFM() != null && StringUtils.isNotEmpty(dateEditor.getStartDateFM().getContent())) {
ITContent newContent = ITContent.copy(content); ITContent newContent = ITContent.copy(content);
newContent.setReplaceObject(dateEditor.getStartDateFM()); newContent.setReplaceObject(dateEditor.getStartDateFM());
newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Start_Time")); newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_FS_Start_Date"));
formulaInfos.add(new FormulaInfo(newContent)); formulaInfos.add(new FormulaInfo(newContent));
} }
} }

40
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/SearchTreeEditorFormulaAction.java

@ -1,11 +1,15 @@
package com.fr.design.actions.replace.action.content.formula.widget; package com.fr.design.actions.replace.action.content.formula.widget;
import com.fr.data.Dictionary;
import com.fr.data.impl.FormulaDictionary;
import com.fr.data.impl.FormulaDisplayDictionary; import com.fr.data.impl.FormulaDisplayDictionary;
import com.fr.data.impl.TableDataDictionary;
import com.fr.data.impl.TreeNodeAttr; import com.fr.data.impl.TreeNodeAttr;
import com.fr.data.impl.TreeNodeWrapper; import com.fr.data.impl.TreeNodeWrapper;
import com.fr.design.actions.replace.info.FormulaInfo; 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.ITContent;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.form.ui.DictionaryContainer;
import com.fr.form.ui.TreeEditor; import com.fr.form.ui.TreeEditor;
import com.fr.form.ui.tree.LayerConfig; import com.fr.form.ui.tree.LayerConfig;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -37,28 +41,38 @@ public class SearchTreeEditorFormulaAction extends AbstractSearchWidgetFormulaAc
if (((TreeEditor) content.getReplaceObject()).getBuildModelConfig() != null) { if (((TreeEditor) content.getReplaceObject()).getBuildModelConfig() != null) {
//LayerConfig[] 急速分层构建 //LayerConfig[] 急速分层构建
//TreeNodeWrapper 普通分层构建 //TreeNodeWrapper 普通分层构建
if (((TreeEditor) content.getReplaceObject()).getBuildModelConfig() instanceof LayerConfig[]) { //TableDataDictionary 自动构建
LayerConfig[] layerConfigs = (LayerConfig[]) ((TreeEditor) content.getReplaceObject()).getBuildModelConfig(); Object object = ((TreeEditor) content.getReplaceObject()).getBuildModelConfig();
if (object instanceof LayerConfig[]) {
LayerConfig[] layerConfigs = (LayerConfig[]) object;
dealWithLayerConfigs(layerConfigs, content, formulaInfos); dealWithLayerConfigs(layerConfigs, content, formulaInfos);
} else if (((TreeEditor) content.getReplaceObject()).getBuildModelConfig() instanceof TreeNodeWrapper) { } else if (object instanceof TreeNodeWrapper) {
TreeNodeWrapper wrapper = (TreeNodeWrapper) ((TreeEditor) content.getReplaceObject()).getBuildModelConfig(); TreeNodeWrapper wrapper = (TreeNodeWrapper) object;
dealWithTreeNodeWrapper(wrapper, content, formulaInfos); dealWithTreeNodeWrapper(wrapper, content, formulaInfos);
} else if (object instanceof TableDataDictionary) {
TableDataDictionary tableDataDictionary = (TableDataDictionary) object;
if (tableDataDictionary.getFormula() != null) {
ITContent autoContent = ITContent.copy(content);
autoContent.addOtherPos(
Toolkit.i18nText("Fine-Design_Basic_Auto_Build"),
Toolkit.i18nText("Fine-Design_Basic_Display_Value")
);
autoContent.setReplaceObject(tableDataDictionary.getFormula());
formulaInfos.add(new FormulaInfo(autoContent));
}
} }
} }
} }
} }
private void dealWithTreeNodeWrapper(TreeNodeWrapper wrapper, ITContent content, List<FormulaInfo> formulaInfos) { private void dealWithTreeNodeWrapper(TreeNodeWrapper wrapper, ITContent content, List<FormulaInfo> formulaInfos) {
for (TreeNodeAttr attr : wrapper.getTreeNodeAttrs()) { for (TreeNodeAttr attr : wrapper.getTreeNodeAttrs()) {
if (((FormulaDisplayDictionary) attr.getDictionary()).getFormula() != null if (attr.getDictionary() != null) {
&& StringUtils.isNotEmpty(((FormulaDisplayDictionary) attr.getDictionary()).getFormula().getContent())) { DictionaryType type = DictionaryType.match(attr.getDictionary().getClass().getSimpleName());
ITContent newContent = ITContent.copy(content); if (type != null) {
newContent.setReplaceObject(((FormulaDisplayDictionary) attr.getDictionary()).getFormula()); type.searchFormulaFromDictionary(content, formulaInfos, attr.getDictionary());
newContent.addOtherPos( }
Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary"),
Toolkit.i18nText("Fine-Design_Basic_Layer_Build")
);
formulaInfos.add(new FormulaInfo(newContent));
} }
} }
} }

31
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java

@ -7,14 +7,20 @@ import com.fr.design.actions.replace.info.JSInfo;
import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.actions.replace.utils.SearchJSUtils; import com.fr.design.actions.replace.utils.SearchJSUtils;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.js.JavaScriptImpl;
import com.fr.js.NameJavaScript; import com.fr.js.NameJavaScript;
import com.fr.js.NameJavaScriptGroup;
import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.base.RefreshMoreLabel; import com.fr.plugin.chart.base.RefreshMoreLabel;
import com.fr.plugin.chart.base.VanChartHtmlLabel; import com.fr.plugin.chart.base.VanChartHtmlLabel;
import com.fr.plugin.chart.custom.CustomPlotFactory;
import com.fr.plugin.chart.custom.VanChartCustomPlot;
import com.fr.plugin.chart.vanchart.VanChart; import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.stable.collections.combination.Pair; import com.fr.stable.collections.combination.Pair;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -58,10 +64,35 @@ public class SearchChartJSAction {
for (int i = 0; i < chartCollection.getChartCount(); i++) { for (int i = 0; i < chartCollection.getChartCount(); i++) {
ITContent chartContent = ITContent.copy(content); ITContent chartContent = ITContent.copy(content);
chartContent.addOtherPos(chartCollection.getChart(i).getChartName()); chartContent.addOtherPos(chartCollection.getChart(i).getChartName());
//坐标轴
searchAxisJS(jsInfos, chartContent, chartCollection.getChart(i)); searchAxisJS(jsInfos, chartContent, chartCollection.getChart(i));
//组合图表-条件属性-超链特判
dealCustomPlot(jsInfos, conditionContent, chartCollection.getChart(i));
}
} }
private void dealCustomPlot(List<JSInfo> jsInfos, ITContent conditionContent, Chart chart) {
if (chart.getPlot() instanceof VanChartCustomPlot) {
VanChartCustomPlot customPlot = chart.getPlot();
for (VanChartPlot plot : customPlot.getCustomPlotList()) {
NameJavaScriptGroup javaScriptGroup = plot.getHotHyperLink();
if (javaScriptGroup != null) {
for (int i = 0; i < javaScriptGroup.size(); i++) {
if (javaScriptGroup.getNameHyperlink(i).getJavaScript() instanceof JavaScriptImpl) {
ITContent content = ITContent.copy(conditionContent);
content.addOtherPos(
CustomPlotFactory.getTitle(CustomPlotFactory.getCustomType(plot)),
javaScriptGroup.getNameHyperlink(i).getName()
);
content.setReplaceObject(javaScriptGroup.getNameHyperlink(i));
jsInfos.add(new JSInfo(content));
}
} }
}
}
}
}
private void dealMonitorRefreshJS(ITContent conditionContent, ChartCollection chartCollection, List<JSInfo> jsInfos) { private void dealMonitorRefreshJS(ITContent conditionContent, ChartCollection chartCollection, List<JSInfo> jsInfos) {
for (int i = 0; i < chartCollection.getChartCount(); i++) { for (int i = 0; i < chartCollection.getChartCount(); i++) {

35
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java

@ -15,6 +15,7 @@ import com.fr.js.JavaScriptImpl;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.report.web.ToolBarManager; import com.fr.report.web.ToolBarManager;
import com.fr.report.web.WebContent; import com.fr.report.web.WebContent;
import com.fr.report.web.util.ReportEngineEventMapping;
import com.fr.web.attr.ReportWebAttr; import com.fr.web.attr.ReportWebAttr;
import java.util.ArrayList; import java.util.ArrayList;
@ -32,6 +33,7 @@ import java.util.Map;
public class SearchWebJSAction implements SearchJS { public class SearchWebJSAction implements SearchJS {
private final static Map<String, String> MAP = new HashMap<>(); private final static Map<String, String> MAP = new HashMap<>();
private final static Map<String, String> SERVER_MAP = new HashMap<>();
private List<WebContent> arrayList = new ArrayList<>(); private List<WebContent> arrayList = new ArrayList<>();
private SearchWebJSAction() { private SearchWebJSAction() {
@ -41,6 +43,9 @@ public class SearchWebJSAction implements SearchJS {
MAP.put("WebPage", Toolkit.i18nText("Fine-Design_Report_Pagination_Setting")); MAP.put("WebPage", Toolkit.i18nText("Fine-Design_Report_Pagination_Setting"));
MAP.put("WebWrite", Toolkit.i18nText("Fine-Design_Report_Write_Setting")); MAP.put("WebWrite", Toolkit.i18nText("Fine-Design_Report_Write_Setting"));
MAP.put("WebView", Toolkit.i18nText("Fine-Design_Report_Data_Analysis_Settings")); MAP.put("WebView", Toolkit.i18nText("Fine-Design_Report_Data_Analysis_Settings"));
SERVER_MAP.put("WebPage", Toolkit.i18nText("Fine-Design_Report_ReportServerP_Report_Server_Parameter") + "-" + Toolkit.i18nText("Fine-Design_Report_Pagination_Setting"));
SERVER_MAP.put("WebWrite", Toolkit.i18nText("Fine-Design_Report_ReportServerP_Report_Server_Parameter") + "-" + Toolkit.i18nText("Fine-Design_Report_Write_Setting"));
SERVER_MAP.put("WebView", Toolkit.i18nText("Fine-Design_Report_ReportServerP_Report_Server_Parameter") + "-" + Toolkit.i18nText("Fine-Design_Report_Data_Analysis_Settings"));
} }
@ -54,6 +59,25 @@ public class SearchWebJSAction implements SearchJS {
private void addJSInfos2ListFromWeb(JTemplate jTemplate, List<JSInfo> jsInfos) { private void addJSInfos2ListFromWeb(JTemplate jTemplate, List<JSInfo> jsInfos) {
dealServerWebAttr(jTemplate, jsInfos);
dealTemplateWebAttr(jTemplate, jsInfos);
}
private void dealServerWebAttr(JTemplate jTemplate, List<JSInfo> jsInfos) {
ReportWebAttr webReportAttr = ReportWebAttr.getInstance();
if (webReportAttr != null) {
webReportAttr.getWebWrite();
ITContent content = new ITContent();
content.setTemplateName(jTemplate.getTemplateName());
content.setJumpAble(false);
addWebContent2Array(webReportAttr);
for (int i = 0; i < arrayList.size(); i++) {
addJSInfos2ListFromServerWebAttr(content, jsInfos, arrayList.get(i));
}
}
}
private void dealTemplateWebAttr(JTemplate jTemplate, List<JSInfo> jsInfos) {
if (jTemplate.getTarget() instanceof WorkBook) { if (jTemplate.getTarget() instanceof WorkBook) {
WorkBook workBook = (WorkBook) jTemplate.getTarget(); WorkBook workBook = (WorkBook) jTemplate.getTarget();
ReportWebAttr webAttr = workBook.getReportWebAttr(); ReportWebAttr webAttr = workBook.getReportWebAttr();
@ -67,6 +91,15 @@ public class SearchWebJSAction implements SearchJS {
} }
} }
private void addJSInfos2ListFromServerWebAttr(ITContent content, List<JSInfo> jsInfos, WebContent webContent) {
ITContent newContent = ITContent.copy(content);
if (SERVER_MAP.containsKey(webContent.getClass().getSimpleName())) {
newContent.addOtherPos(SERVER_MAP.get(webContent.getClass().getSimpleName()));
}
addJSInfos2ListFromWebButton(newContent, jsInfos, webContent);
addJSInfos2ListFromWebListener(newContent, jsInfos, webContent);
}
private void addJSInfos2ListFromArray(ITContent content, List<JSInfo> jsInfos, WebContent webContent) { private void addJSInfos2ListFromArray(ITContent content, List<JSInfo> jsInfos, WebContent webContent) {
ITContent newContent = ITContent.copy(content); ITContent newContent = ITContent.copy(content);
if (MAP.containsKey(webContent.getClass().getSimpleName())) { if (MAP.containsKey(webContent.getClass().getSimpleName())) {
@ -81,6 +114,7 @@ public class SearchWebJSAction implements SearchJS {
Listener listener = webContent.getListener(i); Listener listener = webContent.getListener(i);
ITContent newContent = ITContent.copy(content); ITContent newContent = ITContent.copy(content);
newContent.setReplaceObject(listener); newContent.setReplaceObject(listener);
newContent.addOtherPos(Toolkit.i18nText(ReportEngineEventMapping.getLocaleName(listener.getEventName())));
SearchJSUtils.searchJSFromListener(jsInfos, newContent); SearchJSUtils.searchJSFromListener(jsInfos, newContent);
} }
} }
@ -94,6 +128,7 @@ public class SearchWebJSAction implements SearchJS {
} }
private void addWebContent2Array(ReportWebAttr webAttr) { private void addWebContent2Array(ReportWebAttr webAttr) {
arrayList.clear();
if (webAttr != null) { if (webAttr != null) {
addContent(arrayList, webAttr.getWebWrite()); addContent(arrayList, webAttr.getWebWrite());
addContent(arrayList, webAttr.getWebPage()); addContent(arrayList, webAttr.getWebPage());

28
designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java

@ -219,34 +219,6 @@ public class CellInfo implements Info {
return ((DSColumn) o.getValue()).getDSName(); return ((DSColumn) o.getValue()).getDSName();
} }
}, },
/**
* 富文本形式
* 为了不破坏富文本的格式暂时不对样式不同的文本进行连接替换每个样式不同的文本都是一个独立的个体
*/
RICH_TEXT("RichText") {
@Override
public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) {
cellInfo.updateOldStr(GeneralUtils.objectToString(((RichText) o).getContent()), findStr);
Iterator<RichChar> it = ((RichText) o).charIterator();
while (it.hasNext()) {
RichChar richChar = it.next();
richChar.setText(ShowValueUtils.replaceAll(richChar.getText(), findStr, replaceStr));
}
}
@Override
public void addValue2Map(Object o, HashMap<String, String> map) {
map.put("content", ((RichText) o).getContent());
}
@Override
public String getCheckValue(Info info) {
CellElement o = (CellElement) info.getContent().getReplaceObject();
return ((RichText) o.getValue()).getContent();
}
},
/** /**
* 公式类型 * 公式类型
*/ */

10
designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java

@ -2,6 +2,7 @@ package com.fr.design.actions.replace.info;
import com.fr.data.impl.DBTableData; import com.fr.data.impl.DBTableData;
import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.design.data.DesignTableDataManager;
import com.fr.form.event.Listener; import com.fr.form.event.Listener;
import com.fr.js.JavaScriptImpl; import com.fr.js.JavaScriptImpl;
import com.fr.js.NameJavaScript; import com.fr.js.NameJavaScript;
@ -45,7 +46,7 @@ public enum ReplaceObject implements DealWithInfoValue {
} else { } else {
NameJavaScript javaScript = ((NameJavaScript) (info.getContent().getReplaceObject())); NameJavaScript javaScript = ((NameJavaScript) (info.getContent().getReplaceObject()));
info.updateOldStr(javaScript.getName(), findStr); info.updateOldStr(javaScript.getName(), findStr);
javaScript.setName(javaScript.getName().replaceAll(findStr, replaceStr)); javaScript.setName(ShowValueUtils.replaceAll(javaScript.getName(), findStr, replaceStr));
} }
} }
@ -86,15 +87,13 @@ public enum ReplaceObject implements DealWithInfoValue {
@Override @Override
public void setValue(Info info, String findStr, String replaceStr, List<Pair<Integer, Integer>> operatorArray) { public void setValue(Info info, String findStr, String replaceStr, List<Pair<Integer, Integer>> operatorArray) {
if (((JSInfo) info).isContent()) { if (((JSInfo) info).isContent()) {
if (operatorArray.size() > 0) {
JavaScriptImpl javaScript = (JavaScriptImpl) ((Listener) (info.getContent().getReplaceObject())).getAction(); JavaScriptImpl javaScript = (JavaScriptImpl) ((Listener) (info.getContent().getReplaceObject())).getAction();
info.updateOldStr(javaScript.getContent(), findStr); info.updateOldStr(javaScript.getContent(), findStr);
javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr)); javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr));
}
} else { } else {
Listener listener = ((Listener) ((info.getContent().getReplaceObject()))); Listener listener = ((Listener) ((info.getContent().getReplaceObject())));
info.updateOldStr(listener.getName(), findStr); info.updateOldStr(listener.getName(), findStr);
listener.setName(listener.getName().replaceAll(findStr, replaceStr)); listener.setName(ShowValueUtils.replaceAll(listener.getName(), findStr, replaceStr));
} }
} }
@ -134,14 +133,12 @@ public enum ReplaceObject implements DealWithInfoValue {
@Override @Override
public void setValue(Info info, String findStr, String replaceStr, List<Pair<Integer, Integer>> operatorArray) { public void setValue(Info info, String findStr, String replaceStr, List<Pair<Integer, Integer>> operatorArray) {
if (((JSInfo) info).isContent()) { if (((JSInfo) info).isContent()) {
if (operatorArray.size() > 0) {
VanChartHtmlLabel htmlLabel = ((VanChartHtmlLabel) (info.getContent().getReplaceObject())); VanChartHtmlLabel htmlLabel = ((VanChartHtmlLabel) (info.getContent().getReplaceObject()));
StringBuilder stringBuilder = new StringBuilder(htmlLabel.getCustomText()); StringBuilder stringBuilder = new StringBuilder(htmlLabel.getCustomText());
info.updateOldStr(htmlLabel.getCustomText(), findStr); info.updateOldStr(htmlLabel.getCustomText(), findStr);
htmlLabel.setCustomText(ShowValueUtils.replaceAll(htmlLabel.getCustomText(), findStr, replaceStr)); htmlLabel.setCustomText(ShowValueUtils.replaceAll(htmlLabel.getCustomText(), findStr, replaceStr));
} }
} }
}
@Override @Override
public String getInfoShowStr(Info info) { public String getInfoShowStr(Info info) {
@ -210,6 +207,7 @@ public enum ReplaceObject implements DealWithInfoValue {
DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject();
info.updateOldStr(dbTableData.getQuery(), findStr); info.updateOldStr(dbTableData.getQuery(), findStr);
dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr)); dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr));
//todo DesignTableDataManager
} }
@Override @Override

19
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java

@ -1,16 +1,15 @@
package com.fr.design.actions.replace.ui; package com.fr.design.actions.replace.ui;
import com.fr.design.actions.help.replace.ITReplaceHelper;
import com.fr.design.actions.replace.action.ShowSearchResultAction; import com.fr.design.actions.replace.action.ShowSearchResultAction;
import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.info.Info;
import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.dialog.UIDialog; import com.fr.design.dialog.UIDialog;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
@ -31,6 +30,9 @@ import java.awt.event.ActionListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Pattern;
import static com.fr.design.actions.replace.ui.ITTableEditorPane.getEditTable;
/** /**
* 主面板 * 主面板
@ -51,7 +53,7 @@ public class ITReplaceMainDialog extends UIDialog {
private boolean searchFlag; private boolean searchFlag;
private String searchStr; private String searchStr;
private ITReplaceMainDialog() { public ITReplaceMainDialog() {
super(DesignerContext.getDesignerFrame()); super(DesignerContext.getDesignerFrame());
init(); init();
} }
@ -79,7 +81,6 @@ public class ITReplaceMainDialog extends UIDialog {
} }
} }
} }
instance.fitScreen();
return instance; return instance;
} }
@ -162,16 +163,14 @@ public class ITReplaceMainDialog extends UIDialog {
for (Info info : searchResultList) { for (Info info : searchResultList) {
if (info.getContent().isSelected()) { if (info.getContent().isSelected()) {
info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray()); info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray());
ShowValueUtils.updateHighlight(info, replaceStr);
} }
} }
southPanel.getTableEditorPane().update(); southPanel.getTableEditorPane().update();
northPane.refreshReplaceInputComboBoxItems(); northPane.refreshReplaceInputComboBoxItems();
ITTableEditorPane.getEditTable().repaint(); ITTableEditorPane.getEditTable().repaint();
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTabChange();
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true);
setSearchFlag(false); setSearchFlag(false);
search();
} else { } else {
Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")}; Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")};
int optionSelected = FineJOptionPane.showOptionDialog( int optionSelected = FineJOptionPane.showOptionDialog(
@ -285,12 +284,15 @@ public class ITReplaceMainDialog extends UIDialog {
itTableEditor.clear(); itTableEditor.clear();
String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText();
setSearchStr(searchStr); setSearchStr(searchStr);
ShowValueUtils.containPattern = Pattern.compile(ShowValueUtils.changeRegex(searchStr));
ShowSearchResultAction searchAction = ShowSearchResultAction.match(GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem())); ShowSearchResultAction searchAction = ShowSearchResultAction.match(GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem()));
if (searchAction != null) { if (searchAction != null) {
searchResultList = searchAction.addMatchResult(searchStr, searchAction.showSearchValue(jTemplate)); searchResultList = searchAction.addMatchResult(searchStr, searchAction.showSearchValue(jTemplate));
itTableEditor.add(searchResultList); itTableEditor.add(searchResultList);
northPane.getResultLabel().setText("<html>" + Toolkit.i18nText("Fine-Design_Replace_Search_Finish") + "<font color = 'rgb(61,153,249)'>" + searchResultList.size() + "</font>" + Toolkit.i18nText("Fine-Design_Replace_Result")); northPane.getResultLabel().setText("<html>" + Toolkit.i18nText("Fine-Design_Replace_Search_Finish") + "<font color = 'rgb(61,153,249)'>" + searchResultList.size() + "</font>" + Toolkit.i18nText("Fine-Design_Replace_Result"));
} }
ITTableEditorPane.ITHeaderRenderer renderer = (ITTableEditorPane.ITHeaderRenderer) getEditTable().getTableHeader().getDefaultRenderer();
renderer.refreshHeader(getEditTable());
itTableEditor.fireTableDataChanged(); itTableEditor.fireTableDataChanged();
northPane.refreshFindInputComboBoxItems(); northPane.refreshFindInputComboBoxItems();
setSearchFlag(true); setSearchFlag(true);
@ -307,6 +309,9 @@ public class ITReplaceMainDialog extends UIDialog {
} }
} }
/** /**
* 检测结果是否合法 * 检测结果是否合法
*/ */

5
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java

@ -47,6 +47,7 @@ public class ITReplaceNorthPanel {
private static final int HEIGHT = 161; private static final int HEIGHT = 161;
private static final int BUTTON_WIDTH = 60; private static final int BUTTON_WIDTH = 60;
private static final int BUTTON_GAP = 20; private static final int BUTTON_GAP = 20;
private static final int MATCH_WIDTH = 70;
private int findLabelX, findLabelY, findLabelWidth, findLabelHeight; private int findLabelX, findLabelY, findLabelWidth, findLabelHeight;
@ -83,7 +84,7 @@ public class ITReplaceNorthPanel {
resultLabel = new UILabel(); resultLabel = new UILabel();
String[] rangeItems = new String[]{Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")}; String[] rangeItems = new String[]{Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")};
String[] replaceInputItems = new String[]{""}; String[] replaceInputItems = new String[]{StringUtils.EMPTY};
findCombobox = new UIComboBox(findItems.toArray()); findCombobox = new UIComboBox(findItems.toArray());
rangeCombobox = new UIComboBox(rangeItems); rangeCombobox = new UIComboBox(rangeItems);
findInputCombobox = new UIComboBox(findInputItems.toArray()) { findInputCombobox = new UIComboBox(findInputItems.toArray()) {
@ -247,7 +248,7 @@ public class ITReplaceNorthPanel {
private void setUIRadioButtonBounds(int x, int y, int templateWidth) { private void setUIRadioButtonBounds(int x, int y, int templateWidth) {
matchX = x + templateWidth / 60; matchX = x + templateWidth / 60;
matchY = y + 90; matchY = y + 90;
matchWidth = templateWidth; matchWidth = MATCH_WIDTH;
matchHeight = 25; matchHeight = 25;
matchRadioButton.setBounds(matchX, matchY, matchWidth, matchHeight); matchRadioButton.setBounds(matchX, matchY, matchWidth, matchHeight);
} }

11
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java

@ -14,11 +14,20 @@ import java.awt.Color;
public class ITReplaceSouthPanel { public class ITReplaceSouthPanel {
ITTableEditorPane tableEditorPane; ITTableEditorPane tableEditorPane;
ITTableEditor itTableEditor; ITTableEditor itTableEditor;
//勾选框索引
public static final int CHECKBOX_INDEX = 0;
//ITContent在表格的列索引
public static final int CONTENT_INDEX = 6;
public ITReplaceSouthPanel() { public ITReplaceSouthPanel() {
itTableEditor = new ITTableEditor(); itTableEditor = new ITTableEditor();
tableEditorPane = new ITTableEditorPane<>(itTableEditor); tableEditorPane = new ITTableEditorPane<>(itTableEditor);
RowSorter<ITTableEditor> sorter = new TableRowSorter<ITTableEditor>(itTableEditor); RowSorter<ITTableEditor> sorter = new TableRowSorter<ITTableEditor>(itTableEditor){
@Override
public boolean isSortable(int column) {
return column != CHECKBOX_INDEX || column != CONTENT_INDEX;
}
};
tableEditorPane.getEditTable().setRowSorter(sorter); tableEditorPane.getEditTable().setRowSorter(sorter);
tableEditorPane.getEditTable().setSelectionBackground(new Color(217, 235, 254)); tableEditorPane.getEditTable().setSelectionBackground(new Color(217, 235, 254));
tableEditorPane.getEditTable().setRowHeight(tableEditorPane.getEditTable().getRowHeight() / 2 + tableEditorPane.getEditTable().getRowHeight()); tableEditorPane.getEditTable().setRowHeight(tableEditorPane.getEditTable().getRowHeight() / 2 + tableEditorPane.getEditTable().getRowHeight());

9
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java

@ -5,11 +5,14 @@ import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.ReportComponentComposite;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.AbstractCellEditor; import javax.swing.AbstractCellEditor;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer; import javax.swing.table.TableCellRenderer;
import java.awt.Component; import java.awt.Component;
@ -36,7 +39,7 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor
paraButton.addActionListener(new ActionListener() { paraButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
ITContent content = (ITContent) getEditTable().getValueAt(getEditTable().getEditingRow(), 7); ITContent content = (ITContent) getEditTable().getValueAt(getEditTable().getEditingRow(), 6);
if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) { if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) {
ITReplaceMainDialog.setITReplaceFlag(true); ITReplaceMainDialog.setITReplaceFlag(true);
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(new TRL(GeneralUtils.objectToString(content.getTrlString()))); HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().navigate(new TRL(GeneralUtils.objectToString(content.getTrlString())));
@ -60,7 +63,7 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor
*/ */
@Override @Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
ITContent content = (ITContent) table.getValueAt(row, 7); ITContent content = (ITContent) table.getValueAt(row, 6);
paraButton.setEnabled(content.isJumpAble()); paraButton.setEnabled(content.isJumpAble());
return paraButton; return paraButton;
} }
@ -78,7 +81,7 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor
*/ */
@Override @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
ITContent content = (ITContent) table.getValueAt(row, 7); ITContent content = (ITContent) table.getValueAt(row, 6);
paraButton.setEnabled(content.isJumpAble()); paraButton.setEnabled(content.isJumpAble());
return paraButton; return paraButton;
} }

25
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java

@ -31,7 +31,6 @@ public class ITTableEditor extends UITableModelAdapter {
Toolkit.i18nText("Fine-Design_Replace_Template_Name"), Toolkit.i18nText("Fine-Design_Replace_Template_Name"),
Toolkit.i18nText("Fine-Design_Replace_Sheet_Name"), Toolkit.i18nText("Fine-Design_Replace_Sheet_Name"),
Toolkit.i18nText("Fine-Design_Replace_Block_Name"), Toolkit.i18nText("Fine-Design_Replace_Block_Name"),
Toolkit.i18nText("Fine-Design_Replace_Location"),
Toolkit.i18nText("Fine-Design_Replace_Location_Info"), Toolkit.i18nText("Fine-Design_Replace_Location_Info"),
Toolkit.i18nText("Fine-Design_Replace_Operator"), Toolkit.i18nText("Fine-Design_Replace_Operator"),
}); });
@ -43,15 +42,14 @@ public class ITTableEditor extends UITableModelAdapter {
UILabel.class, UILabel.class,
UILabel.class, UILabel.class,
UILabel.class, UILabel.class,
UILabel.class,
ITTableButton.class, ITTableButton.class,
}); });
this.setDefaultEditor(ITTableButton.class, new ITTableButton()); this.setDefaultEditor(ITTableButton.class, new ITTableButton());
this.setDefaultRenderer(ITTableButton.class, new ITTableButton()); this.setDefaultRenderer(ITTableButton.class, new ITTableButton());
this.createTable().getColumnModel().getColumn(7).setMaxWidth(50); this.createTable().getColumnModel().getColumn(ITReplaceSouthPanel.CONTENT_INDEX).setMaxWidth(50);
this.createTable().getColumnModel().getColumn(0).setMaxWidth(50); this.createTable().getColumnModel().getColumn(ITReplaceSouthPanel.CHECKBOX_INDEX).setMaxWidth(50);
} }
@ -83,7 +81,7 @@ public class ITTableEditor extends UITableModelAdapter {
*/ */
@Override @Override
public boolean isCellEditable(int row, int col) { public boolean isCellEditable(int row, int col) {
return col == 7 || col == 0; return col == ITReplaceSouthPanel.CONTENT_INDEX || col == ITReplaceSouthPanel.CHECKBOX_INDEX;
} }
/** /**
@ -157,21 +155,10 @@ public class ITTableEditor extends UITableModelAdapter {
return " " + content.getBlockName(); return " " + content.getBlockName();
} }
}, },
/** /**
* 第六列展示位置 * 第六列展示路径
*/ */
INDEX_5(5) { INDEX_5(5) {
@Override
public Object returnContentObject(ITContent content) {
return " " + content.getShowObject();
}
},
/**
* 第七列展示路径
*/
INDEX_6(6) {
@Override @Override
public Object returnContentObject(ITContent content) { public Object returnContentObject(ITContent content) {
return " " + content.getOtherPos(); return " " + content.getOtherPos();
@ -179,9 +166,9 @@ public class ITTableEditor extends UITableModelAdapter {
}, },
/** /**
* 展示定位按钮 * 展示定位按钮
*/ */
INDEX_7(7) { INDEX_6(6) {
@Override @Override
public Object returnContentObject(ITContent content) { public Object returnContentObject(ITContent content) {
return content; return content;

22
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java

@ -70,8 +70,8 @@ public class ITTableEditorPane<T> extends BasicPane {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
int row = ((JTable) e.getSource()).rowAtPoint(e.getPoint()); int row = ((JTable) e.getSource()).rowAtPoint(e.getPoint());
int col = ((JTable) e.getSource()).columnAtPoint(e.getPoint()); int col = ((JTable) e.getSource()).columnAtPoint(e.getPoint());
if (col == 0) { if (col == ITReplaceSouthPanel.CHECKBOX_INDEX) {
ITContent content = (ITContent) editTable.getValueAt(row, 7); ITContent content = (ITContent) editTable.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX);
if (content.isSelected()) { if (content.isSelected()) {
content.setSelected(false); content.setSelected(false);
editTable.setValueAt(content.isSelected(), row, col); editTable.setValueAt(content.isSelected(), row, col);
@ -116,7 +116,7 @@ public class ITTableEditorPane<T> extends BasicPane {
if (e.getClickCount() > 0) { if (e.getClickCount() > 0) {
//获得选中列 //获得选中列
int selectColumn = tableHeader.columnAtPoint(e.getPoint()); int selectColumn = tableHeader.columnAtPoint(e.getPoint());
if (selectColumn == 0) { if (selectColumn == ITReplaceSouthPanel.CHECKBOX_INDEX) {
boolean value = !selectBox.isSelected(); boolean value = !selectBox.isSelected();
selectBox.setSelected(value); selectBox.setSelected(value);
selectAllOrNull(value); selectAllOrNull(value);
@ -128,6 +128,16 @@ public class ITTableEditorPane<T> extends BasicPane {
}); });
} }
/**
* 刷新表头
* @param table
*/
public void refreshHeader(JTable table) {
selectBox.setSelected(true);
int rowHeight = table.getRowHeight();
table.updateUI();
table.setRowHeight(rowHeight);
}
@Override @Override
public Component getTableCellRendererComponent(JTable table, public Component getTableCellRendererComponent(JTable table,
@ -142,13 +152,15 @@ public class ITTableEditorPane<T> extends BasicPane {
label.setHorizontalAlignment(SwingConstants.LEFT); label.setHorizontalAlignment(SwingConstants.LEFT);
selectBox.setHorizontalAlignment(SwingConstants.CENTER); selectBox.setHorizontalAlignment(SwingConstants.CENTER);
selectBox.setBorderPainted(true); selectBox.setBorderPainted(true);
JComponent component = (column == 0) ? selectBox : label; JComponent component = (column == ITReplaceSouthPanel.CHECKBOX_INDEX) ? selectBox : label;
component.setForeground(tableHeader.getForeground()); component.setForeground(tableHeader.getForeground());
component.setBackground(tableHeader.getBackground()); component.setBackground(tableHeader.getBackground());
component.setFont(tableHeader.getFont()); component.setFont(tableHeader.getFont());
component.setBorder(UIManager.getBorder("TableHeader.cellBorder")); component.setBorder(UIManager.getBorder("TableHeader.cellBorder"));
return component; return component;
} }
} }
@ -175,7 +187,7 @@ public class ITTableEditorPane<T> extends BasicPane {
*/ */
public static void selectAllOrNull(Boolean value) { public static void selectAllOrNull(Boolean value) {
for (int i = 0; i < getEditTable().getRowCount(); i++) { for (int i = 0; i < getEditTable().getRowCount(); i++) {
((ITContent) (getEditTable().getValueAt(i, 7))).setSelected(value); ((ITContent) (getEditTable().getValueAt(i, ITReplaceSouthPanel.CONTENT_INDEX))).setSelected(value);
} }
} }

25
designer-realize/src/main/java/com/fr/design/actions/replace/utils/ReplaceOperator.java

@ -0,0 +1,25 @@
package com.fr.design.actions.replace.utils;
import com.fr.design.actions.help.replace.ITReplaceHelper;
import com.fr.design.actions.replace.ui.ITReplaceMainDialog;
/**
* 操作面板
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-09-27
*/
public class ReplaceOperator implements ITReplaceHelper {
/**
* 关闭面板
* (当前关闭时机进入权限编辑状态&开发者调试)
*/
@Override
public void close(){
ITReplaceMainDialog.getInstance().dispose();
}
}

111
designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java

@ -1,9 +1,7 @@
package com.fr.design.actions.replace.utils; package com.fr.design.actions.replace.utils;
import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.ui.ITReplaceMainDialog;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.collections.combination.Pair; import com.fr.stable.collections.combination.Pair;
@ -30,6 +28,23 @@ public class ShowValueUtils {
public static final String ANY_THING_REGEX = "."; public static final String ANY_THING_REGEX = ".";
public static final String NUMBER_REGEX = "[0-9]"; public static final String NUMBER_REGEX = "[0-9]";
public static final String ENGLISH_REGEX = "[a-zA-Z]"; public static final String ENGLISH_REGEX = "[a-zA-Z]";
public static Pattern containPattern;
private static List<String> specialCharList = new ArrayList<>();
static {
//正则特殊字符:? * () [] {} ^ $ .
//如果是? 并采用通配符 ,会自动转成“.” 所以 ? 不用处理
//$同理
specialCharList.add("*");
specialCharList.add("(");
specialCharList.add(")");
specialCharList.add("[");
specialCharList.add("]");
specialCharList.add("{");
specialCharList.add("}");
specialCharList.add("^");
specialCharList.add(".");
}
/** /**
* 获取除内容外其他一次性展示所有的内容名称水印... * 获取除内容外其他一次性展示所有的内容名称水印...
@ -42,9 +57,7 @@ public class ShowValueUtils {
if (StringUtils.isEmpty(searchStr)) { if (StringUtils.isEmpty(searchStr)) {
return str; return str;
} else { } else {
return "<html><body><div><nobr>" + return updateHighlight(str, searchStr);
replaceAll(str, searchStr, "<font color = 'rgb(61,153,249)'>" + searchStr + "</font>") +
"</nobr></div></body></html>";
} }
} }
@ -57,20 +70,28 @@ public class ShowValueUtils {
* @return 替换后的字符串 * @return 替换后的字符串
*/ */
public static String replaceAll(String str, String regex, String replacement) { public static String replaceAll(String str, String regex, String replacement) {
if (ITReplaceMainDialog.isMatched()) {
return str.replaceAll(changeRegex(regex), replacement);
} else {
return str.replace(regex, replacement); return str.replace(regex, replacement);
} }
}
/** /**
* 转换正则表达式 * 转换正则表达式
* *
* @param regex * @param regexStr
* @return * @return
*/ */
public static String changeRegex(String regex) { public static String changeRegex(String regexStr) {
regex = regex.replace(NUMBER, NUMBER_REGEX); String change = "\\";
regex = regex.replace(ENGLISH, ENGLISH_REGEX); for (int i = 0; i < specialCharList.size(); i++) {
regex = regex.replace(ANY_THING, ANY_THING_REGEX); regexStr = regexStr.replace(specialCharList.get(i), change + specialCharList.get(i));
return regex; }
regexStr = regexStr.replace(NUMBER, NUMBER_REGEX);
regexStr = regexStr.replace(ENGLISH, ENGLISH_REGEX);
regexStr = regexStr.replace(ANY_THING, ANY_THING_REGEX);
return regexStr;
} }
/** /**
@ -101,21 +122,45 @@ public class ShowValueUtils {
return pairs; return pairs;
} }
/** /**
* 更新高亮状态 * 更新高亮
* *
* @param info * @param str
* @param replaceStr * @param searchStr
* @return
*/ */
public static void updateHighlight(Info info, String replaceStr) { public static String updateHighlight(String str, String searchStr) {
String s = info.getInfoShowStr(info); if (ITReplaceMainDialog.isMatched()) {
s = s.replace(info.getContent().getLastSearchStr(), "<font color = 'rgb(61,153,249)'>" + replaceStr + "</font>"); String result = str;
info.getContent().setShowStr( Pattern pattern = containPattern;
"<html><body><div><nobr>" + s + "</nobr></div></body></html>" Matcher matcher = pattern.matcher(str);
); String head = "<font color = 'rgb(61,153,249)'>";
String tail = "</font>";
int size = head.length() + tail.length();
int index = 0;
StringBuilder builder = new StringBuilder(str);
while (matcher.find()) {
builder.replace(matcher.start() + index, matcher.end() + index, head + changeHtmlStr(matcher.group()) + tail);
index += size;
}
return "<html><body><div><nobr>" +
builder.toString() +
"</nobr></div></body></html>";
} else {
return "<html><body><div><nobr>" +
replaceAll(str, searchStr, "<font color = 'rgb(61,153,249)'>" + changeHtmlStr(searchStr) + "</font>") +
"</nobr></div></body></html>";
}
} }
private static String changeHtmlStr(String searchStr){
String showStr = searchStr;
showStr = showStr.replace("<","&lt;");
showStr = showStr.replace(">", "&gt");
return showStr;
}
/** /**
* 集合是否不为空 * 集合是否不为空
@ -132,18 +177,34 @@ public class ShowValueUtils {
* 支持正则表达式的indexOf * 支持正则表达式的indexOf
* *
* @param str * @param str
* @param regex * @param regexStr
* @return * @return
*/ */
public static int indexOf(String str, String regex) { public static int indexOf(String str, String regexStr) {
CharSequence inputStr = str; CharSequence inputStr = str;
int failReturn = -1; int failReturn = -1;
String patternStr = changeRegex(regex); Pattern pattern = containPattern;
Pattern pattern = Pattern.compile(patternStr);
Matcher matcher = pattern.matcher(inputStr); Matcher matcher = pattern.matcher(inputStr);
if (matcher.find()) { if (matcher.find()) {
return matcher.start(); return matcher.start();
} }
return failReturn; return failReturn;
} }
/**
* 支持通配符的contains
* @param originStr
* @param matchStr
* @return
*/
public static boolean contains(String originStr, String matchStr) {
if (ITReplaceMainDialog.isMatched()) {
Pattern pattern = containPattern;
Matcher matcher = pattern.matcher(originStr);
return matcher.find();
} else {
return originStr.contains(matchStr);
}
}
} }

48
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResourceDetail.java

@ -8,9 +8,10 @@ import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@ -169,7 +170,7 @@ public class TemplateResourceDetail {
JSONObject resource = embedResources.getJSONObject(i); JSONObject resource = embedResources.getJSONObject(i);
if (resourceId.equals(resource.getString(ID))) { if (resourceId.equals(resource.getString(ID))) {
detail.setInfo(resource.getString(INFO)); detail.setInfo(resource.getString(INFO));
detail.setHtmlText(resource.getString(DETAIL_INFO)); detail.setHtmlText(reformat(resource.getString(DETAIL_INFO)));
detail.setVendor(resource.getString(VENDOR)); detail.setVendor(resource.getString(VENDOR));
detail.setPrice(resource.getDouble(PRICE)); detail.setPrice(resource.getDouble(PRICE));
detail.setResourceUrl(resource.getString(URL)); detail.setResourceUrl(resource.getString(URL));
@ -191,7 +192,7 @@ public class TemplateResourceDetail {
// 1请求详细信息 // 1请求详细信息
JSONObject info = helper.getTemplateInfoById(resourceId); JSONObject info = helper.getTemplateInfoById(resourceId);
detail.setInfo(info.getString(INFO)); detail.setInfo(info.getString(INFO));
detail.setHtmlText(info.getString(DETAIL_INFO)); detail.setHtmlText(reformat(info.getString(DETAIL_INFO)));
detail.setVendor(info.getString(VENDOR)); detail.setVendor(info.getString(VENDOR));
detail.setTagsId(info.getString(TAGS_ID).split(",")); detail.setTagsId(info.getString(TAGS_ID).split(","));
detail.setPrice(info.getDouble(PRICE)); detail.setPrice(info.getDouble(PRICE));
@ -214,25 +215,36 @@ public class TemplateResourceDetail {
return null; return null;
} }
static final String A_TAG_FORMAT = "<a href=%s>%s</a>";
static final String HTML_TAG_REGX="<[^>]+>";
static final Pattern A_TAG_PATTERN = Pattern.compile("<a[^>]*href=(\\\"([^\\\"]*)\\\"|\\'([^\\']*)\\'|([^\\\\s>]*))[^>]*>(.*?)</a>");
static final Pattern HTML_TAG_PATTERN = Pattern.compile(HTML_TAG_REGX);
/** /**
* 这里做下数据转换 * 数据格式转换
* 原始数据是html标签写的如下 * 原始数据的格式不统一纯文本html都有; 统一转为纯文本如果有a标签则保留
* "<ol style="list-style-type: decimal;" class=" list-paddingleft-2"><li><p>该模板需用10.0及以上版本设计器预览<br/></p></li><li><p>该模板为库存场景解决方案的部分内容,全部内容可下载<a href="https://market.fanruan.com/template/20000733" target="_self">库存场景解决方案</a>查看</p></li><li><p>为保障模板预览效果,建议安装<a href="https://help.fanruan.com/finereport10.0/doc-view-3665.html" target="_self">新自适应插件</a>(FR11.0版本插件已内置,无需手动安装),有使用需求或疑问,请联系帆软技术支持咨询<br/></p></li></ol>",
*
* 转换的后的数据 是原始数据中所有<p></p>标签内的包括标签的字符串List<String>,如上字符串会转为如下
* List [<p>该模板需用10.0及以上版本设计器预览<br/></p>,
* <p>该模板为库存场景解决方案的部分内容全部内容可下载<a href="https://market.fanruan.com/template/20000733" target="_self">库存场景解决方案</a>查看</p>,
* <p>为保障模板预览效果建议安装<a href="https://help.fanruan.com/finereport10.0/doc-view-3665.html" target="_self">新自适应插件</a>FR11.0版本插件已内置无需手动安装有使用需求或疑问请联系帆软技术支持咨询<br/></p>
* ]
* */ * */
static final Pattern htmlPattern = Pattern.compile("<p>(.+?)</p>"); static String reformat(String htmlDetailInfo) {
static List<String> parseDetailInfo(String htmlDetailInfo) { String result = HTML_TAG_PATTERN.matcher(htmlDetailInfo).replaceAll("");
List<String> infos = new ArrayList<>(); Map<String, String> aMap = getLink(htmlDetailInfo);
Matcher matcher = htmlPattern.matcher(htmlDetailInfo); for (Map.Entry<String, String> entry : aMap.entrySet()) {
String aTag = String.format(A_TAG_FORMAT, entry.getValue(), entry.getKey());
result = result.replace(entry.getKey(), aTag);
}
return result;
}
/**
* 读取dom中的a标签转换为map
*/
static Map<String, String> getLink(String html) {
Map<String, String> map = new HashMap<>();
Matcher matcher = A_TAG_PATTERN.matcher(html);
while (matcher.find()) { while (matcher.find()) {
infos.add(matcher.group()); map.put(matcher.group(5), matcher.group(1));
} }
return infos; return map;
} }
} }

3
designer-realize/src/main/java/com/fr/start/module/DesignerActivator.java

@ -32,6 +32,7 @@ import com.fr.design.actions.insert.flot.FormulaFloatAction;
import com.fr.design.actions.insert.flot.ImageFloatAction; import com.fr.design.actions.insert.flot.ImageFloatAction;
import com.fr.design.actions.insert.flot.TextBoxFloatAction; import com.fr.design.actions.insert.flot.TextBoxFloatAction;
import com.fr.design.actions.replace.ITReplaceAction; import com.fr.design.actions.replace.ITReplaceAction;
import com.fr.design.actions.replace.utils.ReplaceOperator;
import com.fr.design.bridge.DesignToolbarProvider; import com.fr.design.bridge.DesignToolbarProvider;
import com.fr.design.constants.DesignerLaunchStatus; import com.fr.design.constants.DesignerLaunchStatus;
import com.fr.design.env.DesignerWorkspaceLoader; import com.fr.design.env.DesignerWorkspaceLoader;
@ -473,6 +474,8 @@ public class DesignerActivator extends Activator implements Prepare {
DesignModuleFactory.registerFormHierarchyPaneClass(FormHierarchyTreePane.class); DesignModuleFactory.registerFormHierarchyPaneClass(FormHierarchyTreePane.class);
DesignModuleFactory.registerWidgetPropertyPaneClass(WidgetPropertyPane.class); DesignModuleFactory.registerWidgetPropertyPaneClass(WidgetPropertyPane.class);
DesignModuleFactory.registerButtonDetailPaneClass(FormSubmitButtonDetailPane.class); DesignModuleFactory.registerButtonDetailPaneClass(FormSubmitButtonDetailPane.class);
DesignModuleFactory.registerReplace(new ReplaceOperator());
DesignModuleFactory.registerParameterReader(new FormParameterReader()); DesignModuleFactory.registerParameterReader(new FormParameterReader());
StableFactory.registerMarkedClass(BaseJForm.XML_TAG, NewJForm.class); StableFactory.registerMarkedClass(BaseJForm.XML_TAG, NewJForm.class);

6
designer-realize/src/test/java/com.fr/design/mainframe/alphafine/cell/model/ModelTest.java

@ -1,6 +1,6 @@
package com.fr.design.mainframe.alphafine.cell.model; package com.fr.design.mainframe.alphafine.cell.model;
import com.fr.design.actions.help.alphafine.AlphaFineConstants; import com.fr.design.actions.help.alphafine.AlphaFineCloudConstants;
import com.fr.design.mainframe.alphafine.CellType; import com.fr.design.mainframe.alphafine.CellType;
import com.fr.json.JSONException; import com.fr.json.JSONException;
import com.fr.json.JSONObject; import com.fr.json.JSONObject;
@ -14,8 +14,8 @@ public class ModelTest {
Assert.assertEquals("name", documentModel.getName()); Assert.assertEquals("name", documentModel.getName());
Assert.assertEquals("content", documentModel.getContent()); Assert.assertEquals("content", documentModel.getContent());
Assert.assertEquals(1, documentModel.getDocumentId()); Assert.assertEquals(1, documentModel.getDocumentId());
Assert.assertEquals(AlphaFineConstants.DOCUMENT_DOC_URL + documentModel.getDocumentId() + ".html", documentModel.getDocumentUrl()); Assert.assertEquals(AlphaFineCloudConstants.DOCUMENT_DOC_URL + documentModel.getDocumentId() + ".html", documentModel.getDocumentUrl());
Assert.assertEquals(AlphaFineConstants.DOCUMENT_INFORMATION_URL + documentModel.getDocumentId(), documentModel.getInformationUrl()); Assert.assertEquals(AlphaFineCloudConstants.DOCUMENT_INFORMATION_URL + documentModel.getDocumentId(), documentModel.getInformationUrl());
Assert.assertEquals(documentModel.getStoreInformation(), documentModel.getInformationUrl()); Assert.assertEquals(documentModel.getStoreInformation(), documentModel.getInformationUrl());
Assert.assertEquals(CellType.DOCUMENT, documentModel.getType()); Assert.assertEquals(CellType.DOCUMENT, documentModel.getType());
Assert.assertEquals(true, documentModel.hasAction()); Assert.assertEquals(true, documentModel.hasAction());

Loading…
Cancel
Save