Browse Source

Pull request #10503: REPORT-80695 模板全局级别查找替换二期 修复下拉框内容与设计器不匹配的问题,完善单元格过滤,增加设置项、SQL校验

Merge in DESIGN/design from ~DESTINY.LIN/design:feature/x to feature/x

* commit 'cdf23d5e87686b4916583d09831516378931b61f':
  REPORT-80695 去除多余引入
  REPORT-80695 模板全局级别查找替换二期 增加关闭面板后的清除数据动作
  REPORT-80695 模板全局级别查找替换二期 修复下拉框内容与设计器不匹配的问题,完善单元格过滤,增加设置项、SQL校验
feature/x
Destiny.Lin-林锦龙 2 years ago
parent
commit
c9cd53106c
  1. 69
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java
  2. 13
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java
  3. 17
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java
  4. 9
      designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java
  5. 17
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java
  6. 23
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java

69
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java

@ -35,7 +35,7 @@ public enum CellFormatType {
@Override @Override
public List<String> getItems() { public List<String> 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 @Override
@ -57,6 +57,12 @@ public enum CellFormatType {
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) { public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
return cellElement.getStyle().getFormat() == null; 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 @Override
public List<String> getItems() { public List<String> 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 @Override
@ -89,7 +95,7 @@ public enum CellFormatType {
@Override @Override
public List<String> getItems() { public List<String> 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 @Override
@ -97,6 +103,11 @@ public enum CellFormatType {
Format format = cellElement.getStyle().getFormat(); Format format = cellElement.getStyle().getFormat();
return format instanceof FineDateFormat && StringUtils.equals(((FineDateFormat) format).toPattern(), secondStr); 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 @Override
public List<String> getItems() { public List<String> 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 @Override
@ -117,6 +128,11 @@ public enum CellFormatType {
Format format = cellElement.getStyle().getFormat(); Format format = cellElement.getStyle().getFormat();
return format instanceof FineDateFormat && StringUtils.equals(((FineDateFormat) format).toPattern(), secondStr); 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 @Override
public List<String> getItems() { public List<String> 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 @Override
@ -149,7 +165,7 @@ public enum CellFormatType {
@Override @Override
public List<String> getItems() { public List<String> 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 @Override
@ -169,7 +185,7 @@ public enum CellFormatType {
@Override @Override
public List<String> getItems() { public List<String> 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 @Override
@ -187,6 +203,14 @@ public enum CellFormatType {
Format format = cellElement.getStyle().getFormat(); Format format = cellElement.getStyle().getFormat();
return format instanceof TextFormat; 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(); ((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));
}
} }

13
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.CellInfo;
import com.fr.design.actions.replace.info.DataSourceInfo; import com.fr.design.actions.replace.info.DataSourceInfo;
import com.fr.design.actions.replace.info.Info; 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.actions.replace.ui.ITReplaceNorthPanel;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
@ -88,6 +89,18 @@ public enum SettingController implements ShowValue {
type.replace(info, firstStr, secondStr); 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;
}
}, },
/** /**
* 单元格-数据设置 * 单元格-数据设置

17
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; 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.SearchAction;
import com.fr.design.actions.replace.action.content.cell.SearchCellAction; import com.fr.design.actions.replace.action.content.cell.SearchCellAction;
import com.fr.design.actions.replace.info.CellInfo; import com.fr.design.actions.replace.info.CellInfo;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.general.ImageWithSuffix;
import com.fr.report.cell.CellElement; 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.ArrayList;
import java.util.List; import java.util.List;
@ -47,10 +50,12 @@ public class SearchCellFormatAction implements SearchAction {
*/ */
public boolean isFormatValid(CellElement cellElement) { public boolean isFormatValid(CellElement cellElement) {
return cellElement.getStyle() != null return cellElement.getStyle() != null
&& (cellElement.getValue() instanceof Formula && !(cellElement.getValue() instanceof SubReport
|| cellElement.getValue() instanceof DSColumn || cellElement.getValue() instanceof BiasTextPainter
|| cellElement.getValue() instanceof String || cellElement.getValue() instanceof ChartCollection
|| cellElement.getValue() instanceof Integer); || cellElement.getValue() instanceof RichText
|| cellElement.getValue() instanceof ImageWithSuffix
);
} }
public List<CellInfo> getCellInfos() { public List<CellInfo> getCellInfos() {

9
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) { public String getInfoShowStr(Info info) {
return this.getContent().getOldShowStr(); 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;
}
} }

17
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java

@ -30,6 +30,8 @@ import java.awt.Dimension;
import java.awt.Point; import java.awt.Point;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -132,6 +134,7 @@ public class ITReplaceMainDialog extends UIDialog {
southPanel = new ITReplaceSouthPanel(); southPanel = new ITReplaceSouthPanel();
westPanel = new ITReplaceWestPanel(); westPanel = new ITReplaceWestPanel();
initCloseListener();
northPane.fitScreen(0, 0, jTemplate.getWidth()); northPane.fitScreen(0, 0, jTemplate.getWidth());
JPanel center = new JPanel(new BorderLayout()); JPanel center = new JPanel(new BorderLayout());
@ -187,6 +190,20 @@ public class ITReplaceMainDialog extends UIDialog {
center.setVisible(true); 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();
}
});
}
/** /**
* 模板内容替换相关 * 模板内容替换相关
*/ */

23
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java

@ -249,11 +249,9 @@ public class ITReplaceNorthPanel {
}; };
replaceSettingInputComboBox.setSelectedIndex(-1); replaceSettingInputComboBox.setSelectedIndex(-1);
updateSettingPlaceholder(SettingContent.CELL_FORMAT_NAME);
((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setPlaceholder(Toolkit.i18nText("Fine-Design_Replace_Choose_Search") + SettingContent.CELL_FORMAT_NAME);
findSettingInputComboBox.setEditable(true); findSettingInputComboBox.setEditable(true);
((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setEditable(false); ((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); replaceSettingInputComboBox.setEditable(true);
((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setEditable(false); ((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setEditable(false);
@ -301,7 +299,7 @@ public class ITReplaceNorthPanel {
refreshSettingComboBox(SettingController.getSettingRefreshItems(str)); refreshSettingComboBox(SettingController.getSettingRefreshItems(str));
setDataSourceComboBoxStatus(isAllow2Replace()); setDataSourceComboBoxStatus(isAllow2Replace());
replaceSettingButton.setEnabled(false); replaceSettingButton.setEnabled(false);
updateSettingPlaceholder(str);
} }
}); });
@ -784,4 +782,21 @@ public class ITReplaceNorthPanel {
public void setSettingResultLabel(UILabel settingResultLabel) { public void setSettingResultLabel(UILabel settingResultLabel) {
this.settingResultLabel = 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);
}
/**
* 清除搜索结果
*/
public void clear() {
settingResultLabel.setText(StringUtils.EMPTY);
resultLabel.setText(StringUtils.EMPTY);
}
} }

Loading…
Cancel
Save