From 193473d4e3e782e11ac34d1e386f3d9b5dbd1773 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 31 Oct 2022 14:43:22 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-80695=20=E6=A8=A1=E6=9D=BF=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E4=BA=8C=E6=9C=9F=20=E4=BF=AE=E5=A4=8D=E4=B8=8B=E6=8B=89?= =?UTF-8?q?=E6=A1=86=E5=86=85=E5=AE=B9=E4=B8=8E=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E4=B8=8D=E5=8C=B9=E9=85=8D=E7=9A=84=E9=97=AE=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E5=8D=95=E5=85=83=E6=A0=BC=E8=BF=87=E6=BB=A4?= =?UTF-8?q?=EF=BC=8C=E5=A2=9E=E5=8A=A0=E8=AE=BE=E7=BD=AE=E9=A1=B9=E3=80=81?= =?UTF-8?q?SQL=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../action/setting/CellFormatType.java | 69 +++++++++++++++++-- .../action/setting/SettingController.java | 13 ++++ .../action/SearchCellFormatAction.java | 17 +++-- .../design/actions/replace/info/SQLInfo.java | 9 +++ .../replace/ui/ITReplaceNorthPanel.java | 15 ++-- 5 files changed, 106 insertions(+), 17 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java index ab2a71ba97..a468dc995c 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java @@ -35,7 +35,7 @@ public enum CellFormatType { @Override public List getItems() { - return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_NUMBER))); + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_NUMBER), false)); } @Override @@ -57,6 +57,12 @@ public enum CellFormatType { public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { return cellElement.getStyle().getFormat() == null; } + + @Override + public boolean isEverChanged(Info info, String inputStr, String extraStr) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + return (cellElement.getStyle() != null && cellElement.getStyle().getFormat() == null); + } }, /** * 单元格-格式-货币 @@ -69,7 +75,7 @@ public enum CellFormatType { @Override public List getItems() { - return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_MONEY))); + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_MONEY), false)); } @Override @@ -89,7 +95,7 @@ public enum CellFormatType { @Override public List getItems() { - return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_DATE))); + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_DATE), false)); } @Override @@ -97,6 +103,11 @@ public enum CellFormatType { Format format = cellElement.getStyle().getFormat(); return format instanceof FineDateFormat && StringUtils.equals(((FineDateFormat) format).toPattern(), secondStr); } + + @Override + public boolean isEverChanged(Info info, String inputStr, String extraStr) { + return isEverChanged4FineDataFormat(info, extraStr); + } }, /** * 单元格-格式-时间 @@ -109,7 +120,7 @@ public enum CellFormatType { @Override public List getItems() { - return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_TIME))); + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_TIME), false)); } @Override @@ -117,6 +128,11 @@ public enum CellFormatType { Format format = cellElement.getStyle().getFormat(); return format instanceof FineDateFormat && StringUtils.equals(((FineDateFormat) format).toPattern(), secondStr); } + + @Override + public boolean isEverChanged(Info info, String inputStr, String extraStr) { + return isEverChanged4FineDataFormat(info, extraStr); + } }, /** * 单元格-格式-科学计数 @@ -129,7 +145,7 @@ public enum CellFormatType { @Override public List getItems() { - return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_SCIENCE))); + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_SCIENCE), false)); } @Override @@ -149,7 +165,7 @@ public enum CellFormatType { @Override public List getItems() { - return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_PERCENT))); + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_PERCENT), false)); } @Override @@ -169,7 +185,7 @@ public enum CellFormatType { @Override public List getItems() { - return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_PERMILLAGE))); + return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_PERMILLAGE), false)); } @Override @@ -187,6 +203,14 @@ public enum CellFormatType { Format format = cellElement.getStyle().getFormat(); return format instanceof TextFormat; } + + @Override + public boolean isEverChanged(Info info, String inputStr, String extraStr) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + return !(cellElement.getStyle() != null + && cellElement.getStyle().getFormat() != null + && cellElement.getStyle().getFormat() instanceof TextFormat); + } }; @@ -256,4 +280,35 @@ public enum CellFormatType { ((NameStyle) cellElement.getStyle()).refreshStyle(); } } + + /** + * 是否修改过 + * + * @param info 存储单元格信息的数据结构 + * @param inputStr 用户输入的第一级下拉框内容 + * @param extraStr 用户输入的第二级下拉框内容 + * @return 修改过返回true + */ + public boolean isEverChanged(Info info, String inputStr, String extraStr) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + return !(cellElement.getStyle() != null + && cellElement.getStyle().getFormat() != null + && cellElement.getStyle().getFormat() instanceof CoreDecimalFormat + && StringUtils.equals(((CoreDecimalFormat) cellElement.getStyle().getFormat()).toPattern(), extraStr)); + } + + /** + * 针对日期和时间类型的修改判定 + * + * @param info 存储单元格信息的数据结构 + * @param extraStr 用户输入的第二级下拉框内容 + * @return 修改过返回true + */ + public boolean isEverChanged4FineDataFormat(Info info, String extraStr) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + return !(cellElement.getStyle() != null + && cellElement.getStyle().getFormat() != null + && cellElement.getStyle().getFormat() instanceof FineDateFormat + && StringUtils.equals(((FineDateFormat) cellElement.getStyle().getFormat()).toPattern(), extraStr)); + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java index 8dd29b2364..0b481a1272 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java @@ -10,6 +10,7 @@ import com.fr.design.actions.replace.action.setting.action.SearchDSColumnAction; import com.fr.design.actions.replace.info.CellInfo; import com.fr.design.actions.replace.info.DataSourceInfo; import com.fr.design.actions.replace.info.Info; +import com.fr.design.actions.replace.info.ReplaceObject; import com.fr.design.actions.replace.ui.ITReplaceNorthPanel; import com.fr.design.data.DesignTableDataManager; import com.fr.design.file.HistoryTemplateListCache; @@ -88,6 +89,18 @@ public enum SettingController implements ShowValue { type.replace(info, firstStr, secondStr); } } + + @Override + public boolean isEverChanged(Info info, String inputStr, String extraStr) { + CellElement cellElement = (CellElement) info.getContent().getReplaceObject(); + if (cellElement.getStyle() != null) { + CellFormatType type = CellFormatType.match(inputStr); + if (type != null) { + return type.isEverChanged(info, inputStr, extraStr); + } + } + return false; + } }, /** * 单元格-数据设置 diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java index 016f6b259b..e7c8e45dd4 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java @@ -1,13 +1,16 @@ package com.fr.design.actions.replace.action.setting.action; -import com.fr.base.Formula; +import com.fr.chart.chartattr.ChartCollection; import com.fr.design.actions.replace.action.SearchAction; import com.fr.design.actions.replace.action.content.cell.SearchCellAction; import com.fr.design.actions.replace.info.CellInfo; import com.fr.design.mainframe.JTemplate; import com.fr.general.GeneralUtils; +import com.fr.general.ImageWithSuffix; import com.fr.report.cell.CellElement; -import com.fr.report.cell.cellattr.core.group.DSColumn; +import com.fr.report.cell.cellattr.core.RichText; +import com.fr.report.cell.cellattr.core.SubReport; +import com.fr.report.cell.painter.BiasTextPainter; import java.util.ArrayList; import java.util.List; @@ -47,10 +50,12 @@ public class SearchCellFormatAction implements SearchAction { */ public boolean isFormatValid(CellElement cellElement) { return cellElement.getStyle() != null - && (cellElement.getValue() instanceof Formula - || cellElement.getValue() instanceof DSColumn - || cellElement.getValue() instanceof String - || cellElement.getValue() instanceof Integer); + && !(cellElement.getValue() instanceof SubReport + || cellElement.getValue() instanceof BiasTextPainter + || cellElement.getValue() instanceof ChartCollection + || cellElement.getValue() instanceof RichText + || cellElement.getValue() instanceof ImageWithSuffix + ); } public List getCellInfos() { diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java b/designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java index 6006c83754..0fdbbb86de 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java @@ -68,4 +68,13 @@ public class SQLInfo implements Info { public String getInfoShowStr(Info info) { return this.getContent().getOldShowStr(); } + + @Override + public Boolean checkValid() { + ReplaceObject o = ReplaceObject.match(this.content.getReplaceObject().getClass().getSimpleName()); + if (o != null) { + return o.check(this); + } + return false; + } } diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java index 16d2926a60..913150dcd3 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -249,11 +249,9 @@ public class ITReplaceNorthPanel { }; replaceSettingInputComboBox.setSelectedIndex(-1); - - ((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Search") + SettingContent.CELL_FORMAT_NAME); + updateSettingPlaceholder(SettingContent.CELL_FORMAT_NAME); findSettingInputComboBox.setEditable(true); ((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setEditable(false); - ((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Replace") + SettingContent.CELL_FORMAT_NAME); replaceSettingInputComboBox.setEditable(true); ((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setEditable(false); @@ -301,7 +299,7 @@ public class ITReplaceNorthPanel { refreshSettingComboBox(SettingController.getSettingRefreshItems(str)); setDataSourceComboBoxStatus(isAllow2Replace()); replaceSettingButton.setEnabled(false); - + updateSettingPlaceholder(str); } }); @@ -784,4 +782,13 @@ public class ITReplaceNorthPanel { public void setSettingResultLabel(UILabel settingResultLabel) { this.settingResultLabel = settingResultLabel; } + + /** + * 更新展示的默认值 + * @param str 默认值 + */ + public void updateSettingPlaceholder(String str) { + ((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Search") + str); + ((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Replace") + str); + } } From a9314ea89a7fa66dbf2793b3d1574e017e44b6a6 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 31 Oct 2022 15:09:39 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-80695=20=E6=A8=A1=E6=9D=BF=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E7=BA=A7=E5=88=AB=E6=9F=A5=E6=89=BE=E6=9B=BF=E6=8D=A2?= =?UTF-8?q?=E4=BA=8C=E6=9C=9F=20=E5=A2=9E=E5=8A=A0=E5=85=B3=E9=97=AD?= =?UTF-8?q?=E9=9D=A2=E6=9D=BF=E5=90=8E=E7=9A=84=E6=B8=85=E9=99=A4=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=8A=A8=E4=BD=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../replace/ui/ITReplaceMainDialog.java | 19 +++++++++++++++++++ .../replace/ui/ITReplaceNorthPanel.java | 8 ++++++++ 2 files changed, 27 insertions(+) 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 868ad8ad2a..27162e863d 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 @@ -25,11 +25,15 @@ import com.fr.stable.StringUtils; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.WindowConstants; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Point; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; import java.util.ArrayList; import java.util.List; @@ -132,6 +136,7 @@ public class ITReplaceMainDialog extends UIDialog { southPanel = new ITReplaceSouthPanel(); westPanel = new ITReplaceWestPanel(); + initCloseListener(); northPane.fitScreen(0, 0, jTemplate.getWidth()); JPanel center = new JPanel(new BorderLayout()); @@ -187,6 +192,20 @@ public class ITReplaceMainDialog extends UIDialog { center.setVisible(true); } + private void initCloseListener() { + this.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + searchContentResultList.clear(); + searchSettingResultList.clear(); + ITReplaceSouthPanel.getItTableEditor().clear(); + northPane.clear(); + dialogExit(); + } + + }); + } + /** * 模板内容替换相关 */ diff --git a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java index 913150dcd3..977d819807 100644 --- a/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java +++ b/designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java @@ -791,4 +791,12 @@ public class ITReplaceNorthPanel { ((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Search") + str); ((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Replace") + str); } + + /** + * 清除搜索结果 + */ + public void clear() { + settingResultLabel.setText(StringUtils.EMPTY); + resultLabel.setText(StringUtils.EMPTY); + } } From cdf23d5e87686b4916583d09831516378931b61f Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 31 Oct 2022 15:10:35 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-80695=20=E5=8E=BB=E9=99=A4=E5=A4=9A?= =?UTF-8?q?=E4=BD=99=E5=BC=95=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/actions/replace/ui/ITReplaceMainDialog.java | 2 -- 1 file changed, 2 deletions(-) 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 27162e863d..7f2530d2c6 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 @@ -25,7 +25,6 @@ import com.fr.stable.StringUtils; import javax.swing.JOptionPane; import javax.swing.JPanel; -import javax.swing.WindowConstants; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.Point; @@ -33,7 +32,6 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; import java.util.ArrayList; import java.util.List;