From a0a92ce1c472388a467e99e7339aba29598c227b Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Wed, 28 Sep 2022 14:38:43 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-75998=20=E5=88=A0=E9=99=A4=E6=90=9C?= =?UTF-8?q?=E7=B4=A2=E6=9C=8D=E5=8A=A1=E5=99=A8=E5=85=AC=E5=BC=8F=E9=80=BB?= =?UTF-8?q?=E8=BE=91=E3=80=81=E5=A2=9E=E5=8A=A0=E6=90=9C=E7=B4=A2=E9=AB=98?= =?UTF-8?q?=E4=BA=AE=E3=80=81=E6=8C=89=E9=92=AE=E7=BD=AE=E7=81=B0=E3=80=81?= =?UTF-8?q?=E6=90=9C=E7=B4=A2sheet=E5=90=8D=E7=A7=B0=E5=85=AC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/content/formula/FormulaTag.java | 12 ++++++++ .../formula/data/SearchDataFormulaAction.java | 4 +-- .../template/SearchTemplateFormulaAction.java | 25 ++++++++++++++++ .../actions/replace/info/base/SearchTag.java | 5 ++++ .../replace/ui/ITReplaceMainDialog.java | 29 +++++++++++++++++++ .../actions/replace/ui/ITTableEditorPane.java | 16 +++++++++- 6 files changed, 88 insertions(+), 3 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 532a530883..0a20c503ce 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 @@ -7,6 +7,7 @@ import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.info.base.SearchTag; import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.general.GeneralUtils; +import com.fr.main.impl.WorkBook; import com.fr.plugin.chart.map.data.VanMapReportDefinition; import com.fr.stable.collections.combination.Pair; import org.jetbrains.annotations.Nullable; @@ -105,6 +106,17 @@ public enum FormulaTag implements DealWithInfoValue { item.setMessage(ShowValueUtils.replaceAll(item.getMessage(), findStr, replaceStr)); } } + }, + SHEET_NAME(SearchTag.SHEET_NAME) { + @Override + public void setValue(Info info, String findStr, String replaceStr, List> operatorArray) { + if (info.getContent().getHoldObject() instanceof WorkBook) { + WorkBook workBook = (WorkBook) info.getContent().getHoldObject(); + int sheetId = Integer.parseInt(info.getContent().getSheetID()); + String name = workBook.getReportName(sheetId); + workBook.setReportName(sheetId, ShowValueUtils.replaceAll(name, findStr, replaceStr)); + } + } }; int index; diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/SearchDataFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/SearchDataFormulaAction.java index aa296a0721..3d4c66adc0 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/SearchDataFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/data/SearchDataFormulaAction.java @@ -31,8 +31,8 @@ public class SearchDataFormulaAction implements SearchFormula { //模板数据集 dealTemplateData(jTemplate, formulaInfos); - //服务器数据集 - dealServerData(formulaInfos); + ////服务器数据集二期再考虑 + //dealServerData(formulaInfos); } private void dealServerData(List fomulaInfos) { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java index 6c8419512d..de653dd706 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java @@ -10,8 +10,13 @@ import com.fr.data.VerifyItem; import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchCommit2DBJSFormulaAction; import com.fr.design.actions.replace.info.FormulaInfo; import com.fr.design.actions.replace.info.base.ITContent; +import com.fr.design.actions.replace.info.base.SearchTag; +import com.fr.design.file.HistoryTemplateListCache; +import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.i18n.Toolkit; import com.fr.design.mainframe.JTemplate; +import com.fr.design.mainframe.ReportComponentComposite; +import com.fr.design.mainframe.SheetNameTabPane; import com.fr.main.impl.WorkBook; import com.fr.report.core.ReportUtils; import com.fr.report.report.Report; @@ -50,6 +55,26 @@ public class SearchTemplateFormulaAction implements SearchTemplateFormula { searchTemplateWaterMarkFormula(jTemplate, formulaInfos, content); //报表填报属性 searchTemplateWriteAttrFormula(jTemplate, formulaInfos, content); + //sheet名称 + searchTemplateSheetNameFormula(jTemplate, formulaInfos, content); + } + + private void searchTemplateSheetNameFormula(JTemplate jTemplate, List formulaInfos, ITContent content) { + if (jTemplate.getTarget() instanceof WorkBook) { + WorkBook workBook = (WorkBook) jTemplate.getTarget(); + for (int i = 0, len = workBook.getReportCount(); i < len; i++) { + String name = workBook.getReportName(i); + if (CommonUtils.canBeFormula(name)) { + ITContent sheetContent = ITContent.copy(content); + sheetContent.addOtherPos(Toolkit.i18nText("Fine-Design_Replace_Sheet")); + sheetContent.setReplaceObject(name); + sheetContent.setHoldObject(workBook); + sheetContent.setTag(SearchTag.SHEET_NAME); + sheetContent.setSheetID(String.valueOf(i)); + formulaInfos.add(new FormulaInfo(sheetContent)); + } + } + } } private void searchTemplateWriteAttrFormula(JTemplate jTemplate, List formulaInfos, ITContent content) { 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 f7bbff40e7..b4163f57bf 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 @@ -36,6 +36,11 @@ public class SearchTag { * 模板填报属性数据校验提示 */ public static final int WRITE_ATTR_MESSAGE = 6; + /** + * sheet名称 + */ + public static final int SHEET_NAME = 7; + } 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 de4628b590..96ee17b6cd 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 @@ -51,6 +51,8 @@ public class ITReplaceMainDialog extends UIDialog { private ITReplaceWestPanel westPanel; private boolean searchFlag; private String searchStr; + private static final int FIRST_ROW = 0; + public static int selectCount = 0; public ITReplaceMainDialog() { super(DesignerContext.getDesignerFrame()); @@ -117,6 +119,7 @@ public class ITReplaceMainDialog extends UIDialog { northPane.getFindInputCombobox().setEditable(true); northPane.getReplaceInputCombobox().setEditable(false); + northPane.getReplaceButton().setEnabled(false); ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Search_Input")); ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Input")); @@ -282,9 +285,13 @@ public class ITReplaceMainDialog extends UIDialog { templateID = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID(); itTableEditor.clear(); String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); + //更新搜索内容 setSearchStr(searchStr); + //处理通配符的regexStr ShowValueUtils.containPattern = Pattern.compile(ShowValueUtils.changeRegex(searchStr)); + //获取搜索目标 ShowSearchResultAction searchAction = ShowSearchResultAction.match(GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem())); + //搜索 if (searchAction != null) { searchResultList = searchAction.addMatchResult(searchStr, searchAction.showSearchValue(jTemplate)); itTableEditor.add(searchResultList); @@ -295,7 +302,15 @@ public class ITReplaceMainDialog extends UIDialog { itTableEditor.fireTableDataChanged(); northPane.refreshFindInputComboBoxItems(); setSearchFlag(true); + selectCount = searchResultList.size(); + //如果有结果,默认选中第一行 + 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); @@ -309,7 +324,21 @@ public class ITReplaceMainDialog extends UIDialog { } + public ITReplaceSouthPanel getSouthPanel() { + return southPanel; + } + + public void setSouthPanel(ITReplaceSouthPanel southPanel) { + this.southPanel = southPanel; + } + + public ITReplaceNorthPanel getNorthPane() { + return northPane; + } + public void setNorthPane(ITReplaceNorthPanel northPane) { + this.northPane = northPane; + } /** * 检测结果是否合法 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 a9fe470edd..4d2f39718d 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 @@ -75,9 +75,13 @@ public class ITTableEditorPane extends BasicPane { 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); } } @@ -120,6 +124,11 @@ public class ITTableEditorPane extends BasicPane { boolean value = !selectBox.isSelected(); selectBox.setSelected(value); selectAllOrNull(value); + if (value) { + ITReplaceMainDialog.selectCount = getEditTable().getRowCount(); + } else { + ITReplaceMainDialog.selectCount = 0; + } tableHeader.repaint(); table.repaint(); } @@ -130,6 +139,7 @@ public class ITTableEditorPane extends BasicPane { /** * 刷新表头 + * * @param table */ public void refreshHeader(JTable table) { @@ -186,7 +196,11 @@ public class ITTableEditorPane extends BasicPane { * @param value */ public static void selectAllOrNull(Boolean value) { - for (int i = 0; i < getEditTable().getRowCount(); i++) { + int len = getEditTable().getRowCount(); + if (len > 0) { + ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(value); + } + for (int i = 0; i < len; i++) { ((ITContent) (getEditTable().getValueAt(i, ITReplaceSouthPanel.CONTENT_INDEX))).setSelected(value); } }