|
|
|
@ -11,6 +11,8 @@ import com.fr.data.condition.ListCondition;
|
|
|
|
|
import com.fr.data.core.Compare; |
|
|
|
|
import com.fr.data.impl.NameTableData; |
|
|
|
|
import com.fr.data.impl.TableDataDictionary; |
|
|
|
|
import com.fr.data.impl.TreeNodeAttr; |
|
|
|
|
import com.fr.data.impl.TreeNodeWrapper; |
|
|
|
|
import com.fr.design.actions.replace.action.content.cell.SearchCellAction; |
|
|
|
|
import com.fr.design.actions.replace.action.content.formula.SearchFormulaManager; |
|
|
|
|
import com.fr.design.actions.replace.action.content.formula.cell.SearchCellFormulaAction; |
|
|
|
@ -26,20 +28,32 @@ import com.fr.design.actions.replace.info.WidgetInfo;
|
|
|
|
|
import com.fr.design.actions.replace.info.base.ITContent; |
|
|
|
|
import com.fr.design.mainframe.JTemplate; |
|
|
|
|
import com.fr.form.FormElementCaseProvider; |
|
|
|
|
import com.fr.form.data.DataBinding; |
|
|
|
|
import com.fr.form.ui.DataControl; |
|
|
|
|
import com.fr.form.ui.DictionaryContainer; |
|
|
|
|
import com.fr.form.ui.ElementCaseEditor; |
|
|
|
|
import com.fr.form.ui.TreeEditor; |
|
|
|
|
import com.fr.form.ui.Widget; |
|
|
|
|
import com.fr.form.ui.concept.data.ValueInitializer; |
|
|
|
|
import com.fr.form.ui.tree.LayerConfig; |
|
|
|
|
import com.fr.general.ComparatorUtils; |
|
|
|
|
import com.fr.general.data.Condition; |
|
|
|
|
import com.fr.general.data.TableDataColumn; |
|
|
|
|
import com.fr.js.JavaScript; |
|
|
|
|
import com.fr.js.NameJavaScript; |
|
|
|
|
import com.fr.js.NameJavaScriptGroup; |
|
|
|
|
import com.fr.main.impl.WorkBook; |
|
|
|
|
import com.fr.main.parameter.ReportParameterAttr; |
|
|
|
|
import com.fr.report.cell.CellElement; |
|
|
|
|
import com.fr.report.cell.FloatElement; |
|
|
|
|
import com.fr.report.cell.TemplateCellElement; |
|
|
|
|
import com.fr.report.cell.cellattr.core.group.DSColumn; |
|
|
|
|
import com.fr.report.cell.cellattr.highlight.DefaultHighlight; |
|
|
|
|
import com.fr.report.cell.cellattr.highlight.Highlight; |
|
|
|
|
import com.fr.report.cell.cellattr.highlight.HighlightGroup; |
|
|
|
|
import com.fr.report.cell.cellattr.highlight.HyperlinkHighlightAction; |
|
|
|
|
import com.fr.report.cell.cellattr.highlight.PresentHighlightAction; |
|
|
|
|
import com.fr.report.cell.cellattr.highlight.WidgetHighlightAction; |
|
|
|
|
import com.fr.report.elementcase.ElementCase; |
|
|
|
|
import com.fr.report.report.Report; |
|
|
|
|
import com.fr.report.utils.ElementCaseHelper; |
|
|
|
@ -297,6 +311,51 @@ public class ReplaceUtils {
|
|
|
|
|
replaceJs(javaScripts, entities); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void replaceCellHighlight(CellElement cell, List<TableReplacementEntity> entities) { |
|
|
|
|
if (cell instanceof TemplateCellElement) { |
|
|
|
|
HighlightGroup group = ((TemplateCellElement) cell).getHighlightGroup(); |
|
|
|
|
if (group != null) { |
|
|
|
|
for (int i = 0 ; i < group.size(); i++) { |
|
|
|
|
Highlight highlight = group.getHighlight(i); |
|
|
|
|
replaceHighlight(highlight, entities); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void replaceHighlight(Highlight highlight, List<TableReplacementEntity> entities) { |
|
|
|
|
if (highlight instanceof DefaultHighlight) { |
|
|
|
|
DefaultHighlight defaultHighlight = (DefaultHighlight) highlight; |
|
|
|
|
for (int i = 0 ; i < defaultHighlight.actionCount() ; i++) { |
|
|
|
|
if (defaultHighlight.getHighlightAction(i) instanceof PresentHighlightAction) { |
|
|
|
|
PresentHighlightAction action = (PresentHighlightAction) defaultHighlight.getHighlightAction(i); |
|
|
|
|
ElementCaseHelper.replacePresent(action.getPresent(), entities); |
|
|
|
|
} else if (defaultHighlight.getHighlightAction(i) instanceof WidgetHighlightAction) { |
|
|
|
|
WidgetHighlightAction action = (WidgetHighlightAction) defaultHighlight.getHighlightAction(i); |
|
|
|
|
replaceWidget(action.getWidget(), entities); |
|
|
|
|
} else if (defaultHighlight.getHighlightAction(i) instanceof HyperlinkHighlightAction) { |
|
|
|
|
HyperlinkHighlightAction action = (HyperlinkHighlightAction) defaultHighlight.getHighlightAction(i); |
|
|
|
|
NameJavaScriptGroup group = action.getHperlink(); |
|
|
|
|
dealNameJavaScriptGroup(group, entities); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void dealNameJavaScriptGroup(NameJavaScriptGroup group, List<TableReplacementEntity> entities) { |
|
|
|
|
if (group != null) { |
|
|
|
|
for (int i = 0 ; i < group.size(); i++) { |
|
|
|
|
NameJavaScript javaScript = group.getNameHyperlink(i); |
|
|
|
|
if (javaScript.getJavaScript() instanceof ChartHyperPoplink) { |
|
|
|
|
if (((ChartHyperPoplink) javaScript.getJavaScript()).getChartCollection() instanceof ChartCollection) { |
|
|
|
|
replaceChart((ChartCollection) ((ChartHyperPoplink) javaScript.getJavaScript()).getChartCollection(), entities); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void replaceJs(List<JavaScript> javaScripts, List<TableReplacementEntity> entity) { |
|
|
|
|
for (JavaScript javaScript : javaScripts) { |
|
|
|
@ -403,6 +462,8 @@ public class ReplaceUtils {
|
|
|
|
|
replacePresentAndDictionary(cell, entity); |
|
|
|
|
// 处理【单元格值】
|
|
|
|
|
replaceCellValue(cell, entity); |
|
|
|
|
// 处理【条件属性】
|
|
|
|
|
replaceCellHighlight(cell, entity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -485,6 +546,10 @@ public class ReplaceUtils {
|
|
|
|
|
private static void replaceWidget(Widget widget, List<TableReplacementEntity> entities) { |
|
|
|
|
if (widget instanceof DictionaryContainer) { |
|
|
|
|
DictionaryContainer db = (DictionaryContainer) widget; |
|
|
|
|
if (widget instanceof TreeEditor) { |
|
|
|
|
Object config = ((TreeEditor) widget).getBuildModelConfig(); |
|
|
|
|
replaceTreeConfig(config, entities); |
|
|
|
|
} |
|
|
|
|
if (db.getDictionary() instanceof TableDataDictionary) { |
|
|
|
|
TableDataDictionary tdd = (TableDataDictionary) db.getDictionary(); |
|
|
|
|
NameTableData ndd = (NameTableData) tdd.getTableData(); |
|
|
|
@ -492,6 +557,53 @@ public class ReplaceUtils {
|
|
|
|
|
ElementCaseHelper.replaceTableDataDictionary(tdd, ndd, entities); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
if (widget instanceof DataControl) { |
|
|
|
|
ValueInitializer value = ((DataControl) widget).getWidgetValue(); |
|
|
|
|
if (value.getValue() instanceof DataBinding) { |
|
|
|
|
DataBinding binding = (DataBinding) value.getValue(); |
|
|
|
|
for (TableReplacementEntity entity : entities) { |
|
|
|
|
if (StringUtils.equals(entity.getOldName(), binding.getDataSourceName())) { |
|
|
|
|
value.setValue(new DataBinding(entity.getNewName(), entity.getTargetField(binding.getDataBindingKey()))); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void replaceTreeConfig(Object config, List<TableReplacementEntity> entities) { |
|
|
|
|
if (config instanceof LayerConfig[]) { |
|
|
|
|
LayerConfig[] layerConfigs = (LayerConfig[]) config; |
|
|
|
|
dealWithLayerConfigs(layerConfigs, entities); |
|
|
|
|
} else if (config instanceof TreeNodeWrapper) { |
|
|
|
|
TreeNodeWrapper wrapper = (TreeNodeWrapper) config; |
|
|
|
|
dealWithTreeNodeWrapper(wrapper, entities); |
|
|
|
|
} else if (config instanceof TableDataDictionary) { |
|
|
|
|
TableDataDictionary tableDataDictionary = (TableDataDictionary) config; |
|
|
|
|
ElementCaseHelper.replaceTableDataDictionary(tableDataDictionary, (NameTableData) tableDataDictionary.getTableData(), entities); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void dealWithTreeNodeWrapper(TreeNodeWrapper wrapper, List<TableReplacementEntity> entities) { |
|
|
|
|
for (TreeNodeAttr attr : wrapper.getTreeNodeAttrs()) { |
|
|
|
|
if (attr.getDictionary() instanceof TableDataDictionary) { |
|
|
|
|
TableDataDictionary tableDataDictionary = (TableDataDictionary) attr.getDictionary(); |
|
|
|
|
ElementCaseHelper.replaceTableDataDictionary(tableDataDictionary, (NameTableData) tableDataDictionary.getTableData(), entities); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static void dealWithLayerConfigs(LayerConfig[] layerConfigs, List<TableReplacementEntity> entities) { |
|
|
|
|
for (LayerConfig layerConfig : layerConfigs) { |
|
|
|
|
if (layerConfig.getDictionary() != null ) { |
|
|
|
|
for (TableReplacementEntity entity : entities) { |
|
|
|
|
if (layerConfig.getTableData() instanceof NameTableData && StringUtils.equals(layerConfig.getTableData().getName(), entity.getOldName())) { |
|
|
|
|
layerConfig.setTableData(new NameTableData(entity.getNewName())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
ElementCaseHelper.replaceTableDataDictionary(layerConfig.getDictionary(), (NameTableData) layerConfig.getDictionary().getTableData(), entities); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|