Browse Source

REPORT-53211 && REPORT-53208 && REPORT-53209 && REPORT-53207 几个使用公式的场景未联动修改

feature/10.0
hades 4 years ago
parent
commit
ade05d9005
  1. 10
      designer-base/src/main/java/com/fr/design/mod/ContentObjectManager.java
  2. 82
      designer-base/src/main/java/com/fr/design/mod/ContentReplaceUtil.java
  3. 10
      designer-base/src/main/java/com/fr/design/mod/ContentReplacerCenter.java
  4. 6
      designer-base/src/main/java/com/fr/design/mod/impl/change/DSColumnContentChange.java
  5. 36
      designer-base/src/main/java/com/fr/design/mod/impl/change/formula/CardSwitchButtonContentChange.java
  6. 35
      designer-base/src/main/java/com/fr/design/mod/impl/change/formula/CellGUIAttrContentChange.java
  7. 35
      designer-base/src/main/java/com/fr/design/mod/impl/change/formula/FunctionGrouperContentChange.java
  8. 35
      designer-base/src/main/java/com/fr/design/mod/impl/change/formula/SelectCountContentChange.java
  9. 35
      designer-base/src/main/java/com/fr/design/mod/impl/change/formula/WidgetTitleContentChange.java
  10. 5
      designer-base/src/main/java/com/fr/design/mod/impl/repalce/DSColumn4TableDataNameContentReplacer.java
  11. 19
      designer-base/src/main/java/com/fr/design/mod/impl/repalce/DSColumn4WidgetNameContentReplacer.java
  12. 96
      designer-base/src/main/java/com/fr/design/mod/impl/repalce/FormulaReplacer.java

10
designer-base/src/main/java/com/fr/design/mod/ContentObjectManager.java

@ -10,12 +10,17 @@ import com.fr.data.condition.FormulaCondition;
import com.fr.data.impl.FormulaDictionary;
import com.fr.data.impl.NameTableData;
import com.fr.form.main.FormHyperlink;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.WidgetTitle;
import com.fr.invoke.ClassHelper;
import com.fr.js.JavaScriptImpl;
import com.fr.plugin.chart.base.VanChartHtmlLabel;
import com.fr.report.cell.cellattr.CellExpandAttr;
import com.fr.report.cell.cellattr.CellGUIAttr;
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.FunctionGrouper;
import com.fr.report.cell.cellattr.core.group.SelectCount;
import com.fr.stable.Filter;
import java.util.HashSet;
import java.util.Map;
@ -60,6 +65,11 @@ public class ContentObjectManager {
set.add(FormulaHFElement.class.getName());
set.add(FormulaPresent.class.getName());
set.add(RichChar.class.getName());
set.add(CardSwitchButton.class.getName());
set.add(CellGUIAttr.class.getName());
set.add(SelectCount.class.getName());
set.add(WidgetTitle.class.getName());
set.add(FunctionGrouper.class.getName());
}
public void searchObject(Object ob) {

82
designer-base/src/main/java/com/fr/design/mod/ContentReplaceUtil.java

@ -51,24 +51,40 @@ public class ContentReplaceUtil {
}
}
/**
* 通过公式编辑框框输入的且带有"="
*
* @param content
* @param oldName
* @param newName
* @return
*/
public static String replaceFormulaContent4WidgetName(String content, String oldName, String newName) {
if (StringUtils.isNotEmpty(content)) {
content = getFormulaPureContent(content);
FRFormulaTransformer frFormulaTransformer = new FRFormulaTransformer();
frFormulaTransformer.addRenamedWidget(oldName, newName);
return EQ_STRING + frFormulaTransformer.transform(content);
return replaceFormulaContent4WidgetName0(content, oldName, newName);
}
return content;
}
public static String replaceFormulaContent4TableDataName(String content, String oldName, String newName) {
if (StringUtils.isNotEmpty(content)) {
return replaceFormulaContent4TableDataName0(content, oldName, newName);
}
return content;
}
private static String replaceFormulaContent4WidgetName0(String content, String oldName, String newName) {
content = getFormulaPureContent(content);
FRFormulaTransformer frFormulaTransformer = new FRFormulaTransformer();
frFormulaTransformer.addRenamedDataset(oldName, newName);
frFormulaTransformer.addRenamedWidget(oldName, newName);
return EQ_STRING + frFormulaTransformer.transform(content);
}
return content;
private static String replaceFormulaContent4TableDataName0(String content, String oldName, String newName) {
content = getFormulaPureContent(content);
FRFormulaTransformer frFormulaTransformer = new FRFormulaTransformer();
frFormulaTransformer.addRenamedWidget(oldName, newName);
return EQ_STRING + frFormulaTransformer.transform(content);
}
public static String getRichCharFormulaPureContent(String content) {
@ -99,4 +115,58 @@ public class ContentReplaceUtil {
return content;
}
private static boolean isFormula(String content) {
return StringUtils.isNotEmpty(content) && content.startsWith(EQ_STRING);
}
/**
* 适用于替换非显示使用的公式的地方 有可能只是文本 需要先判断下
* 可通过使用位置是否使用公式编辑框区分
*
* @param content
* @param oldName
* @param newName
* @return
*/
public static String replaceFormulaString4WidgetName(String content, String oldName, String newName) {
if (isFormula(content)) {
return replaceFormulaContent4WidgetName0(content, oldName, newName);
}
return content;
}
public static String replaceFormulaString4TableDataName(String content, String oldName, String newName ) {
if (isFormula(content)) {
return replaceFormulaContent4TableDataName0(content, oldName, newName);
}
return content;
}
/**
* 替换纯公式内容 "="
*
* @param content
* @param oldName
* @param newName
* @return
*/
public static String replacePureFormula4WidgetName(String content, String oldName, String newName ) {
if (StringUtils.isNotEmpty(content)) {
FRFormulaTransformer frFormulaTransformer = new FRFormulaTransformer();
frFormulaTransformer.addRenamedWidget(oldName, newName);
return frFormulaTransformer.transform(content);
}
return content;
}
public static String replacePureFormula4TableDataName(String content, String oldName, String newName ) {
if (StringUtils.isNotEmpty(content)) {
FRFormulaTransformer frFormulaTransformer = new FRFormulaTransformer();
frFormulaTransformer.addRenamedDataset(oldName, newName);
return frFormulaTransformer.transform(content);
}
return content;
}
}

10
designer-base/src/main/java/com/fr/design/mod/ContentReplacerCenter.java

@ -8,7 +8,9 @@ import com.fr.design.mod.impl.change.ChartHyperRelateCellLinkContentChange;
import com.fr.design.mod.impl.change.ChartHyperRelateFloatLinkContentChange;
import com.fr.design.mod.impl.change.DSColumnContentChange;
import com.fr.design.mod.impl.change.FormHyperlinkContentChange;
import com.fr.design.mod.impl.change.formula.CardSwitchButtonContentChange;
import com.fr.design.mod.impl.change.formula.CellExpandAttrContentChange;
import com.fr.design.mod.impl.change.formula.CellGUIAttrContentChange;
import com.fr.design.mod.impl.change.formula.FormulaConditionContentChange;
import com.fr.design.mod.impl.change.formula.FormulaContentChange;
import com.fr.design.mod.impl.change.JavaScriptContentChange;
@ -18,7 +20,10 @@ import com.fr.design.mod.impl.change.VanChartHtmlLabelContentChange;
import com.fr.design.mod.impl.change.formula.FormulaDictionaryContentChange;
import com.fr.design.mod.impl.change.formula.FormulaHFElementContentChange;
import com.fr.design.mod.impl.change.formula.FormulaPresentContentChange;
import com.fr.design.mod.impl.change.formula.FunctionGrouperContentChange;
import com.fr.design.mod.impl.change.formula.RichCharContentChange;
import com.fr.design.mod.impl.change.formula.SelectCountContentChange;
import com.fr.design.mod.impl.change.formula.WidgetTitleContentChange;
import com.fr.event.Event;
import com.fr.event.EventDispatcher;
import com.fr.event.Listener;
@ -93,6 +98,11 @@ public class ContentReplacerCenter {
contentChangeList.add(new FormulaHFElementContentChange());
contentChangeList.add(new FormulaPresentContentChange());
contentChangeList.add(new RichCharContentChange());
contentChangeList.add(new CardSwitchButtonContentChange());
contentChangeList.add(new CellGUIAttrContentChange());
contentChangeList.add(new SelectCountContentChange());
contentChangeList.add(new WidgetTitleContentChange());
contentChangeList.add(new FunctionGrouperContentChange());
}
private void onRename(List<ContentChangeItem> contentChangeItemList, List<ContentChange> contentChangeList) {

6
designer-base/src/main/java/com/fr/design/mod/impl/change/DSColumnContentChange.java

@ -3,7 +3,8 @@ package com.fr.design.mod.impl.change;
import com.fr.design.mod.ContentChange;
import com.fr.design.mod.ContentReplacer;
import com.fr.design.mod.bean.ChangeItem;
import com.fr.design.mod.impl.repalce.DSColumnContentReplacer;
import com.fr.design.mod.impl.repalce.DSColumn4TableDataNameContentReplacer;
import com.fr.design.mod.impl.repalce.DSColumn4WidgetNameContentReplacer;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import java.util.HashMap;
import java.util.Map;
@ -19,7 +20,8 @@ public class DSColumnContentChange implements ContentChange<DSColumn> {
public DSColumnContentChange() {
map = new HashMap<>();
map.put(ChangeItem.TABLE_DATA_NAME, new DSColumnContentReplacer());
map.put(ChangeItem.TABLE_DATA_NAME, new DSColumn4TableDataNameContentReplacer());
map.put(ChangeItem.WIDGET_NAME, new DSColumn4WidgetNameContentReplacer());
}
@Override

36
designer-base/src/main/java/com/fr/design/mod/impl/change/formula/CardSwitchButtonContentChange.java

@ -0,0 +1,36 @@
package com.fr.design.mod.impl.change.formula;
import com.fr.design.mod.ContentChange;
import com.fr.design.mod.ContentReplacer;
import com.fr.design.mod.bean.ChangeItem;
import com.fr.design.mod.impl.repalce.FormulaReplacer;
import com.fr.form.ui.CardSwitchButton;
import java.util.HashMap;
import java.util.Map;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/6/3
*/
public class CardSwitchButtonContentChange implements ContentChange<CardSwitchButton> {
private final Map<ChangeItem, ContentReplacer<CardSwitchButton>> map;
public CardSwitchButtonContentChange() {
map = new HashMap<>();
map.put(ChangeItem.WIDGET_NAME, FormulaReplacer.CardSwitchButton4WidgetNameContentReplacer);
map.put(ChangeItem.TABLE_DATA_NAME, FormulaReplacer.CardSwitchButton4TableDataNameContentReplacer);
}
@Override
public String type() {
return CardSwitchButton.class.getName();
}
@Override
public Map<ChangeItem, ContentReplacer<CardSwitchButton>> changeInfo() {
return map;
}
}

35
designer-base/src/main/java/com/fr/design/mod/impl/change/formula/CellGUIAttrContentChange.java

@ -0,0 +1,35 @@
package com.fr.design.mod.impl.change.formula;
import com.fr.design.mod.ContentChange;
import com.fr.design.mod.ContentReplacer;
import com.fr.design.mod.bean.ChangeItem;
import com.fr.design.mod.impl.repalce.FormulaReplacer;
import com.fr.report.cell.cellattr.CellGUIAttr;
import java.util.HashMap;
import java.util.Map;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/6/3
*/
public class CellGUIAttrContentChange implements ContentChange<CellGUIAttr> {
private Map<ChangeItem, ContentReplacer<CellGUIAttr>> map;
public CellGUIAttrContentChange() {
map = new HashMap<>();
map.put(ChangeItem.WIDGET_NAME, FormulaReplacer.CellGUIAttr4WidgetNameContentReplacer);
map.put(ChangeItem.TABLE_DATA_NAME, FormulaReplacer.CellGUIAttr4TableDataNameContentReplacer);
}
@Override
public String type() {
return CellGUIAttr.class.getName();
}
@Override
public Map<ChangeItem, ContentReplacer<CellGUIAttr>> changeInfo() {
return map;
}
}

35
designer-base/src/main/java/com/fr/design/mod/impl/change/formula/FunctionGrouperContentChange.java

@ -0,0 +1,35 @@
package com.fr.design.mod.impl.change.formula;
import com.fr.design.mod.ContentChange;
import com.fr.design.mod.ContentReplacer;
import com.fr.design.mod.bean.ChangeItem;
import com.fr.design.mod.impl.repalce.FormulaReplacer;
import com.fr.report.cell.cellattr.core.group.FunctionGrouper;
import java.util.HashMap;
import java.util.Map;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/6/3
*/
public class FunctionGrouperContentChange implements ContentChange<FunctionGrouper> {
private final Map<ChangeItem, ContentReplacer<FunctionGrouper>> map;
public FunctionGrouperContentChange() {
map = new HashMap<>();
map.put(ChangeItem.WIDGET_NAME, FormulaReplacer.FunctionGrouper4WidgetNameContentReplacer);
map.put(ChangeItem.TABLE_DATA_NAME, FormulaReplacer.FunctionGrouper4TableDataNameContentReplacer);
}
@Override
public String type() {
return FunctionGrouper.class.getName();
}
@Override
public Map<ChangeItem, ContentReplacer<FunctionGrouper>> changeInfo() {
return map;
}
}

35
designer-base/src/main/java/com/fr/design/mod/impl/change/formula/SelectCountContentChange.java

@ -0,0 +1,35 @@
package com.fr.design.mod.impl.change.formula;
import com.fr.design.mod.ContentChange;
import com.fr.design.mod.ContentReplacer;
import com.fr.design.mod.bean.ChangeItem;
import com.fr.design.mod.impl.repalce.FormulaReplacer;
import com.fr.report.cell.cellattr.core.group.SelectCount;
import java.util.HashMap;
import java.util.Map;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/6/3
*/
public class SelectCountContentChange implements ContentChange<SelectCount> {
private final Map<ChangeItem, ContentReplacer<SelectCount>> map;
public SelectCountContentChange() {
map = new HashMap<>();
map.put(ChangeItem.WIDGET_NAME, FormulaReplacer.SelectCount4WidgetNameContentReplacer);
map.put(ChangeItem.TABLE_DATA_NAME, FormulaReplacer.SelectCount4TableDataNameContentReplacer);
}
@Override
public String type() {
return SelectCount.class.getName();
}
@Override
public Map<ChangeItem, ContentReplacer<SelectCount>> changeInfo() {
return map;
}
}

35
designer-base/src/main/java/com/fr/design/mod/impl/change/formula/WidgetTitleContentChange.java

@ -0,0 +1,35 @@
package com.fr.design.mod.impl.change.formula;
import com.fr.design.mod.ContentChange;
import com.fr.design.mod.ContentReplacer;
import com.fr.design.mod.bean.ChangeItem;
import com.fr.design.mod.impl.repalce.FormulaReplacer;
import com.fr.form.ui.WidgetTitle;
import java.util.HashMap;
import java.util.Map;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/6/3
*/
public class WidgetTitleContentChange implements ContentChange<WidgetTitle> {
private final Map<ChangeItem, ContentReplacer<WidgetTitle>> map;
public WidgetTitleContentChange() {
map = new HashMap<>();
map.put(ChangeItem.WIDGET_NAME, FormulaReplacer.WidgetTitle4WidgetNameContentReplacer);
map.put(ChangeItem.TABLE_DATA_NAME, FormulaReplacer.WidgetTitle4TableDataNameContentReplacer);
}
@Override
public String type() {
return WidgetTitle.class.getName();
}
@Override
public Map<ChangeItem, ContentReplacer<WidgetTitle>> changeInfo() {
return map;
}
}

5
designer-base/src/main/java/com/fr/design/mod/impl/repalce/DSColumnContentReplacer.java → designer-base/src/main/java/com/fr/design/mod/impl/repalce/DSColumn4TableDataNameContentReplacer.java

@ -1,5 +1,6 @@
package com.fr.design.mod.impl.repalce;
import com.fr.design.mod.ContentReplaceUtil;
import com.fr.design.mod.ContentReplacer;
import com.fr.general.ComparatorUtils;
import com.fr.report.cell.cellattr.core.group.DSColumn;
@ -9,12 +10,14 @@ import com.fr.report.cell.cellattr.core.group.DSColumn;
* @version 10.0
* Created by hades on 2021/6/2
*/
public class DSColumnContentReplacer implements ContentReplacer<DSColumn> {
public class DSColumn4TableDataNameContentReplacer implements ContentReplacer<DSColumn> {
@Override
public void replace(DSColumn dsColumn, String oldName, String newName) {
if (ComparatorUtils.equals(dsColumn.getDSName(), oldName)) {
dsColumn.setDSName(newName);
}
dsColumn.setResult(ContentReplaceUtil.replacePureFormula4TableDataName(dsColumn.getResult(), oldName, newName));
dsColumn.setSortFormula(ContentReplaceUtil.replacePureFormula4TableDataName(dsColumn.getSortFormula(), oldName, newName));
}
}

19
designer-base/src/main/java/com/fr/design/mod/impl/repalce/DSColumn4WidgetNameContentReplacer.java

@ -0,0 +1,19 @@
package com.fr.design.mod.impl.repalce;
import com.fr.design.mod.ContentReplaceUtil;
import com.fr.design.mod.ContentReplacer;
import com.fr.report.cell.cellattr.core.group.DSColumn;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/6/3
*/
public class DSColumn4WidgetNameContentReplacer implements ContentReplacer<DSColumn> {
@Override
public void replace(DSColumn dsColumn, String oldName, String newName) {
dsColumn.setResult(ContentReplaceUtil.replacePureFormula4WidgetName(dsColumn.getResult(), oldName, newName));
dsColumn.setSortFormula(ContentReplaceUtil.replacePureFormula4WidgetName(dsColumn.getSortFormula(), oldName, newName));
}
}

96
designer-base/src/main/java/com/fr/design/mod/impl/repalce/FormulaReplacer.java

@ -7,8 +7,13 @@ import com.fr.data.condition.FormulaCondition;
import com.fr.data.impl.FormulaDictionary;
import com.fr.design.mod.ContentReplaceUtil;
import com.fr.design.mod.ContentReplacer;
import com.fr.form.ui.CardSwitchButton;
import com.fr.form.ui.WidgetTitle;
import com.fr.report.cell.cellattr.CellExpandAttr;
import com.fr.report.cell.cellattr.CellGUIAttr;
import com.fr.report.cell.cellattr.core.RichChar;
import com.fr.report.cell.cellattr.core.group.FunctionGrouper;
import com.fr.report.cell.cellattr.core.group.SelectCount;
/**
* 持有公式内容对象汇总
@ -148,4 +153,95 @@ public class FormulaReplacer {
}
};
/**
* 公式分组
*
*/
public static final ContentReplacer<FunctionGrouper> FunctionGrouper4TableDataNameContentReplacer = new ContentReplacer<FunctionGrouper>() {
@Override
public void replace(FunctionGrouper functionGrouper, String oldName, String newName) {
functionGrouper.setFormulaContent(ContentReplaceUtil.replacePureFormula4TableDataName(functionGrouper.getFormulaContent(), oldName, newName));
}
};
public static final ContentReplacer<FunctionGrouper> FunctionGrouper4WidgetNameContentReplacer = new ContentReplacer<FunctionGrouper>() {
@Override
public void replace(FunctionGrouper functionGrouper, String oldName, String newName) {
functionGrouper.setFormulaContent(ContentReplaceUtil.replacePureFormula4WidgetName(functionGrouper.getFormulaContent(), oldName, newName));
}
};
/**
* 结果集筛选
*/
public static final ContentReplacer<SelectCount> SelectCount4TableDataNameContentReplacer = new ContentReplacer<SelectCount>() {
@Override
public void replace(SelectCount selectCount, String oldName, String newName) {
selectCount.setFormulaCount(ContentReplaceUtil.replacePureFormula4TableDataName(selectCount.getFormulaCount(), oldName, newName));
}
};
public static final ContentReplacer<SelectCount> SelectCount4WidgetNameContentReplacer = new ContentReplacer<SelectCount>() {
@Override
public void replace(SelectCount selectCount, String oldName, String newName) {
selectCount.setFormulaCount(ContentReplaceUtil.replacePureFormula4WidgetName(selectCount.getFormulaCount(), oldName, newName));
}
};
/**
* tab块标题
*/
public static final ContentReplacer<CardSwitchButton> CardSwitchButton4TableDataNameContentReplacer = new ContentReplacer<CardSwitchButton>() {
@Override
public void replace(CardSwitchButton cardSwitchButton, String oldName, String newName) {
cardSwitchButton.setText(ContentReplaceUtil.replaceFormulaString4TableDataName(cardSwitchButton.getText(), oldName, newName));
}
};
public static final ContentReplacer<CardSwitchButton> CardSwitchButton4WidgetNameContentReplacer = new ContentReplacer<CardSwitchButton>() {
@Override
public void replace(CardSwitchButton cardSwitchButton, String oldName, String newName) {
cardSwitchButton.setText(ContentReplaceUtil.replaceFormulaString4WidgetName(cardSwitchButton.getText(), oldName, newName));
}
};
/**
* 悬浮提示
*/
public static final ContentReplacer<CellGUIAttr> CellGUIAttr4TableDataNameContentReplacer = new ContentReplacer<CellGUIAttr>() {
@Override
public void replace(CellGUIAttr cellGUIAttr, String oldName, String newName) {
cellGUIAttr.setTooltipText(ContentReplaceUtil.replaceFormulaString4TableDataName(cellGUIAttr.getTooltipText(), oldName, newName));
}
};
public static final ContentReplacer<CellGUIAttr> CellGUIAttr4WidgetNameContentReplacer = new ContentReplacer<CellGUIAttr>() {
@Override
public void replace(CellGUIAttr cellGUIAttr, String oldName, String newName) {
cellGUIAttr.setTooltipText(ContentReplaceUtil.replaceFormulaString4WidgetName(cellGUIAttr.getTooltipText(), oldName, newName));
}
};
/**
* 图表/报表块等标题
*/
public static final ContentReplacer<WidgetTitle> WidgetTitle4TableDataNameContentReplacer = new ContentReplacer<WidgetTitle>() {
@Override
public void replace(WidgetTitle widgetTitle, String oldName, String newName) {
if (widgetTitle.getTextObject() instanceof String) {
String content = (String) widgetTitle.getTextObject();
widgetTitle.setTextObject(ContentReplaceUtil.replaceFormulaString4TableDataName(content, oldName, newName));
}
}
};
public static final ContentReplacer<WidgetTitle> WidgetTitle4WidgetNameContentReplacer = new ContentReplacer<WidgetTitle>() {
@Override
public void replace(WidgetTitle widgetTitle, String oldName, String newName) {
if (widgetTitle.getTextObject() instanceof String) {
String content = (String) widgetTitle.getTextObject();
widgetTitle.setTextObject(ContentReplaceUtil.replaceFormulaString4WidgetName(content, oldName, newName));
}
}
};
}

Loading…
Cancel
Save