From c7f87592a4bbfac239d8cdf4b76f9fdfd8b72fa3 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 29 Sep 2022 13:40:36 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-75998=20=E6=9B=B4=E6=94=B9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=AD=97=E5=85=B8-=E5=85=AC=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=E3=80=81=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=8B=BE=E9=80=89=E6=A1=86=E7=9A=84=E5=88=B7=E6=96=B0=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E3=80=81=E6=9F=A5=E6=89=BE=E6=A1=86=E6=97=A0=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=97=B6=E6=9B=BF=E6=8D=A2=E6=A1=86=E7=A6=81=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/content/formula/FormulaTag.java | 19 ++++++++ .../formula/widget/DictionaryType.java | 9 +++- .../actions/replace/info/FormulaInfo.java | 16 ++----- .../actions/replace/info/base/SearchTag.java | 8 ++++ .../replace/ui/ITReplaceMainDialog.java | 27 +++++++----- .../actions/replace/ui/ITTableEditorPane.java | 44 +++++++++++++------ 6 files changed, 83 insertions(+), 40 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java index ff8755974b..c3f3c83a1d 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java @@ -2,6 +2,7 @@ package com.fr.design.actions.replace.action.content.formula; import com.fr.chart.chartdata.MeterReportDefinition; import com.fr.data.VerifyItem; +import com.fr.data.impl.FormulaDictionary; import com.fr.design.actions.replace.info.DealWithInfoValue; import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.info.base.SearchTag; @@ -133,6 +134,24 @@ public enum FormulaTag implements DealWithInfoValue { attr.setTooltipText(ShowValueUtils.replaceAll(attr.getTooltipText(), findStr, replaceStr)); } } + }, + DICT_EXCUTE(SearchTag.DICT_EXCUTE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof FormulaDictionary) { + FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject(); + dictionary.setExcuteFormula(ShowValueUtils.replaceAll(dictionary.getExcuteFormula(), findStr, replaceStr)); + } + } + }, + DICT_PRODUCE(SearchTag.DICT_PRODUCE) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof FormulaDictionary) { + FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject(); + dictionary.setProduceFormula(ShowValueUtils.replaceAll(dictionary.getProduceFormula(), findStr, replaceStr)); + } + } }; int index; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java index 22d4cb3959..6a55aebf9b 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/widget/DictionaryType.java @@ -6,6 +6,7 @@ import com.fr.data.impl.FormulaDictionary; import com.fr.data.impl.TableDataDictionary; import com.fr.design.actions.replace.info.FormulaInfo; import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.info.base.SearchTag; import com.fr.design.i18n.Toolkit; import org.jetbrains.annotations.Nullable; @@ -32,23 +33,27 @@ public enum DictionaryType implements DictionaryAction { //显示值 if (formulaDictionary.getExcuteFormula() != null) { ITContent excuteContent = ITContent.copy(content); - excuteContent.setReplaceObject(dictionary); + excuteContent.setReplaceObject(formulaDictionary.getExcuteFormula()); excuteContent.addOtherPos( Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary"), Toolkit.i18nText("Fine-Design_Basic_Formula"), Toolkit.i18nText("Fine-Design_Basic_Display_Value") ); + excuteContent.setHoldObject(dictionary); + excuteContent.setTag(SearchTag.DICT_EXCUTE); formulaInfos.add(new FormulaInfo(excuteContent)); } //实际值 if (formulaDictionary.getProduceFormula() != null) { ITContent produceContent = ITContent.copy(content); - produceContent.setReplaceObject(dictionary); + produceContent.setReplaceObject(formulaDictionary.getProduceFormula()); produceContent.addOtherPos( Toolkit.i18nText("Fine-Design_Basic_DS_Dictionary"), Toolkit.i18nText("Fine-Design_Basic_Formula"), Toolkit.i18nText("Fine-Design_Basic_Actual_Value") ); + produceContent.setHoldObject(dictionary); + produceContent.setTag(SearchTag.DICT_PRODUCE); formulaInfos.add(new FormulaInfo(produceContent)); } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java index 73a0750cb8..ce2ecd36c6 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/FormulaInfo.java @@ -40,14 +40,7 @@ public class FormulaInfo implements Info { @Override public Map getValue(Object... o) { Map map = new HashMap<>(); - //这边比较特殊,存的都是FormulaDictionary ,特殊判断一下 - if (this.content.getOtherPos().contains(DISPLAY)) { - map.put("content", ((FormulaDictionary) this.getContent().getReplaceObject()).getExcuteFormula()); - } else if (this.content.getOtherPos().contains(ACTUAL)) { - map.put("content", ((FormulaDictionary) this.getContent().getReplaceObject()).getProduceFormula()); - } else { - map = getCommonValue(); - } + map = getCommonValue(); return map; } @@ -70,11 +63,8 @@ public class FormulaInfo implements Info { @Override public Boolean checkValid() { - FormulaReplaceObject formulaReplaceObject = FormulaReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); - if (formulaReplaceObject != null) { - return formulaReplaceObject.check(this); - } - return false; + //校验二期才完善,目前都给过 + return true; } private Map getCommonValue() { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java index 1bbba05b35..956d3ff386 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java @@ -44,6 +44,14 @@ public class SearchTag { * 单元格属性-其他-内容提示 */ public static final int CELL_TOOL_TIP = 8; + /** + * 数据字典-公式-显示值 + */ + public static final int DICT_EXCUTE = 9; + /** + * 数据字典-公式-实际值 + */ + public static final int DICT_PRODUCE = 10; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java index 96ee17b6cd..4843df57f4 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java @@ -9,6 +9,7 @@ import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.UIDialog; import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.DesignerContext; @@ -22,6 +23,7 @@ import com.fr.stable.StringUtils; import javax.swing.JOptionPane; import javax.swing.JPanel; import java.awt.BorderLayout; +import java.awt.Color; import java.awt.Dimension; import java.awt.Point; import java.awt.event.ActionEvent; @@ -117,8 +119,10 @@ public class ITReplaceMainDialog extends UIDialog { JPanel center = new JPanel(new BorderLayout()); + UIComboBox replaceComboBox = northPane.getReplaceInputCombobox(); northPane.getFindInputCombobox().setEditable(true); - northPane.getReplaceInputCombobox().setEditable(false); + replaceComboBox.setEnabled(false); + replaceComboBox.setEditable(true); northPane.getReplaceButton().setEnabled(false); ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Search_Input")); @@ -160,7 +164,8 @@ public class ITReplaceMainDialog extends UIDialog { private void replace() { String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText(); - if (StringUtils.equals(getSearchStr(), searchStr)) { + //替换内容为空需要触发搜索 + if (StringUtils.equals(getSearchStr(), searchStr) && StringUtils.isNotEmpty(replaceStr)) { if (isITReplaceValid() && checkTemplateChanged(searchResultList)) { for (Info info : searchResultList) { if (info.getContent().isSelected()) { @@ -298,7 +303,8 @@ public class ITReplaceMainDialog extends UIDialog { northPane.getResultLabel().setText("" + Toolkit.i18nText("Fine-Design_Replace_Search_Finish") + "" + searchResultList.size() + "" + Toolkit.i18nText("Fine-Design_Replace_Result")); } ITTableEditorPane.ITHeaderRenderer renderer = (ITTableEditorPane.ITHeaderRenderer) getEditTable().getTableHeader().getDefaultRenderer(); - renderer.refreshHeader(getEditTable()); + //刷新表头,并且重新勾选中表头全选框 + renderer.refreshHeader(getEditTable(), true); itTableEditor.fireTableDataChanged(); northPane.refreshFindInputComboBoxItems(); setSearchFlag(true); @@ -306,18 +312,17 @@ public class ITReplaceMainDialog extends UIDialog { //如果有结果,默认选中第一行 if (searchResultList.size() > 0){ getEditTable().addRowSelectionInterval(FIRST_ROW,FIRST_ROW); - northPane.getReplaceButton().setEnabled(true); } - - //设置替换输入框的可用性 - if (StringUtils.isNotEmpty(searchStr)) { - ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setEditable(true); - northPane.getReplaceInputCombobox().setEditable(true); + //更新替换按钮可用性 + if (StringUtils.isEmpty(searchStr) || searchResultList.size() == 0){ + northPane.getReplaceButton().setEnabled(false); } else { - ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setEditable(false); - northPane.getReplaceInputCombobox().setEditable(false); + northPane.getReplaceButton().setEnabled(true); } + + //设置替换输入框的可用性 + northPane.getReplaceInputCombobox().setEnabled(StringUtils.isNotEmpty(searchStr)); } else { //todo } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java index 4d2f39718d..0a743d34eb 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java @@ -72,17 +72,8 @@ public class ITTableEditorPane extends BasicPane { int col = ((JTable) e.getSource()).columnAtPoint(e.getPoint()); if (col == ITReplaceSouthPanel.CHECKBOX_INDEX) { ITContent content = (ITContent) editTable.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX); - if (content.isSelected()) { - content.setSelected(false); - editTable.setValueAt(content.isSelected(), row, col); - ITReplaceMainDialog.selectCount--; - ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(ITReplaceMainDialog.selectCount > 0); - } else { - content.setSelected(true); - editTable.setValueAt(content.isSelected(), row, col); - ITReplaceMainDialog.selectCount++; - ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(true); - } + //改变面板的各个状态 + changeComponentStatus(content, row, col); } } @@ -90,10 +81,35 @@ public class ITTableEditorPane extends BasicPane { UIScrollPane scrollPane = new UIScrollPane(editTable); scrollPane.setBorder(new UIRoundedBorder(UIConstants.TITLED_BORDER_COLOR, 1, UIConstants.ARC)); pane.add(scrollPane, BorderLayout.CENTER); + } - + /** + * 改变面板的各个状态(替换按钮、表头勾选框) + * @param content + * @param row + * @param col + */ + public void changeComponentStatus(ITContent content, int row, int col) { + if (content.isSelected()) { + content.setSelected(false); + editTable.setValueAt(content.isSelected(), row, col); + ITReplaceMainDialog.selectCount--; + //如果没有选中,替换按钮需要置灰 + ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(ITReplaceMainDialog.selectCount > 0); + } else { + content.setSelected(true); + editTable.setValueAt(content.isSelected(), row, col); + ITReplaceMainDialog.selectCount++; + ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(true); + } + //更新表头的勾选框状态 + if (editTable.getTableHeader().getDefaultRenderer() instanceof ITHeaderRenderer) { + ITHeaderRenderer renderer = (ITHeaderRenderer) editTable.getTableHeader().getDefaultRenderer(); + renderer.refreshHeader(editTable, ITReplaceMainDialog.selectCount >= editTable.getRowCount()); + } } + public UITableModelAdapter getTableModel() { return tableModel; } @@ -142,8 +158,8 @@ public class ITTableEditorPane extends BasicPane { * * @param table */ - public void refreshHeader(JTable table) { - selectBox.setSelected(true); + public void refreshHeader(JTable table, boolean value) { + selectBox.setSelected(value); int rowHeight = table.getRowHeight(); table.updateUI(); table.setRowHeight(rowHeight); From 9f293a456bbf5956f3bc72f8b5eeaf524bba9c9b Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 29 Sep 2022 14:11:34 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-75998=20=E6=9B=B4=E6=94=B9=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=AD=97=E5=85=B8-=E5=85=AC=E5=BC=8F=E7=9A=84?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91=E3=80=81=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=8B=BE=E9=80=89=E6=A1=86=E7=9A=84=E5=88=B7=E6=96=B0=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E3=80=81=E6=9F=A5=E6=89=BE=E6=A1=86=E6=97=A0=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=97=B6=E6=9B=BF=E6=8D=A2=E6=A1=86=E7=A6=81=E7=94=A8?= =?UTF-8?q?=20REPORT-75998=20=E5=A2=9E=E5=8A=A0=E6=90=9C=E7=B4=A2=E6=A8=A1?= =?UTF-8?q?=E6=9D=BFWeb=E5=B1=9E=E6=80=A7=E5=BC=95=E7=94=A8JS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/content/js/SearchWebJSAction.java | 20 +++++++ .../actions/replace/info/ReplaceObject.java | 58 ++++++++++++++++--- .../actions/replace/info/base/SearchTag.java | 4 ++ 3 files changed, 75 insertions(+), 7 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java index 0ceec53617..725d1280db 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java @@ -4,6 +4,7 @@ import com.fr.design.actions.replace.info.JSInfo; import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.info.base.SearchTag; import com.fr.design.actions.replace.utils.SearchJSUtils; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JTemplate; @@ -19,6 +20,7 @@ import com.fr.report.web.util.ReportEngineEventMapping; import com.fr.web.attr.ReportWebAttr; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -86,12 +88,30 @@ public class SearchWebJSAction implements SearchJS { content.setTemplateName(jTemplate.getTemplateName()); content.setJumpAble(false); addWebContent2Array(webAttr); + //处理引用JS + dealImportJS(content,jsInfos,webAttr); for (int i = 0; i < arrayList.size(); i++) { addJSInfos2ListFromArray(content, jsInfos, arrayList.get(i)); } } } + private void dealImportJS(ITContent content, List jsInfos, ReportWebAttr webAttr) { + if (webAttr != null){ + for (String jsStr : webAttr.getJSImport()){ + ITContent jsContent = ITContent.copy(content); + jsContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Report_Web_Attributes"), + Toolkit.i18nText("Fine-Design_Report_Import_JavaScript") + ); + jsContent.setReplaceObject(jsStr); + jsContent.setHoldObject(webAttr); + jsContent.setTag(SearchTag.IMPORT_JS); + jsInfos.add(new JSInfo(jsContent)); + } + } + } + private void addJSInfos2ListFromServerWebAttr(ITContent content, List jsInfos, WebContent webContent) { ITContent newContent = ITContent.copy(content); if (SERVER_MAP.containsKey(webContent.getClass().getSimpleName())) { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java index 3d615e18a9..d803f31012 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java @@ -3,13 +3,16 @@ package com.fr.design.actions.replace.info; import com.fr.data.impl.DBTableData; import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.form.event.Listener; +import com.fr.general.GeneralUtils; import com.fr.js.JavaScriptImpl; import com.fr.js.NameJavaScript; import com.fr.plugin.chart.base.VanChartHtmlLabel; import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; +import com.fr.web.attr.ReportWebAttr; import org.jetbrains.annotations.Nullable; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -184,36 +187,77 @@ public enum ReplaceObject implements DealWithInfoValue { return StringUtils.equals(javaScript.getContent(), info.getContent().getOldShowStr()); } }, + /** + * 模板Web属性——引用JS + */ + IMPORT_JS("String") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + addValue2Map(contentKey, GeneralUtils.objectToString(o[0]), map); + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof ReportWebAttr) { + ReportWebAttr attr = (ReportWebAttr) info.getContent().getHoldObject(); + List jsImports = Arrays.asList(attr.getJSImport()); + String jsName = GeneralUtils.objectToString(info.getContent().getReplaceObject()); + for (int i = 0, len = jsImports.size(); i < len; i++) { + if (StringUtils.equals(jsImports.get(i), jsName)) { + jsImports.set(i, ShowValueUtils.replaceAll(jsName, findStr, replaceStr)); + } + } + attr.clearJSImportList(); + for (int i = 0, len = jsImports.size(); i < len; i++) { + attr.addJSImport(jsImports.get(i)); + } + } + } + + @Override + public String getInfoShowStr(Info info) { + return GeneralUtils.objectToString(info.getContent().getReplaceObject()); + } + + @Override + boolean check(Info info) { + return true; + } + }, /** * DBTableData——SQL */ DB_TABLE_DATA("DBTableData") { @Override - boolean check(Info info) { + boolean check (Info info){ DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); return StringUtils.equals(dbTableData.getQuery(), info.getContent().getOldShowStr()); } @Override - public Map getValue(Object... o) { + public Map getValue (Object...o){ HashMap map = new HashMap<>(); addValue2Map(contentKey, ((DBTableData) o[0]).getQuery(), map); return map; } @Override - public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + public void setValue (Info info, String findStr, String + replaceStr, List < Pair < Integer, Integer >> operatorArray){ DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); info.updateOldStr(dbTableData.getQuery(), findStr); dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr)); - //todo DesignTableDataManager } @Override - public String getInfoShowStr(Info info) { + public String getInfoShowStr (Info info){ return info.getInfoShowStr(info); } - }; + } + + ; String name; @@ -256,4 +300,4 @@ public enum ReplaceObject implements DealWithInfoValue { abstract boolean check(Info info); -} + } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java index 956d3ff386..b5e202bcb1 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java @@ -52,6 +52,10 @@ public class SearchTag { * 数据字典-公式-实际值 */ public static final int DICT_PRODUCE = 10; + /** + * 引用JS + */ + public static final int IMPORT_JS = 11; From 9094e69ddf871eb27bde8e3d2843dac3eac98b24 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 29 Sep 2022 14:11:34 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-75998=20=E5=A2=9E=E5=8A=A0=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=A8=A1=E6=9D=BFWeb=E5=B1=9E=E6=80=A7=E5=BC=95?= =?UTF-8?q?=E7=94=A8JS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/content/js/SearchWebJSAction.java | 20 +++++++ .../actions/replace/info/ReplaceObject.java | 58 ++++++++++++++++--- .../actions/replace/info/base/SearchTag.java | 4 ++ 3 files changed, 75 insertions(+), 7 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java index 0ceec53617..725d1280db 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchWebJSAction.java @@ -4,6 +4,7 @@ import com.fr.design.actions.replace.info.JSInfo; import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.info.base.SearchTag; import com.fr.design.actions.replace.utils.SearchJSUtils; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JTemplate; @@ -19,6 +20,7 @@ import com.fr.report.web.util.ReportEngineEventMapping; import com.fr.web.attr.ReportWebAttr; import java.util.ArrayList; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -86,12 +88,30 @@ public class SearchWebJSAction implements SearchJS { content.setTemplateName(jTemplate.getTemplateName()); content.setJumpAble(false); addWebContent2Array(webAttr); + //处理引用JS + dealImportJS(content,jsInfos,webAttr); for (int i = 0; i < arrayList.size(); i++) { addJSInfos2ListFromArray(content, jsInfos, arrayList.get(i)); } } } + private void dealImportJS(ITContent content, List jsInfos, ReportWebAttr webAttr) { + if (webAttr != null){ + for (String jsStr : webAttr.getJSImport()){ + ITContent jsContent = ITContent.copy(content); + jsContent.addOtherPos( + Toolkit.i18nText("Fine-Design_Basic_Report_Web_Attributes"), + Toolkit.i18nText("Fine-Design_Report_Import_JavaScript") + ); + jsContent.setReplaceObject(jsStr); + jsContent.setHoldObject(webAttr); + jsContent.setTag(SearchTag.IMPORT_JS); + jsInfos.add(new JSInfo(jsContent)); + } + } + } + private void addJSInfos2ListFromServerWebAttr(ITContent content, List jsInfos, WebContent webContent) { ITContent newContent = ITContent.copy(content); if (SERVER_MAP.containsKey(webContent.getClass().getSimpleName())) { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java index 3d615e18a9..d803f31012 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java @@ -3,13 +3,16 @@ package com.fr.design.actions.replace.info; import com.fr.data.impl.DBTableData; import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.form.event.Listener; +import com.fr.general.GeneralUtils; import com.fr.js.JavaScriptImpl; import com.fr.js.NameJavaScript; import com.fr.plugin.chart.base.VanChartHtmlLabel; import com.fr.stable.StringUtils; import com.fr.stable.collections.combination.Pair; +import com.fr.web.attr.ReportWebAttr; import org.jetbrains.annotations.Nullable; +import java.util.Arrays; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -184,36 +187,77 @@ public enum ReplaceObject implements DealWithInfoValue { return StringUtils.equals(javaScript.getContent(), info.getContent().getOldShowStr()); } }, + /** + * 模板Web属性——引用JS + */ + IMPORT_JS("String") { + @Override + public Map getValue(Object... o) { + HashMap map = new HashMap<>(); + addValue2Map(contentKey, GeneralUtils.objectToString(o[0]), map); + return map; + } + + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof ReportWebAttr) { + ReportWebAttr attr = (ReportWebAttr) info.getContent().getHoldObject(); + List jsImports = Arrays.asList(attr.getJSImport()); + String jsName = GeneralUtils.objectToString(info.getContent().getReplaceObject()); + for (int i = 0, len = jsImports.size(); i < len; i++) { + if (StringUtils.equals(jsImports.get(i), jsName)) { + jsImports.set(i, ShowValueUtils.replaceAll(jsName, findStr, replaceStr)); + } + } + attr.clearJSImportList(); + for (int i = 0, len = jsImports.size(); i < len; i++) { + attr.addJSImport(jsImports.get(i)); + } + } + } + + @Override + public String getInfoShowStr(Info info) { + return GeneralUtils.objectToString(info.getContent().getReplaceObject()); + } + + @Override + boolean check(Info info) { + return true; + } + }, /** * DBTableData——SQL */ DB_TABLE_DATA("DBTableData") { @Override - boolean check(Info info) { + boolean check (Info info){ DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); return StringUtils.equals(dbTableData.getQuery(), info.getContent().getOldShowStr()); } @Override - public Map getValue(Object... o) { + public Map getValue (Object...o){ HashMap map = new HashMap<>(); addValue2Map(contentKey, ((DBTableData) o[0]).getQuery(), map); return map; } @Override - public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + public void setValue (Info info, String findStr, String + replaceStr, List < Pair < Integer, Integer >> operatorArray){ DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); info.updateOldStr(dbTableData.getQuery(), findStr); dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr)); - //todo DesignTableDataManager } @Override - public String getInfoShowStr(Info info) { + public String getInfoShowStr (Info info){ return info.getInfoShowStr(info); } - }; + } + + ; String name; @@ -256,4 +300,4 @@ public enum ReplaceObject implements DealWithInfoValue { abstract boolean check(Info info); -} + } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java index 956d3ff386..b5e202bcb1 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/base/SearchTag.java @@ -52,6 +52,10 @@ public class SearchTag { * 数据字典-公式-实际值 */ public static final int DICT_PRODUCE = 10; + /** + * 引用JS + */ + public static final int IMPORT_JS = 11; From 8548304e6266631af204bc8ff46a68c1fe79f5c3 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 29 Sep 2022 14:22:14 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-75998=20=E4=BF=AE=E6=94=B9=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/replace/info/ReplaceObject.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java index d803f31012..53bd77a4d1 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java @@ -244,8 +244,7 @@ public enum ReplaceObject implements DealWithInfoValue { } @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){ DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); info.updateOldStr(dbTableData.getQuery(), findStr); dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr)); @@ -255,9 +254,7 @@ public enum ReplaceObject implements DealWithInfoValue { public String getInfoShowStr (Info info){ return info.getInfoShowStr(info); } - } - - ; + }; String name;