Browse Source

Merge pull request #10559 in DESIGN/design from release/11.0 to final/11.0

* commit '3e01391dbc2bb45bf23e25105469f67a013e690c': (63 commits)
  REPORT-80693 数据脱敏二期 圈复杂度问题
  REPORT-80693 数据脱敏二期 【问题原因】一期和二期一起剩余了比较多的bug,处理有风险,跟Lipei、Harrison、Alicia透明讨论后,确定先延期迭代,已修改的代码屏蔽功能入口与关键位置 【改动方案】具体屏蔽的内容,详见https://kms.fineres.com/pages/viewpage.action?pageId=568269880 【review建议】
  REPORT-83876 单元格替换了3次但撤回变成了2次
  REPORT-80695 模板全局级别查找替换二期 修改钻取地图的获取逻辑
  REPORT-80695 模板全局级别查找替换二期 修改钻取地图的获取逻辑
  REPORT-80695 模板全局级别查找替换二期 为了通过插件校验,增加一下注释
  REPORT-80695 模板全局级别查找替换二期 校验
  REPORT-80690 增加注释
  REPORT-83313 数据脱敏-点击“数据脱敏设置”后预览页面没有消失 【问题原因】原本做的是"数据脱敏设置"面板是预览面板为parent的另一个dialog,没按照产品文档里做 【改动方案】修改下,打开脱敏设置面板的同时,预览页面消失 【review建议】
  REPORT-83624 模板查找替换提示语句key合并
  REPORT-80690 修改传入格式数据
  REPORT-80690 修改传入格式数据
  REPORT-80690 添加适配适配埋点
  REPORT-83083 FR图表全量覆盖-部分位置内容查不到相应位置信息,需要补充一下
  REPORT-83604 模板内容所有类型的替换:单条替换会替换所有
  REPORT-83302 设置项弹窗打开后再次编辑的内容无法实时显示在可选项里
  REPORT-83571 数据列设置从分组-普通替换为列表不生效
  REPORT-83305 修复修改后界面出现异常
  REPORT-83498 单元格-格式-常规选中替换会提示查找内容不符
  REPORT-83501 多次替换时,下一次会覆盖上一次替换的记录
  ...
new-design
superman 2 years ago
parent
commit
f0fd0cef1f
  1. 14
      designer-base/src/main/java/com/fr/design/actions/UpdateAction.java
  2. 1
      designer-base/src/main/java/com/fr/design/constants/UIConstants.java
  3. 21
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java
  4. 6
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java
  5. 189
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java
  6. 114
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java
  7. 94
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/common/DesensitizationOpenPane.java
  8. 319
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java
  9. 128
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java
  10. 299
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java
  11. 82
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRulePane.java
  12. 49
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleSourceChoosePane.java
  13. 98
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java
  14. 442
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java
  15. 66
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTablePane.java
  16. 15
      designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java
  17. 81
      designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java
  18. 2
      designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java
  19. 7
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  20. 3
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  21. 10
      designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java
  22. 11
      designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java
  23. 7
      designer-base/src/main/resources/com/fr/design/images/control/refresh_normal.svg
  24. 3
      designer-base/src/main/resources/com/fr/design/standard/add/add_black_normal.svg
  25. 6
      designer-base/src/main/resources/com/fr/design/standard/debug/debug_disabled.svg
  26. 4
      designer-base/src/main/resources/com/fr/design/standard/debug/debug_normal.svg
  27. 5
      designer-base/src/main/resources/com/fr/design/standard/edit/edit_disabled.svg
  28. 3
      designer-base/src/main/resources/com/fr/design/standard/edit/edit_normal.svg
  29. 7
      designer-base/src/main/resources/com/fr/design/standard/remove/remove_red_normal.svg
  30. 3
      designer-base/src/main/resources/com/fr/design/standard/tip/tips_normal.svg
  31. 5
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java
  32. 8
      designer-form/src/main/java/com/fr/design/fit/menupane/FitRadioGroup.java
  33. 57
      designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java
  34. 5
      designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnWidthAction.java
  35. 4
      designer-realize/src/main/java/com/fr/design/actions/columnrow/RowHeightAction.java
  36. 135
      designer-realize/src/main/java/com/fr/design/actions/replace/action/ITChecker.java
  37. 35
      designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java
  38. 12
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java
  39. 118
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java
  40. 41
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java
  41. 158
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java
  42. 41
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMapDataFormulaAction.java
  43. 3
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchChartHyperPopLinkAction.java
  44. 4
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java
  45. 15
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckTag.java
  46. 70
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckType.java
  47. 56
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java
  48. 3
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java
  49. 2
      designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/SearchWidgetAction.java
  50. 314
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellFormatType.java
  51. 249
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java
  52. 74
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingContent.java
  53. 387
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java
  54. 82
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellDSColumnAction.java
  55. 103
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java
  56. 114
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java
  57. 87
      designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java
  58. 29
      designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java
  59. 25
      designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java
  60. 28
      designer-realize/src/main/java/com/fr/design/actions/replace/info/DataSourceInfo.java
  61. 14
      designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java
  62. 16
      designer-realize/src/main/java/com/fr/design/actions/replace/info/Info.java
  63. 31
      designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java
  64. 9
      designer-realize/src/main/java/com/fr/design/actions/replace/info/SQLInfo.java
  65. 49
      designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java
  66. 55
      designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java
  67. 97
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java
  68. 64
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckEditor.java
  69. 443
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceMainDialog.java
  70. 518
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceNorthPanel.java
  71. 20
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java
  72. 62
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java
  73. 7
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java
  74. 77
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java
  75. 46
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java
  76. 77
      designer-realize/src/main/java/com/fr/design/actions/replace/utils/CheckUtils.java
  77. 172
      designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java
  78. 120
      designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java
  79. 80
      designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java
  80. 22
      designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java
  81. 27
      designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java
  82. 10
      designer-realize/src/main/java/com/fr/design/dscolumn/SelectedDataColumnPane.java
  83. 79
      designer-realize/src/main/java/com/fr/design/report/ReportEnginePane.java
  84. 76
      designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java
  85. 6
      designer-realize/src/main/java/com/fr/nx/app/designer/JStreamBook.java
  86. 226
      designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java
  87. 130
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java
  88. 50
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java
  89. 52
      designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellStringQuickEditor.java

14
designer-base/src/main/java/com/fr/design/actions/UpdateAction.java

@ -185,12 +185,24 @@ public abstract class UpdateAction extends ShortCut implements Action {
* @param resource 图标资源路径 * @param resource 图标资源路径
*/ */
public void setSmallIcon(String resource) { public void setSmallIcon(String resource) {
setSmallIcon(resource, true);
}
/**
* 使用传入资源url的方式设置Icon会自动设置_normal.svg然后通过needDisable参数判断是否需要自动设置_disable.svg
* 因为有些地方是不需要设置灰化图标的所以不存在灰化图标资源这边如果一并设置就会报错文件找不到
* @param resource
* @param needDisable
*/
public void setSmallIcon(String resource, boolean needDisable) {
if (StringUtils.equals(resource, StringUtils.EMPTY)) { if (StringUtils.equals(resource, StringUtils.EMPTY)) {
this.putValue(Action.SMALL_ICON, null); this.putValue(Action.SMALL_ICON, null);
return; return;
} }
this.putValue(Action.SMALL_ICON, IconUtils.readIcon(resource)); this.putValue(Action.SMALL_ICON, IconUtils.readIcon(resource));
this.putValue(UpdateAction.DISABLED_ICON, IconUtils.readSVGIcon(resource, IconUtils.ICON_TYPE_DISABLED)); if (needDisable) {
this.putValue(UpdateAction.DISABLED_ICON, IconUtils.readSVGIcon(resource, IconUtils.ICON_TYPE_DISABLED));
}
} }
public void setSmallIcon(Icon[] smallIcon, boolean white) { public void setSmallIcon(Icon[] smallIcon, boolean white) {

1
designer-base/src/main/java/com/fr/design/constants/UIConstants.java

@ -150,6 +150,7 @@ public interface UIConstants {
public static final Color LIST_ITEM_SPLIT_LINE = new Color(0xf0f0f3); public static final Color LIST_ITEM_SPLIT_LINE = new Color(0xf0f0f3);
public static final Color DESIGNER_LOGIN_BACKGROUND = new Color(0xf1ad14); public static final Color DESIGNER_LOGIN_BACKGROUND = new Color(0xf1ad14);
public static final Color DESIGNER_LOGIN_BACKGROUND_ONCLICK = new Color(0xd89600); public static final Color DESIGNER_LOGIN_BACKGROUND_ONCLICK = new Color(0xd89600);
public static final Color CHECK_BOX_TIP_FONT_COLOR = new Color(51, 51, 52, (int)Math.round(0.5 * 255));
public static final BufferedImage DRAG_BAR = IOUtils.readImage("com/fr/design/images/control/bar.png"); public static final BufferedImage DRAG_BAR = IOUtils.readImage("com/fr/design/images/control/bar.png");
public static final BufferedImage DRAG_BAR_LIGHT = IOUtils.readImage("com/fr/design/images/control/bar-light.png"); public static final BufferedImage DRAG_BAR_LIGHT = IOUtils.readImage("com/fr/design/images/control/bar-light.png");

21
designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTableModel.java

@ -20,12 +20,20 @@ public class PreviewTableModel extends AbstractTableModel {
private static final int LEN_LIMIT = 1000; private static final int LEN_LIMIT = 1000;
private static final String THREE_DOT = "..."; private static final String THREE_DOT = "...";
private static final int DEFAULT_MAX_ROW_COUNT = 10000;
private DataModel dataModel; private DataModel dataModel;
private String erroMessage = null; private String erroMessage = null;
public IntList dateIndexs = new IntList(4); public IntList dateIndexs = new IntList(4);
/**
* 为了兼容子类的空参构造一般不主动使用
*/
public PreviewTableModel() {
this(new ErrorResultSet(), DEFAULT_MAX_ROW_COUNT);
}
public PreviewTableModel(int maxRowCount) { public PreviewTableModel(int maxRowCount) {
// peter:默认必须显示错误的数据源. // peter:默认必须显示错误的数据源.
this(new ErrorResultSet(), maxRowCount); this(new ErrorResultSet(), maxRowCount);
@ -108,6 +116,19 @@ public class PreviewTableModel extends AbstractTableModel {
} }
} }
/**
* 根据列名获取列序号当返回-1时代表异常异常会被忽略不打印日志或给出前台提示
* @param columnName
* @return
*/
public int getColumnIndexWithExceptionIngore(String columnName) {
try {
return dataModel.getColumnIndex(columnName);
} catch (TableDataException ingore) {
return -1;
}
}
public int getRowCount() { public int getRowCount() {
try { try {
return this.dataModel.getRowCount(); return this.dataModel.getRowCount();

6
designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java

@ -222,7 +222,11 @@ public class PreviewTablePane extends BasicPane {
return this.worker; return this.worker;
} }
// elake:为预览表的columnIndex列着c色. /**
* elake:为预览表的columnIndex列着色.
* @param columnIndex
* @param c
*/
private void setPreviewTableColumnColor(final int columnIndex, final Color c) { private void setPreviewTableColumnColor(final int columnIndex, final Color c) {
addLoadedListener(new LoadedEventListener() { addLoadedListener(new LoadedEventListener() {
@Override @Override

189
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java

@ -0,0 +1,189 @@
package com.fr.design.data.datapane.preview.desensitization;
import com.fr.base.TableData;
import com.fr.data.desensitize.base.DesensitizationTableData;
import com.fr.data.desensitize.base.TableDataDesensitizationItem;
import com.fr.data.desensitize.manage.DesensitizationManager;
import com.fr.data.desensitize.util.DesentizationUtils;
import com.fr.decision.webservice.bean.user.DepartmentPostBean;
import com.fr.decision.webservice.bean.user.RoleBean;
import com.fr.decision.webservice.utils.DecisionServiceConstants;
import com.fr.decision.webservice.v10.user.CustomRoleService;
import com.fr.decision.webservice.v10.user.PositionService;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.preview.PreviewTableModel;
import com.fr.design.data.datapane.preview.desensitization.model.DesensitizedPreviewTableModel;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import java.util.Collection;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* 管理所有数据集预览过程中的脱敏计算
*
* @author Yvan
* @version 11.0
* Created by Yvan on 2022/9/14
*/
public class TableDataPreviewDesensitizeManager implements DesensitizationManager {
private static final String CONNECTOR = "_";
private TableDataPreviewDesensitizeManager() {
}
private static class Holder {
private static final TableDataPreviewDesensitizeManager INSTANCE = new TableDataPreviewDesensitizeManager();
}
/**
* 获取TableDataPreviewDesensitizeManager单例
*
* @return
*/
public static TableDataPreviewDesensitizeManager getInstance() {
return TableDataPreviewDesensitizeManager.Holder.INSTANCE;
}
/**
* 判断数据集预览时是否需要脱敏这里不需要判断roleIds因为默认有权限编辑的人一定有权限看脱敏前后字段值
* 只需要保证此数据集存在脱敏配置就行
*
* @param tableData
* @return
*/
public boolean needDesensitize(TableData tableData) {
return tableData instanceof DesensitizationTableData &&
DesentizationUtils.isCollectionNotEmpty(((DesensitizationTableData) tableData).getDesensitizationConfig().getDesensitizationItems());
}
/**
* 数据集预览脱敏使用DesensitizedPreviewTableModel对当前的预览TableModel做包装
*
* @param model
* @return
*/
public PreviewTableModel desensitizeTableModel(TableData tableData, PreviewTableModel model) {
Map<Integer, TableDataDesensitizationItem> desensitizationItemMap = new LinkedHashMap<>();
// 获取此数据集的所有脱敏信息
Collection<TableDataDesensitizationItem> desensitizationItems = ((DesensitizationTableData) tableData).getDesensitizationConfig().getDesensitizationItems();
if (DesentizationUtils.isCollectionNotEmpty(desensitizationItems)) {
// 先对脱敏配置项集合做过滤和排序处理
List<TableDataDesensitizationItem> items = desensitizationItems.stream()
.filter(item -> item.getRule().isEnable() &&
matchColumnIndex(item, model) >= 0)
.sorted(Comparator.comparingInt(item -> matchColumnIndex(item, model)))
.collect(Collectors.toList());
// 然后转换成Map
for (int i = 0; i < items.size(); i++) {
desensitizationItemMap.put(i, items.get(i));
}
}
// 包装TableModel
return new DesensitizedPreviewTableModel(model, desensitizationItemMap);
}
/**
* 通过TableData获取其列名
* 实现逻辑有点绕TableData本身并不能返回列名集合只能先去获取当前模板所有数据集然后匹配名称拿到TableDataWrapper再获取列名
*
* @param tableData
* @return
*/
public List<String> getColumnNamesByTableData(TableData tableData) {
return DesignTableDataManager.getColumnNamesByTableData(tableData);
}
/**
* 这个api会返回 部门职位 + 自定义角色 的Map
* 其中 key为 "pid" + "_" + "id"value为 "ptext" + "text"
*
* @return
*/
public Map<String, String> getAllRoles() {
Map<String, String> rolesMap = new LinkedHashMap<>();
// 处理部门职位相关的用户组
addDepartmentAndPositionRoles2Map(rolesMap);
// 处理自定义角色相关的用户组
addCustomRoles2Map(rolesMap);
return rolesMap;
}
/**
* 获取所有的部门职位按照 key为 "pid" + "_" + "id"value为 "ptext" + "text"的格式添加到参数Map中
*
* @param rolesMap
*/
private void addDepartmentAndPositionRoles2Map(Map<String, String> rolesMap) {
try {
List<DepartmentPostBean> postBeans = PositionService.getInstance().getDepartmentPostNameList();
for (DepartmentPostBean postBean : postBeans) {
String department = postBean.getpText();
String position = postBean.getText();
String departmentId = postBean.getpId();
String positionId = postBean.getId();
if (!ComparatorUtils.equals(DecisionServiceConstants.DECISION_DEP_ROOT, postBean.getId()) && StringUtils.isNotEmpty(position)) {
// 只添加部门和职位同时存在的
rolesMap.put(mergeRoleId(departmentId, positionId), mergeRoleText(department, position));
}
}
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, "[Desensitization] failed to add department and position roles to map for {}", e.getMessage());
}
}
/**
* 获取所有的自定义角色按照 id - name添加到参数map里
*
* @param rolesMap
*/
private void addCustomRoles2Map(Map<String, String> rolesMap) {
try {
List<RoleBean> allCustomRole = CustomRoleService.getInstance().getAllCustomRoleNameList(null);
allCustomRole.forEach(roleBean -> rolesMap.put(roleBean.getId(), roleBean.getText()));
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, "[Desensitization] failed to add custom role to map for {}", e.getMessage());
}
}
/**
* 合并部门 + 职位的名称
*
* @param departmentName
* @param positionName
* @return
*/
public String mergeRoleText(String departmentName, String positionName) {
return departmentName + positionName;
}
/**
* 合并部门 + 职位的id
*
* @param departmentId
* @param positionId
* @return
*/
public String mergeRoleId(String departmentId, String positionId) {
return departmentId + CONNECTOR + positionId;
}
/**
* 根据列名从PreviewTableModel中匹配列序号如果返回-1代表未匹配到
* @param desensitizationItem
* @param previewModel
* @return
*/
public int matchColumnIndex(TableDataDesensitizationItem desensitizationItem, PreviewTableModel previewModel) {
return previewModel.getColumnIndexWithExceptionIngore(desensitizationItem.getColumnName());
}
}

114
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/model/DesensitizedPreviewTableModel.java

@ -0,0 +1,114 @@
package com.fr.design.data.datapane.preview.desensitization.model;
import com.fr.data.desensitize.base.TableDataDesensitizationItem;
import com.fr.data.desensitize.calculate.DesensitizationCalculator;
import com.fr.data.desensitize.rule.base.DesensitizationRule;
import com.fr.design.data.datapane.preview.PreviewTableModel;
import com.fr.design.data.datapane.preview.desensitization.TableDataPreviewDesensitizeManager;
import java.util.Map;
import java.util.Objects;
/**
* 数据集预览TableModel的脱敏实现
*
* @author Yvan
* @version 11.0
* Created by Yvan on 2022/9/14
*/
public class DesensitizedPreviewTableModel extends PreviewTableModel {
/**
* 原始数据Model
*/
private PreviewTableModel previewTableModel;
/**
* 脱敏后新组装的TableModel中列序号 - 脱敏信息 对应的Map
*/
private Map<Integer, TableDataDesensitizationItem> desensitizationItemMap;
private boolean needDesensitize = false;
public DesensitizedPreviewTableModel(PreviewTableModel previewTableModel, Map<Integer, TableDataDesensitizationItem> desensitizationItemMap) {
this.previewTableModel = previewTableModel;
this.desensitizationItemMap = desensitizationItemMap;
}
@Override
public String getColumnName(int column) {
return needDesensitize ?
desensitizationItemMap.get(column).getColumnName() :
previewTableModel.getColumnName(column);
}
@Override
public int getRowCount() {
return previewTableModel.getRowCount();
}
@Override
public int getColumnCount() {
return needDesensitize ?
getDesensitizeColumnsCount() :
previewTableModel.getColumnCount();
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
return needDesensitize && Objects.nonNull(desensitizationItemMap.get(columnIndex)) ?
getDesensitizedValue(rowIndex, columnIndex) :
previewTableModel.getValueAt(rowIndex, columnIndex);
}
/**
* 返回脱敏后的数据值
*
* @param rowIndex
* @param columnIndex
* @return
*/
private Object getDesensitizedValue(int rowIndex, int columnIndex) {
// 先通过columnIndex找到对应原TableModel的列序号
int originColumnIndex = TableDataPreviewDesensitizeManager.getInstance().matchColumnIndex(desensitizationItemMap.get(columnIndex), previewTableModel);
// 获取原值
Object value = previewTableModel.getValueAt(rowIndex, originColumnIndex);
// 判空
if (Objects.isNull(value)) {
return value;
}
// 脱敏
String strValue = String.valueOf(value);
value = desensitizeValue(strValue, columnIndex);
return value;
}
/**
* 计算脱敏后的value,此时columnIndex对应的脱敏信息一定不为空
*
* @param strValue
* @param columnIndex
* @return
*/
private String desensitizeValue(String strValue, int columnIndex) {
DesensitizationRule rule = desensitizationItemMap.get(columnIndex).getRule();
return DesensitizationCalculator.getInstance().desensitize(strValue, rule);
}
/**
* 获取当前有效的脱敏字段个数
*
* @return
*/
public int getDesensitizeColumnsCount() {
return desensitizationItemMap.size();
}
/**
* 切换脱敏状态
*/
public void toggleNeedDesensite() {
this.needDesensitize = !needDesensitize;
}
}

94
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/common/DesensitizationOpenPane.java

@ -0,0 +1,94 @@
package com.fr.design.data.datapane.preview.desensitization.view.common;
import com.fr.base.svg.IconUtils;
import com.fr.design.border.UITitledBorder;
import com.fr.design.constants.UIConstants;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.log.FineLoggerFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Desktop;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.net.URL;
/**
* 启用数据脱敏的面板
*
* @author Yvan
* @version 11.0
* Created by Yvan on 2022/10/12
*/
public class DesensitizationOpenPane extends JPanel {
/**
* 数据脱敏启用框
*/
private UICheckBox desensitizeOpenCheckBox;
/**
* 跳转帮助文档Label
*/
private UILabel hyperlinkLabel;
/**
* 启用提示Label
*/
private UILabel tipsLabel;
public DesensitizationOpenPane() {
VerticalFlowLayout layout = new VerticalFlowLayout(VerticalFlowLayout.TOP);
layout.setAlignLeft(true);
this.setLayout(layout);
this.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Report_Desensitization_Config")));
JPanel panel = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
// 启用数据脱敏的勾选框
desensitizeOpenCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Desensitization_Opened"));
// 跳转帮助文档Label
hyperlinkLabel = new UILabel(IconUtils.readIcon("/com/fr/design/standard/tip/tips"));
hyperlinkLabel.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Desensitization_Open_Tips"));
hyperlinkLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent event) {
try {
URL url = new URL(Toolkit.i18nText("Fine-Design_Report_Desensitization_Help_Document_Url"));
Desktop.getDesktop().browse(url.toURI());
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, "open browse of table data desensitization help document failed for {}", e.getMessage());
}
}
});
panel.add(desensitizeOpenCheckBox);
panel.add(hyperlinkLabel);
// 提示Label
tipsLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Opened_Tooltips"));
tipsLabel.setForeground(UIConstants.CHECK_BOX_TIP_FONT_COLOR);
this.add(panel);
this.add(tipsLabel);
}
/**
* 数据脱敏启用状态
* @return
*/
public boolean isDesensitizationOpened() {
return desensitizeOpenCheckBox.isSelected();
}
/**
* 设置数据脱敏启用状态
* @param opened
*/
public void setDesensitizationOpened(boolean opened) {
desensitizeOpenCheckBox.setSelected(opened);
}
}

319
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleChoosePane.java

@ -0,0 +1,319 @@
package com.fr.design.data.datapane.preview.desensitization.view.rule;
import com.fr.base.svg.IconUtils;
import com.fr.data.desensitize.rule.DesensitizationRuleManager;
import com.fr.data.desensitize.rule.base.DesensitizationRule;
import com.fr.data.desensitize.rule.base.DesensitizationRuleSource;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.UITableEditAction;
import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.gui.itableeditorpane.UITableModelAdapter;
import com.fr.design.i18n.Toolkit;
import com.fr.stable.StringUtils;
import com.fr.stable.collections.CollectionUtils;
import javax.swing.AbstractCellEditor;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 脱敏规则选择页面
*
* @author Yvan
* @version 11.0
* Created by Yvan on 2022/9/26
*/
public class DesensitizationRuleChoosePane extends JPanel {
private CardLayout cardLayout;
private UITableEditorPane<DesensitizationRule> serverRuleEditPane;
private UITableEditorPane<DesensitizationRule> customRuleEditPane;
private DesensitizationRuleSource currentRuleSource;
public DesensitizationRuleChoosePane() {
this.cardLayout = new CardLayout();
this.setLayout(cardLayout);
serverRuleEditPane = new UITableEditorPane<>(new DesensitizationRuleChooseTableModel(this, true));
customRuleEditPane = new UITableEditorPane<>(new DesensitizationRuleChooseTableModel(this, false));
serverRuleEditPane.setHeaderResizing(false);
customRuleEditPane.setHeaderResizing(false);
populateDesensitizationRules();
this.add(serverRuleEditPane, DesensitizationRuleSource.SERVER.name());
this.add(customRuleEditPane, DesensitizationRuleSource.CUSTOM.name());
// 默认显示平台规则
switchPaneByRuleSource(DesensitizationRuleSource.SERVER);
}
/**
* 通过脱敏规则来源切换显示不同的脱敏规则Table面板
*
* @param ruleSource
*/
public void switchPaneByRuleSource(DesensitizationRuleSource ruleSource) {
this.currentRuleSource = ruleSource;
this.cardLayout.show(this, ruleSource.name());
}
/**
* 展示当前规则
*/
private void populateDesensitizationRules() {
serverRuleEditPane.populate(DesensitizationRuleManager.getInstance().getRules(DesensitizationRuleSource.SERVER));
customRuleEditPane.populate(DesensitizationRuleManager.getInstance().getRules(DesensitizationRuleSource.CUSTOM));
}
/**
* 获取当前选中的规则
*
* @return
*/
public DesensitizationRule getSelectedDesensitizationRule() {
switch (currentRuleSource) {
case SERVER:
return serverRuleEditPane.getTableModel().getSelectedValue();
case CUSTOM:
return customRuleEditPane.getTableModel().getSelectedValue();
default:
return null;
}
}
/**
* 规则选择Table的TableModel
*/
private class DesensitizationRuleChooseTableModel extends UITableModelAdapter<DesensitizationRule> {
private Component parent;
private boolean debugActionOnly;
protected DesensitizationRuleChooseTableModel(Component parent, boolean debugActionOnly) {
super(new String[]{
StringUtils.EMPTY,
Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Name"),
Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Description")
});
this.parent = parent;
this.debugActionOnly = debugActionOnly;
this.setColumnClass(new Class[]{
RuleChoosePane.class,
UILabel.class,
UILabel.class
});
this.setDefaultEditor(RuleChoosePane.class, new RuleChoosePane());
this.setDefaultRenderer(RuleChoosePane.class, new RuleChoosePane());
this.createTable().getColumnModel().getColumn(0).setMaxWidth(20);
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
DesensitizationRule rule = getList().get(rowIndex);
switch (columnIndex) {
case 0:
// 选中状态
return rule.equals(getSelectedValue());
case 1:
// 脱敏规则名称
return rule.getRuleName();
case 2:
// 脱敏规则描述
return DesensitizationRule.getDescription(rule);
default:
return StringUtils.EMPTY;
}
}
@Override
public boolean isCellEditable(int row, int col) {
return true;
}
@Override
public UITableEditAction[] createAction() {
return debugActionOnly ?
new UITableEditAction[]{new DebugRuleAction(parent)} :
new UITableEditAction[]{new AddRuleAction(), new EditRuleAction(), new DeleteRuleAction(parent), new DebugRuleAction(parent)};
}
private Set<String> getCurrentExistRuleNames(String excludeName) {
List<DesensitizationRule> rules = getList();
return CollectionUtils.isEmpty(rules) ?
new LinkedHashSet<>() :
rules.stream()
.map(DesensitizationRule::getRuleName)
.filter(name -> !StringUtils.equals(name, excludeName))
.collect(Collectors.toSet());
}
private class RuleChoosePane extends AbstractCellEditor implements TableCellEditor, TableCellRenderer {
private UIRadioButton selectedButton;
public RuleChoosePane() {
this.selectedButton = new UIRadioButton();
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
selectedButton.setSelected(isSelected);
return selectedButton;
}
@Override
public Object getCellEditorValue() {
return selectedButton.isSelected();
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
selectedButton.setSelected(isSelected);
return selectedButton;
}
}
/**
* 添加规则
*/
private class AddRuleAction extends AddTableRowAction {
public AddRuleAction() {
this.setName(Toolkit.i18nText("Fine-Design_Report_Desensitization_Add"));
this.setSmallIcon("/com/fr/design/standard/add/add_black", false);
}
@Override
public void actionPerformed(ActionEvent e) {
// 新增一条规则
DesensitizationRuleEditPane editPane = new DesensitizationRuleEditPane(getCurrentExistRuleNames(StringUtils.EMPTY));
BasicDialog basicDialog = editPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(parent), new DialogActionAdapter() {
@Override
public void doOk() {
DesensitizationRule rule = editPane.updateBean();
// 添加到Rule Manager中
if (DesensitizationRule.valid(rule)) {
DesensitizationRuleManager.getInstance().addRule(rule);
}
// 添加到Table中
addRow(rule);
fireTableDataChanged();
}
@Override
public void doCancel() {
super.doCancel();
}
}, BasicDialog.DEFAULT);
basicDialog.setVisible(true);
}
}
private class EditRuleAction extends UITableEditAction {
public EditRuleAction() {
this.setName(Toolkit.i18nText("Fine-Design_Basic_Edit"));
this.setSmallIcon(IconUtils.readIcon("/com/fr/design/standard/edit/edit"));
}
@Override
public void checkEnabled() {
setEnabled(table.getSelectedRow() != -1);
}
@Override
public void actionPerformed(ActionEvent e) {
// 获取当前选中规则
DesensitizationRule selectedValue = getSelectedValue();
DesensitizationRuleEditPane editPane = new DesensitizationRuleEditPane(getCurrentExistRuleNames(selectedValue.getRuleName()));
editPane.populateBean(selectedValue);
BasicDialog basicDialog = editPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(parent), new DialogActionAdapter() {
@Override
public void doOk() {
DesensitizationRule rule = editPane.updateBean();
// 修改同步到RuleManager中
if (DesensitizationRule.valid(rule)) {
DesensitizationRuleManager.getInstance().updateRule(rule);
}
fireTableDataChanged();
}
@Override
public void doCancel() {
super.doCancel();
}
}, BasicDialog.DEFAULT);
basicDialog.setVisible(true);
}
}
private class DeleteRuleAction extends DeleteAction {
public DeleteRuleAction(Component parent) {
super(parent);
this.setName(Toolkit.i18nText("Fine-Design_Basic_Base_Remove"));
this.setSmallIcon("/com/fr/design/images/control/remove");
}
@Override
public void checkEnabled() {
setEnabled(table.getSelectedRow() != -1);
}
@Override
public void actionPerformed(ActionEvent e) {
// 获取当前选中规则
DesensitizationRule selectedRule = getSelectedValue();
// 删除同步到RuleManager中
if (DesensitizationRule.valid(selectedRule)) {
DesensitizationRuleManager.getInstance().removeRule(selectedRule);
}
super.actionPerformed(e);
}
}
private class DebugRuleAction extends UITableEditAction {
private Component parent;
public DebugRuleAction(Component parent) {
this.parent = parent;
this.setName(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Debug"));
this.setSmallIcon("/com/fr/design/standard/debug/debug");
}
@Override
public void checkEnabled() {
setEnabled(table.getSelectedRow() != -1);
}
@Override
public void actionPerformed(ActionEvent e) {
// 获取当前选中规则
DesensitizationRule selectedRule = getSelectedValue();
if (selectedRule == null) {
return;
}
DesensitizationRuleDebugPane ruleDebugPane = new DesensitizationRuleDebugPane(selectedRule);
BasicDialog ruleDebugDialog = ruleDebugPane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(parent), null, BasicDialog.DEFAULT);
ruleDebugDialog.setVisible(true);
}
}
}
}

128
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleDebugPane.java

@ -0,0 +1,128 @@
package com.fr.design.data.datapane.preview.desensitization.view.rule;
import com.fr.data.desensitize.calculate.DesensitizationCalculator;
import com.fr.data.desensitize.rule.base.DesensitizationRule;
import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
/**
* 脱敏规则调试页
*
* @author Yvan
* @version 11.0
* Created by Yvan on 2022/9/8
*/
public class DesensitizationRuleDebugPane extends BasicPane {
/**
* 脱敏规则
*/
private DesensitizationRule rule;
public DesensitizationRuleDebugPane(DesensitizationRule rule) {
this.rule = rule;
initComponent();
}
private void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(initNorthPane(), BorderLayout.NORTH);
this.add(initCenterPane(), BorderLayout.CENTER);
}
private JPanel initNorthPane() {
JPanel northPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Description"));
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.setBorder(BorderFactory.createEmptyBorder(20, 10, 0, 0));
UILabel desensitizationRule = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Algorithm"));
UILabel characterReplace = new UILabel(rule.getRuleType().getRuleTypeName());
UILabel description = new UILabel(DesensitizationRule.getDescription(rule));
JComponent[][] components = new JComponent[][]{
{desensitizationRule, characterReplace},
{new UILabel(), description}
};
panel.add(
TableLayoutHelper.createCommonTableLayoutPane(
components,
new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED},
new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED},
20),
BorderLayout.CENTER);
northPane.add(panel);
return northPane;
}
private JPanel initCenterPane() {
JPanel centerPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Debug"));
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.setBorder(BorderFactory.createEmptyBorder(20, 10, 0, 0));
UILabel beforeDesensitize = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Before"));
UITextField beforeDesensitizeText = new UITextField(20);
beforeDesensitizeText.setPlaceholder(Toolkit.i18nText("Fine-Design_Report_Desensitization_Enter_Content"));
UILabel afterDesensitize = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_After"));
UITextField afterDesensitizeText = new UITextField(20);
afterDesensitizeText.setEditable(false);
UIButton desensitizeButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_Desensitization_Debug"));
beforeDesensitizeText.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
afterDesensitizeText.setText(StringUtils.EMPTY);
}
@Override
public void focusLost(FocusEvent e) {
}
});
desensitizeButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String text = beforeDesensitizeText.getText();
if (StringUtils.isEmpty(text)) {
FineJOptionPane.showMessageDialog(DesensitizationRuleDebugPane.this,
Toolkit.i18nText("Fine-Design_Report_Desensitization_Please_Enter_Valid_Content"));
}
String desensitizedText = DesensitizationCalculator.getInstance().desensitize(text, rule);
afterDesensitizeText.setText(desensitizedText);
}
});
JComponent[][] components = new JComponent[][]{
{beforeDesensitize, beforeDesensitizeText, desensitizeButton},
{afterDesensitize, afterDesensitizeText, new UILabel()}
};
panel.add(
TableLayoutHelper.createCommonTableLayoutPane(
components,
new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED},
new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.PREFERRED},
20),
BorderLayout.CENTER);
centerPane.add(panel);
return centerPane;
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Debug");
}
}

299
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleEditPane.java

@ -0,0 +1,299 @@
package com.fr.design.data.datapane.preview.desensitization.view.rule;
import com.fr.data.desensitize.rule.base.DesensitizationCondition;
import com.fr.data.desensitize.rule.base.DesensitizationRule;
import com.fr.data.desensitize.rule.base.DesensitizationRuleType;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.constants.UIConstants;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Insets;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.util.Arrays;
import java.util.Set;
/**
* 脱敏规则编辑页
*
* @author Yvan
* @version 11.0
* Created by Yvan on 2022/9/8
*/
public class DesensitizationRuleEditPane extends BasicBeanPane<DesensitizationRule> {
/**
* 已经存在的规则名称用于检测重名
*/
private Set<String> existRuleNames;
private UITextField ruleNameTextField;
private UIComboBox ruleTypeComboBox;
private UINumberField retainFrontTextField;
private UINumberField retainBackTextField;
private UITextField firstSymbolTextField;
private UITextField secondSymbolTextField;
private CardLayout cardLayout;
private JPanel ruleConditionPane;
private DesensitizationRule rule = DesensitizationRule.createDefaultEmptyRule();
private final FocusListener retainFrontListener = new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent e) {
rule.getCondition().setRetainFront((int) retainFrontTextField.getValue());
}
};
private final FocusListener retainBackListener = new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent e) {
rule.getCondition().setRetainBack((int) retainBackTextField.getValue());
}
};
private final FocusListener firstSymbolListener = new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent e) {
rule.getCondition().setSymbol(firstSymbolTextField.getText());
}
};
private final FocusListener secondSymbolListener = new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
}
@Override
public void focusLost(FocusEvent e) {
rule.getCondition().setRetainFront(0);
rule.getCondition().setRetainBack(0);
rule.getCondition().setSymbol(secondSymbolTextField.getText());
}
};
public DesensitizationRuleEditPane(Set<String> existRuleNames) {
this.existRuleNames = existRuleNames;
initComponent();
}
/**
* 初始化面板
*/
private void initComponent() {
this.setLayout(FRGUIPaneFactory.createLeftZeroVgapNormalHgapLayout());
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.setBorder(BorderFactory.createEmptyBorder(20, 10, 0, 0));
UILabel ruleNameLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Name"));
// 规则名称输入框
initRuleNameTextField();
UILabel ruleTypeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Algorithm"));
// 脱敏算法Type设置
JPanel ruleTypePane = initRuleTypePane();
// 脱敏算法Condition设置
JPanel ruleConditionPane = initRuleConditionPane();
JComponent[][] components = {
{ruleNameLabel, ruleNameTextField},
{ruleTypeLabel, ruleTypePane},
{new UILabel(), ruleConditionPane}
};
panel.add(
TableLayoutHelper.createGapTableLayoutPane(
components,
new double[]{TableLayout.PREFERRED, TableLayout.PREFERRED, TableLayout.FILL},
new double[]{TableLayout.FILL, TableLayout.PREFERRED},
20,
20),
BorderLayout.CENTER);
this.add(panel);
}
/**
* 初始化规则类型面板
*
* @return
*/
private JPanel initRuleTypePane() {
JPanel ruleTypePane = FRGUIPaneFactory.createBorderLayout_S_Pane();
// 脱敏算法类型下拉框
initRuleTypeComboBox();
ruleTypePane.add(ruleTypeComboBox, BorderLayout.CENTER);
return ruleTypePane;
}
/**
* 初始化规则条件面板
*
* @return
*/
private JPanel initRuleConditionPane() {
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
cardLayout = new CardLayout();
ruleConditionPane = new JPanel(cardLayout);
// 字符替换
JPanel characterReplacePane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
UILabel retainFrontLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_Retain_Front") + StringUtils.BLANK);
retainFrontTextField = new UINumberField(5);
retainFrontTextField.addFocusListener(retainFrontListener);
UILabel retainBackLabel = new UILabel(StringUtils.BLANK + Toolkit.i18nText("Fine-Design_Report_Desensitization_Count_And_Back") + StringUtils.BLANK);
retainBackTextField = new UINumberField(5);
retainBackTextField.addFocusListener(retainBackListener);
UILabel replaceLabel = new UILabel(StringUtils.BLANK + Toolkit.i18nText("Fine-Design_Report_Desensitization_Count_And_Other_Character_Replace_By") + StringUtils.BLANK);
firstSymbolTextField = new UITextField(10);
firstSymbolTextField.addFocusListener(firstSymbolListener);
characterReplacePane.add(retainFrontLabel);
characterReplacePane.add(retainFrontTextField);
characterReplacePane.add(retainBackLabel);
characterReplacePane.add(retainBackTextField);
characterReplacePane.add(replaceLabel);
characterReplacePane.add(firstSymbolTextField);
// 整体替换
JPanel characterAllReplacePane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
UILabel allReplaceLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Desensitization_All_Character_Replace_By") + StringUtils.BLANK);
secondSymbolTextField = new UITextField(10);
secondSymbolTextField.addFocusListener(secondSymbolListener);
characterAllReplacePane.add(allReplaceLabel);
characterAllReplacePane.add(secondSymbolTextField);
ruleConditionPane.add(characterReplacePane, DesensitizationRuleType.CHARACTER_REPLACE.getRuleTypeName());
ruleConditionPane.add(characterAllReplacePane, DesensitizationRuleType.ALL_CHARACTERS_REPLACE.getRuleTypeName());
// 初始化状态为字符替换
switchRuleConditionPane(DesensitizationRuleType.CHARACTER_REPLACE);
panel.add(ruleConditionPane, BorderLayout.CENTER);
return panel;
}
/**
* 切换规则类型面板
*
* @param ruleType
*/
private void switchRuleConditionPane(DesensitizationRuleType ruleType) {
this.cardLayout.show(ruleConditionPane, ruleType.getRuleTypeName());
}
/**
* 初始化规则类型下拉框
*/
private void initRuleTypeComboBox() {
ruleTypeComboBox = new UIComboBox(Arrays.stream(DesensitizationRuleType.values()).map(DesensitizationRuleType::getRuleTypeName).toArray());
ruleTypeComboBox.setSelectedIndex(0);
ruleTypeComboBox.registerChangeListener(new UIObserverListener() {
@Override
public void doChange() {
DesensitizationRuleType ruleType = DesensitizationRuleType.matchByTypeName((String) ruleTypeComboBox.getSelectedItem());
rule.setRuleType(ruleType);
// 修改底下的conditionPane
switchRuleConditionPane(ruleType);
}
});
}
/**
* 初始化规则名称输入框
*/
private void initRuleNameTextField() {
ruleNameTextField = new UITextField(20) {
@Override
public Insets getInsets() {
return new Insets(2, 4, 0, 4);
}
};
ruleNameTextField.setPlaceholder(Toolkit.i18nText("Fine-Design_Report_Desensitization_Please_Enter_Rule_Name"));
ruleNameTextField.setBorderPainted(true);
ruleNameTextField.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
ruleNameTextField.setBorder(BorderFactory.createLineBorder(UIConstants.NORMAL_BLUE));
ruleNameTextField.repaint();
}
@Override
public void focusLost(FocusEvent e) {
ruleNameTextField.setBorder(BorderFactory.createLineBorder(UIConstants.TOOLBAR_BORDER_COLOR));
rule.setRuleName(ruleNameTextField.getText());
ruleNameTextField.repaint();
}
});
}
@Override
public void populateBean(DesensitizationRule ob) {
this.rule = ob;
this.ruleNameTextField.setText(rule.getRuleName());
String typeName = rule.getRuleType().getRuleTypeName();
this.ruleTypeComboBox.setSelectedItem(typeName);
switch (DesensitizationRuleType.matchByTypeName(typeName)) {
case CHARACTER_REPLACE:
this.retainFrontTextField.setValue(rule.getCondition().getRetainFront());
this.retainBackTextField.setValue(rule.getCondition().getRetainBack());
this.firstSymbolTextField.setText(rule.getCondition().getSymbol());
break;
case ALL_CHARACTERS_REPLACE:
this.secondSymbolTextField.setText(rule.getCondition().getSymbol());
break;
default:
}
}
@Override
public DesensitizationRule updateBean() {
rule.setEnable(true);
return rule;
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Report_Desensitization_Custom_Config_Rules");
}
@Override
public void checkValid() throws Exception {
// 保存rule前检查下
String checkMessage = StringUtils.EMPTY;
if (StringUtils.isEmpty(rule.getRuleName())) {
checkMessage = Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Name_Cannot_Be_Empty");
} else if (existRuleNames.contains(rule.getRuleName())) {
checkMessage = Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Name_Cannot_Repeat");
} else if (DesensitizationCondition.invalid(rule.getCondition())) {
checkMessage = Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Wrong_Condition");
}
if (StringUtils.isNotEmpty(checkMessage)) {
throw new Exception(checkMessage);
}
}
}

82
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRulePane.java

@ -0,0 +1,82 @@
package com.fr.design.data.datapane.preview.desensitization.view.rule;
import com.fr.data.desensitize.rule.base.DesensitizationRule;
import com.fr.data.desensitize.rule.base.DesensitizationRuleSource;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.border.UITitledBorder;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
/**
* 脱敏规则展示页
*
* @author Yvan
* @version 11.0
* Created by Yvan on 2022/9/8
*/
public class DesensitizationRulePane extends BasicBeanPane<DesensitizationRule> {
/**
* 规则来源选择面板
*/
private DesensitizationRuleSourceChoosePane ruleSourceChoosePane;
/**
* 规则选择面板
*/
private DesensitizationRuleChoosePane ruleChoosePane;
/**
* 内容面板
*/
private JPanel contentPane;
public DesensitizationRulePane() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
initPane();
}
private void initPane() {
// 内容面板
contentPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
contentPane.setBorder(UITitledBorder.createBorderWithTitle(Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Choose")));
this.add(contentPane, BorderLayout.CENTER);
// 规则来源选择Pane
ruleSourceChoosePane = new DesensitizationRuleSourceChoosePane(this);
// 规则选择Pane
ruleChoosePane = new DesensitizationRuleChoosePane();
contentPane.add(ruleSourceChoosePane, BorderLayout.NORTH);
contentPane.add(ruleChoosePane, BorderLayout.CENTER);
}
/**
* 处理规则来源选择面板中改动来源的事件
*
* @param newRuleSource
*/
public void dealWithRuleSourceChanged(DesensitizationRuleSource newRuleSource) {
ruleChoosePane.switchPaneByRuleSource(newRuleSource);
}
@Override
public void populateBean(DesensitizationRule ob) {
// 这边展示当前所有规则时,不依靠外界传值,初始化的时候,从规则管理中心去获取
}
@Override
public DesensitizationRule updateBean() {
DesensitizationRule desensitizationRule = ruleChoosePane.getSelectedDesensitizationRule();
return DesensitizationRule.valid(desensitizationRule) ?
desensitizationRule :
DesensitizationRule.createDefaultEmptyRule();
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule");
}
}

49
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/rule/DesensitizationRuleSourceChoosePane.java

@ -0,0 +1,49 @@
package com.fr.design.data.datapane.preview.desensitization.view.rule;
import com.fr.data.desensitize.rule.base.DesensitizationRuleSource;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.i18n.Toolkit;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JPanel;
import java.awt.FlowLayout;
/**
* 脱敏规则来源选择页面
*
* @author Yvan
* @version 11.0
* Created by Yvan on 2022/9/26
*/
public class DesensitizationRuleSourceChoosePane extends JPanel {
/**
* 来源平台的按钮
*/
private UIRadioButton serverSource;
/**
* 来源本地的按钮
*/
private UIRadioButton customSource;
public DesensitizationRuleSourceChoosePane(DesensitizationRulePane desensitizationRulePane) {
this.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
serverSource = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Desensitization_Server_Config_Rules"));
customSource = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Desensitization_Custom_Config_Rules"));
ButtonGroup buttonGroup = new ButtonGroup();
buttonGroup.add(serverSource);
buttonGroup.add(customSource);
serverSource.setSelected(true);
serverSource.registerChangeListener(() -> desensitizationRulePane.dealWithRuleSourceChanged(DesensitizationRuleSource.SERVER));
customSource.registerChangeListener(() -> desensitizationRulePane.dealWithRuleSourceChanged(DesensitizationRuleSource.CUSTOM));
this.add(serverSource);
this.add(customSource);
}
}

98
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationSettingPane.java

@ -0,0 +1,98 @@
package com.fr.design.data.datapane.preview.desensitization.view.setting;
import com.fr.data.desensitize.base.DesensitizationTableData;
import com.fr.data.desensitize.base.TableDataDesensitizationItem;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.data.datapane.preview.desensitization.view.common.DesensitizationOpenPane;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.JComponent;
import java.awt.BorderLayout;
import java.util.List;
/**
* 数据集脱敏字段设置页面
*
* @author Yvan
* @version 11.0
* Created by Yvan on 2022/9/8
*/
public class TableDataDesensitizationSettingPane extends BasicBeanPane<DesensitizationTableData> {
/**
* 设置针对的数据集
*/
private DesensitizationTableData tableData;
private DesensitizationOpenPane desensitizationOpenPane;
private TableDataDesensitizationTablePane tableDataDesensitizationTablePane;
public TableDataDesensitizationSettingPane(DesensitizationTableData tableData) {
this.tableData = tableData;
initComponents();
}
private void initComponents() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(initNorthPane(), BorderLayout.NORTH);
this.add(initCenterPane(), BorderLayout.CENTER);
}
/**
* 初始化启用数据脱敏面板
*
* @return
*/
private JComponent initNorthPane() {
this.desensitizationOpenPane = new DesensitizationOpenPane();
return desensitizationOpenPane;
}
/**
* 初始化数据脱敏规则表面板
*
* @return
*/
private JComponent initCenterPane() {
this.tableDataDesensitizationTablePane = new TableDataDesensitizationTablePane(tableData, this);
return tableDataDesensitizationTablePane;
}
@Override
protected String title4PopupWindow() {
return Toolkit.i18nText("Fine-Design_Report_Desensitization_Config");
}
@Override
public void populateBean(DesensitizationTableData tableData) {
this.tableData = tableData;
this.desensitizationOpenPane.setDesensitizationOpened(tableData.getDesensitizationConfig().isDesensitizeOpened());
tableDataDesensitizationTablePane.populateDesensitizationSetting(tableData);
}
@Override
public DesensitizationTableData updateBean() {
saveDesensitizeOpened();
saveDesensitizationBeans(tableDataDesensitizationTablePane.updateDesensitizationSetting());
return tableData;
}
/**
* 保存脱敏启用状态
*/
public void saveDesensitizeOpened() {
tableData.getDesensitizationConfig().setDesensitizeOpened(this.desensitizationOpenPane.isDesensitizationOpened());
}
/**
* 保存脱敏规则配置信息
*
* @param desensitizationItems
*/
public void saveDesensitizationBeans(List<TableDataDesensitizationItem> desensitizationItems) {
tableData.getDesensitizationConfig().setDesensitizationItems(desensitizationItems);
}
}

442
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java

@ -0,0 +1,442 @@
package com.fr.design.data.datapane.preview.desensitization.view.setting;
import com.fr.data.desensitize.base.DesensitizationTableData;
import com.fr.data.desensitize.base.TableDataDesensitizationItem;
import com.fr.data.desensitize.rule.base.DesensitizationRule;
import com.fr.design.data.datapane.preview.desensitization.TableDataPreviewDesensitizeManager;
import com.fr.design.data.datapane.preview.desensitization.view.rule.DesensitizationRulePane;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombocheckbox.UIComboCheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.UITableEditAction;
import com.fr.design.gui.itableeditorpane.UITableModelAdapter;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.stable.StringUtils;
import org.jetbrains.annotations.Nullable;
import javax.swing.AbstractCellEditor;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
/**
* 处理TableDataDesensitizationTablePane中TableEditPane的Model
*
* @author Yvan
* @version 11.0
* Created by Yvan on 2022/9/23
*/
public class TableDataDesensitizationTableModel extends UITableModelAdapter<TableDataDesensitizationItem> {
private static final String APOSTROPHE = "...";
private DesensitizationTableData tableData;
/**
* 当前数据集的所有列名
*/
private List<String> columnNames;
/**
* key为用户组唯一标识id拼接value为用户组名称
*/
private Map<String, String> roleMap;
private Component parent;
private DesensitizationRuleChooser ruleChooser;
private DesensitizationRuleDescriptionPane descriptionPane;
public TableDataDesensitizationTableModel(DesensitizationTableData tableData, Component parent) {
// table相关
super(new String[]{
Toolkit.i18nText("Fine-Design_Report_Desensitization_Column"),
Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule"),
StringUtils.EMPTY,
Toolkit.i18nText("Fine-Design_Report_Desensitization_Effected_Roles")
});
// 一些数据相关
this.tableData = tableData;
// 获取当前数据集的所有列名
this.columnNames = TableDataPreviewDesensitizeManager.getInstance().getColumnNamesByTableData(tableData);
// 获取当前所有用户组
this.roleMap = TableDataPreviewDesensitizeManager.getInstance().getAllRoles();
this.parent = parent;
this.setColumnClass(new Class[]{
// 列名选择
ColumnNamesComboBox.class,
// 规则选择
DesensitizationRuleChooser.class,
// 规则详情展示
DesensitizationRuleDescriptionPane.class,
// 生效用户组选择
EffectedRolesChooser.class
});
this.setDefaultEditor(ColumnNamesComboBox.class, new ColumnNamesComboBox());
this.ruleChooser = new DesensitizationRuleChooser();
this.setDefaultEditor(DesensitizationRuleChooser.class, ruleChooser);
this.setDefaultRenderer(DesensitizationRuleChooser.class, ruleChooser);
this.descriptionPane = new DesensitizationRuleDescriptionPane();
this.setDefaultEditor(DesensitizationRuleDescriptionPane.class, new DesensitizationRuleDescriptionPane());
this.setDefaultEditor(EffectedRolesChooser.class, new EffectedRolesChooser());
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
TableDataDesensitizationItem desensitizationItem = this.getList().get(rowIndex);
switch (columnIndex) {
case 0:
// 选中的数据集字段名称
return desensitizationItem.getColumnName();
case 1:
// 脱敏规则名称
return desensitizationItem.getRule().getRuleName();
case 2:
// 脱敏规则详情
return DesensitizationRule.getDescription(desensitizationItem.getRule());
case 3:
// 生效用户组
return matchRoleNamesByIds(desensitizationItem.getRoleIds());
default:
return StringUtils.EMPTY;
}
}
/**
* 通过id匹配此用户组对应的部门职位名称或者说自定义角色名称
*
* @param roleIds
* @return
*/
private List<String> matchRoleNamesByIds(Collection<String> roleIds) {
List<String> result = new ArrayList<>();
for (String roleId : roleIds) {
if (roleMap != null && roleMap.containsKey(roleId)) {
result.add(roleMap.get(roleId));
}
}
return result;
}
@Override
public boolean isCellEditable(int row, int col) {
return true;
}
@Override
public UITableEditAction[] createAction() {
return new UITableEditAction[]{new AddDesensitizationAction(), new RemoveDesensitizationAction(parent)};
}
/**
* 获取当前选中的item可能为null
*
* @return
*/
@Nullable
private TableDataDesensitizationItem getCurrentSelectBean() {
return table.getSelectedRow() == -1 ?
null :
getList().get(table.getSelectedRow());
}
/**
* 列名选择下拉框
*/
private class ColumnNamesComboBox extends AbstractCellEditor implements TableCellEditor, TableCellRenderer {
private UIComboBox columnNameComboBox;
ColumnNamesComboBox() {
columnNameComboBox = new UIComboBox(columnNames.toArray(new String[0]));
this.addCellEditorListener(new CellEditorListener() {
@Override
public void editingStopped(ChangeEvent e) {
TableDataDesensitizationItem desensitizationItem = getCurrentSelectBean();
if (Objects.nonNull(desensitizationItem)) {
desensitizationItem.setColumnName(columnNames.get(columnNameComboBox.getSelectedIndex()));
fireTableDataChanged();
}
}
@Override
public void editingCanceled(ChangeEvent e) {
}
});
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
columnNameComboBox.setSelectedItem(getList().get(row).getColumnName());
return columnNameComboBox;
}
@Override
public Object getCellEditorValue() {
Object selectedItem = columnNameComboBox.getSelectedItem();
return Objects.isNull(selectedItem) ? StringUtils.EMPTY : selectedItem.toString();
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
columnNameComboBox.setSelectedItem(getList().get(row).getColumnName());
return columnNameComboBox;
}
}
private class DesensitizationRuleChooser extends AbstractCellEditor implements TableCellEditor, TableCellRenderer {
/**
* 规则选择页面
*/
private JPanel choosePane;
/**
* 规则名称
*/
private UITextField ruleNameTextField;
/**
* 规则选择按钮
*/
private UIButton chooseButton;
/**
* 规则
*/
private DesensitizationRule rule;
private ActionListener chooseRuleListener = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
DesensitizationRulePane rulePane = new DesensitizationRulePane();
BasicDialog ruleDialog = rulePane.showWindowWithCustomSize(SwingUtilities.getWindowAncestor(parent), new DialogActionAdapter() {
@Override
public void doOk() {
rule = rulePane.updateBean();
TableDataDesensitizationItem desensitizationItem = getCurrentSelectBean();
if (Objects.nonNull(desensitizationItem) && Objects.nonNull(rule)) {
desensitizationItem.setRule(rule);
desensitizationItem.setRuleName(rule.getRuleName());
fireTableDataChanged();
}
rule = null;
}
}, BasicDialog.DEFAULT);
ruleDialog.setVisible(true);
}
};
DesensitizationRuleChooser() {
// 规则名称展示
ruleNameTextField = new UITextField();
ruleNameTextField.setEnabled(false);
// 规则选择按钮
chooseButton = new UIButton(APOSTROPHE);
chooseButton.addActionListener(chooseRuleListener);
// 规则选择页面
Component[][] templateChooserComponent = {{ruleNameTextField, chooseButton}};
double[] rowSize = {TableLayout.PREFERRED};
double[] columnSize = {TableLayout.FILL, 22};
choosePane = TableLayoutHelper.createCommonTableLayoutPane(templateChooserComponent, rowSize, columnSize, 0);
this.addCellEditorListener(new CellEditorListener() {
@Override
public void editingCanceled(ChangeEvent e) {
}
@Override
public void editingStopped(ChangeEvent e) {
TableDataDesensitizationItem desensitizationItem = getCurrentSelectBean();
if (Objects.nonNull(desensitizationItem) && Objects.nonNull(rule)) {
desensitizationItem.setRule(rule);
desensitizationItem.setRuleName(rule.getRuleName());
fireTableDataChanged();
}
}
});
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
ruleNameTextField.setText(getList().get(row).getRule().getRuleName());
return choosePane;
}
@Override
public Object getCellEditorValue() {
return ruleNameTextField.getText();
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
ruleNameTextField.setText((String) value);
return choosePane;
}
}
private class DesensitizationRuleDescriptionPane extends AbstractCellEditor implements TableCellEditor {
private UILabel descriptionLabel;
DesensitizationRuleDescriptionPane() {
// 规则描述
this.descriptionLabel = new UILabel();
}
/**
* 根据脱敏规则信息刷新下规则描述文字主要用于与规则选择器的联动
*
* @param desensitizationRule
*/
public void refreshDescription(DesensitizationRule desensitizationRule) {
this.descriptionLabel.setText(DesensitizationRule.getDescription(desensitizationRule));
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
refreshDescription(getList().get(row).getRule());
return descriptionLabel;
}
@Override
public Object getCellEditorValue() {
return this.descriptionLabel.getText();
}
}
private class EffectedRolesChooser extends AbstractCellEditor implements TableCellEditor, TableCellRenderer {
private UIComboCheckBox rolesCheckBox;
EffectedRolesChooser() {
this.rolesCheckBox = new UIComboCheckBox(roleMap.values().toArray(), true);
this.addCellEditorListener(new CellEditorListener() {
@Override
public void editingStopped(ChangeEvent e) {
TableDataDesensitizationItem desensitizationItem = getCurrentSelectBean();
if (Objects.nonNull(desensitizationItem)) {
desensitizationItem.setRoleIds(generateRolesIdsBySelectedValues());
fireTableDataChanged();
}
}
@Override
public void editingCanceled(ChangeEvent e) {
}
});
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
rolesCheckBox.setSelectedValues(generateRolesCheckBoxSelectedValues(getList().get(row)));
return rolesCheckBox;
}
/**
* 根据当前的规则配置信息生成选中的rolesMap用来展示
*
* @param desensitizationItem
* @return
*/
private Map<Object, Boolean> generateRolesCheckBoxSelectedValues(TableDataDesensitizationItem desensitizationItem) {
Map<Object, Boolean> result = new HashMap<>(roleMap.size());
for (Map.Entry<String, String> roleEntry : roleMap.entrySet()) {
String roleId = roleEntry.getKey();
String roleName = roleEntry.getValue();
if (desensitizationItem.getRoleIds().contains(roleId)) {
result.put(roleName, true);
} else {
result.put(roleName, false);
}
}
return result;
}
/**
* 根据当前的RoleName选择项生成其对应的RoleId的set存入规则配置信息
*
* @return
*/
private Set<String> generateRolesIdsBySelectedValues() {
Set<String> result = new LinkedHashSet<>();
Object[] selectedValues = rolesCheckBox.getSelectedValues();
for (Object selectedValue : selectedValues) {
String selectedRoleName = (String) selectedValue;
if (roleMap.containsValue(selectedRoleName)) {
Optional<Map.Entry<String, String>> matchedEntry = roleMap.entrySet().stream().filter(entry -> StringUtils.equals(entry.getValue(), selectedRoleName)).findFirst();
matchedEntry.ifPresent(stringStringEntry -> result.add(stringStringEntry.getKey()));
}
}
return result;
}
@Override
public Object getCellEditorValue() {
return rolesCheckBox.getSelectedValues();
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
rolesCheckBox.setSelectedValues(generateRolesCheckBoxSelectedValues(getList().get(row)));
return rolesCheckBox;
}
}
private class AddDesensitizationAction extends AddTableRowAction {
public AddDesensitizationAction() {
this.setName(Toolkit.i18nText("Fine-Design_Report_Desensitization_Add"));
this.setSmallIcon("/com/fr/design/standard/add/add_black", false);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
// 添加一条空白数据
addRow(TableDataDesensitizationItem.createDefault());
fireTableDataChanged();
table.getSelectionModel().setSelectionInterval(table.getRowCount() - 1, table.getRowCount() - 1);
}
}
private class RemoveDesensitizationAction extends DeleteAction {
public RemoveDesensitizationAction(Component component) {
super(component);
this.setName(Toolkit.i18nText("Fine-Design_Basic_Base_Remove"));
this.setSmallIcon("/com/fr/design/standard/remove/remove_red", false);
}
@Override
public void actionPerformed(ActionEvent e) {
super.actionPerformed(e);
}
}
}

66
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTablePane.java

@ -0,0 +1,66 @@
package com.fr.design.data.datapane.preview.desensitization.view.setting;
import com.fr.data.desensitize.base.DesensitizationTableData;
import com.fr.data.desensitize.base.TableDataDesensitizationItem;
import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.layout.FRGUIPaneFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.List;
/**
* 脱敏字段设置页面中的Table
*
* @author Yvan
* @version 11.0
* Created by Yvan on 2022/9/14
*/
public class TableDataDesensitizationTablePane extends JPanel {
/**
* 脱敏数据集
*/
private DesensitizationTableData tableData;
/**
* 父页面
*/
private Component parent;
/**
* 脱敏信息Table
*/
private UITableEditorPane<TableDataDesensitizationItem> editorPane;
public TableDataDesensitizationTablePane(DesensitizationTableData tableData, Component parent) {
this.tableData = tableData;
this.parent = parent;
initComponent();
}
private void initComponent() {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.editorPane = new UITableEditorPane<>(new TableDataDesensitizationTableModel(tableData, parent));
this.editorPane.setHeaderResizing(false);
this.add(editorPane, BorderLayout.CENTER);
}
/**
* 展示此TableData中已配置的脱敏规则信息
*
* @param tableData
*/
public void populateDesensitizationSetting(DesensitizationTableData tableData) {
this.tableData = tableData;
editorPane.populate(tableData.getDesensitizationConfig().getDesensitizationItems().toArray(new TableDataDesensitizationItem[0]));
}
/**
* 获取当前对TableData的配置脱敏规则信息
*/
public List<TableDataDesensitizationItem> updateDesensitizationSetting() {
return editorPane.update();
}
}

15
designer-base/src/main/java/com/fr/design/gui/icheckbox/UICheckBox.java

@ -139,6 +139,15 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser
return true; return true;
} }
/**
* 获取UICheckBox的UI层可以用于设置UI
*
* @return UICheckBoxUI
*/
public UICheckBoxUI getUICheckBoxUI(){
return new UICheckBoxUI();
}
private class UICheckBoxUI extends MetalCheckBoxUI { private class UICheckBoxUI extends MetalCheckBoxUI {
@Override @Override
public synchronized void paint(Graphics g, JComponent c) { public synchronized void paint(Graphics g, JComponent c) {
@ -186,9 +195,9 @@ public class UICheckBox extends JCheckBox implements UIObserver, GlobalNameObser
g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC); g2d.drawRoundRect(iconRect.x, iconRect.y, iconRect.width - 1, iconRect.height - 1, UIConstants.ARC, UIConstants.ARC);
} }
if (model.isSelected()) { if (model.isSelected()) {
UIConstants.YES_ICON.paintIcon(c, g, iconRect.x + 2, iconRect.y + 2); UIConstants.YES_ICON.paintIcon(c, g, iconRect.x + 2, iconRect.y + 2);
} }
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
// Draw the Text // Draw the Text

81
designer-base/src/main/java/com/fr/design/gui/style/TextFormatPaneContainer.java

@ -0,0 +1,81 @@
package com.fr.design.gui.style;
import com.fr.base.Style;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
/**
* 封装格式panel管理 AttributeChangeListener
*
* @author Leo.Qin
* @version 11.0
* Created by Leo.Qin on 2022/10/31
*/
public class TextFormatPaneContainer extends AbstractAttrNoScrollPane {
private TextFormatPane formatPane;
private AttributeChangeListener oldListner;
@Override
protected JPanel createContentPane() {
formatPane = new TextFormatPane();
return formatPane;
}
protected void initContentPane() {
leftContentPane = createContentPane();
if (leftContentPane != null) {
leftContentPane.setBorder(BorderFactory.createEmptyBorder());
this.add(leftContentPane, BorderLayout.CENTER);
}
}
@Override
public Dimension getPreferredSize() {
if (formatPane == null) {
return super.getPreferredSize();
}
return formatPane.getPreferredSize();
}
/**
* 根据单元格样式填充面板设置
*
* @param style 单元格样式
*/
public void populateBean(Style style) {
formatPane.populateBean(style);
}
/**
* 根据面板设置获取修改后的单元格样式
*
* @param style 单元格当前样式
* @return 更新后的单元格样式
*/
public Style update(Style style) {
return formatPane.update(style);
}
@Override
public void removeAttributeChangeListener() {
super.removeAttributeChangeListener();
}
@Override
public void addAttributeChangeListener(AttributeChangeListener listener) {
oldListner = listener;
super.addAttributeChangeListener(listener);
}
/**
* 恢复使用AttributeChangeListener
*/
public void restoreAttributeChangeListener() {
super.addAttributeChangeListener(oldListner);
}
}

2
designer-base/src/main/java/com/fr/design/gui/style/TranslucentBorderSpecialPane.java

@ -191,7 +191,7 @@ public class TranslucentBorderSpecialPane extends AbstractBorderPackerPane imple
String lastUsedBorderImageDirPath = history.getLastSelectedBorderImageDir(); String lastUsedBorderImageDirPath = history.getLastSelectedBorderImageDir();
File lastUsedBorderImageDir = StringUtils.isNotEmpty(lastUsedBorderImageDirPath) ? new File(lastUsedBorderImageDirPath) : null; File lastUsedBorderImageDir = StringUtils.isNotEmpty(lastUsedBorderImageDirPath) ? new File(lastUsedBorderImageDirPath) : null;
File inbuiltBorderImagesDir = new File(StableUtils.pathJoin(ProjectLibrary.getInstance().getLibHome(), ProjectConstants.ASSETS_NAME, "border_images")); File inbuiltBorderImagesDir = new File(StableUtils.pathJoin(ProjectLibrary.getInstance().getLibHome(), ProjectConstants.LOCAL, ProjectConstants.BORDER_IMAGES));
if (lastUsedBorderImageDir!= null && lastUsedBorderImageDir.exists()) { if (lastUsedBorderImageDir!= null && lastUsedBorderImageDir.exists()) {
imageFileChooser.setCurrentDirectory(lastUsedBorderImageDir); imageFileChooser.setCurrentDirectory(lastUsedBorderImageDir);

7
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -354,12 +354,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
public void updateCellElementState(boolean isSelectedOneCell) { public void updateCellElementState(boolean isSelectedOneCell) {
PropertyItem cellElement = propertyItemMap.get(KEY_CELL_ELEMENT); PropertyItem cellElement = propertyItemMap.get(KEY_CELL_ELEMENT);
if (isSelectedOneCell) { enableCellElementPane(cellElement);
enableCellElementPane(cellElement);
} else { // 如果选中多个单元格,禁用单元格元素 tab
disableCellElementPane(cellElement);
refreshRightPane();
}
} }
// 禁用单元格元素tab // 禁用单元格元素tab

3
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -111,6 +111,7 @@ import java.awt.BorderLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FontMetrics; import java.awt.FontMetrics;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
import java.nio.file.Paths;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
@ -1620,7 +1621,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
return StringUtils.EMPTY; return StringUtils.EMPTY;
} }
String path = this.getEditingFILE().getPath(); String path = this.getEditingFILE().getPath();
CptxMetadata metadata = CptxFileUtils.getMetadata(path); CptxMetadata metadata = Paths.get(path).isAbsolute() ? null : CptxFileUtils.getMetadata(path);
//是否是兼容模式,兼容模式下,设置了新引擎的cpt和cptx的后缀不同 //是否是兼容模式,兼容模式下,设置了新引擎的cpt和cptx的后缀不同
if (metadata != null && metadata.isForceCpt()) { if (metadata != null && metadata.isForceCpt()) {
if (path.endsWith(".cptx")) { if (path.endsWith(".cptx")) {

10
designer-base/src/main/java/com/fr/design/style/color/ColorPicker.java

@ -67,16 +67,10 @@ public class ColorPicker extends JDialog implements ActionListener {
hideCursor(); hideCursor();
// 如果要求实时变化,确保先关闭弹窗,再截屏 // 如果要求实时变化,确保先关闭弹窗,再截屏
// 主要针对"图案"选项卡中的"前景"、"背景"
if (this.setColorRealTime) { if (this.setColorRealTime) {
colorSelectable.setColor(Color.WHITE); // setColor 可以关闭弹窗 colorSelectable.setColor(Color.WHITE); // setColor 可以关闭弹窗
try { // REPORT-82110 确保关闭所有弹窗后截屏
Thread.sleep(100); // 等待弹窗关闭 SwingUtilities.invokeLater(colorPickerPanel :: captureScreen);
} catch (InterruptedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
Thread.currentThread().interrupt();
}
colorPickerPanel.captureScreen();
} }
} }

11
designer-base/src/main/java/com/fr/design/style/color/UIToolbarColorButton.java

@ -153,12 +153,23 @@ public class UIToolbarColorButton extends UICombinationButton implements PopupHi
popupWin = null; popupWin = null;
} }
/**
* 取色器取色时隐藏弹出框与另一个hide的区别是无需经过macOS的判断以规避REPORT-25645的mac适配bug
*/
public void hidePopupMenu4PickColor() {
if (popupWin != null) {
popupWin.setVisible(false);
}
popupWin = null;
}
private ColorControlWindow getColorControlWindow() { private ColorControlWindow getColorControlWindow() {
//find parant. //find parant.
if (this.popupWin == null) { if (this.popupWin == null) {
this.popupWin = new ColorControlWindow(this.isCanBeNull(), UIToolbarColorButton.this) { this.popupWin = new ColorControlWindow(this.isCanBeNull(), UIToolbarColorButton.this) {
@Override @Override
protected void colorChanged() { protected void colorChanged() {
hidePopupMenu4PickColor();
UIToolbarColorButton.this.setColor(this.getColor()); UIToolbarColorButton.this.setColor(this.getColor());
} }

7
designer-base/src/main/resources/com/fr/design/images/control/refresh_normal.svg

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon_刷新_normal</title>
<g id="icon_刷新_normal" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M13.0593807,1 C13.4802225,1 13.8213822,1.34115968 13.8213822,1.76200147 L13.8213822,1.76200147 L13.8213822,5.2534957 C13.8213822,5.67433749 13.4802225,6.01549717 13.0593807,6.01549717 L13.0593807,6.01549717 L9.56788646,6.01549717 C9.14704467,6.01549717 8.80588499,5.67433749 8.80588499,5.2534957 C8.80588499,4.83265391 9.14704467,4.49149423 9.56788646,4.49149423 L9.56788646,4.49149423 L11.169634,4.48959417 C10.8434607,4.27112237 10.4895308,4.09123525 10.1125367,3.95402064 C7.56533579,3.02691531 4.74885407,4.34026231 3.82174874,6.88746326 C2.89464341,9.43466421 4.20799041,12.2511459 6.75519136,13.1782513 C9.30239231,14.1053566 12.118874,12.7920096 13.0459794,10.2448086 C13.1899157,9.84934672 13.6271844,9.64544497 14.0226464,9.78938133 C14.4181083,9.9333177 14.62201,10.3705864 14.4780737,10.7660483 C13.2630956,14.1041731 9.57207646,15.8253236 6.23395166,14.6103456 C2.89582685,13.3953675 1.17467636,9.70434836 2.38965442,6.36622356 C3.60463249,3.02809876 7.29565164,1.30694826 10.6337764,2.52192632 C11.3047108,2.76612647 11.9217951,3.11486447 12.467588,3.55405023 L12.297,3.423 L12.2973792,1.76200147 C12.2973792,1.37622983 12.5840481,1.05741329 12.9559816,1.00695618 Z" id="Combined-Shape" fill="#333334" fill-rule="nonzero"></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.6 KiB

3
designer-base/src/main/resources/com/fr/design/standard/add/add_black_normal.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 2C7.6134 2 7.3 2.3134 7.3 2.7V7.3H2.7C2.3134 7.3 2 7.6134 2 8C2 8.3866 2.3134 8.7 2.7 8.7H7.3V13.3C7.3 13.6866 7.6134 14 8 14C8.3866 14 8.7 13.6866 8.7 13.3V8.7H13.3C13.6866 8.7 14 8.3866 14 8C14 7.6134 13.6866 7.3 13.3 7.3H8.7V2.7C8.7 2.3134 8.3866 2 8 2Z" fill="#333334"/>
</svg>

After

Width:  |  Height:  |  Size: 430 B

6
designer-base/src/main/resources/com/fr/design/standard/debug/debug_disabled.svg

@ -0,0 +1,6 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g opacity="0.3">
<path fill-rule="evenodd" clip-rule="evenodd" d="M1 15V1H15V7.75777C14.6915 7.55127 14.356 7.3819 14 7.25606V2H2V14H8.75777C9.01056 14.3776 9.31899 14.7149 9.67133 15H1ZM8.5 9.4364C8.18047 10.0545 8 10.7562 8 11.5C8 11.8437 8.03853 12.1784 8.11151 12.5H7.5V8.8H7V8V7.8V7H7.5V3.5H8.5V7H9V7.8V8V8.67133C8.9658 8.7136 8.93235 8.75649 8.89967 8.8H8.5V9.4364ZM12 7.02746C11.6533 7.06579 11.3184 7.14352 11 7.25606V3.5H12V7.02746ZM5 3.5H4V5H3.5V5.8V6V6.8H4V12.5H5V6.8H5.5V6V5.8V5H5V3.5Z" fill="#333334"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.5 8C12.0858 8 11.75 8.33579 11.75 8.75V9.11511C11.6089 9.15943 11.4731 9.21594 11.344 9.2834L11.0858 9.02516C10.7929 8.73227 10.318 8.73227 10.0251 9.02516C9.73222 9.31806 9.73222 9.79293 10.0251 10.0858L10.2832 10.3439C10.2156 10.473 10.159 10.6088 10.1147 10.75H9.75C9.33579 10.75 9 11.0858 9 11.5C9 11.9142 9.33579 12.25 9.75 12.25H10.1142C10.1588 12.3921 10.2158 12.5287 10.2838 12.6586L10.0266 12.916C9.73378 13.209 9.73378 13.684 10.0266 13.977C10.3194 14.27 10.7941 14.27 11.0869 13.977L11.3452 13.7185C11.4739 13.7857 11.6093 13.842 11.75 13.8862V14.25C11.75 14.6642 12.0858 15 12.5 15C12.9142 15 13.25 14.6642 13.25 14.25V13.8862C13.3914 13.8418 13.5274 13.7851 13.6568 13.7175L13.9142 13.9749C14.2071 14.2678 14.682 14.2678 14.9749 13.9749C15.2678 13.682 15.2678 13.2071 14.9749 12.9142L14.7173 12.6567C14.7848 12.5273 14.8414 12.3914 14.8858 12.25H15.25C15.6642 12.25 16 11.9142 16 11.5C16 11.0858 15.6642 10.75 15.25 10.75H14.8853C14.841 10.609 14.7845 10.4734 14.7171 10.3444L14.9747 10.0866C15.2675 9.79364 15.2675 9.31861 14.9747 9.02562C14.6819 8.73263 14.2072 8.73263 13.9144 9.02562L13.6565 9.28367C13.5272 9.21609 13.3913 9.15949 13.25 9.11511V8.75C13.25 8.33579 12.9142 8 12.5 8ZM12.5 12.5C13.0523 12.5 13.5 12.0523 13.5 11.5C13.5 10.9477 13.0523 10.5 12.5 10.5C11.9477 10.5 11.5 10.9477 11.5 11.5C11.5 12.0523 11.9477 12.5 12.5 12.5Z" fill="#333334"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

4
designer-base/src/main/resources/com/fr/design/standard/debug/debug_normal.svg

@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M1 15V1H15V7.75777C14.6915 7.55127 14.356 7.3819 14 7.25606V2H2V14H8.75777C9.01056 14.3776 9.31899 14.7149 9.67133 15H1ZM8.5 9.4364C8.18047 10.0545 8 10.7562 8 11.5C8 11.8437 8.03853 12.1784 8.11151 12.5H7.5V8.8H7V8V7.8V7H7.5V3.5H8.5V7H9V7.8V8V8.67133C8.9658 8.7136 8.93235 8.75649 8.89967 8.8H8.5V9.4364ZM12 7.02746C11.6533 7.06579 11.3184 7.14352 11 7.25606V3.5H12V7.02746ZM5 3.5H4V5H3.5V5.8V6V6.8H4V12.5H5V6.8H5.5V6V5.8V5H5V3.5Z" fill="#333334"/>
<path fill-rule="evenodd" clip-rule="evenodd" d="M12.5 8C12.0858 8 11.75 8.33579 11.75 8.75V9.11511C11.6089 9.15943 11.4731 9.21594 11.344 9.2834L11.0858 9.02516C10.7929 8.73227 10.318 8.73227 10.0251 9.02516C9.73222 9.31806 9.73222 9.79293 10.0251 10.0858L10.2832 10.3439C10.2156 10.473 10.159 10.6088 10.1147 10.75H9.75C9.33579 10.75 9 11.0858 9 11.5C9 11.9142 9.33579 12.25 9.75 12.25H10.1142C10.1588 12.3921 10.2158 12.5287 10.2838 12.6586L10.0266 12.916C9.73378 13.209 9.73378 13.684 10.0266 13.977C10.3194 14.27 10.7941 14.27 11.0869 13.977L11.3452 13.7185C11.4739 13.7857 11.6093 13.842 11.75 13.8862V14.25C11.75 14.6642 12.0858 15 12.5 15C12.9142 15 13.25 14.6642 13.25 14.25V13.8862C13.3914 13.8418 13.5274 13.7851 13.6568 13.7175L13.9142 13.9749C14.2071 14.2678 14.682 14.2678 14.9749 13.9749C15.2678 13.682 15.2678 13.2071 14.9749 12.9142L14.7173 12.6567C14.7848 12.5273 14.8414 12.3914 14.8858 12.25H15.25C15.6642 12.25 16 11.9142 16 11.5C16 11.0858 15.6642 10.75 15.25 10.75H14.8853C14.841 10.609 14.7845 10.4734 14.7171 10.3444L14.9747 10.0866C15.2675 9.79364 15.2675 9.31861 14.9747 9.02562C14.6819 8.73263 14.2072 8.73263 13.9144 9.02562L13.6565 9.28367C13.5272 9.21609 13.3913 9.15949 13.25 9.11511V8.75C13.25 8.33579 12.9142 8 12.5 8ZM12.5 12.5C13.0523 12.5 13.5 12.0523 13.5 11.5C13.5 10.9477 13.0523 10.5 12.5 10.5C11.9477 10.5 11.5 10.9477 11.5 11.5C11.5 12.0523 11.9477 12.5 12.5 12.5Z" fill="#333334"/>
</svg>

After

Width:  |  Height:  |  Size: 2.0 KiB

5
designer-base/src/main/resources/com/fr/design/standard/edit/edit_disabled.svg

@ -0,0 +1,5 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<g opacity="0.3">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3 1C2.44772 1 2 1.44772 2 2V14C2 14.5523 2.44772 15 3 15H13C13.5523 15 14 14.5523 14 14V6H13V14H3V2H9V1H3ZM13.6741 3.2816L7.37761 11.3408L5.4982 12.1221L5.80159 10.1095L12.0981 2.05028C12.4381 1.61507 13.0666 1.53791 13.5018 1.87793C13.937 2.21795 14.0142 2.8464 13.6741 3.2816Z" fill="#333334"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 473 B

3
designer-base/src/main/resources/com/fr/design/standard/edit/edit_normal.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3 1C2.44772 1 2 1.44772 2 2V14C2 14.5523 2.44772 15 3 15H13C13.5523 15 14 14.5523 14 14V6H13V14H3V2H9V1H3ZM13.6741 3.2816L7.37761 11.3408L5.4982 12.1221L5.80159 10.1095L12.0981 2.05028C12.4381 1.61507 13.0666 1.53791 13.5018 1.87793C13.937 2.21795 14.0142 2.8464 13.6741 3.2816Z" fill="#333334"/>
</svg>

After

Width:  |  Height:  |  Size: 450 B

7
designer-base/src/main/resources/com/fr/design/standard/remove/remove_red_normal.svg

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon_关闭_red</title>
<g id="icon_关闭_red" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M7.89949494,0.899494937 C8.28609426,0.899494937 8.59949494,1.21820884 8.59949494,1.59375711 L8.59849494,7.19949494 L14.2052328,7.19949494 C14.5567106,7.19949494 14.8471855,7.46057376 14.8931571,7.80394288 L14.8994949,7.89949494 C14.8994949,8.28609426 14.580781,8.59949494 14.2052328,8.59949494 L8.59849494,8.59849494 L8.59949494,14.2052328 C8.59949494,14.5567106 8.33841611,14.8471855 7.99504699,14.8931571 L7.89949494,14.8994949 C7.51289561,14.8994949 7.19949494,14.580781 7.19949494,14.2052328 L7.19949494,8.59849494 L1.59375711,8.59949494 C1.24227924,8.59949494 0.951804388,8.33841611 0.905832732,7.99504699 L0.899494937,7.89949494 C0.899494937,7.51289561 1.21820884,7.19949494 1.59375711,7.19949494 L7.19949494,7.19949494 L7.19949494,1.59375711 C7.19949494,1.24227924 7.46057376,0.951804388 7.80394288,0.905832732 L7.89949494,0.899494937 Z" id="Combined-Shape" fill="#EB1D1F" transform="translate(7.899495, 7.899495) rotate(45.000000) translate(-7.899495, -7.899495) "></path>
</g>
</svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

3
designer-base/src/main/resources/com/fr/design/standard/tip/tips_normal.svg

@ -0,0 +1,3 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 15C4.13401 15 1 11.866 1 8C1 4.13401 4.13401 1 8 1C11.866 1 15 4.13401 15 8C15 11.866 11.866 15 8 15ZM8 14C11.3137 14 14 11.3137 14 8C14 4.68629 11.3137 2 8 2C4.68629 2 2 4.68629 2 8C2 11.3137 4.68629 14 8 14ZM6.193 4.696C6.655 4.223 7.293 3.992 8.107 3.992C8.811 3.992 9.383 4.179 9.823 4.575C10.263 4.96 10.483 5.488 10.483 6.148C10.483 6.687 10.34 7.138 10.065 7.49C9.966 7.611 9.658 7.897 9.141 8.348C8.932 8.524 8.778 8.722 8.679 8.92C8.558 9.14 8.503 9.382 8.503 9.646V9.733C8.503 9.78823 8.45823 9.833 8.403 9.833H7.426C7.37077 9.833 7.326 9.78823 7.326 9.733V9.646C7.326 9.239 7.392 8.887 7.546 8.601C7.689 8.293 8.107 7.842 8.789 7.237L8.976 7.028C9.174 6.775 9.284 6.511 9.284 6.225C9.284 5.84 9.174 5.543 8.965 5.323C8.745 5.103 8.426 4.993 8.03 4.993C7.535 4.993 7.172 5.147 6.952 5.466C6.76786 5.71152 6.66935 6.05217 6.65646 6.48796C6.65482 6.54316 6.61023 6.588 6.555 6.588H5.6C5.54477 6.588 5.49986 6.54311 5.50122 6.4879C5.51978 5.7327 5.75038 5.13862 6.193 4.696ZM7.337 10.647C7.491 10.493 7.689 10.427 7.909 10.427C8.14 10.427 8.338 10.493 8.492 10.647C8.646 10.79 8.723 10.977 8.723 11.208C8.723 11.439 8.635 11.626 8.481 11.78C8.327 11.923 8.129 12 7.909 12C7.689 12 7.491 11.923 7.337 11.769C7.183 11.615 7.106 11.428 7.106 11.208C7.106 10.977 7.183 10.79 7.337 10.647Z" fill="#333334"/>
</svg>

After

Width:  |  Height:  |  Size: 1.4 KiB

5
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/TableDataPane.java

@ -15,6 +15,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.ChartDataPane; import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane; import com.fr.design.mainframe.chart.gui.data.table.AbstractTableDataContentPane;
import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import java.awt.BorderLayout; import java.awt.BorderLayout;
@ -74,6 +75,10 @@ public class TableDataPane extends FurtherBasicBeanPane<ChartCollection>{
return; return;
} }
if(dataContentPane != null) { if(dataContentPane != null) {
// 如果属性编辑画板中选中的数据集发生改变,则清空之前的匹配项
if (!StringUtils.equals(dataContentPane.getTableName(), dataWrap.getTableDataName())) {
dataContentPane.clearAllBoxList();
}
dataContentPane.onSelectTableData(dataWrap); dataContentPane.onSelectTableData(dataWrap);
dataContentPane.setTableName(dataWrap.getTableDataName()); dataContentPane.setTableName(dataWrap.getTableDataName());
} }

8
designer-form/src/main/java/com/fr/design/fit/menupane/FitRadioGroup.java

@ -77,4 +77,12 @@ public class FitRadioGroup extends ButtonGroup {
} }
} }
/**
*
* @return 被选中的按钮
*/
public UIRadioButton getSelectedButton() {
return radioButtons.get(this.getSelectRadioIndex());
}
} }

57
designer-realize/src/main/java/com/fr/design/actions/cell/AbstractCellElementAction.java

@ -9,11 +9,14 @@ import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.grid.GridUtils; import com.fr.grid.GridUtils;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.core.SheetUtils; import com.fr.report.core.SheetUtils;
import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.elementcase.TemplateElementCase;
import com.fr.report.stable.ReportConstants; import com.fr.report.stable.ReportConstants;
import java.awt.Rectangle;
/** /**
* TODO ALEX_SEP 这个类与AbstractCellAction有什么关系? * TODO ALEX_SEP 这个类与AbstractCellAction有什么关系?
* *
@ -45,34 +48,44 @@ public abstract class AbstractCellElementAction extends CellSelectionAction {
dialog.addDialogActionListener(new DialogActionAdapter() { dialog.addDialogActionListener(new DialogActionAdapter() {
@Override @Override
public void doOk() { public void doOk() {
// 需要先行后列地增加新元素。 for (int rect = 0; rect < finalCS.getCellRectangleCount(); rect++) {
for (int j = 0; j < finalCS.getRowSpan(); j++) { Rectangle cellRectangle = finalCS.getCellRectangle(rect);
for (int i = 0; i < finalCS.getColumnSpan(); i++) { // 需要先行后列地增加新元素。
int column = i + finalCS.getColumn(); for (int j = 0; j < cellRectangle.height; j++) {
int row = j + finalCS.getRow(); for (int i = 0; i < cellRectangle.width; i++) {
TemplateCellElement editCellElement = tplEC.getTemplateCellElement(column, row); int column = i + cellRectangle.x;
if (editCellElement == null) { int row = j + cellRectangle.y;
editCellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row); TemplateCellElement editCellElement = tplEC.getTemplateCellElement(column, row);
tplEC.addCellElement(editCellElement); if (editCellElement == null) {
} editCellElement = DefaultThemedTemplateCellElementCase.createInstance(column, row);
// alex:不加这一句话会导致跨行跨列的格子被多次update tplEC.addCellElement(editCellElement);
if (editCellElement.getColumn() != column || editCellElement.getRow() != row) { }
continue; // alex:不加这一句话会导致跨行跨列的格子被多次update
} if (editCellElement.getColumn() != column || editCellElement.getRow() != row) {
updateBasicPane(bp, editCellElement); continue;
// update cell attributes }
if (isNeedShinkToFit()) { updateBasicPane(bp, editCellElement);
// shink to fit.(如果value是String) // update cell attributes
Object editElementValue = editCellElement.getValue(); if (isNeedShinkToFit()) {
if (editElementValue != null && (editElementValue instanceof String || editElementValue instanceof Number)) { // shink to fit.(如果value是String)
// TODO ALEX_SEP 暂时用FIT_DEFAULT替代,不取reportsetting里面的设置,因为也不知道是应该放在report里面还是elementcase里面 Object editElementValue = editCellElement.getValue();
GridUtils.shrinkToFit(ReportConstants.AUTO_SHRINK_TO_FIT_DEFAULT, tplEC, editCellElement); if (checkValueType(editElementValue)) {
// TODO ALEX_SEP 暂时用FIT_DEFAULT替代,不取reportsetting里面的设置,因为也不知道是应该放在report里面还是elementcase里面
GridUtils.shrinkToFit(ReportConstants.AUTO_SHRINK_TO_FIT_DEFAULT, tplEC, editCellElement);
}
} }
} }
} }
} }
if (!ePane.isSelectedOneCell()) {
CellQuickEditor.record(CellQuickEditor.multipleOperationType.FILTER);
}
ePane.fireTargetModified(); ePane.fireTargetModified();
} }
private boolean checkValueType(Object editElementValue) {
return editElementValue instanceof String || editElementValue instanceof Number;
}
}); });
//控件设置记住dlg,提交入库智能添加单元格后可以show出来 //控件设置记住dlg,提交入库智能添加单元格后可以show出来
DesignerContext.setReportWritePane(dialog); DesignerContext.setReportWritePane(dialog);

5
designer-realize/src/main/java/com/fr/design/actions/columnrow/ColumnWidthAction.java

@ -4,8 +4,8 @@
package com.fr.design.actions.columnrow; package com.fr.design.actions.columnrow;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.elementcase.ElementCase; import com.fr.report.elementcase.ElementCase;
import com.fr.stable.unit.UNIT; import com.fr.stable.unit.UNIT;
@ -32,6 +32,9 @@ public class ColumnWidthAction extends ColumnRowSizingAction {
for (int i = 0; i < columns.length; i++) { for (int i = 0; i < columns.length; i++) {
report.setColumnWidth(columns[i], len); report.setColumnWidth(columns[i], len);
} }
if (columns.length > 1) {
CellQuickEditor.record(CellQuickEditor.multipleOperationType.HEIHT_AND_COLUMN);
}
} }
protected UNIT getIndexLen(int index, ElementCase report){ protected UNIT getIndexLen(int index, ElementCase report){

4
designer-realize/src/main/java/com/fr/design/actions/columnrow/RowHeightAction.java

@ -6,6 +6,7 @@ package com.fr.design.actions.columnrow;
import com.fr.design.mainframe.ElementCasePane; import com.fr.design.mainframe.ElementCasePane;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.elementcase.ElementCase; import com.fr.report.elementcase.ElementCase;
import com.fr.stable.unit.UNIT; import com.fr.stable.unit.UNIT;
@ -32,6 +33,9 @@ public class RowHeightAction extends ColumnRowSizingAction {
for (int i = 0; i < rows.length; i++) { for (int i = 0; i < rows.length; i++) {
report.setRowHeight(rows[i], len); report.setRowHeight(rows[i], len);
} }
if (rows.length > 1) {
CellQuickEditor.record(CellQuickEditor.multipleOperationType.HEIHT_AND_COLUMN);
}
} }
@Override @Override

135
designer-realize/src/main/java/com/fr/design/actions/replace/action/ITChecker.java

@ -0,0 +1,135 @@
package com.fr.design.actions.replace.action;
import com.fr.design.actions.replace.info.Info;
import com.fr.design.i18n.Toolkit;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 校验JS公式控件组件
* 比较用户的所有对应类别的改动不论是否选中要替换只要整体类别改动过就算模板内容改动过
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-11-03
*/
public enum ITChecker {
/**
* 控件
*/
WIDGET_CHECK_TAG(Toolkit.i18nText("Fine-Design_Basic_Widget")),
/**
* 公式
*/
FORMULA_CHECK_TAG(Toolkit.i18nText("Fine-Design_Basic_Formula")),
/**
* JS
*/
JS_CHECK_TAG(Toolkit.i18nText("Fine-Design_Replace_JS")),
/**
* 组件
*/
COMPONENT_CHECK_TAG(Toolkit.i18nText("Fine-Design_Replace_Component"))
;
String name;
ITChecker(String name) {
this.name = name;
}
/**
* 匹配
*
* @param name 对应的检查类型
* @return 对应的检查checker
*/
@Nullable
public static ITChecker match(String name) {
ITChecker[] values = ITChecker.values();
for (ITChecker value : values) {
if (value.name.equals(name)) {
return value;
}
}
return null;
}
public static List<? extends Info> checkList = new ArrayList<>();
public static Map<String, Integer> appearTimesMap = new HashMap<>();
/**
* 更新对应的check列表
*
* @param list 查找后的searchList
*/
public static void updateCheckInfo(List<? extends Info> list) {
checkList = list;
updateCheckMapFromList(list);
}
/**
* 根据列表来更新对应元素的匹配Map
*
* @param list 更新后的checkList
*/
private static void updateCheckMapFromList(List<? extends Info> list) {
appearTimesMap.clear();
for (Info info : list) {
String showStr = info.getContent().getOldShowStr();
if (appearTimesMap.containsKey(showStr)) {
//如果已经存过了就个数+1
appearTimesMap.put(showStr, appearTimesMap.get(showStr) + 1);
} else {
//没有的话就把个数初始化为1个
appearTimesMap.put(showStr, 1);
}
}
}
/**
* 判断是否修改过
*
* @param list 重新获取的当前模板最新的list
* @return 修改过返回true
*/
public boolean isChanged(List<? extends Info> list) {
if (list.size() != checkList.size()) {
//如果总的数据的数量变了,就说明肯定修改过,没必要再进行下一步
return true;
}
return isChangedCheckByMap(list);
}
/**
* 通过检查Map来比较是否修改过
*
* @param list 传入的用于比较的list
* @return 修改过则返回true
*/
private boolean isChangedCheckByMap(List<? extends Info> list) {
for (Info info : list) {
String showStr = info.getContent().getOldShowStr();
if (appearTimesMap.containsKey(showStr)) {
//如果map中存在对应的值,就抵消,个数-1
appearTimesMap.put(showStr, appearTimesMap.get(showStr) - 1);
if (appearTimesMap.get(showStr) < 0) {
//如果map中的值小于0了,就说明数量对不上,修改过
return true;
}
} else {
//如果存在map中没存的值就没必要继续下去了,肯定改过
return true;
}
}
return false;
}
}

35
designer-realize/src/main/java/com/fr/design/actions/replace/action/ShowValue.java

@ -3,6 +3,7 @@ package com.fr.design.actions.replace.action;
import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.info.Info;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@ -17,18 +18,36 @@ public interface ShowValue {
/** /**
* 获取搜索结果 * 获取搜索结果
* *
* @param jTemplate * @param jTemplate 要搜索的模板
* @return * @return 所有对应类型的集合
*/ */
List<? extends Info> showSearchValue(JTemplate jTemplate); default List<? extends Info> showSearchValue(JTemplate jTemplate) {
return new ArrayList<>();
}
/** /**
* 对搜索结果进行过滤 * 对搜索结果进行过滤主要针对模板内容只需要用户输入要搜索的文本内容即可
* *
* @param str * @param str 用户输入的内容
* @param list * @param list 包含所有内容的列表
* @return * @return 过滤后的内容
*/ */
List<? extends Info> addMatchResult(String str, List<? extends Info> list); default List<? extends Info> addMatchResult(String str, List<? extends Info> list) {
return new ArrayList<>();
}
/**
* 对搜索结果进行过滤多个过滤条件主要针对设置项
* 通过用户输入的级别去界定指定的搜索类型
*
* @param list 包含所有内容的列表
* @param settingStr 用户输入的第一级下拉框内容
* @param extraStr 用户输入的第二级下拉框内容
* @return 界定后符合条件的内容组合成的列表
*/
default List<? extends Info> addMatchResult(List<? extends Info> list, String settingStr, String extraStr) {
return new ArrayList<>();
}
} }

12
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/component/ComponentType.java

@ -126,7 +126,9 @@ public enum ComponentType implements DealWithInfoValue {
info.updateOldStr(titleLayout.getWidgetName(), findStr); info.updateOldStr(titleLayout.getWidgetName(), findStr);
titleLayout.setWidgetName(ShowValueUtils.replaceAll(titleLayout.getWidgetName(), findStr, replaceStr)); titleLayout.setWidgetName(ShowValueUtils.replaceAll(titleLayout.getWidgetName(), findStr, replaceStr));
CRBoundsWidget crBoundsWidget = ((CRBoundsWidget) titleLayout.getWidget(0)); CRBoundsWidget crBoundsWidget = ((CRBoundsWidget) titleLayout.getWidget(0));
crBoundsWidget.getWidget().setWidgetName(ShowValueUtils.replaceAll(crBoundsWidget.getWidget().getWidgetName(), findStr, replaceStr)); String str = crBoundsWidget.getWidget().getWidgetName();
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
crBoundsWidget.getWidget().setWidgetName(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
}, },
@ -144,7 +146,9 @@ public enum ComponentType implements DealWithInfoValue {
info.updateOldStr(scaleLayout.getWidgetName(), findStr); info.updateOldStr(scaleLayout.getWidgetName(), findStr);
scaleLayout.setWidgetName(ShowValueUtils.replaceAll(scaleLayout.getWidgetName(), findStr, replaceStr)); scaleLayout.setWidgetName(ShowValueUtils.replaceAll(scaleLayout.getWidgetName(), findStr, replaceStr));
CRBoundsWidget crBoundsWidget = ((CRBoundsWidget) scaleLayout.getWidget(0)); CRBoundsWidget crBoundsWidget = ((CRBoundsWidget) scaleLayout.getWidget(0));
crBoundsWidget.getWidget().setWidgetName(ShowValueUtils.replaceAll(crBoundsWidget.getWidget().getWidgetName(), findStr, replaceStr)); String str = crBoundsWidget.getWidget().getWidgetName();
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
crBoundsWidget.getWidget().setWidgetName(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
}, },
@ -333,8 +337,10 @@ public enum ComponentType implements DealWithInfoValue {
Object replaceObject = info.getContent().getReplaceObject(); Object replaceObject = info.getContent().getReplaceObject();
if (replaceObject instanceof Widget) { if (replaceObject instanceof Widget) {
Widget widget = ((Widget) replaceObject); Widget widget = ((Widget) replaceObject);
String str = widget.getWidgetName();
info.updateOldStr(widget.getWidgetName(), findStr); info.updateOldStr(widget.getWidgetName(), findStr);
widget.setWidgetName(widget.getWidgetName().replaceAll(findStr, replaceStr)); ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
widget.setWidgetName(ShowValueUtils.replaceAll(widget.getWidgetName(), findStr, replaceStr));
} }
} }

118
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaReplaceObject.java

@ -58,12 +58,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
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) {
Object replaceObject = info.getContent().getReplaceObject(); Object replaceObject = info.getContent().getReplaceObject();
info.updateOldStr(((Formula) replaceObject).getContent(), findStr); info.updateOldStr(((Formula) replaceObject).getContent(), findStr);
((Formula) replaceObject).setContent(ShowValueUtils.replaceAll(((Formula) replaceObject).getContent(), findStr, replaceStr)); String str = ((Formula) replaceObject).getContent();
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((Formula) replaceObject).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof Formula){ if (info.getContent().getReplaceObject() instanceof Formula) {
Formula formula = (Formula) info.getContent().getReplaceObject(); Formula formula = (Formula) info.getContent().getReplaceObject();
return StringUtils.equals(formula.getContent(), info.getContent().getOldShowStr()); return StringUtils.equals(formula.getContent(), info.getContent().getOldShowStr());
} }
@ -88,13 +90,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
Object replaceObject = info.getContent().getReplaceObject(); Object replaceObject = info.getContent().getReplaceObject();
//更新上一次操作的信息 //更新上一次操作的信息
info.updateOldStr(((FormulaCondition) replaceObject).getFormula(), findStr); info.updateOldStr(((FormulaCondition) replaceObject).getFormula(), findStr);
String str = ((FormulaCondition) replaceObject).getFormula();
((FormulaCondition) replaceObject).setFormula(ShowValueUtils.replaceAll(((FormulaCondition) replaceObject).getFormula(), findStr, replaceStr)); ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((FormulaCondition) replaceObject).setFormula(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof FormulaCondition){ if (info.getContent().getReplaceObject() instanceof FormulaCondition) {
FormulaCondition condition = (FormulaCondition) info.getContent().getReplaceObject(); FormulaCondition condition = (FormulaCondition) info.getContent().getReplaceObject();
return StringUtils.equals(condition.getFormula(), info.getContent().getOldShowStr()); return StringUtils.equals(condition.getFormula(), info.getContent().getOldShowStr());
} }
@ -120,14 +123,15 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
if (((Compare) replaceObject).getValue() instanceof Formula) { if (((Compare) replaceObject).getValue() instanceof Formula) {
Formula formula = (Formula) ((Compare) replaceObject).getValue(); Formula formula = (Formula) ((Compare) replaceObject).getValue();
info.updateOldStr(formula.getContent(), findStr); info.updateOldStr(formula.getContent(), findStr);
String str = formula.getContent();
formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr)); ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
formula.setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof Compare){ if (info.getContent().getReplaceObject() instanceof Compare) {
Compare compare = (Compare) info.getContent().getReplaceObject(); Compare compare = (Compare) info.getContent().getReplaceObject();
return StringUtils.equals(GeneralUtils.objectToString(compare.getValue()), info.getContent().getOldShowStr()); return StringUtils.equals(GeneralUtils.objectToString(compare.getValue()), info.getContent().getOldShowStr());
} }
@ -151,13 +155,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
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) {
Object replaceObject = info.getContent().getReplaceObject(); Object replaceObject = info.getContent().getReplaceObject();
info.updateOldStr(((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).getContent(), findStr); info.updateOldStr(((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).getContent(), findStr);
String str = ((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).getContent();
((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).setContent(ShowValueUtils.replaceAll(((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).getContent(), findStr, replaceStr)); ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((Formula) ((com.fr.base.core.KV) replaceObject).getValue()).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof com.fr.base.core.KV){ if (info.getContent().getReplaceObject() instanceof com.fr.base.core.KV) {
com.fr.base.core.KV kv = (com.fr.base.core.KV) info.getContent().getReplaceObject(); com.fr.base.core.KV kv = (com.fr.base.core.KV) info.getContent().getReplaceObject();
return StringUtils.equals(GeneralUtils.objectToString(kv.getValue()), info.getContent().getOldShowStr()); return StringUtils.equals(GeneralUtils.objectToString(kv.getValue()), info.getContent().getOldShowStr());
} }
@ -181,12 +186,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
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) {
Object replaceObject = info.getContent().getReplaceObject(); Object replaceObject = info.getContent().getReplaceObject();
info.updateOldStr(((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).getContent(), findStr); info.updateOldStr(((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).getContent(), findStr);
((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).getContent(), findStr, replaceStr)); String str = ((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).getContent();
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((Formula) (((CellInsertPolicyAttr) replaceObject).getDefaultInsertValue())).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof CellInsertPolicyAttr){ if (info.getContent().getReplaceObject() instanceof CellInsertPolicyAttr) {
CellInsertPolicyAttr policyAttr = (CellInsertPolicyAttr) info.getContent().getReplaceObject(); CellInsertPolicyAttr policyAttr = (CellInsertPolicyAttr) info.getContent().getReplaceObject();
return StringUtils.equals(GeneralUtils.objectToString(policyAttr.getDefaultInsertValue()), info.getContent().getOldShowStr()); return StringUtils.equals(GeneralUtils.objectToString(policyAttr.getDefaultInsertValue()), info.getContent().getOldShowStr());
} }
@ -210,13 +217,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
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) {
Object replaceObject = info.getContent().getReplaceObject(); Object replaceObject = info.getContent().getReplaceObject();
info.updateOldStr(((FormulaPresent) replaceObject).getFormulaContent(), findStr); info.updateOldStr(((FormulaPresent) replaceObject).getFormulaContent(), findStr);
String str = ((FormulaPresent) replaceObject).getFormulaContent();
((FormulaPresent) replaceObject).setFormulaContent(ShowValueUtils.replaceAll(((FormulaPresent) replaceObject).getFormulaContent(), findStr, replaceStr)); ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((FormulaPresent) replaceObject).setFormulaContent(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof FormulaPresent){ if (info.getContent().getReplaceObject() instanceof FormulaPresent) {
FormulaPresent present = (FormulaPresent) info.getContent().getReplaceObject(); FormulaPresent present = (FormulaPresent) info.getContent().getReplaceObject();
return StringUtils.equals(present.getFormulaContent(), info.getContent().getOldShowStr()); return StringUtils.equals(present.getFormulaContent(), info.getContent().getOldShowStr());
} }
@ -240,12 +248,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
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) {
Object replaceObject = info.getContent().getReplaceObject(); Object replaceObject = info.getContent().getReplaceObject();
info.updateOldStr(((SingleJavaScript) replaceObject).getFileName(), findStr); info.updateOldStr(((SingleJavaScript) replaceObject).getFileName(), findStr);
((SingleJavaScript) replaceObject).setFileName(ShowValueUtils.replaceAll(((SingleJavaScript) replaceObject).getFileName(), findStr, replaceStr)); String str = ((SingleJavaScript) replaceObject).getFileName();
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((SingleJavaScript) replaceObject).setFileName(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof SingleJavaScript){ if (info.getContent().getReplaceObject() instanceof SingleJavaScript) {
SingleJavaScript javaScript = (SingleJavaScript) info.getContent().getReplaceObject(); SingleJavaScript javaScript = (SingleJavaScript) info.getContent().getReplaceObject();
return StringUtils.equals(javaScript.getFileName(), info.getContent().getOldShowStr()); return StringUtils.equals(javaScript.getFileName(), info.getContent().getOldShowStr());
} }
@ -269,15 +279,16 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
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) {
Object replaceObject = info.getContent().getReplaceObject(); Object replaceObject = info.getContent().getReplaceObject();
info.updateOldStr(((Formula) (((ParameterProvider) replaceObject).getValue())).getContent(), findStr); info.updateOldStr(((Formula) (((ParameterProvider) replaceObject).getValue())).getContent(), findStr);
String str = ((Formula) (((ParameterProvider) replaceObject).getValue())).getContent();
((Formula) (((ParameterProvider) replaceObject).getValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((ParameterProvider) replaceObject).getValue())).getContent(), findStr, replaceStr)); ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((Formula) (((ParameterProvider) replaceObject).getValue())).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof ParameterProvider){ if (info.getContent().getReplaceObject() instanceof ParameterProvider) {
ParameterProvider provider = (ParameterProvider) info.getContent().getReplaceObject(); ParameterProvider provider = (ParameterProvider) info.getContent().getReplaceObject();
if (provider.getValue() instanceof Formula){ if (provider.getValue() instanceof Formula) {
return StringUtils.equals(GeneralUtils.objectToString(provider.getValue()), info.getContent().getOldShowStr()); return StringUtils.equals(GeneralUtils.objectToString(provider.getValue()), info.getContent().getOldShowStr());
} }
} }
@ -301,13 +312,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
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) {
Object replaceObject = info.getContent().getReplaceObject(); Object replaceObject = info.getContent().getReplaceObject();
info.updateOldStr(((FormulaProvider) replaceObject).getContent(), findStr); info.updateOldStr(((FormulaProvider) replaceObject).getContent(), findStr);
String str = ((FormulaProvider) replaceObject).getContent();
((FormulaProvider) replaceObject).setContent(ShowValueUtils.replaceAll(((FormulaProvider) replaceObject).getContent(), findStr, replaceStr)); ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((FormulaProvider) replaceObject).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof FormulaProvider){ if (info.getContent().getReplaceObject() instanceof FormulaProvider) {
FormulaProvider provider = (FormulaProvider) info.getContent().getReplaceObject(); FormulaProvider provider = (FormulaProvider) info.getContent().getReplaceObject();
return StringUtils.equals(provider.getContent(), info.getContent().getOldShowStr()); return StringUtils.equals(provider.getContent(), info.getContent().getOldShowStr());
} }
@ -331,15 +343,16 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
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) {
Object replaceObject = info.getContent().getReplaceObject(); Object replaceObject = info.getContent().getReplaceObject();
info.updateOldStr(((Formula) (((Parameter) replaceObject).getValue())).getContent(), findStr); info.updateOldStr(((Formula) (((Parameter) replaceObject).getValue())).getContent(), findStr);
String str = ((Formula) (((Parameter) replaceObject).getValue())).getContent();
((Formula) (((Parameter) replaceObject).getValue())).setContent(ShowValueUtils.replaceAll(((Formula) (((Parameter) replaceObject).getValue())).getContent(), findStr, replaceStr)); ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((Formula) (((Parameter) replaceObject).getValue())).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof Parameter){ if (info.getContent().getReplaceObject() instanceof Parameter) {
Parameter parameter = (Parameter) info.getContent().getReplaceObject(); Parameter parameter = (Parameter) info.getContent().getReplaceObject();
if (parameter.getValue() instanceof Formula){ if (parameter.getValue() instanceof Formula) {
return StringUtils.equals(((Formula) parameter.getValue()).getContent(), info.getContent().getOldShowStr()); return StringUtils.equals(((Formula) parameter.getValue()).getContent(), info.getContent().getOldShowStr());
} }
} }
@ -363,13 +376,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
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) {
Object replaceObject = info.getContent().getReplaceObject(); Object replaceObject = info.getContent().getReplaceObject();
info.updateOldStr(((DSColumn) replaceObject).getResult(), findStr); info.updateOldStr(((DSColumn) replaceObject).getResult(), findStr);
String str = ((DSColumn) replaceObject).getResult();
((DSColumn) replaceObject).setResult(ShowValueUtils.replaceAll(((DSColumn) replaceObject).getResult(), findStr, replaceStr)); ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((DSColumn) replaceObject).setResult(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof DSColumn){ if (info.getContent().getReplaceObject() instanceof DSColumn) {
DSColumn column = (DSColumn) info.getContent().getReplaceObject(); DSColumn column = (DSColumn) info.getContent().getReplaceObject();
return StringUtils.equals(column.getResult(), info.getContent().getOldShowStr()); return StringUtils.equals(column.getResult(), info.getContent().getOldShowStr());
} }
@ -393,13 +407,14 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
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) {
Object replaceObject = info.getContent().getReplaceObject(); Object replaceObject = info.getContent().getReplaceObject();
info.updateOldStr(((BaseFormula) replaceObject).getContent(), findStr); info.updateOldStr(((BaseFormula) replaceObject).getContent(), findStr);
String str = ((BaseFormula) replaceObject).getContent();
((BaseFormula) replaceObject).setContent(ShowValueUtils.replaceAll(((BaseFormula) replaceObject).getContent(), findStr, replaceStr)); ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((BaseFormula) replaceObject).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof BaseFormula){ if (info.getContent().getReplaceObject() instanceof BaseFormula) {
BaseFormula formula = (BaseFormula) info.getContent().getReplaceObject(); BaseFormula formula = (BaseFormula) info.getContent().getReplaceObject();
return StringUtils.equals(formula.getContent(), info.getContent().getOldShowStr()); return StringUtils.equals(formula.getContent(), info.getContent().getOldShowStr());
} }
@ -423,16 +438,17 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
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) {
Object replaceObject = info.getContent().getReplaceObject(); Object replaceObject = info.getContent().getReplaceObject();
info.updateOldStr(((Formula) ((StoreProcedureParameter) replaceObject).getValue()).getContent(), findStr); info.updateOldStr(((Formula) ((StoreProcedureParameter) replaceObject).getValue()).getContent(), findStr);
String str = ((Formula) ((StoreProcedureParameter) replaceObject).getValue()).getContent();
((Formula) ((StoreProcedureParameter) replaceObject).getValue()).setContent(ShowValueUtils.replaceAll(((Formula) ((StoreProcedureParameter) replaceObject).getValue()).getContent(), findStr, replaceStr)); ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((Formula) ((StoreProcedureParameter) replaceObject).getValue()).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof StoreProcedureParameter){ if (info.getContent().getReplaceObject() instanceof StoreProcedureParameter) {
StoreProcedureParameter procedureParameter = (StoreProcedureParameter) info.getContent().getReplaceObject(); StoreProcedureParameter procedureParameter = (StoreProcedureParameter) info.getContent().getReplaceObject();
if (procedureParameter.getValue() instanceof Formula){ if (procedureParameter.getValue() instanceof Formula) {
return StringUtils.equals(GeneralUtils.objectToString(procedureParameter.getValue()), info.getContent().getOldShowStr()); return StringUtils.equals(GeneralUtils.objectToString(procedureParameter.getValue()), info.getContent().getOldShowStr());
} }
} }
@ -457,13 +473,15 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
WorkBook workBook = (WorkBook) HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget(); WorkBook workBook = (WorkBook) HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget();
WatermarkAttr watermarkAttr = (WatermarkAttr) info.getContent().getReplaceObject(); WatermarkAttr watermarkAttr = (WatermarkAttr) info.getContent().getReplaceObject();
info.updateOldStr(watermarkAttr.getText(), findStr); info.updateOldStr(watermarkAttr.getText(), findStr);
watermarkAttr.setText(ShowValueUtils.replaceAll(watermarkAttr.getText(), findStr, replaceStr)); String str = watermarkAttr.getText();
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
watermarkAttr.setText(ShowValueUtils.replaceAll(str, findStr, replaceStr));
workBook.addAttrMark(watermarkAttr); workBook.addAttrMark(watermarkAttr);
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof WatermarkAttr){ if (info.getContent().getReplaceObject() instanceof WatermarkAttr) {
WatermarkAttr watermarkAttr = ((WatermarkAttr) info.getContent().getReplaceObject()); WatermarkAttr watermarkAttr = ((WatermarkAttr) info.getContent().getReplaceObject());
return StringUtils.equals(watermarkAttr.getText(), info.getContent().getOldShowStr()); return StringUtils.equals(watermarkAttr.getText(), info.getContent().getOldShowStr());
} }
@ -473,11 +491,11 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
/** /**
* 存储字符串类型需要特殊处理 * 存储字符串类型需要特殊处理
*/ */
STRING("String"){ STRING("String") {
@Override @Override
public Map<String, String> getValue(Object... o) { public Map<String, String> getValue(Object... o) {
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
if (StringUtils.isNotEmpty(GeneralUtils.objectToString(o[0]))){ if (StringUtils.isNotEmpty(GeneralUtils.objectToString(o[0]))) {
map.put("content", GeneralUtils.objectToString(o[0])); map.put("content", GeneralUtils.objectToString(o[0]));
} }
return map; return map;
@ -486,7 +504,7 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
@Override @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) {
FormulaTag formulaTag = FormulaTag.match(info.getContent().getTag()); FormulaTag formulaTag = FormulaTag.match(info.getContent().getTag());
if (formulaTag != null){ if (formulaTag != null) {
info.updateOldStr(GeneralUtils.objectToString(info.getContent().getReplaceObject()), findStr); info.updateOldStr(GeneralUtils.objectToString(info.getContent().getReplaceObject()), findStr);
formulaTag.setValue(info, findStr, replaceStr, operatorArray); formulaTag.setValue(info, findStr, replaceStr, operatorArray);
} }
@ -500,7 +518,7 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
/** /**
* 排序 * 排序
*/ */
FORMULA_SORT_EXPRESSION("FormulaSortExpression"){ FORMULA_SORT_EXPRESSION("FormulaSortExpression") {
@Override @Override
public Map<String, String> getValue(Object... o) { public Map<String, String> getValue(Object... o) {
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
@ -514,19 +532,20 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
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) {
Object replaceObject = info.getContent().getReplaceObject(); Object replaceObject = info.getContent().getReplaceObject();
info.updateOldStr((((FormulaSortExpression) replaceObject).getFormula()), findStr); info.updateOldStr((((FormulaSortExpression) replaceObject).getFormula()), findStr);
((FormulaSortExpression) replaceObject).setFormula(ShowValueUtils.replaceAll((((FormulaSortExpression) replaceObject).getFormula()), findStr, replaceStr)); String str = (((FormulaSortExpression) replaceObject).getFormula());
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((FormulaSortExpression) replaceObject).setFormula(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
public boolean check(Info info) { public boolean check(Info info) {
if (info.getContent().getReplaceObject() instanceof FormulaSortExpression){ if (info.getContent().getReplaceObject() instanceof FormulaSortExpression) {
FormulaSortExpression sortExpression = (FormulaSortExpression) info.getContent().getReplaceObject(); FormulaSortExpression sortExpression = (FormulaSortExpression) info.getContent().getReplaceObject();
return StringUtils.equals(sortExpression.getFormula(), info.getContent().getOldShowStr()); return StringUtils.equals(sortExpression.getFormula(), info.getContent().getOldShowStr());
} }
return false; return false;
} }
} };
;
String name; String name;
@ -554,6 +573,7 @@ public enum FormulaReplaceObject implements DealWithInfoValue {
/** /**
* 校验内容 * 校验内容
*
* @param info * @param info
* @return * @return
*/ */

41
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/FormulaTag.java

@ -33,7 +33,9 @@ public enum FormulaTag implements DealWithInfoValue {
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) {
if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) {
VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject();
definition.setLongitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getLongitude()), findStr, replaceStr)); String str = GeneralUtils.objectToString(definition.getLongitude());
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
definition.setLongitude(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
}, },
@ -45,7 +47,9 @@ public enum FormulaTag implements DealWithInfoValue {
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) {
if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) {
VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject();
definition.setLatitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getLatitude()), findStr, replaceStr)); String str = GeneralUtils.objectToString(definition.getLatitude());
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
definition.setLatitude(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
}, },
@ -57,7 +61,9 @@ public enum FormulaTag implements DealWithInfoValue {
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) {
if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) {
VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject();
definition.setCategoryName(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getCategoryName()), findStr, replaceStr)); String str = GeneralUtils.objectToString(definition.getCategoryName());
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
definition.setCategoryName(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
}, },
@ -69,7 +75,9 @@ public enum FormulaTag implements DealWithInfoValue {
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) {
if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) {
VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject();
definition.setEndLongitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getEndLongitude()), findStr, replaceStr)); String str = GeneralUtils.objectToString(definition.getEndLongitude());
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
definition.setEndLongitude(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
}, },
@ -81,7 +89,9 @@ public enum FormulaTag implements DealWithInfoValue {
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) {
if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) {
VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject();
definition.setEndLatitude(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getEndLatitude()), findStr, replaceStr)); String str = GeneralUtils.objectToString(definition.getEndLatitude());
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
definition.setEndLatitude(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
}, },
@ -93,7 +103,9 @@ public enum FormulaTag implements DealWithInfoValue {
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) {
if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) { if (info.getContent().getHoldObject() instanceof VanMapReportDefinition) {
VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject(); VanMapReportDefinition definition = (VanMapReportDefinition) info.getContent().getHoldObject();
definition.setEndAreaName(ShowValueUtils.replaceAll(GeneralUtils.objectToString(definition.getEndAreaName()), findStr, replaceStr)); String str = GeneralUtils.objectToString(definition.getEndAreaName());
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
definition.setEndAreaName(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
}, },
@ -105,7 +117,9 @@ public enum FormulaTag implements DealWithInfoValue {
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) {
if (info.getContent().getHoldObject() instanceof VerifyItem) { if (info.getContent().getHoldObject() instanceof VerifyItem) {
VerifyItem item = (VerifyItem) info.getContent().getHoldObject(); VerifyItem item = (VerifyItem) info.getContent().getHoldObject();
item.setMessage(ShowValueUtils.replaceAll(item.getMessage(), findStr, replaceStr)); String str = item.getMessage();
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
item.setMessage(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
}, },
@ -119,6 +133,7 @@ public enum FormulaTag implements DealWithInfoValue {
WorkBook workBook = (WorkBook) info.getContent().getHoldObject(); WorkBook workBook = (WorkBook) info.getContent().getHoldObject();
int sheetId = Integer.parseInt(info.getContent().getSheetID()); int sheetId = Integer.parseInt(info.getContent().getSheetID());
String name = workBook.getReportName(sheetId); String name = workBook.getReportName(sheetId);
ShowValueUtils.updateAfterReplaceStr(info, name, findStr, replaceStr);
workBook.setReportName(sheetId, ShowValueUtils.replaceAll(name, findStr, replaceStr)); workBook.setReportName(sheetId, ShowValueUtils.replaceAll(name, findStr, replaceStr));
} }
} }
@ -131,7 +146,9 @@ public enum FormulaTag implements DealWithInfoValue {
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) {
if (info.getContent().getHoldObject() instanceof CellGUIAttr) { if (info.getContent().getHoldObject() instanceof CellGUIAttr) {
CellGUIAttr attr = (CellGUIAttr) info.getContent().getHoldObject(); CellGUIAttr attr = (CellGUIAttr) info.getContent().getHoldObject();
attr.setTooltipText(ShowValueUtils.replaceAll(attr.getTooltipText(), findStr, replaceStr)); String str = attr.getTooltipText();
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
attr.setTooltipText(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
}, },
@ -140,7 +157,9 @@ public enum FormulaTag implements DealWithInfoValue {
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) {
if (info.getContent().getHoldObject() instanceof FormulaDictionary) { if (info.getContent().getHoldObject() instanceof FormulaDictionary) {
FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject(); FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject();
dictionary.setExcuteFormula(ShowValueUtils.replaceAll(dictionary.getExcuteFormula(), findStr, replaceStr)); String str = dictionary.getExcuteFormula();
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
dictionary.setExcuteFormula(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
}, },
@ -149,7 +168,9 @@ public enum FormulaTag implements DealWithInfoValue {
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) {
if (info.getContent().getHoldObject() instanceof FormulaDictionary) { if (info.getContent().getHoldObject() instanceof FormulaDictionary) {
FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject(); FormulaDictionary dictionary = (FormulaDictionary) info.getContent().getHoldObject();
dictionary.setProduceFormula(ShowValueUtils.replaceAll(dictionary.getProduceFormula(), findStr, replaceStr)); String str = dictionary.getProduceFormula();
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
dictionary.setProduceFormula(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
}; };

158
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartCollectionFormulaAction.java

@ -13,15 +13,14 @@ import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartattr.SwitchTitle; import com.fr.chart.chartattr.SwitchTitle;
import com.fr.chart.chartattr.Title; import com.fr.chart.chartattr.Title;
import com.fr.chart.chartdata.NormalReportDataDefinition;
import com.fr.chart.chartdata.SeriesDefinition;
import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction; import com.fr.design.actions.replace.action.content.formula.highlight.javascript.SearchJSHighlightAction;
import com.fr.design.actions.replace.action.content.formula.widget.DictionaryType; import com.fr.design.actions.replace.action.content.formula.widget.DictionaryType;
import com.fr.design.actions.replace.info.CellInfo;
import com.fr.design.actions.replace.info.FormulaInfo; import com.fr.design.actions.replace.info.FormulaInfo;
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.ITContent;
import com.fr.design.actions.replace.utils.SearchJSUtils;
import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.js.NameJavaScript; import com.fr.js.NameJavaScript;
@ -29,10 +28,14 @@ import com.fr.js.NameJavaScriptGroup;
import com.fr.plugin.chart.attr.axis.VanChartAlertValue; import com.fr.plugin.chart.attr.axis.VanChartAlertValue;
import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.axis.VanChartValueAxis; import com.fr.plugin.chart.attr.axis.VanChartValueAxis;
import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot;
import com.fr.plugin.chart.custom.CustomDefinition;
import com.fr.plugin.chart.custom.CustomPlotFactory; import com.fr.plugin.chart.custom.CustomPlotFactory;
import com.fr.plugin.chart.custom.VanChartCustomPlot; import com.fr.plugin.chart.custom.VanChartCustomPlot;
import com.fr.plugin.chart.custom.type.CustomPlotType; import com.fr.plugin.chart.custom.type.CustomPlotType;
import com.fr.report.cell.TemplateCellElement; import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot;
import com.fr.plugin.chart.map.VanChartMapPlot;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.util.List; import java.util.List;
@ -104,6 +107,10 @@ public class SearchChartCollectionFormulaAction {
customContent.addOtherPos(CustomPlotFactory.getTitle(CustomPlotFactory.getCustomType(plot.getCustomPlotList().get(i)))); customContent.addOtherPos(CustomPlotFactory.getTitle(CustomPlotFactory.getCustomType(plot.getCustomPlotList().get(i))));
dealPlot(formulaInfos, customContent, plot.getCustomPlotList().get(i)); dealPlot(formulaInfos, customContent, plot.getCustomPlotList().get(i));
} }
} else if (chart.getPlot() instanceof VanChartDrillMapPlot) {
ITContent drillContent = ITContent.copy(conditionContent);
drillContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Drill_Dir"));
dealNameJavaScriptGroup(formulaInfos, drillContent, ((VanChartDrillMapPlot) chart.getPlot()).getDrillUpHyperLink());
} else if (chart.getPlot() != null) { } else if (chart.getPlot() != null) {
dealPlot(formulaInfos, conditionContent, chart.getPlot()); dealPlot(formulaInfos, conditionContent, chart.getPlot());
} }
@ -111,21 +118,41 @@ public class SearchChartCollectionFormulaAction {
} }
private void dealPlot(List<FormulaInfo> formulaInfos, ITContent content, Plot plot) { private void dealPlot(List<FormulaInfo> formulaInfos, ITContent content, Plot plot) {
NameJavaScriptGroup javaScriptGroup = plot.getHotHyperLink(); if (SearchJSUtils.isCustomMapPlot(plot)) {
dealNameJavaScriptGroup(formulaInfos, ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_Region_Map")), ((VanChartMapPlot) plot).getAreaHotHyperLink());
dealNameJavaScriptGroup(formulaInfos, ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_LineMap")), ((VanChartMapPlot) plot).getLineHotHyperLink());
dealNameJavaScriptGroup(formulaInfos, ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_PointMap")), ((VanChartMapPlot) plot).getPointHotHyperLink());
} else {
NameJavaScriptGroup javaScriptGroup = plot.getHotHyperLink();
dealNameJavaScriptGroup(formulaInfos, content, javaScriptGroup);
}
}
private void dealNameJavaScriptGroup(List<FormulaInfo> formulaInfos, ITContent content, NameJavaScriptGroup javaScriptGroup) {
if (javaScriptGroup != null) { if (javaScriptGroup != null) {
for (int i = 0; i < javaScriptGroup.size(); i++) { for (int i = 0; i < javaScriptGroup.size(); i++) {
ITContent formulaContent = ITContent.copy(content);
NameJavaScript javaScript = javaScriptGroup.getNameHyperlink(i); NameJavaScript javaScript = javaScriptGroup.getNameHyperlink(i);
content.addOtherPos(javaScript.getName()); formulaContent.addOtherPos(javaScript.getName());
SearchJSHighlightAction action = SearchJSHighlightAction.getInstance(); SearchJSHighlightAction action = SearchJSHighlightAction.getInstance();
action.searchJSFormulaFromOther(formulaInfos, content, javaScript.getJavaScript()); action.searchJSFormulaFromOther(formulaInfos, formulaContent, javaScript.getJavaScript());
} }
} }
} }
private void searchFormulaFromChartPresent(List<FormulaInfo> formulaInfos, ITContent content, TopDefinitionProvider provider) { private void searchFormulaFromChartPresent(List<FormulaInfo> formulaInfos, ITContent content, TopDefinitionProvider provider) {
searchPresent4Formula(provider.getCategoryPresent(), content, formulaInfos); if (provider instanceof CustomDefinition) {
searchPresent4Formula(provider.getSeriesPresent(), content, formulaInfos); CustomDefinition definition = (CustomDefinition) provider;
Map<CustomPlotType, TopDefinitionProvider> map = definition.getDefinitionProviderMap();
for (CustomPlotType type : map.keySet()) {
ITContent customContent = ITContent.copy(content);
customContent.addOtherPos(CustomPlotFactory.getTitle(type));
searchFormulaFromChartPresent(formulaInfos, customContent, map.get(type));
}
} else {
searchPresent4Formula(provider.getCategoryPresent(), ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_Category")), formulaInfos);
searchPresent4Formula(provider.getSeriesPresent(), ShowValueUtils.getCustomMapContent(content, Toolkit.i18nText("Fine-Design_Chart_Series")), formulaInfos);
}
} }
private void searchPresent4Formula(Present present, ITContent content, List<FormulaInfo> formulaInfos) { private void searchPresent4Formula(Present present, ITContent content, List<FormulaInfo> formulaInfos) {
@ -195,36 +222,40 @@ public class SearchChartCollectionFormulaAction {
private void searchChartPatternFormulaFromAlertLine(List<FormulaInfo> formulaInfos, ITContent chartContent, Chart chart) { private void searchChartPatternFormulaFromAlertLine(List<FormulaInfo> formulaInfos, ITContent chartContent, Chart chart) {
if (chart.getPlot() != null) { if (chart.getPlot() != null) {
Axis xAxis = chart.getPlot().getxAxis(); if (chart.getPlot() instanceof VanChartRectanglePlot) {
Axis yAxis = chart.getPlot().getyAxis(); VanChartRectanglePlot plot = chart.getPlot();
for (VanChartAxis axis : plot.getXAxisList()) {
dealAlertLineFormula(formulaInfos, chartContent, axis);
}
for (VanChartAxis axis : plot.getYAxisList()) {
dealAlertLineFormula(formulaInfos, chartContent, axis);
}
} else {
dealAlertLineFormula(formulaInfos, chartContent, chart.getPlot().getxAxis());
dealAlertLineFormula(formulaInfos, chartContent, chart.getPlot().getyAxis());
}
}
}
private void dealAlertLineFormula(List<FormulaInfo> formulaInfos, ITContent chartContent, Axis axis) {
if (axis instanceof VanChartAxis) {
ITContent content = ITContent.copy(chartContent); ITContent content = ITContent.copy(chartContent);
content.addOtherPos( content.addOtherPos(
Toolkit.i18nText("Fine-Design_Chart_Pattern"), Toolkit.i18nText("Fine-Design_Chart_Pattern"),
Toolkit.i18nText("Fine-Design_Chart_Background"), Toolkit.i18nText("Fine-Design_Chart_Background"),
Toolkit.i18nText("Fine-Design_Chart_Plot_Region"), Toolkit.i18nText("Fine-Design_Chart_Plot_Region"),
Toolkit.i18nText("Fine-Design_Chart_Alert_Line") Toolkit.i18nText("Fine-Design_Chart_Alert_Line"),
((VanChartAxis) axis).getAxisName()
); );
if (xAxis instanceof VanChartAxis) {
List<VanChartAlertValue> list = ((VanChartAxis) xAxis).getAlertValues(); List<VanChartAlertValue> list = ((VanChartAxis) axis).getAlertValues();
for (VanChartAlertValue alertValue : list) { for (VanChartAlertValue alertValue : list) {
//警戒线设置 //警戒线设置
dealAlertValue(formulaInfos, content, alertValue); dealAlertValue(formulaInfos, content, alertValue);
//提示文字 //提示文字
dealAlertContent(formulaInfos, content, alertValue); dealAlertContent(formulaInfos, content, alertValue);
}
}
if (yAxis instanceof VanChartAxis) {
List<VanChartAlertValue> list = ((VanChartAxis) yAxis).getAlertValues();
for (VanChartAlertValue alertValue : list) {
//警戒线设置
dealAlertValue(formulaInfos, content, alertValue);
//提示文字
dealAlertContent(formulaInfos, content, alertValue);
}
} }
} }
} }
private void dealAlertContent(List<FormulaInfo> formulaInfos, ITContent content, VanChartAlertValue alertValue) { private void dealAlertContent(List<FormulaInfo> formulaInfos, ITContent content, VanChartAlertValue alertValue) {
@ -247,39 +278,42 @@ public class SearchChartCollectionFormulaAction {
private void searchChartPatternFormulaFromAxisValue(List<FormulaInfo> formulaInfos, ITContent chartContent, Chart chart) { private void searchChartPatternFormulaFromAxisValue(List<FormulaInfo> formulaInfos, ITContent chartContent, Chart chart) {
if (chart.getPlot() != null) { if (chart.getPlot() != null) {
Axis xAxis = chart.getPlot().getxAxis(); if (chart.getPlot() instanceof VanChartRectanglePlot) {
Axis yAxis = chart.getPlot().getyAxis(); searchVanChartRectanglePlotAxisFormula(formulaInfos, chartContent, chart.getPlot(), chart);
//样式-坐标轴-x轴 } else {
if (xAxis != null) { Axis xAxis = chart.getPlot().getxAxis();
//轴标题 Axis yAxis = chart.getPlot().getyAxis();
ITContent xAxisContent = ITContent.copy(chartContent); //样式-坐标轴
if (!chartContent.isFrm()) { dealAxisFormula(formulaInfos, chartContent, xAxis, chart);
xAxisContent.addOtherPos(chart.getChartName()); dealAxisFormula(formulaInfos, chartContent, yAxis, chart);
}
xAxisContent.addOtherPos(
Toolkit.i18nText("Fine-Design_Chart_Pattern"),
Toolkit.i18nText("Fine-Design_Chart_Axis"),
Toolkit.i18nText("Fine-Design_Chart_X_Axis")
);
dealTitle(formulaInfos, xAxisContent, xAxis.getTitle());
dealChartValueDefine(formulaInfos, xAxisContent, xAxis);
} }
}
}
//样式-坐标轴-y轴-轴标题 private void searchVanChartRectanglePlotAxisFormula(List<FormulaInfo> formulaInfos, ITContent chartContent, VanChartRectanglePlot plot, Chart chart) {
if (yAxis != null) { for (VanChartAxis axis : plot.getXAxisList()) {
ITContent yAxisContent = ITContent.copy(chartContent); dealAxisFormula(formulaInfos, chartContent, axis, chart);
yAxisContent.addOtherPos(
chart.getChartName(),
Toolkit.i18nText("Fine-Design_Chart_Pattern"),
Toolkit.i18nText("Fine-Design_Chart_Axis"),
Toolkit.i18nText("Fine-Design_Chart_Y_Axis")
);
dealTitle(formulaInfos, yAxisContent, yAxis.getTitle());
dealChartValueDefine(formulaInfos, yAxisContent, yAxis);
}
} }
for (VanChartAxis axis : plot.getYAxisList()) {
dealAxisFormula(formulaInfos, chartContent, axis, chart);
}
}
private void dealAxisFormula(List<FormulaInfo> formulaInfos, ITContent chartContent, Axis axis, Chart chart) {
if (axis instanceof VanChartAxis) {
//轴标题
ITContent content = ITContent.copy(chartContent);
if (!chartContent.isFrm()) {
content.addOtherPos(chart.getChartName());
}
content.addOtherPos(
Toolkit.i18nText("Fine-Design_Chart_Pattern"),
Toolkit.i18nText("Fine-Design_Chart_Axis"),
((VanChartAxis) axis).getAxisName()
);
dealTitle(formulaInfos, content, axis.getTitle());
dealChartValueDefine(formulaInfos, content, axis);
}
} }
private void dealChartValueDefine(List<FormulaInfo> formulaInfos, ITContent axisContent, Axis axis) { private void dealChartValueDefine(List<FormulaInfo> formulaInfos, ITContent axisContent, Axis axis) {

41
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/chart/SearchChartMapDataFormulaAction.java

@ -34,11 +34,11 @@ public class SearchChartMapDataFormulaAction implements SearchChartDataFormula {
//流向地图 //流向地图
ITContent lineContent = ITContent.copy(content); ITContent lineContent = ITContent.copy(content);
lineContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_LineMap")); lineContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_LineMap"));
dealLineDefinition(formulaInfos, content, mapDefinition.getLineDefinition()); dealLineDefinition(formulaInfos, lineContent, mapDefinition.getLineDefinition());
//点地图 //点地图
ITContent pointContent = ITContent.copy(content); ITContent pointContent = ITContent.copy(content);
pointContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_PointMap")); pointContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_PointMap"));
dealPointDefinition(formulaInfos, content, mapDefinition.getPointDefinition()); dealPointDefinition(formulaInfos, pointContent, mapDefinition.getPointDefinition());
} }
} }
@ -101,7 +101,7 @@ public class SearchChartMapDataFormulaAction implements SearchChartDataFormula {
formulaInfos.add(new FormulaInfo(endAreaNameContent)); formulaInfos.add(new FormulaInfo(endAreaNameContent));
} }
//区域名 //区域名
dealAreaName(formulaInfos, lineContent, definition.getCategoryName(), definition); dealAreaName(formulaInfos, lineContent, definition.getCategoryName(), definition, true);
} }
} }
@ -160,18 +160,34 @@ public class SearchChartMapDataFormulaAction implements SearchChartDataFormula {
} }
/** /**
* 处理区域名 * 处理区域名不用考虑特殊起名
* @param formulaInfos * @param formulaInfos 存储信息的数据结构
* @param content * @param content ITContent
* @param object * @param object 分类
* @param definition * @param definition 数据
*/ */
public void dealAreaName(List<FormulaInfo> formulaInfos, ITContent content, Object object, VanMapReportDefinition definition) { public void dealAreaName(List<FormulaInfo> formulaInfos, ITContent content, Object object, VanMapReportDefinition definition) {
dealAreaName(formulaInfos, content, object, definition, false);
}
/**
* 处理区域名特殊起名
* @param formulaInfos 存储信息的数据结构
* @param content ITContent
* @param object 分类
* @param definition 数据
* @param lineFlag 线地图的标志
*/
public void dealAreaName(List<FormulaInfo> formulaInfos, ITContent content, Object object, VanMapReportDefinition definition, boolean lineFlag) {
String str;
if (lineFlag) {
str = Toolkit.i18nText("Fine-Design_Chart_Start_Area_Name");
} else {
str = Toolkit.i18nText("Fine-Design_Chart_Area_Name");
}
if (object instanceof Formula) { if (object instanceof Formula) {
ITContent cateContent = ITContent.copy(content); ITContent cateContent = ITContent.copy(content);
cateContent.addOtherPos( cateContent.addOtherPos(str);
Toolkit.i18nText("Fine-Design_Chart_Area_Name")
);
cateContent.setReplaceObject(object); cateContent.setReplaceObject(object);
formulaInfos.add(new FormulaInfo(cateContent)); formulaInfos.add(new FormulaInfo(cateContent));
} else if (isFormulaString(object)) { } else if (isFormulaString(object)) {
@ -179,12 +195,11 @@ public class SearchChartMapDataFormulaAction implements SearchChartDataFormula {
strContent.setHoldObject(definition); strContent.setHoldObject(definition);
strContent.setTag(SearchTag.CHART_AREA_NAME); strContent.setTag(SearchTag.CHART_AREA_NAME);
strContent.setReplaceObject(object); strContent.setReplaceObject(object);
strContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Area_Name")); strContent.addOtherPos(str);
formulaInfos.add(new FormulaInfo(strContent)); formulaInfos.add(new FormulaInfo(strContent));
} }
} }
/** /**
* 处理系列名& * 处理系列名&
*/ */

3
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/highlight/javascript/SearchChartHyperPopLinkAction.java

@ -27,7 +27,8 @@ public class SearchChartHyperPopLinkAction implements SearchJSFormula {
if (javaScript instanceof ChartHyperPoplink) { if (javaScript instanceof ChartHyperPoplink) {
ChartHyperPoplink chartHyperPoplink = (ChartHyperPoplink) javaScript; ChartHyperPoplink chartHyperPoplink = (ChartHyperPoplink) javaScript;
if (chartHyperPoplink.getChartCollection() instanceof ChartCollection) { if (chartHyperPoplink.getChartCollection() instanceof ChartCollection) {
SearchChartCollectionFormulaAction.getInstance().searchChartCollectionFormula(formulaInfos, content, (ChartCollection) chartHyperPoplink.getChartCollection()); ITContent chartContent = ITContent.copy(content);
SearchChartCollectionFormulaAction.getInstance().searchChartCollectionFormula(formulaInfos, chartContent, (ChartCollection) chartHyperPoplink.getChartCollection());
} }
} }
} }

4
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/formula/template/SearchTemplateFormulaAction.java

@ -149,8 +149,8 @@ public class SearchTemplateFormulaAction implements SearchTemplateFormula {
@Override @Override
public void searchTemplateWaterMarkFormula(JTemplate jTemplate, List<FormulaInfo> formulaInfos, ITContent content) { public void searchTemplateWaterMarkFormula(JTemplate jTemplate, List<FormulaInfo> formulaInfos, ITContent content) {
WatermarkAttr watermarkAttr = ReportUtils.getWatermarkAttrFromTemplateAndGlobal((AttrMark) jTemplate.getTarget()); WatermarkAttr watermarkAttr = ReportUtils.getWatermarkAttrFromTemplate((AttrMark) jTemplate.getTarget());
if (watermarkAttr != null) { if (watermarkAttr != null && watermarkAttr.isValid()) {
ITContent waterMarkContent = ITContent.copy(content); ITContent waterMarkContent = ITContent.copy(content);
waterMarkContent.addOtherPos(Toolkit.i18nText("Fine-Design_Form_WaterMark")); waterMarkContent.addOtherPos(Toolkit.i18nText("Fine-Design_Form_WaterMark"));
waterMarkContent.setReplaceObject(watermarkAttr); waterMarkContent.setReplaceObject(watermarkAttr);

15
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckTag.java

@ -0,0 +1,15 @@
package com.fr.design.actions.replace.action.content.js;
/**
* 检查JS的标签
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-26
*/
public class JSCheckTag {
/**
* 单元格-超级链接
*/
public static final int CELL_HYPERLINK = 0;
}

70
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/JSCheckType.java

@ -0,0 +1,70 @@
package com.fr.design.actions.replace.action.content.js;
import com.fr.design.actions.replace.info.Info;
import com.fr.js.NameJavaScript;
import com.fr.js.NameJavaScriptGroup;
import com.fr.report.cell.Elem;
import org.jetbrains.annotations.Nullable;
/**
* 检查JS是否修改过
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-26
*/
public enum JSCheckType {
/**
* 单元格-超级链接
*/
CELL_HYPERLINK(JSCheckTag.CELL_HYPERLINK) {
@Override
public boolean check(Info info) {
Elem elem = (Elem) info.getContent().getHoldObject();
NameJavaScriptGroup group = elem.getNameHyperlinkGroup();
int len = group.size();
if (len == 0) {
return false;
}
NameJavaScript javaScript = (NameJavaScript) info.getContent().getReplaceObject();
for (int i = 0; i < len; i++) {
if (group.getNameHyperlink(i).equals(javaScript)) {
return true;
}
}
return false;
}
};
int index;
JSCheckType(int index) {
this.index = index;
}
/**
* 匹配
*
* @param index
* @return
*/
@Nullable
public static JSCheckType match(int index) {
JSCheckType[] values = JSCheckType.values();
for (JSCheckType value : values) {
if (value.index == index) {
return value;
}
}
return null;
}
/**
* 校验是否修改
* @param info 存储信息的数据结构
* @return
*/
public abstract boolean check(Info info);
}

56
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/js/SearchChartJSAction.java

@ -13,6 +13,7 @@ import com.fr.js.NameJavaScript;
import com.fr.js.NameJavaScriptGroup; import com.fr.js.NameJavaScriptGroup;
import com.fr.plugin.chart.attr.axis.VanChartAxis; import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.plot.VanChartPlot; import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.attr.plot.VanChartRectanglePlot;
import com.fr.plugin.chart.base.RefreshMoreLabel; import com.fr.plugin.chart.base.RefreshMoreLabel;
import com.fr.plugin.chart.base.VanChartHtmlLabel; import com.fr.plugin.chart.base.VanChartHtmlLabel;
import com.fr.plugin.chart.custom.CustomPlotFactory; import com.fr.plugin.chart.custom.CustomPlotFactory;
@ -45,7 +46,7 @@ public class SearchChartJSAction {
*/ */
public void searchChartJS(ChartCollection chartCollection, ITContent content, List<JSInfo> jsInfos) { public void searchChartJS(ChartCollection chartCollection, ITContent content, List<JSInfo> jsInfos) {
List<Pair<VanChartHtmlLabel, String>> htmlLabels = SearchJSUtils.getHtmlLabel(chartCollection); List<Pair<VanChartHtmlLabel, String>> htmlLabels = SearchJSUtils.getHtmlLabel(chartCollection);
List<NameJavaScript> nameJavaScripts = SearchJSUtils.getNameJavaScript(chartCollection); List<NameJavaScript> nameJavaScripts = SearchJSUtils.getNameJavaScript(chartCollection, content, jsInfos);
//图表-样式-标签以及图表-特效-条件显示 //图表-样式-标签以及图表-特效-条件显示
ITContent htmlITContent = ITContent.copy(content); ITContent htmlITContent = ITContent.copy(content);
htmlITContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Chart")); htmlITContent.addOtherPos(Toolkit.i18nText("Fine-Design_Chart_Chart"));
@ -117,29 +118,44 @@ public class SearchChartJSAction {
private void searchAxisJS(List<JSInfo> jsInfos, ITContent chartContent, Chart chart) { private void searchAxisJS(List<JSInfo> jsInfos, ITContent chartContent, Chart chart) {
if (chart.getPlot() != null) { if (chart.getPlot() != null) {
Axis xAxis = chart.getPlot().getxAxis(); if (chart.getPlot() instanceof VanChartRectanglePlot) {
Axis yAxis = chart.getPlot().getyAxis(); searchVanChartRectanglePlotAxisJS(jsInfos, chartContent, chart.getPlot());
if (xAxis instanceof VanChartAxis) { } else {
ITContent xAxisContent = ITContent.copy(chartContent); Axis xAxis = chart.getPlot().getxAxis();
xAxisContent.addOtherPos( Axis yAxis = chart.getPlot().getyAxis();
Toolkit.i18nText("Fine-Design_Chart_Axis"), dealAxis(jsInfos, chartContent, xAxis);
Toolkit.i18nText("Fine-Design_Chart_X_Axis"), dealAxis(jsInfos, chartContent, yAxis);
Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format")
);
dealAxisHtmlLabelJS(jsInfos, ((VanChartAxis) xAxis).getHtmlLabel(), xAxisContent);
} }
}
if (yAxis instanceof VanChartAxis) { }
ITContent yAxisContent = ITContent.copy(chartContent);
yAxisContent.addOtherPos( private void dealAxis(List<JSInfo> jsInfos, ITContent chartContent, Axis axis) {
Toolkit.i18nText("Fine-Design_Chart_Axis"), if (axis instanceof VanChartAxis) {
Toolkit.i18nText("Fine-Design_Chart_Y_Axis"), ITContent yAxisContent = ITContent.copy(chartContent);
Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format") yAxisContent.addOtherPos(
); Toolkit.i18nText("Fine-Design_Chart_Axis"),
dealAxisHtmlLabelJS(jsInfos, ((VanChartAxis) yAxis).getHtmlLabel(), yAxisContent); ((VanChartAxis) axis).getAxisName(),
} Toolkit.i18nText("Fine-Design_Chart_Axis_Label_Format")
);
dealAxisHtmlLabelJS(jsInfos, ((VanChartAxis) axis).getHtmlLabel(), yAxisContent);
} }
}
/**
* 自定义的图表可以存放多个轴
* @param jsInfos 存储信息的数据结构
* @param chartContent ITContent
* @param plot 图表的VanChartRectanglePlot
*/
private void searchVanChartRectanglePlotAxisJS(List<JSInfo> jsInfos, ITContent chartContent, VanChartRectanglePlot plot) {
for (VanChartAxis axis : plot.getXAxisList()) {
dealAxis(jsInfos, chartContent, axis);
}
for (VanChartAxis axis : plot.getYAxisList()) {
dealAxis(jsInfos, chartContent, axis);
}
} }
private void dealAxisHtmlLabelJS(List<JSInfo> jsInfos, VanChartHtmlLabel label, ITContent content) { private void dealAxisHtmlLabelJS(List<JSInfo> jsInfos, VanChartHtmlLabel label, ITContent content) {

3
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/FrmWidgetType.java

@ -130,7 +130,7 @@ public enum FrmWidgetType implements SearchFrmWidget, DealWithInfoValue {
public List<WidgetInfo> dealAbsoluteWidget(ITContent content, Widget widget) { public List<WidgetInfo> dealAbsoluteWidget(ITContent content, Widget widget) {
ArrayList<WidgetInfo> widgetInfos = new ArrayList<>(); ArrayList<WidgetInfo> widgetInfos = new ArrayList<>();
ITContent newContent = ITContent.copy(content); ITContent newContent = ITContent.copy(content);
widgetInfos.add(new WidgetInfo(newContent)); widgetInfos.add(new WidgetInfo(newContent, true));
return widgetInfos; return widgetInfos;
} }
@ -167,6 +167,7 @@ public enum FrmWidgetType implements SearchFrmWidget, DealWithInfoValue {
if (((WidgetInfo) info).isWaterMark()) { if (((WidgetInfo) info).isWaterMark()) {
WaterMark waterMark = (WaterMark) widget; WaterMark waterMark = (WaterMark) widget;
info.updateOldStr(waterMark.getWaterMark(), findStr); info.updateOldStr(waterMark.getWaterMark(), findStr);
ShowValueUtils.updateAfterReplaceStr(info, waterMark.getWaterMark(), findStr, replaceStr);
waterMark.setWaterMark(ShowValueUtils.replaceAll(waterMark.getWaterMark(), findStr, replaceStr)); waterMark.setWaterMark(ShowValueUtils.replaceAll(waterMark.getWaterMark(), findStr, replaceStr));
} else { } else {
info.updateOldStr(widget.getWidgetName(), findStr); info.updateOldStr(widget.getWidgetName(), findStr);

2
designer-realize/src/main/java/com/fr/design/actions/replace/action/content/widget/SearchWidgetAction.java

@ -148,7 +148,7 @@ public class SearchWidgetAction implements SearchAction {
newContent.setReplaceObject(widget); newContent.setReplaceObject(widget);
newContent.setJumpAble(false); newContent.setJumpAble(false);
newContent.setShowObject(Toolkit.i18nText("Fine-Design_Parameter_Panel")); newContent.setShowObject(Toolkit.i18nText("Fine-Design_Parameter_Panel"));
widgetInfos.add(new WidgetInfo(newContent)); widgetInfos.add(new WidgetInfo(newContent, true));
} }
} }

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

@ -0,0 +1,314 @@
package com.fr.design.actions.replace.action.setting;
import com.fr.base.CoreDecimalFormat;
import com.fr.base.NameStyle;
import com.fr.base.TextFormat;
import com.fr.data.core.FormatField;
import com.fr.design.actions.replace.info.Info;
import com.fr.general.date.FineDateFormat;
import com.fr.report.cell.CellElement;
import com.fr.stable.StringUtils;
import org.jetbrains.annotations.Nullable;
import java.text.Format;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 单元格-格式
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-25
*/
public enum CellFormatType {
/**
* 单元格-格式-数字
*/
CELL_FORMAT_NUMBER(SettingContent.FORMAT_NUMBER) {
@Override
public boolean hasExpand(String parentStr) {
return true;
}
@Override
public List<String> getItems() {
return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_NUMBER), false));
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
Format format = cellElement.getStyle().getFormat();
return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr);
}
},
/**
* 单元格-格式-常规
*/
CELL_FORMAT_COMMON(SettingContent.FORMAT_COMMON) {
@Override
public List<String> getItems() {
return super.getItems();
}
@Override
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);
}
},
/**
* 单元格-格式-货币
*/
CELL_FORMAT_MONEY(SettingContent.FORMAT_MONEY) {
@Override
public boolean hasExpand(String parentStr) {
return true;
}
@Override
public List<String> getItems() {
return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_MONEY), false));
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
Format format = cellElement.getStyle().getFormat();
return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr);
}
},
/**
* 单元格-格式-日期
*/
CELL_FORMAT_DATE(SettingContent.FORMAT_DATE) {
@Override
public boolean hasExpand(String parentStr) {
return true;
}
@Override
public List<String> getItems() {
return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_DATE), false));
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
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);
}
},
/**
* 单元格-格式-时间
*/
CELL_FORMAT_TIME(SettingContent.FORMAT_TIME) {
@Override
public boolean hasExpand(String parentStr) {
return true;
}
@Override
public List<String> getItems() {
return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_TIME), false));
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
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);
}
},
/**
* 单元格-格式-科学计数
*/
CELL_FORMAT_SCIENCE(SettingContent.FORMAT_SCIENCE) {
@Override
public boolean hasExpand(String parentStr) {
return true;
}
@Override
public List<String> getItems() {
return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_SCIENCE), false));
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
Format format = cellElement.getStyle().getFormat();
return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr);
}
},
/**
* 单元格-格式-百分比
*/
CELL_FORMAT_PERCENT(SettingContent.FORMAT_PERCENT) {
@Override
public boolean hasExpand(String parentStr) {
return true;
}
@Override
public List<String> getItems() {
return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_PERCENT), false));
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
Format format = cellElement.getStyle().getFormat();
return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr);
}
},
/**
* 单元格-格式-千分比
*/
CELL_FORMAT_PERMILLAGE(SettingContent.FORMAT_PERMILLAGE) {
@Override
public boolean hasExpand(String parentStr) {
return true;
}
@Override
public List<String> getItems() {
return Arrays.asList(FormatField.getInstance().getFormatArray(FormatField.getInstance().getContents(SettingContent.FORMAT_PERMILLAGE), false));
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
Format format = cellElement.getStyle().getFormat();
return format instanceof CoreDecimalFormat && StringUtils.equals(((CoreDecimalFormat) format).toPattern(), secondStr);
}
},
/**
* 单元格-格式-文本
*/
CELL_FORMAT_TEXT(SettingContent.FORMAT_TEXT) {
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
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);
}
};
private String name;
CellFormatType(String name) {
this.name = name;
}
/**
* 匹配
*
* @param name
* @return
*/
@Nullable
public static CellFormatType match(String name) {
CellFormatType[] values = CellFormatType.values();
for (CellFormatType value : values) {
if (StringUtils.equals(value.name, name)) {
return value;
}
}
return null;
}
/**
* 是否能扩展选项
*
* @return 能扩展则返回true
*/
public boolean hasExpand(String parentStr) {
return false;
}
/**
* 获取界面数据
*/
public List<String> getItems() {
return new ArrayList<>();
}
/**
* 是否是要查找的内容
*
* @param cellElement
* @param firstStr
* @param secondStr
* @return
*/
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
return false;
}
/**
* 替换
*
* @param info 存储信息的数据结构
* @param firstStr 用户输入的第一级下拉框内容
* @param secondStr 用户输入的第二级下拉框内容
*/
public void replace(Info info, String firstStr, String secondStr) {
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
cellElement.setStyle(cellElement.getStyle().deriveFormat(FormatField.getInstance().getFormat(FormatField.getInstance().getContents(firstStr), secondStr)));
if (cellElement.getStyle() instanceof NameStyle) {
((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));
}
}

249
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/CellGroupType.java

@ -0,0 +1,249 @@
package com.fr.design.actions.replace.action.setting;
import com.fr.data.util.function.AverageFunction;
import com.fr.data.util.function.CountFunction;
import com.fr.data.util.function.DataFunction;
import com.fr.data.util.function.MaxFunction;
import com.fr.data.util.function.MinFunction;
import com.fr.data.util.function.NoneFunction;
import com.fr.data.util.function.SumFunction;
import com.fr.design.actions.replace.info.Info;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.cell.cellattr.core.group.FunctionGrouper;
import com.fr.report.cell.cellattr.core.group.RecordGrouper;
import com.fr.report.cell.cellattr.core.group.SummaryGrouper;
import com.fr.stable.StringUtils;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 处理单元格的格式对于高级由于需要自定义不加入处理范围
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-26
*/
public enum CellGroupType {
/**
* 分组
*/
GROUP(SettingContent.DIGIT_SETTING_GROUP) {
@Override
public List<String> getItems() {
List<String> items = new ArrayList<String>() {
{
add(SettingContent.GROUP_COMMON);
add(SettingContent.GROUP_CONTINUUM);
}
};
return items;
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
DSColumn column = (DSColumn) cellElement.getValue();
RecordGrouper grouper = column.getGrouper();
return grouper instanceof FunctionGrouper && grouper.getDivideMode() == getGroupType(secondStr);
}
},
/**
* 列表
*/
LIST(SettingContent.DIGIT_SETTING_LIST) {
@Override
public boolean hasExpand(String parentStr) {
return false;
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
DSColumn column = (DSColumn) cellElement.getValue();
RecordGrouper grouper = column.getGrouper();
return grouper instanceof FunctionGrouper && grouper.getDivideMode() == getGroupType(firstStr);
}
},
/**
* 汇总
*/
SUM(SettingContent.DIGIT_SETTING_SUM) {
@Override
public List<String> getItems() {
List<String> items = new ArrayList<String>() {
{
add(SettingContent.SUMMARY_SUM);
add(SettingContent.SUMMARY_AVERAGE);
add(SettingContent.SUMMARY_MAX);
add(SettingContent.SUMMARY_MIN);
add(SettingContent.SUMMARY_COUNT);
add(SettingContent.SUMMARY_NONE);
}
};
return items;
}
@Override
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
DSColumn column = (DSColumn) cellElement.getValue();
RecordGrouper grouper = column.getGrouper();
return grouper instanceof SummaryGrouper && ((SummaryGrouper) grouper).getFunction() != null && StringUtils.equals(((SummaryGrouper) grouper).getFunction().getClass().getSimpleName(), getSummaryType(secondStr));
}
@Override
public void replace(Info info, String firstStr, String secondStr) {
SummaryGrouper grouper = new SummaryGrouper();
grouper.setFunction(createDataFunction(secondStr));
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
DSColumn column = (DSColumn) cellElement.getValue();
column.setGrouper(grouper);
}
};
private String name;
private Map<String, Integer> groupMap = new HashMap<String, Integer>() {
{
put(SettingContent.GROUP_COMMON, FunctionGrouper.GROUPING_MODE);
put(SettingContent.GROUP_CONTINUUM, FunctionGrouper.CONTINUUM_MODE);
put(SettingContent.DIGIT_LIST, FunctionGrouper.LIST_MODE);
}
};
private Map<String, String> summaryMap = new HashMap<String, String>() {
{
put(SettingContent.SUMMARY_SUM, SUM_FUNCTION);
put(SettingContent.SUMMARY_AVERAGE, AVERAGE_FUNCTION);
put(SettingContent.SUMMARY_MAX, MAX_FUNCTION);
put(SettingContent.SUMMARY_MIN, MIN_FUNCTION);
put(SettingContent.SUMMARY_COUNT, COUNT_FUNCTION);
put(SettingContent.SUMMARY_NONE, NONE_FUNCTION);
}
};
public static final String SUM_FUNCTION = "SumFunction";
public static final String AVERAGE_FUNCTION = "AverageFunction";
public static final String MAX_FUNCTION = "MaxFunction";
public static final String MIN_FUNCTION = "MinFunction";
public static final String COUNT_FUNCTION = "CountFunction";
public static final String NONE_FUNCTION = "NoneFunction";
CellGroupType(String name) {
this.name = name;
}
/**
* 匹配
*
* @param name
* @return
*/
@Nullable
public static CellGroupType match(String name) {
CellGroupType[] values = CellGroupType.values();
for (CellGroupType value : values) {
if (StringUtils.equals(value.name, name)) {
return value;
}
}
return null;
}
/**
* 是否是要查找的内容
*
* @param cellElement
* @param firstStr
* @param secondStr
* @return
*/
public boolean isNeed(CellElement cellElement, String firstStr, String secondStr) {
DSColumn column = (DSColumn) cellElement.getValue();
RecordGrouper recordGrouper = column.getGrouper();
return recordGrouper instanceof FunctionGrouper && recordGrouper.getDivideMode() == getGroupType(secondStr);
}
/**
* 匹配分组
*
* @param str
* @return
*/
public Integer getGroupType(String str) {
return groupMap.getOrDefault(str, -1);
}
/**
* 匹配汇总
*/
public String getSummaryType(String str) {
return summaryMap.getOrDefault(str, StringUtils.EMPTY);
}
/**
* 创建对应汇总的DataFunction
*
* @param str 汇总子级下拉框的内容
* @return 指定类型的DataFunction
*/
public DataFunction createDataFunction(String str) {
switch (getSummaryType(str)) {
case SUM_FUNCTION:
return new SumFunction();
case AVERAGE_FUNCTION:
return new AverageFunction();
case MAX_FUNCTION:
return new MaxFunction();
case MIN_FUNCTION:
return new MinFunction();
case COUNT_FUNCTION:
return new CountFunction();
default:
return new NoneFunction();
}
}
/**
* 是否能扩展选项
*
* @return 能扩展则返回true
*/
public boolean hasExpand(String parentStr) {
return true;
}
/**
* 获取界面数据
*/
public List<String> getItems() {
return new ArrayList<>();
}
/**
* 替换
*
* @param info 存储信息的数据结构
* @param firstStr 用户输入的第一级下拉框
* @param secondStr 用户输入的第二级下拉框
*/
public void replace(Info info, String firstStr, String secondStr) {
FunctionGrouper grouper = new FunctionGrouper();
if (StringUtils.equals(firstStr, SettingContent.DIGIT_SETTING_LIST)) {
grouper.setDivideMode(getGroupType(firstStr));
} else {
grouper.setDivideMode(getGroupType(secondStr));
}
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
DSColumn column = (DSColumn) cellElement.getValue();
column.setGrouper(grouper);
}
}

74
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingContent.java

@ -0,0 +1,74 @@
package com.fr.design.actions.replace.action.setting;
import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.design.i18n.Toolkit;
/**
* 设置项的一些常用常量
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-24
*/
public class SettingContent {
public static final String CELL_FORMAT_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Cell"), Toolkit.i18nText("Fine-Design_Report_Base_Format"));
public static final String CELL_DATA_SETTING_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Cell"), Toolkit.i18nText("Fine-Design_Chart_Data_Setting"));
public static final String CELL_DS_COLUMN_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Cell"), Toolkit.i18nText("Fine-Design_Basic_DS_Column"));
public static final String DATASOURCE_CONNECTION_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Replace_Data_Source"), Toolkit.i18nText("Fine-Design_Replace_Data_Connection"));
public static final String DATASOURCE_COLLECT_NAME = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Replace_Data_Source"), Toolkit.i18nText("Fine-Design_Replace_Data_Collect"));
/**
* 单元格-格式
*/
public static final String FORMAT_COMMON = Toolkit.i18nText("Fine-Design_Replace_Common");
public static final String FORMAT_NUMBER = Toolkit.i18nText("Fine-Design_Replace_Number");
public static final String FORMAT_MONEY = Toolkit.i18nText("Fine-Design_Replace_Money");
public static final String FORMAT_PERCENT = Toolkit.i18nText("Fine-Design_Replace_Percent");
public static final String FORMAT_PERMILLAGE = Toolkit.i18nText("Fine-Design_Replace_Permillage");
public static final String FORMAT_SCIENCE = Toolkit.i18nText("Fine-Design_Replace_Science");
public static final String FORMAT_DATE = Toolkit.i18nText("Fine-Design_Replace_Date");
public static final String FORMAT_TIME = Toolkit.i18nText("Fine-Design_Replace_Time");
public static final String FORMAT_TEXT = Toolkit.i18nText("Fine-Design_Replace_Text");
/**
* 单元格-数据设置
*/
public static final String DIGIT_SETTING_GROUP = Toolkit.i18nText("Fine-Design_Replace_Group");
public static final String DIGIT_SETTING_LIST = Toolkit.i18nText("Fine-Design_Replace_List");
public static final String DIGIT_SETTING_SUM = Toolkit.i18nText("Fine-Design_Replace_Sum");
/**
* 单元格-数据设置-分组
*/
public static final String GROUP_COMMON = Toolkit.i18nText("Fine-Design_Report_Common");
public static final String GROUP_CONTINUUM = Toolkit.i18nText("Fine-Design_Report_Continuum");
/**
* 单元格-数据设置-列表
*/
public static final String DIGIT_LIST = Toolkit.i18nText("Fine-Design_Report_Bind_Column_Select");
/**
* 单元格-数据设置-汇总
*/
public static final String SUMMARY_SUM = Toolkit.i18nText("Fine-Design_DataFunction_Sum");
public static final String SUMMARY_AVERAGE = Toolkit.i18nText("Fine-Design_DataFunction_Average");
public static final String SUMMARY_MAX = Toolkit.i18nText("Fine-Design_DataFunction_Max");
public static final String SUMMARY_MIN = Toolkit.i18nText("Fine-Design_DataFunction_Min");
public static final String SUMMARY_COUNT = Toolkit.i18nText("Fine-Design_DataFunction_Count");
public static final String SUMMARY_NONE = Toolkit.i18nText("Fine-Design_DataFunction_None");
/**
* 数据连接
*/
public static final String CONNECTION_TEMPLATE = Toolkit.i18nText("Fine-Design_Basic_DS_Report_TableData");
/**
* 扩展出来的可能的选项
*/
public static final String DS_COLUMN_EXPEND = "DS_COLUMN_EXPEND";
}

387
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/SettingController.java

@ -0,0 +1,387 @@
package com.fr.design.actions.replace.action.setting;
import com.fr.data.TableDataSource;
import com.fr.design.actions.replace.action.ShowValue;
import com.fr.design.actions.replace.action.setting.action.SearchCellDSColumnAction;
import com.fr.design.actions.replace.action.setting.action.SearchCellFormatAction;
import com.fr.design.actions.replace.action.setting.action.SearchConnectionAction;
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;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.ConnectionConfig;
import com.fr.general.data.TableDataColumn;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.stable.StringUtils;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/**
* 设置项的查找内容
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-24
*/
public enum SettingController implements ShowValue {
/**
* 单元格-格式
*/
CELL_FORMAT(SettingContent.CELL_FORMAT_NAME) {
@Override
public List<String> getItems() {
return ITReplaceNorthPanel.formatItems;
}
@Override
public List<? extends Info> showSearchValue(JTemplate jTemplate) {
SearchCellFormatAction.getInstance().search4Infos(jTemplate);
return SearchCellFormatAction.getInstance().getCellInfos();
}
@Override
public List<? extends Info> addMatchResult(List<? extends Info> list, String settingStr, String extraStr) {
List<CellInfo> cellInfos = new ArrayList<>();
for (Info info : list) {
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
CellFormatType type = CellFormatType.match(settingStr);
if (type != null && type.isNeed(cellElement, settingStr, extraStr)) {
cellInfos.add((CellInfo) info);
}
}
return cellInfos;
}
@Override
public boolean hasExpand(String str, String parentStr) {
CellFormatType type = CellFormatType.match(parentStr);
if (type != null) {
return type.hasExpand(parentStr);
}
return false;
}
@Override
public List<String> getExtraItems(String str) {
CellFormatType type = CellFormatType.match(str);
if (type != null) {
return type.getItems();
}
return new ArrayList<>();
}
@Override
public void replace(Info info, String firstStr, String secondStr) {
CellFormatType type = CellFormatType.match(firstStr);
if (type != null) {
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;
}
},
/**
* 单元格-数据设置
*/
CELL_DATA_SETTING(SettingContent.CELL_DATA_SETTING_NAME) {
@Override
public List<String> getItems() {
return ITReplaceNorthPanel.digitItems;
}
@Override
public List<? extends Info> showSearchValue(JTemplate jTemplate) {
SearchCellDSColumnAction.getInstance().search4Infos(jTemplate);
return SearchCellDSColumnAction.getInstance().getCellInfos();
}
@Override
public List<? extends Info> addMatchResult(List<? extends Info> list, String settingStr, String extraStr) {
List<CellInfo> cellInfos = new ArrayList<>();
for (Info info : list) {
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
//能到这步说明单元格里是数据列
CellGroupType cellGroupType = CellGroupType.match(settingStr);
if (cellGroupType != null && cellGroupType.isNeed(cellElement, settingStr, extraStr)) {
cellInfos.add((CellInfo) info);
}
}
return cellInfos;
}
@Override
public List<String> getExtraItems(String str) {
CellGroupType type = CellGroupType.match(str);
if (type != null) {
return type.getItems();
}
return new ArrayList<>();
}
@Override
public boolean hasExpand(String str, String parentStr) {
CellGroupType type = CellGroupType.match(parentStr);
if (type != null) {
return type.hasExpand(parentStr);
}
return false;
}
@Override
public void replace(Info info, String firstStr, String secondStr) {
CellGroupType type = CellGroupType.match(firstStr);
if (type != null) {
type.replace(info, firstStr, secondStr);
}
}
},
/**
* 单元格-数据列
*/
CELL_DS_COLUMN(SettingContent.CELL_DS_COLUMN_NAME) {
@Override
public List<? extends Info> showSearchValue(JTemplate jTemplate) {
SearchCellDSColumnAction.getInstance().search4Infos(jTemplate);
return SearchCellDSColumnAction.getInstance().getCellInfos();
}
@Override
public List<? extends Info> addMatchResult(List<? extends Info> list, String settingStr, String extraStr) {
List<CellInfo> cellInfos = new ArrayList<>();
for (Info info : list) {
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
//能到这步说明单元格里是数据列
DSColumn dsColumn = (DSColumn) cellElement.getValue();
if (isNeed(dsColumn, settingStr, extraStr)) {
cellInfos.add((CellInfo) info);
}
}
return cellInfos;
}
public boolean isNeed(DSColumn dsColumn, String settingStr, String extraStr) {
return dsColumn != null && StringUtils.equals(settingStr, dsColumn.getDSName()) && dsColumn.getColumn() != null && StringUtils.equals(dsColumn.getColumnName(), extraStr);
}
@Override
public List<String> getItems() {
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
List<String> tableDataArray = new ArrayList<>();
if (jTemplate != null && jTemplate.getTarget() instanceof TableDataSource) {
TableDataSource source = (TableDataSource) jTemplate.getTarget();
Iterator dataIterator = source.getTableDataNameIterator();
while (dataIterator.hasNext()) {
String dataName = (String) dataIterator.next();
tableDataArray.add(dataName);
}
}
return tableDataArray;
}
@Override
public List<String> getExtraItems(String str) {
JTemplate<?, ?> jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
List<String> tableDataArray = new ArrayList<>();
if (jTemplate != null) {
TableDataSource source = jTemplate.getTarget();
tableDataArray = Arrays.asList(DesignTableDataManager.getSelectedColumnNames(source, str));
}
return tableDataArray;
}
@Override
public boolean hasExpand(String str, String parentStr) {
return true;
}
@Override
public void replace(Info info, String firstStr, String secondStr) {
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
DSColumn dsColumn = (DSColumn) cellElement.getValue();
dsColumn.setDSName(firstStr);
dsColumn.setColumn(TableDataColumn.createColumn(secondStr));
}
},
/**
* 数据源-数据连接
*/
DATASOURCE_CONNECTION(SettingContent.DATASOURCE_CONNECTION_NAME) {
@Override
public List<? extends Info> showSearchValue(JTemplate jTemplate) {
SearchConnectionAction.getInstance().search4Infos(jTemplate);
return SearchConnectionAction.getInstance().getConnectionInfos();
}
@Override
public List<? extends Info> addMatchResult(List<? extends Info> list, String settingStr, String extraStr) {
List<DataSourceInfo> connectionInfos = new ArrayList<>();
for (Info info : list) {
if (StringUtils.equals(info.getContent().getShowStr(), settingStr)) {
connectionInfos.add((DataSourceInfo) info);
}
}
return connectionInfos;
}
@Override
public List<String> getItems() {
List<String> nameList = new ArrayList<>();
for (String name : ConnectionConfig.getInstance().getConnections().keySet()) {
nameList.add(name);
}
return nameList;
}
},
/**
* 数据源-数据集
*/
DATASOURCE_COLLECT(SettingContent.DATASOURCE_COLLECT_NAME) {
@Override
public List<? extends Info> showSearchValue(JTemplate jTemplate) {
SearchDSColumnAction.getInstance().search4Infos(jTemplate);
return SearchDSColumnAction.getInstance().getDsColumnInfos();
}
@Override
public List<? extends Info> addMatchResult(List<? extends Info> list, String settingStr, String extraStr) {
return list;
}
@Override
public List<String> getItems() {
return ITReplaceNorthPanel.dsColumnItems;
}
};
private String name;
SettingController(String name) {
this.name = name;
}
/**
* 匹配
*
* @param name
* @return
*/
@Nullable
public static SettingController match(String name) {
SettingController[] values = SettingController.values();
for (SettingController value : values) {
if (StringUtils.equals(value.name, name)) {
return value;
}
}
return null;
}
/**
* 获取界面的数据使之与选项匹配
*
* @param name 选项
*/
public static List<String> getSettingRefreshItems(String name) {
SettingController[] values = SettingController.values();
for (SettingController value : values) {
if (StringUtils.equals(value.name, name)) {
return value.getItems();
}
}
return new ArrayList<>();
}
/**
* 获取界面的数据使之与选项匹配
*
* @param parentStr 选项
*/
public static List<String> getSettingExtraRefreshItems(String str, String parentStr) {
SettingController[] values = SettingController.values();
for (SettingController value : values) {
if (StringUtils.equals(value.name, str)) {
return value.getExtraItems(parentStr);
}
}
return new ArrayList<>();
}
/**
* 获取界面数据
*/
public List<String> getItems() {
return new ArrayList<>();
}
/**
* 获取扩展数据
*
* @param str 父类名称
* @return 扩展的数据列表
*/
public List<String> getExtraItems(String str) {
return new ArrayList<>();
}
/**
* 是否能扩展选项
*
* @return 能扩展则返回true
*/
public boolean hasExpand(String str, String parentStr) {
return false;
}
/**
* 替换
*
* @param info 存储信息的数据结构
* @param firstStr 用户设定的第一级下拉框的内容
* @param secondStr 用户设定的第二级下拉框的内容
*/
public void replace(Info info, String firstStr, String secondStr) {
}
/**
* 是否修改过
*
* @param info 存储信息的数据结构
* @param inputStr 用户搜索的一级下拉框内容
* @param extraStr 用户搜索的二级下拉框内容
* @return 没修改过则返回false
*/
public boolean isEverChanged(Info info, String inputStr, String extraStr) {
return false;
}
}

82
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellDSColumnAction.java

@ -0,0 +1,82 @@
package com.fr.design.actions.replace.action.setting.action;
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.report.cell.CellElement;
import com.fr.report.cell.cellattr.core.group.DSColumn;
import java.util.ArrayList;
import java.util.List;
/**
* 存储单元格-数据列
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-26
*/
public class SearchCellDSColumnAction implements SearchAction {
private List<CellInfo> cellInfos = new ArrayList<>();
private SearchCellDSColumnAction() {
}
@Override
public void search4Infos(JTemplate jTemplate) {
List<CellInfo> cellInfos = new ArrayList<>();
SearchCellAction.getInstance().search4Infos(jTemplate);
for (CellInfo info : SearchCellAction.getInstance().getCellInfos()) {
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
if (cellElement.getValue() instanceof DSColumn) {
info.getContent().setShowStr(GeneralUtils.objectToString(cellElement.getValue()));
cellInfos.add(info);
}
}
setCellInfos(cellInfos);
}
public List<CellInfo> getCellInfos() {
return cellInfos;
}
public void setCellInfos(List<CellInfo> cellInfos) {
this.cellInfos = cellInfos;
}
/**
* 对外开放的获取对象的方法
*
* @return
*/
public static SearchCellDSColumnAction getInstance() {
return SearchCellDSColumnActionEnum.SINGLETON.getInstance();
}
/**
* 枚举实现单例
*/
private enum SearchCellDSColumnActionEnum {
/**
* 单例
*/
SINGLETON;
private SearchCellDSColumnAction instance;
SearchCellDSColumnActionEnum() {
instance = new SearchCellDSColumnAction();
}
/**
* 获取对象
*
* @return
*/
public SearchCellDSColumnAction getInstance() {
return instance;
}
}
}

103
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchCellFormatAction.java

@ -0,0 +1,103 @@
package com.fr.design.actions.replace.action.setting.action;
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.RichText;
import com.fr.report.cell.cellattr.core.SubReport;
import com.fr.report.cell.painter.BiasTextPainter;
import java.util.ArrayList;
import java.util.List;
/**
* 存储有格式的单元格
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-25
*/
public class SearchCellFormatAction implements SearchAction {
private List<CellInfo> cellInfos = new ArrayList<>();
private SearchCellFormatAction() {
}
@Override
public void search4Infos(JTemplate jTemplate) {
List<CellInfo> cellInfos = new ArrayList<>();
SearchCellAction.getInstance().search4Infos(jTemplate);
for (CellInfo info : SearchCellAction.getInstance().getCellInfos()) {
CellElement cellElement = (CellElement) info.getContent().getReplaceObject();
if (isFormatValid(cellElement)) {
info.getContent().setShowStr(GeneralUtils.objectToString(cellElement.getValue()));
cellInfos.add(info);
}
}
setCellInfos(cellInfos);
}
/**
* 单元格的内容是否是在查找范围内
*
* @param cellElement 单元格
* @return 在查找范围内返回true
*/
public boolean isFormatValid(CellElement cellElement) {
return cellElement.getStyle() != null
&& !(cellElement.getValue() instanceof SubReport
|| cellElement.getValue() instanceof BiasTextPainter
|| cellElement.getValue() instanceof ChartCollection
|| cellElement.getValue() instanceof RichText
|| cellElement.getValue() instanceof ImageWithSuffix
);
}
public List<CellInfo> getCellInfos() {
return cellInfos;
}
public void setCellInfos(List<CellInfo> cellInfos) {
this.cellInfos = cellInfos;
}
/**
* 对外开放的获取对象的方法
*
* @return
*/
public static SearchCellFormatAction getInstance() {
return SearchCellFormatActionEnum.SINGLETON.getInstance();
}
/**
* 枚举实现单例
*/
private enum SearchCellFormatActionEnum {
/**
* 单例
*/
SINGLETON;
private SearchCellFormatAction instance;
SearchCellFormatActionEnum() {
instance = new SearchCellFormatAction();
}
/**
* 获取对象
*
* @return
*/
public SearchCellFormatAction getInstance() {
return instance;
}
}
}

114
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchConnectionAction.java

@ -0,0 +1,114 @@
package com.fr.design.actions.replace.action.setting.action;
import com.fr.base.TableData;
import com.fr.base.TableDataConnection;
import com.fr.data.TableDataSource;
import com.fr.data.impl.Connection;
import com.fr.data.impl.NameDatabaseConnection;
import com.fr.design.actions.replace.action.SearchAction;
import com.fr.design.actions.replace.info.DataSourceInfo;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.ConnectionConfig;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
/**
* 存储数据连接信息
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-26
*/
public class SearchConnectionAction implements SearchAction {
private List<DataSourceInfo> connectionInfos = new ArrayList<>();
private SearchConnectionAction() {
}
@Override
public void search4Infos(JTemplate jTemplate) {
List<DataSourceInfo> connectionInfos = new ArrayList<>();
Map<String, Connection> map = ConnectionConfig.getInstance().getConnections();
Map<String, Connection> needMap = new HashMap<>();
TableDataSource source = (TableDataSource) jTemplate.getTarget();
Iterator dataIterator = source.getTableDataNameIterator();
while (dataIterator.hasNext()) {
String dataName = (String) dataIterator.next();
TableData data = source.getTableData(dataName);
if (isNameDataBaseConnectionValid(data)) {
NameDatabaseConnection connection = (NameDatabaseConnection) ((TableDataConnection) data).getDatabase();
if (map.containsKey(connection.getName())) {
needMap.put(connection.getName(), connection);
}
}
}
for (String name : needMap.keySet()) {
ITContent content = new ITContent();
content.setReplaceObject(needMap.get(name));
content.setTemplateName(jTemplate.getTemplateName());
content.setJumpAble(false);
content.setShowStr(name);
connectionInfos.add(new DataSourceInfo(content));
}
setConnectionInfos(connectionInfos);
}
/**
* 数据连接是否可用
*
* @param data 数据库
* @return 可用返回true
*/
public boolean isNameDataBaseConnectionValid(TableData data) {
return data instanceof TableDataConnection && ((TableDataConnection) data).getDatabase() instanceof NameDatabaseConnection;
}
public List<DataSourceInfo> getConnectionInfos() {
return connectionInfos;
}
public void setConnectionInfos(List<DataSourceInfo> connectionInfos) {
this.connectionInfos = connectionInfos;
}
/**
* 对外开放的获取对象的方法
*
* @return
*/
public static SearchConnectionAction getInstance() {
return SearchConnectionActionEnum.SINGLETON.getInstance();
}
/**
* 枚举实现单例
*/
private enum SearchConnectionActionEnum {
/**
* 单例
*/
SINGLETON;
private SearchConnectionAction instance;
SearchConnectionActionEnum() {
instance = new SearchConnectionAction();
}
/**
* 获取对象
*
* @return
*/
public SearchConnectionAction getInstance() {
return instance;
}
}
}

87
designer-realize/src/main/java/com/fr/design/actions/replace/action/setting/action/SearchDSColumnAction.java

@ -0,0 +1,87 @@
package com.fr.design.actions.replace.action.setting.action;
import com.fr.base.TableData;
import com.fr.data.TableDataSource;
import com.fr.design.actions.replace.action.SearchAction;
import com.fr.design.actions.replace.info.DataSourceInfo;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.mainframe.JTemplate;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
* 搜索数据列
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-26
*/
public class SearchDSColumnAction implements SearchAction {
private List<DataSourceInfo> dsColumnInfos = new ArrayList<>();
private SearchDSColumnAction() {
}
@Override
public void search4Infos(JTemplate jTemplate) {
List<DataSourceInfo> dsColumnInfos = new ArrayList<>();
TableDataSource source = (TableDataSource) jTemplate.getTarget();
Iterator dataIterator = source.getTableDataNameIterator();
while (dataIterator.hasNext()) {
String dataName = (String) dataIterator.next();
TableData data = source.getTableData(dataName);
ITContent content = new ITContent();
content.setJumpAble(false);
content.setReplaceObject(data);
content.setShowStr(dataName);
content.setTemplateName(jTemplate.getTemplateName());
dsColumnInfos.add(new DataSourceInfo(content));
}
setDsColumnInfos(dsColumnInfos);
}
public List<DataSourceInfo> getDsColumnInfos() {
return dsColumnInfos;
}
public void setDsColumnInfos(List<DataSourceInfo> dsColumnInfos) {
this.dsColumnInfos = dsColumnInfos;
}
/**
* 对外开放的获取对象的方法
*
* @return
*/
public static SearchDSColumnAction getInstance() {
return SearchDSColumnActionEnum.SINGLETON.getInstance();
}
/**
* 枚举实现单例
*/
private enum SearchDSColumnActionEnum {
/**
* 单例
*/
SINGLETON;
private SearchDSColumnAction instance;
SearchDSColumnActionEnum() {
instance = new SearchDSColumnAction();
}
/**
* 获取对象
*
* @return
*/
public SearchDSColumnAction getInstance() {
return instance;
}
}
}

29
designer-realize/src/main/java/com/fr/design/actions/replace/info/CellInfo.java

@ -99,10 +99,13 @@ public class CellInfo implements Info {
if (title.getTextObject() instanceof Formula) { if (title.getTextObject() instanceof Formula) {
Formula formula = (Formula) title.getTextObject(); Formula formula = (Formula) title.getTextObject();
updateOldStr(formula.getContent(), findStr); updateOldStr(formula.getContent(), findStr);
ShowValueUtils.updateAfterReplaceStr(info, formula.getContent(), findStr, replaceStr);
formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr)); formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr));
} else { } else {
updateOldStr(GeneralUtils.objectToString(title.getTextObject()), findStr); updateOldStr(GeneralUtils.objectToString(title.getTextObject()), findStr);
title.setTextObject(ShowValueUtils.replaceAll(GeneralUtils.objectToString(title.getTextObject()), findStr, replaceStr)); String str = GeneralUtils.objectToString(title.getTextObject());
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
title.setTextObject(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} else { } else {
CellValueType cellValueType = CellValueType.match(cellElement.getValue().getClass().getSimpleName()); CellValueType cellValueType = CellValueType.match(cellElement.getValue().getClass().getSimpleName());
@ -110,7 +113,9 @@ public class CellInfo implements Info {
cellValueType.setValue(this, cellElement.getValue(), findStr, replaceStr); cellValueType.setValue(this, cellElement.getValue(), findStr, replaceStr);
} else { } else {
updateOldStr(GeneralUtils.objectToString(cellElement.getValue()), findStr); updateOldStr(GeneralUtils.objectToString(cellElement.getValue()), findStr);
cellElement.setValue(ShowValueUtils.replaceAll(GeneralUtils.objectToString(cellElement.getValue()), findStr, replaceStr)); String str = GeneralUtils.objectToString(cellElement.getValue());
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
cellElement.setValue(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
@ -205,7 +210,9 @@ public class CellInfo implements Info {
@Override @Override
public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) { public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) {
cellInfo.updateOldStr(GeneralUtils.objectToString(((DSColumn) o).getDSName()), findStr); cellInfo.updateOldStr(GeneralUtils.objectToString(((DSColumn) o).getDSName()), findStr);
((DSColumn) o).setDSName(ShowValueUtils.replaceAll(((DSColumn) o).getDSName(), findStr, replaceStr)); String str = ((DSColumn) o).getDSName();
ShowValueUtils.updateAfterReplaceStr(cellInfo, str, findStr, replaceStr);
((DSColumn) o).setDSName(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
@ -226,7 +233,9 @@ public class CellInfo implements Info {
@Override @Override
public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) { public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) {
cellInfo.updateOldStr(GeneralUtils.objectToString(o), findStr); cellInfo.updateOldStr(GeneralUtils.objectToString(o), findStr);
((Formula) o).setContent(ShowValueUtils.replaceAll(((Formula) o).getContent(), findStr, replaceStr)); String str = ((Formula) o).getContent();
ShowValueUtils.updateAfterReplaceStr(cellInfo, str, findStr, replaceStr);
((Formula) o).setContent(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
@ -243,8 +252,10 @@ public class CellInfo implements Info {
@Override @Override
public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) { public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) {
LinkWorkBookTemplate workBookTemplate = (LinkWorkBookTemplate) ((SubReport) o).getPackee(); LinkWorkBookTemplate workBookTemplate = (LinkWorkBookTemplate) ((SubReport) o).getPackee();
cellInfo.updateOldStr(workBookTemplate.getTemplatePath(), findStr); String str = workBookTemplate.getTemplatePath();
workBookTemplate.setTemplatePath(ShowValueUtils.replaceAll(workBookTemplate.getTemplatePath(), findStr, replaceStr)); cellInfo.updateOldStr(str, findStr);
ShowValueUtils.updateAfterReplaceStr(cellInfo, str, findStr, replaceStr);
workBookTemplate.setTemplatePath(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override
@ -267,8 +278,10 @@ public class CellInfo implements Info {
BIAS_TEXT_PAINTER("BiasTextPainter") { BIAS_TEXT_PAINTER("BiasTextPainter") {
@Override @Override
public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) { public void setValue(CellInfo cellInfo, Object o, String findStr, String replaceStr) {
cellInfo.updateOldStr(((BiasTextPainter) o).getText(), findStr); String str = ((BiasTextPainter) o).getText();
((BiasTextPainter) o).setText(ShowValueUtils.replaceAll(((BiasTextPainter) o).getText(), findStr, replaceStr)); cellInfo.updateOldStr(str, findStr);
ShowValueUtils.updateAfterReplaceStr(cellInfo, str, findStr, replaceStr);
((BiasTextPainter) o).setText(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
@Override @Override

25
designer-realize/src/main/java/com/fr/design/actions/replace/info/ComponentInfo.java

@ -1,10 +1,15 @@
package com.fr.design.actions.replace.info; package com.fr.design.actions.replace.info;
import com.fr.design.actions.replace.action.content.component.ComponentType; import com.fr.design.actions.replace.action.content.component.ComponentType;
import com.fr.design.actions.replace.action.content.component.SearchComponentAction;
import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.collections.combination.Pair; import com.fr.stable.collections.combination.Pair;
import com.fr.stable.js.WidgetName;
import java.util.HashMap; import java.util.HashMap;
@ -79,4 +84,24 @@ public class ComponentInfo implements Info {
public String getInfoShowStr(Info info) { public String getInfoShowStr(Info info) {
return this.getContent().getOldShowStr(); return this.getContent().getOldShowStr();
} }
@Override
public Boolean isLegalValid(JTemplate<?, ?> jTemplate, String searchStr, String replaceStr) {
if (StringUtils.isEmpty(replaceStr)) {
this.getContent().setCheckStr(Toolkit.i18nText("Fine-Design_Replace_Not_Empty"));
return false;
}
SearchComponentAction.getInstance().search4Infos(jTemplate);
List<ComponentInfo> list = SearchComponentAction.getInstance().getComponentInfos();
String replacedName = ShowValueUtils.replaceAll(((Widget)this.getContent().getReplaceObject()).getWidgetName(), searchStr, replaceStr);
for (ComponentInfo info : list) {
String widgetName = ((Widget)info.getContent().getReplaceObject()).getWidgetName();
if (StringUtils.equals(replacedName, widgetName)) {
this.getContent().setCheckStr(Toolkit.i18nText("Fine-Design_Replace_Exist_Same_Name"));
return false;
}
}
return true;
}
} }

28
designer-realize/src/main/java/com/fr/design/actions/replace/info/DataSourceInfo.java

@ -0,0 +1,28 @@
package com.fr.design.actions.replace.info;
import com.fr.design.actions.replace.info.base.ITContent;
/**
* 存储数据源相关的信息后续数据源部分如果有自己额外的信息把这个当成父类进行拓展即可
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-28
*/
public class DataSourceInfo implements Info{
private ITContent content;
public DataSourceInfo(ITContent content) {
this.content = content;
}
@Override
public ITContent getContent() {
return content;
}
public void setContent(ITContent content) {
this.content = content;
}
}

14
designer-realize/src/main/java/com/fr/design/actions/replace/info/FloatInfo.java

@ -92,20 +92,26 @@ public class FloatInfo implements Info {
if (title.getTextObject() instanceof Formula) { if (title.getTextObject() instanceof Formula) {
Formula formula = (Formula) title.getTextObject(); Formula formula = (Formula) title.getTextObject();
updateOldStr(formula.getContent(), findStr); updateOldStr(formula.getContent(), findStr);
ShowValueUtils.updateAfterReplaceStr(info, formula.getContent(), findStr, replaceStr);
formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr)); formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr));
} else { } else {
updateOldStr(GeneralUtils.objectToString(title.getTextObject()), findStr); String str = GeneralUtils.objectToString(title.getTextObject());
title.setTextObject(ShowValueUtils.replaceAll(GeneralUtils.objectToString(title.getTextObject()), findStr, replaceStr)); ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
updateOldStr(str, findStr);
title.setTextObject(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} else { } else {
FloatElement floatElement = ((FloatElement) this.getContent().getReplaceObject()); FloatElement floatElement = ((FloatElement) this.getContent().getReplaceObject());
if (floatElement.getValue() instanceof Formula) { if (floatElement.getValue() instanceof Formula) {
Formula formula = (Formula) floatElement.getValue(); Formula formula = (Formula) floatElement.getValue();
updateOldStr(formula.getContent(), findStr); updateOldStr(formula.getContent(), findStr);
ShowValueUtils.updateAfterReplaceStr(info, formula.getContent(), findStr, replaceStr);
formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr)); formula.setContent(ShowValueUtils.replaceAll(formula.getContent(), findStr, replaceStr));
} else { } else {
updateOldStr(GeneralUtils.objectToString(floatElement.getValue()), findStr); String str = GeneralUtils.objectToString(floatElement.getValue());
floatElement.setValue(ShowValueUtils.replaceAll(GeneralUtils.objectToString(floatElement.getValue()), findStr, replaceStr)); ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
updateOldStr(str, findStr);
floatElement.setValue(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} }
} }
} }

16
designer-realize/src/main/java/com/fr/design/actions/replace/info/Info.java

@ -1,6 +1,7 @@
package com.fr.design.actions.replace.info; package com.fr.design.actions.replace.info;
import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.mainframe.JTemplate;
/** /**
@ -41,5 +42,18 @@ public interface Info extends DealWithInfoValue {
return true; return true;
} }
; /**
* 校验合法性(内容是否合法
* 当前需要检测的目标
* 控件名值是否为空重名
* 组件名值是否为空重名
*
* @param jTemplate 要检测的模板
* @param searchStr 搜索的内容
* @param replaceStr 替换的内容
* @return 检测合法则返回true
*/
default Boolean isLegalValid(JTemplate<?, ?> jTemplate,String searchStr, String replaceStr) {
return true;
}
} }

31
designer-realize/src/main/java/com/fr/design/actions/replace/info/ReplaceObject.java

@ -2,6 +2,7 @@ package com.fr.design.actions.replace.info;
import com.fr.data.impl.DBTableData; import com.fr.data.impl.DBTableData;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.replace.action.content.js.JSCheckType;
import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.data.datapane.TableDataTreePane; import com.fr.design.data.datapane.TableDataTreePane;
@ -47,10 +48,12 @@ public enum ReplaceObject implements DealWithInfoValue {
if (((JSInfo) info).isContent()) { if (((JSInfo) info).isContent()) {
JavaScriptImpl javaScript = (JavaScriptImpl) ((NameJavaScript) (info.getContent().getReplaceObject())).getJavaScript(); JavaScriptImpl javaScript = (JavaScriptImpl) ((NameJavaScript) (info.getContent().getReplaceObject())).getJavaScript();
info.updateOldStr(javaScript.getContent(), findStr); info.updateOldStr(javaScript.getContent(), findStr);
ShowValueUtils.updateAfterReplaceStr(info, javaScript.getContent(), findStr, replaceStr);
javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr)); javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr));
} else { } else {
NameJavaScript javaScript = ((NameJavaScript) (info.getContent().getReplaceObject())); NameJavaScript javaScript = ((NameJavaScript) (info.getContent().getReplaceObject()));
info.updateOldStr(javaScript.getName(), findStr); info.updateOldStr(javaScript.getName(), findStr);
ShowValueUtils.updateAfterReplaceStr(info, javaScript.getName(), findStr, replaceStr);
javaScript.setName(ShowValueUtils.replaceAll(javaScript.getName(), findStr, replaceStr)); javaScript.setName(ShowValueUtils.replaceAll(javaScript.getName(), findStr, replaceStr));
} }
} }
@ -94,10 +97,12 @@ public enum ReplaceObject implements DealWithInfoValue {
if (((JSInfo) info).isContent()) { if (((JSInfo) info).isContent()) {
JavaScriptImpl javaScript = (JavaScriptImpl) ((Listener) (info.getContent().getReplaceObject())).getAction(); JavaScriptImpl javaScript = (JavaScriptImpl) ((Listener) (info.getContent().getReplaceObject())).getAction();
info.updateOldStr(javaScript.getContent(), findStr); info.updateOldStr(javaScript.getContent(), findStr);
ShowValueUtils.updateAfterReplaceStr(info, javaScript.getContent(), findStr, replaceStr);
javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr)); javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr));
} else { } else {
Listener listener = ((Listener) ((info.getContent().getReplaceObject()))); Listener listener = ((Listener) ((info.getContent().getReplaceObject())));
info.updateOldStr(listener.getName(), findStr); info.updateOldStr(listener.getName(), findStr);
ShowValueUtils.updateAfterReplaceStr(info, listener.getName(), findStr, replaceStr);
listener.setName(ShowValueUtils.replaceAll(listener.getName(), findStr, replaceStr)); listener.setName(ShowValueUtils.replaceAll(listener.getName(), findStr, replaceStr));
} }
} }
@ -141,6 +146,7 @@ public enum ReplaceObject implements DealWithInfoValue {
VanChartHtmlLabel htmlLabel = ((VanChartHtmlLabel) (info.getContent().getReplaceObject())); VanChartHtmlLabel htmlLabel = ((VanChartHtmlLabel) (info.getContent().getReplaceObject()));
StringBuilder stringBuilder = new StringBuilder(htmlLabel.getCustomText()); StringBuilder stringBuilder = new StringBuilder(htmlLabel.getCustomText());
info.updateOldStr(htmlLabel.getCustomText(), findStr); info.updateOldStr(htmlLabel.getCustomText(), findStr);
ShowValueUtils.updateAfterReplaceStr(info, htmlLabel.getCustomText(), findStr, replaceStr);
htmlLabel.setCustomText(ShowValueUtils.replaceAll(htmlLabel.getCustomText(), findStr, replaceStr)); htmlLabel.setCustomText(ShowValueUtils.replaceAll(htmlLabel.getCustomText(), findStr, replaceStr));
} }
} }
@ -175,6 +181,7 @@ public enum ReplaceObject implements DealWithInfoValue {
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) {
JavaScriptImpl javaScript = (JavaScriptImpl) (info.getContent().getReplaceObject()); JavaScriptImpl javaScript = (JavaScriptImpl) (info.getContent().getReplaceObject());
info.updateOldStr(javaScript.getContent(), findStr); info.updateOldStr(javaScript.getContent(), findStr);
ShowValueUtils.updateAfterReplaceStr(info, javaScript.getContent(), findStr, replaceStr);
javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr)); javaScript.setContent(ShowValueUtils.replaceAll(javaScript.getContent(), findStr, replaceStr));
} }
@ -209,6 +216,7 @@ public enum ReplaceObject implements DealWithInfoValue {
String jsName = GeneralUtils.objectToString(info.getContent().getReplaceObject()); String jsName = GeneralUtils.objectToString(info.getContent().getReplaceObject());
for (int i = 0, len = jsImports.size(); i < len; i++) { for (int i = 0, len = jsImports.size(); i < len; i++) {
if (StringUtils.equals(jsImports.get(i), jsName)) { if (StringUtils.equals(jsImports.get(i), jsName)) {
ShowValueUtils.updateAfterReplaceStr(info, jsName, findStr, replaceStr);
jsImports.set(i, ShowValueUtils.replaceAll(jsName, findStr, replaceStr)); jsImports.set(i, ShowValueUtils.replaceAll(jsName, findStr, replaceStr));
} }
} }
@ -234,22 +242,23 @@ public enum ReplaceObject implements DealWithInfoValue {
*/ */
DB_TABLE_DATA("DBTableData") { DB_TABLE_DATA("DBTableData") {
@Override @Override
boolean check (Info info){ boolean check(Info info) {
DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject(); DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject();
return StringUtils.equals(dbTableData.getQuery(), info.getContent().getOldShowStr()); return StringUtils.equals(dbTableData.getQuery(), info.getContent().getOldShowStr());
} }
@Override @Override
public Map<String, String> getValue (Object...o){ public Map<String, String> getValue(Object... o) {
HashMap<String, String> map = new HashMap<>(); HashMap<String, String> map = new HashMap<>();
addValue2Map(contentKey, ((DBTableData) o[0]).getQuery(), map); addValue2Map(contentKey, ((DBTableData) o[0]).getQuery(), map);
return map; return map;
} }
@Override @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(); DBTableData dbTableData = (DBTableData) info.getContent().getReplaceObject();
info.updateOldStr(dbTableData.getQuery(), findStr); info.updateOldStr(dbTableData.getQuery(), findStr);
ShowValueUtils.updateAfterReplaceStr(info, dbTableData.getQuery(), findStr, replaceStr);
dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr)); dbTableData.setQuery(ShowValueUtils.replaceAll(dbTableData.getQuery(), findStr, replaceStr));
//清除缓存 //清除缓存
DesignTableDataManager.removeSelectedColumnNames(dbTableData.getName()); DesignTableDataManager.removeSelectedColumnNames(dbTableData.getName());
@ -258,7 +267,7 @@ public enum ReplaceObject implements DealWithInfoValue {
} }
@Override @Override
public String getInfoShowStr (Info info){ public String getInfoShowStr(Info info) {
return info.getInfoShowStr(info); return info.getInfoShowStr(info);
} }
}; };
@ -304,4 +313,18 @@ public enum ReplaceObject implements DealWithInfoValue {
abstract boolean check(Info info); abstract boolean check(Info info);
/**
* 修改会引入新对象的放入这里检查
*
* @param info
* @return
*/
public boolean checkQuote(Info info) {
JSCheckType o = JSCheckType.match(info.getContent().getTag());
if (o != null) {
return o.check(info);
}
return true;
} }
}

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;
}
} }

49
designer-realize/src/main/java/com/fr/design/actions/replace/info/WidgetInfo.java

@ -3,13 +3,18 @@ package com.fr.design.actions.replace.info;
import com.fr.design.actions.replace.action.content.widget.FrmWidgetType; import com.fr.design.actions.replace.action.content.widget.FrmWidgetType;
import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.actions.replace.utils.CheckUtils;
import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.actions.replace.utils.ShowValueUtils;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.JTemplate;
import com.fr.form.ui.WaterMark; import com.fr.form.ui.WaterMark;
import com.fr.form.ui.Widget; import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WScaleLayout; import com.fr.form.ui.container.WScaleLayout;
import com.fr.form.ui.widget.CRBoundsWidget; import com.fr.form.ui.widget.CRBoundsWidget;
import com.fr.stable.AssistUtils; import com.fr.stable.AssistUtils;
import com.fr.stable.StringUtils;
import com.fr.stable.collections.combination.Pair; import com.fr.stable.collections.combination.Pair;
import com.fr.stable.js.WidgetName;
import java.util.HashMap; import java.util.HashMap;
@ -26,11 +31,17 @@ import java.util.Map;
public class WidgetInfo implements Info, DealWithInfoValue { public class WidgetInfo implements Info, DealWithInfoValue {
private ITContent content; private ITContent content;
private boolean waterMarkFlag = true; private boolean waterMarkFlag = true;
private boolean need2Check = false;
public WidgetInfo(ITContent content) { public WidgetInfo(ITContent content) {
this.content = content; this.content = content;
} }
public WidgetInfo(ITContent content, boolean need2Check) {
this.content = content;
this.need2Check = need2Check;
}
@Override @Override
public ITContent getContent() { public ITContent getContent() {
return content; return content;
@ -66,10 +77,13 @@ public class WidgetInfo implements Info, DealWithInfoValue {
} }
} else { } else {
if (isWaterMark()) { if (isWaterMark()) {
updateOldStr(((WaterMark) widget).getWaterMark(), findStr); String str = ((WaterMark) widget).getWaterMark();
((WaterMark) widget).setWaterMark(ShowValueUtils.replaceAll(((WaterMark) widget).getWaterMark(), findStr, replaceStr)); updateOldStr(str, findStr);
ShowValueUtils.updateAfterReplaceStr(info, str, findStr, replaceStr);
((WaterMark) widget).setWaterMark(ShowValueUtils.replaceAll(str, findStr, replaceStr));
} else { } else {
updateOldStr(widget.getWidgetName(), findStr); updateOldStr(widget.getWidgetName(), findStr);
ShowValueUtils.updateAfterReplaceStr(info, widget.getWidgetName(), findStr, replaceStr);
widget.setWidgetName(ShowValueUtils.replaceAll(widget.getWidgetName(), findStr, replaceStr)); widget.setWidgetName(ShowValueUtils.replaceAll(widget.getWidgetName(), findStr, replaceStr));
} }
} }
@ -89,7 +103,9 @@ public class WidgetInfo implements Info, DealWithInfoValue {
*/ */
public WidgetInfo copy(WidgetInfo widgetInfo) { public WidgetInfo copy(WidgetInfo widgetInfo) {
ITContent content = ITContent.copy(widgetInfo.getContent()); ITContent content = ITContent.copy(widgetInfo.getContent());
return new WidgetInfo(content); WidgetInfo info = new WidgetInfo(content);
info.setNeed2Check(widgetInfo.isNeed2Check());
return info;
} }
/** /**
@ -105,6 +121,14 @@ public class WidgetInfo implements Info, DealWithInfoValue {
this.waterMarkFlag = waterMarkFlag; this.waterMarkFlag = waterMarkFlag;
} }
public boolean isNeed2Check() {
return need2Check;
}
public void setNeed2Check(boolean need2Check) {
this.need2Check = need2Check;
}
/** /**
* ReplaceObject是否存在 * ReplaceObject是否存在
* *
@ -125,4 +149,23 @@ public class WidgetInfo implements Info, DealWithInfoValue {
} }
@Override
public Boolean isLegalValid(JTemplate<?, ?> jTemplate,String searchStr, String replaceStr) {
if (StringUtils.isEmpty(replaceStr)) {
this.getContent().setCheckStr(Toolkit.i18nText("Fine-Design_Replace_Not_Empty"));
return false;
}
if (!this.isWaterMark() && this.isNeed2Check()) {
String replacedName = ShowValueUtils.replaceAll(((Widget)this.getContent().getReplaceObject()).getWidgetName(), searchStr, replaceStr);
for (WidgetName name : CheckUtils.getNeed2CheckWidgetsName(jTemplate)) {
String widgetName = name.getName();
if (StringUtils.equals(replacedName, widgetName)) {
this.getContent().setCheckStr(Toolkit.i18nText("Fine-Design_Replace_Exist_Same_Name"));
return false;
}
}
}
return true;
}
} }

55
designer-realize/src/main/java/com/fr/design/actions/replace/info/base/ITContent.java

@ -77,6 +77,23 @@ public class ITContent implements Cloneable {
*/ */
private int tag = -1; private int tag = -1;
/**
* 替换后内容
*/
private String afterReplaceStr;
/**
* 是否替换过
*/
private boolean replaced = false;
/**
*
*/
private String checkStr = StringUtils.EMPTY;
private boolean wrongful = false;
public ITContent() { public ITContent() {
this.sheetID = StringUtils.EMPTY; this.sheetID = StringUtils.EMPTY;
this.sheetName = StringUtils.EMPTY; this.sheetName = StringUtils.EMPTY;
@ -92,6 +109,7 @@ public class ITContent implements Cloneable {
this.operatorArray = new ArrayList<>(); this.operatorArray = new ArrayList<>();
this.holdObject = new Object(); this.holdObject = new Object();
this.templatePath = StringUtils.EMPTY; this.templatePath = StringUtils.EMPTY;
this.afterReplaceStr = StringUtils.EMPTY;
} }
@ -102,7 +120,7 @@ public class ITContent implements Cloneable {
*/ */
public static ITContent copy(ITContent content) { public static ITContent copy(ITContent content) {
ITContent result = new ITContent(); ITContent result = new ITContent();
if (content != null){ if (content != null) {
result.setSheetID(content.getSheetID()); result.setSheetID(content.getSheetID());
result.setSheetName(content.getSheetName()); result.setSheetName(content.getSheetName());
result.setTemplateName(content.getTemplateName()); result.setTemplateName(content.getTemplateName());
@ -120,6 +138,9 @@ public class ITContent implements Cloneable {
result.setHoldObject(content.getHoldObject()); result.setHoldObject(content.getHoldObject());
result.setTag(content.getTag()); result.setTag(content.getTag());
result.setTemplatePath(content.getTemplatePath()); result.setTemplatePath(content.getTemplatePath());
result.setAfterReplaceStr(content.getAfterReplaceStr());
result.setReplaced(content.isReplaced());
result.setWrongful(content.isWrongful());
} }
return result; return result;
} }
@ -216,6 +237,38 @@ public class ITContent implements Cloneable {
this.templatePath = templatePath; this.templatePath = templatePath;
} }
public String getAfterReplaceStr() {
return afterReplaceStr;
}
public void setAfterReplaceStr(String afterReplaceStr) {
this.afterReplaceStr = afterReplaceStr;
}
public boolean isReplaced() {
return replaced;
}
public void setReplaced(boolean replaced) {
this.replaced = replaced;
}
public String getCheckStr() {
return checkStr;
}
public void setCheckStr(String checkStr) {
this.checkStr = checkStr;
}
public boolean isWrongful() {
return wrongful;
}
public void setWrongful(boolean wrongful) {
this.wrongful = wrongful;
}
/** /**
* 添加位置信息 * 添加位置信息
* *

97
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckDialog.java

@ -0,0 +1,97 @@
package com.fr.design.actions.replace.ui;
import com.fr.design.dialog.UIDialog;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.i18n.Toolkit;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static com.fr.design.actions.replace.ui.ITTableEditorPane.getEditTable;
/**
* 合法性校验的面板
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-28
*/
public class ITCheckDialog extends UIDialog {
private UITableEditorPane editorPane;
private ITCheckEditor editor;
private static final int DIALOG_WIDTH = 660, DIALOG_HEIGHT = 400;
private static final int TABLE_WIDTH = 640, TABLE_HEIGHT = 320;
private static final int LABEL_HEIGHT = 20;
public ITCheckDialog() {
super(ITReplaceMainDialog.getInstance());
setModal(true);
setTitle(Toolkit.i18nText("Fine-Design_Replace_Check_Title"));
JPanel centerPanel = new JPanel();
JPanel southPanel = new JPanel();
southPanel.setLayout(new FlowLayout(FlowLayout.RIGHT));
editor = new ITCheckEditor();
editorPane = new UITableEditorPane(editor);
editor.add(ITReplaceMainDialog.getCheckValidList());
UILabel label = new UILabel("<html>" + Toolkit.i18nText("Fine-Design_Replace_Check", "<font color = 'rgb(236,124,125)'>" + ITReplaceMainDialog.contentReplaceFailedCount + "</font>"));
JPanel center = new JPanel(new BorderLayout());
UIButton location = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Location"));
UIButton cancel = new UIButton(Toolkit.i18nText("Fine-Design_Basic_Cancel"));
location.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
for (int i : ITReplaceMainDialog.getSerialNumber()) {
getEditTable().addRowSelectionInterval(i, i);
}
ITCheckDialog.this.dispose();
}
});
cancel.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
ITCheckDialog.this.dispose();
}
});
editorPane.setPreferredSize(new Dimension(TABLE_WIDTH, TABLE_HEIGHT));
label.setPreferredSize(new Dimension(TABLE_WIDTH, LABEL_HEIGHT));
centerPanel.add(editorPane);
southPanel.add(location);
southPanel.add(cancel);
center.add(southPanel, BorderLayout.SOUTH);
center.add(label, BorderLayout.NORTH);
center.add(centerPanel, BorderLayout.CENTER);
center.setVisible(true);
//主体部分
add(center);
setSize(DIALOG_WIDTH, DIALOG_HEIGHT);
setMaximumSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT));
setMinimumSize(new Dimension(DIALOG_WIDTH, DIALOG_HEIGHT));
setLocation(ITReplaceMainDialog.getInstance().getX() + ITReplaceMainDialog.getInstance().getWidth() / 2 - DIALOG_WIDTH / 2, ITReplaceMainDialog.getInstance().getY());
setVisible(true);
}
@Override
public void checkValid() throws Exception {
}
}

64
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITCheckEditor.java

@ -0,0 +1,64 @@
package com.fr.design.actions.replace.ui;
import com.fr.design.actions.replace.info.Info;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.UITableEditAction;
import com.fr.design.gui.itableeditorpane.UITableModelAdapter;
import com.fr.design.i18n.Toolkit;
import java.util.List;
/**
* 合法性校验表格的Model
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-28
*/
public class ITCheckEditor extends UITableModelAdapter {
public ITCheckEditor() {
super(new String[]{
Toolkit.i18nText("Fine-Design_Replace_Check_Content"),
Toolkit.i18nText("Fine-Design_Replace_Check_Reason")
});
this.setColumnClass(new Class[]{
UILabel.class,
UILabel.class,
});
}
@Override
public Object getValueAt(int rowIndex, int columnIndex) {
ITContent content = (ITContent) this.getList().get(rowIndex);
if (columnIndex == 0) {
return content.getShowStr();
} else {
return content.getCheckStr();
}
}
@Override
public boolean isCellEditable(int row, int col) {
return false;
}
@Override
public UITableEditAction[] createAction() {
return new UITableEditAction[0];
}
/**
* 添加数据
*
* @param list
*/
public void add(List<? extends Info> list) {
for (Info info : list) {
addRow(info.getContent());
}
fireTableDataChanged();
}
}

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

@ -1,8 +1,10 @@
package com.fr.design.actions.replace.ui; package com.fr.design.actions.replace.ui;
import com.fr.design.actions.replace.action.ITChecker;
import com.fr.design.actions.replace.action.ShowSearchResultAction; import com.fr.design.actions.replace.action.ShowSearchResultAction;
import com.fr.design.actions.replace.action.setting.SettingController;
import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.info.Info;
import com.fr.design.actions.replace.utils.ShowValueUtils; import com.fr.design.actions.replace.utils.ShowValueUtils;
@ -15,6 +17,8 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.toast.DesignerToastMsgUtil;
import com.fr.design.mainframe.toast.ToastMsgDialog;
import com.fr.general.GeneralUtils; import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -27,11 +31,14 @@ 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;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import static com.fr.design.actions.replace.ui.ITTableEditorPane.editTable;
import static com.fr.design.actions.replace.ui.ITTableEditorPane.getEditTable; import static com.fr.design.actions.replace.ui.ITTableEditorPane.getEditTable;
/** /**
@ -42,7 +49,10 @@ import static com.fr.design.actions.replace.ui.ITTableEditorPane.getEditTable;
* created by Destiny.Lin on 2022-08-10 * created by Destiny.Lin on 2022-08-10
*/ */
public class ITReplaceMainDialog extends UIDialog { public class ITReplaceMainDialog extends UIDialog {
List<? extends Info> searchResultList = new ArrayList<>(); private static List<? extends Info> searchContentResultList = new ArrayList<>();
private static List<? extends Info> searchSettingResultList = new ArrayList<>();
private static List<Info> checkValidList = new ArrayList<>();
private static List<Integer> serialNumber = new ArrayList<>();
private static boolean ITReplaceFlag = false; private static boolean ITReplaceFlag = false;
private static boolean matched = false; private static boolean matched = false;
private static volatile ITReplaceMainDialog instance = null; private static volatile ITReplaceMainDialog instance = null;
@ -53,9 +63,21 @@ public class ITReplaceMainDialog extends UIDialog {
private ITReplaceWestPanel westPanel; private ITReplaceWestPanel westPanel;
private boolean searchFlag; private boolean searchFlag;
private String searchStr; private String searchStr;
private String settingInputStr;
private String settingExtraStr;
private static final int FIRST_ROW = 0; private static final int FIRST_ROW = 0;
private static final int NONE = 0;
public static int selectCount = 0; public static int selectCount = 0;
public static int MAIN_PANEL_WIDTH = 929; public static int MAIN_PANEL_WIDTH = 929;
public static int replaceContentNum = 0;
public static int replaceSettingNum = 0;
public static int contentReplaceCount = 0;
public static int contentReplaceFailedCount = 0;
public static int settingReplaceCount = 0;
public static int settingReplaceFailedCount = 0;
public static final String COMPONENT = Toolkit.i18nText("Fine-Design_Replace_Component");
public static final String WIDGET = Toolkit.i18nText("Fine-Design_Basic_Widget");
public ITReplaceMainDialog() { public ITReplaceMainDialog() {
super(DesignerContext.getDesignerFrame()); super(DesignerContext.getDesignerFrame());
@ -116,6 +138,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());
@ -131,15 +154,14 @@ public class ITReplaceMainDialog extends UIDialog {
((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).addActionListener(new ActionListener() { ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
search(); search4Content();
} }
}); });
northPane.getSearchButton().addActionListener(new ActionListener() { northPane.getSearchButton().addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
search(); search4Content();
} }
}); });
@ -147,11 +169,24 @@ public class ITReplaceMainDialog extends UIDialog {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (isSearchFlag()) { if (isSearchFlag()) {
replace(); replace4Content();
} }
} }
}); });
center.add(northPane.getScrollPane(), BorderLayout.NORTH);
northPane.getSearchSettingButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
search4Setting();
}
});
northPane.getReplaceSettingButton().addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
replace4Setting();
}
});
center.add(ITReplaceNorthPanel.getCardPanel(), BorderLayout.NORTH);
center.add(southPanel.getTableEditorPane(), BorderLayout.CENTER); center.add(southPanel.getTableEditorPane(), BorderLayout.CENTER);
add(westPanel.getLeftPanel(), BorderLayout.WEST); add(westPanel.getLeftPanel(), BorderLayout.WEST);
//主体部分 //主体部分
@ -159,27 +194,42 @@ 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();
}
});
}
/** /**
* 替换 * 模板内容替换相关
*/ */
private void replace() { private void replace4Content() {
String type = ((UITextField) (northPane.getFindCombobox().getEditor().getEditorComponent())).getText();
String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText(); String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText();
String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText(); String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText();
//替换内容为空需要触发搜索 clearContentCount();
if (isITReplaceValid() && checkTemplateChanged(searchResultList)) { if (isITReplaceValid() && checkTemplateChanged(searchContentResultList, type)) {
if (StringUtils.equals(getSearchStr(), searchStr) && StringUtils.isNotEmpty(replaceStr)) { ShowSearchResultAction searchAction = ShowSearchResultAction.match(GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem()));
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true); ITChecker.updateCheckInfo(searchAction.addMatchResult(searchStr, searchAction.showSearchValue(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())));
for (Info info : searchResultList) { if (StringUtils.equals(getSearchStr(), searchStr)) {
if (info.getContent().isSelected()) { String str = GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem());
info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray()); //如果是控件或组件才要进行合法性校验
} if (StringUtils.equals(str, COMPONENT) || StringUtils.equals(str, WIDGET)) {
checkLegalValiditySelector(searchStr, replaceStr);
} else {
replace(searchStr, replaceStr);
} }
southPanel.getTableEditorPane().update(); } else {
northPane.refreshReplaceInputComboBoxItems(); search4Content();
ITTableEditorPane.getEditTable().repaint();
setSearchFlag(false);
} }
search();
} else { } else {
Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")}; Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")};
int optionSelected = FineJOptionPane.showOptionDialog( int optionSelected = FineJOptionPane.showOptionDialog(
@ -187,7 +237,7 @@ public class ITReplaceMainDialog extends UIDialog {
Toolkit.i18nText("Fine-Design_Replace_Message"), Toolkit.i18nText("Fine-Design_Replace_Message"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.ERROR_MESSAGE, JOptionPane.WARNING_MESSAGE,
null, null,
// 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框) // 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框)
options, options,
@ -195,17 +245,118 @@ public class ITReplaceMainDialog extends UIDialog {
); );
//如果选择了重新查找,则再查找一遍 //如果选择了重新查找,则再查找一遍
if (optionSelected == 0) { if (optionSelected == 0) {
search(); search4Content();
}
}
}
/**
* 替换
*
* @param searchStr
* @param replaceStr
*/
public void replace(String searchStr, String replaceStr) {
for (Info info : searchContentResultList) {
if (!info.getContent().isWrongful() && info.getContent().isSelected()) {
info.setValue(info, searchStr, replaceStr, info.getContent().getOperatorArray());
}
if (info.getContent().isSelected()) {
info.getContent().setReplaced(true);
}
}
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true);
northPane.getResultLabel().setText(ShowValueUtils.getResultTip(searchContentResultList.size(), contentReplaceCount, contentReplaceFailedCount));
southPanel.getTableEditorPane().update();
northPane.refreshReplaceInputComboBoxItems();
ITTableEditorPane.getEditTable().repaint();
}
/**
* 合法性校验选择器选择是否进行校验
*/
public void checkLegalValiditySelector(String searchStr, String replaceStr) {
Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Go_To_Check"), Toolkit.i18nText("Fine-Design_Replace_Direct")};
int optionSelected = FineJOptionPane.showOptionDialog(
ITReplaceMainDialog.this,
Toolkit.i18nText("Fine-Design_Replace_Legal"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
// 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框)
options,
options[0]
);
updateCheckValidList();
//如果选择了直接替换,则直接执行替换
if (optionSelected == 1) {
replace(searchStr, replaceStr);
} else {
checkLegalValidity();
}
}
/**
* 检测
*/
public void checkLegalValidity() {
if (contentReplaceFailedCount == 0) {
ToastMsgDialog dialog = DesignerToastMsgUtil.createPromptDialog(Toolkit.i18nText("Fine-Design_Replace_Check_None"));
dialog.setVisible(true);
} else {
new ITCheckDialog();
}
}
private void updateCheckValidList() {
checkValidList.clear();
serialNumber.clear();
int count = 0;
String searchStr = ((UITextField) (northPane.getFindInputCombobox().getEditor().getEditorComponent())).getText();
String replaceStr = ((UITextField) (northPane.getReplaceInputCombobox().getEditor().getEditorComponent())).getText();
for (Info info : searchContentResultList) {
if (isAllow2Replace(info)) {
if (!info.isLegalValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(), searchStr, replaceStr)) {
contentReplaceFailedCount++;
checkValidList.add(info);
serialNumber.add(count);
info.getContent().setWrongful(true);
info.getContent().setReplaced(true);
} else {
contentReplaceCount++;
}
count++;
} }
} }
southPanel.getTableEditorPane().update();
ITTableEditorPane.getEditTable().repaint();
}
/**
* 是否能够替换
*
* @param info 存储信息的数据结构
* @return 能则返回true
*/
private boolean isAllow2Replace(Info info) {
return info.getContent().isSelected() && !info.getContent().isReplaced();
} }
private Boolean checkTemplateChanged(List<? extends Info> searchResultList) {
for (Info info : searchResultList) { private Boolean checkTemplateChanged(List<? extends Info> searchResultList, String type) {
if (!info.checkValid()) { ITChecker checker = ITChecker.match(type);
return false; //对于JS、控件、组件、公式进行全量校验,不只针对当前选中的地方,这边先这样处理
if (checker != null) {
ShowSearchResultAction searchAction = ShowSearchResultAction.match(GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem()));
return !checker.isChanged(searchAction.addMatchResult(searchStr, searchAction.showSearchValue(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())));
} else {
//其他地方走各自的校验逻辑
for (Info info : searchResultList) {
if (!info.getContent().isReplaced() && !info.checkValid()) {
return false;
}
} }
} }
return true; return true;
@ -281,10 +432,11 @@ public class ITReplaceMainDialog extends UIDialog {
} }
/** /**
* 搜索 * 搜索模板内容
*/ */
public void search() { public void search4Content() {
ITTableEditor itTableEditor = southPanel.getItTableEditor(); ITTableEditor itTableEditor = southPanel.getItTableEditor();
clearContentCount();
if (JTemplate.isValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) { if (JTemplate.isValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) {
JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate jTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
templateID = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID(); templateID = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID();
@ -299,24 +451,27 @@ public class ITReplaceMainDialog extends UIDialog {
ShowSearchResultAction searchAction = ShowSearchResultAction.match(GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem())); ShowSearchResultAction searchAction = ShowSearchResultAction.match(GeneralUtils.objectToString(northPane.getFindCombobox().getSelectedItem()));
//搜索 //搜索
if (searchAction != null) { if (searchAction != null) {
searchResultList = searchAction.addMatchResult(searchStr, searchAction.showSearchValue(jTemplate)); List<? extends Info> showValueList = searchAction.showSearchValue(jTemplate);
itTableEditor.add(searchResultList); searchContentResultList = searchAction.addMatchResult(searchStr, showValueList);
northPane.getResultLabel().setText("<html>" + Toolkit.i18nText("Fine-Design_Replace_Search_Finish") + "<font color = 'rgb(61,153,249)'>" + searchResultList.size() + "</font>" + Toolkit.i18nText("Fine-Design_Replace_Result")); ITChecker.updateCheckInfo(searchContentResultList);
itTableEditor.add(searchContentResultList);
northPane.getResultLabel().setText(ShowValueUtils.getResultTip(searchContentResultList.size(), contentReplaceCount, contentReplaceFailedCount));
} }
replaceContentNum = 0;
ITTableEditorPane.ITHeaderRenderer renderer = (ITTableEditorPane.ITHeaderRenderer) getEditTable().getTableHeader().getDefaultRenderer(); ITTableEditorPane.ITHeaderRenderer renderer = (ITTableEditorPane.ITHeaderRenderer) getEditTable().getTableHeader().getDefaultRenderer();
//刷新表头,并且重新勾选中表头全选框 //刷新表头,并且重新勾选中表头全选框
renderer.refreshHeader(getEditTable(), true); renderer.refreshHeader(getEditTable(), true);
itTableEditor.fireTableDataChanged(); itTableEditor.fireTableDataChanged();
northPane.refreshFindInputComboBoxItems(); northPane.refreshFindInputComboBoxItems();
setSearchFlag(true); setSearchFlag(true);
selectCount = searchResultList.size(); selectCount = searchContentResultList.size();
//如果有结果,默认选中第一行 //如果有结果,默认选中第一行
if (searchResultList.size() > 0) { if (searchContentResultList.size() > 0) {
getEditTable().addRowSelectionInterval(FIRST_ROW, FIRST_ROW); getEditTable().addRowSelectionInterval(FIRST_ROW, FIRST_ROW);
} }
//更新替换按钮可用性 //更新替换按钮可用性
if (StringUtils.isEmpty(searchStr) || searchResultList.size() == 0) { if (StringUtils.isEmpty(searchStr) || searchContentResultList.size() == 0) {
northPane.getReplaceButton().setEnabled(false); northPane.getReplaceButton().setEnabled(false);
} else { } else {
northPane.getReplaceButton().setEnabled(true); northPane.getReplaceButton().setEnabled(true);
@ -330,6 +485,129 @@ public class ITReplaceMainDialog extends UIDialog {
} }
/**
* 搜索设置项
*/
public void search4Setting() {
ITTableEditor settingEditor = southPanel.getItTableEditor();
templateID = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget().getTemplateID();
templateName = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTemplateName();
clearSettingCount();
if (JTemplate.isValid(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate())) {
String firstStr = GeneralUtils.objectToString(northPane.getFindSettingComboBox().getSelectedItem());
String secondStr = GeneralUtils.objectToString(northPane.getFindSettingInputComboBox().getSelectedItem());
String thirdStr = GeneralUtils.objectToString(northPane.getFindExtraSettingComboBox().getSelectedItem());
setSettingInputStr(secondStr);
setSettingExtraStr(thirdStr);
SettingController controller = SettingController.match(firstStr);
if (controller != null) {
searchSettingResultList = controller.addMatchResult(controller.showSearchValue(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate()), secondStr, thirdStr);
settingEditor.clear();
settingEditor.add(searchSettingResultList);
ITTableEditorPane.ITHeaderRenderer renderer = (ITTableEditorPane.ITHeaderRenderer) getEditTable().getTableHeader().getDefaultRenderer();
renderer.refreshHeader(getEditTable(), true);
settingEditor.fireTableDataChanged();
}
//如果有结果,默认选中第一行
if (searchSettingResultList.size() > 0) {
getEditTable().addRowSelectionInterval(FIRST_ROW, FIRST_ROW);
}
northPane.getSettingResultLabel().setText(ShowValueUtils.getResultTip(searchSettingResultList.size(), settingReplaceCount, settingReplaceFailedCount));
}
}
/**
* 替换设置项
*/
public void replace4Setting() {
String firstStr = GeneralUtils.objectToString(northPane.getFindSettingComboBox().getSelectedItem());
String inputStr = GeneralUtils.objectToString(northPane.getFindSettingInputComboBox().getSelectedItem());
String extraStr = GeneralUtils.objectToString(northPane.getFindExtraSettingComboBox().getSelectedItem());
clearSettingCount();
if (isITReplaceValid() && !isSettingEverChanged(searchSettingResultList, firstStr, inputStr, extraStr)) {
if (isInputStrValid(inputStr, extraStr)) {
String secondStr = GeneralUtils.objectToString(northPane.getReplaceSettingInputComboBox().getSelectedItem());
String thirdStr = GeneralUtils.objectToString(northPane.getReplaceExtraSettingComboBox().getSelectedItem());
for (Info info : searchSettingResultList) {
if (isSupportReplace(info)) {
SettingController controller = SettingController.match(firstStr);
if (controller != null) {
controller.replace(info, secondStr, thirdStr);
info.getContent().setReplaced(true);
settingReplaceCount++;
}
}
}
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().fireTargetModified(true);
northPane.getSettingResultLabel().setText(ShowValueUtils.getResultTip(searchSettingResultList.size(), settingReplaceCount, settingReplaceFailedCount));
southPanel.getTableEditorPane().update();
ITTableEditorPane.getEditTable().repaint();
} else {
search4Setting();
}
} else {
Object[] options = new Object[]{Toolkit.i18nText("Fine-Design_Replace_Search_Again"), Toolkit.i18nText("Fine-Design_Basic_Cancel")};
int optionSelected = FineJOptionPane.showOptionDialog(
ITReplaceMainDialog.this,
Toolkit.i18nText("Fine-Design_Replace_Message"),
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.YES_NO_CANCEL_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
// 如果传null, 则按钮为 optionType 类型所表示的按钮(也就是确认对话框)
options,
options[0]
);
//如果选择了重新查找,则再查找一遍
if (isSelectSearch(optionSelected)) {
search4Setting();
}
}
}
private boolean isSupportReplace(Info info) {
return info.getContent().isSelected() && !info.getContent().isReplaced();
}
private boolean isSelectSearch(int optionSelected) {
return optionSelected == NONE;
}
/**
* 用户的输入是否更改
*
* @param inputStr 用户的一级输入框
* @param extraStr 用户的二级输入框
* @return 没更改过返回true
*/
public boolean isInputStrValid(String inputStr, String extraStr) {
return StringUtils.equals(inputStr, getSettingInputStr()) && StringUtils.equals(extraStr, getSettingExtraStr());
}
/**
* 设置项的内容是否更改过
*
* @param searchSettingResultList 数据
* @param controllerMatch controller的类型
* @param inputStr 用户的一级输入框
* @param extraStr 用户的二级输入框
* @return 更改过返回true
*/
public boolean isSettingEverChanged(List<? extends Info> searchSettingResultList, String controllerMatch, String inputStr, String extraStr) {
for (Info info : searchSettingResultList) {
if (info.getContent().isSelected() && !info.getContent().isReplaced()) {
SettingController controller = SettingController.match(controllerMatch);
if (controller != null && controller.isEverChanged(info, inputStr, extraStr)) {
return true;
}
}
}
return false;
}
public ITReplaceSouthPanel getSouthPanel() { public ITReplaceSouthPanel getSouthPanel() {
return southPanel; return southPanel;
} }
@ -346,10 +624,105 @@ public class ITReplaceMainDialog extends UIDialog {
this.northPane = northPane; this.northPane = northPane;
} }
public String getSettingInputStr() {
return settingInputStr;
}
public void setSettingInputStr(String settingInputStr) {
this.settingInputStr = settingInputStr;
}
public String getSettingExtraStr() {
return settingExtraStr;
}
public void setSettingExtraStr(String settingExtraStr) {
this.settingExtraStr = settingExtraStr;
}
/**
* 获取不合法的序号
*
* @return 不合法的元素的序号列表
*/
public static List<Integer> getSerialNumber() {
return serialNumber;
}
/** /**
* 检测结果是否合法 * 检测结果是否合法
*/ */
@Override @Override
public void checkValid() throws Exception { public void checkValid() throws Exception {
} }
/**
* 获取模板内容数据
*
* @return 存储数据的list
*/
public static List<? extends Info> getSearchContentResultList() {
return searchContentResultList;
}
/**
* 设置模板内容数据
*
* @param searchContentResultList 模板内容表格的数据
*/
public static void setSearchContentResultList(List<? extends Info> searchContentResultList) {
ITReplaceMainDialog.searchContentResultList = searchContentResultList;
}
/**
* 获取设置项数据
*
* @return 存储数据的list
*/
public static List<? extends Info> getSearchSettingResultList() {
return searchSettingResultList;
}
/**
* 设置设置项的数据
*
* @param searchSettingResultList 设置项表格的数据
*/
public static void setSearchSettingResultList(List<? extends Info> searchSettingResultList) {
ITReplaceMainDialog.searchSettingResultList = searchSettingResultList;
}
/**
* 获取检测的列表
*
* @return
*/
public static List<Info> getCheckValidList() {
return checkValidList;
}
/**
* 设置检测列表
*
* @param checkValidList
*/
public static void setCheckValidList(List<Info> checkValidList) {
ITReplaceMainDialog.checkValidList = checkValidList;
}
/**
* 重置计数
*/
public void clearContentCount() {
contentReplaceCount = NONE;
contentReplaceFailedCount = NONE;
}
/**
* 重置计数
*/
public void clearSettingCount() {
settingReplaceCount = NONE;
settingReplaceFailedCount = NONE;
}
} }

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

@ -1,12 +1,17 @@
package com.fr.design.actions.replace.ui; package com.fr.design.actions.replace.ui;
import com.fr.base.svg.IconUtils; import com.fr.base.svg.IconUtils;
import com.fr.design.actions.replace.action.setting.SettingContent;
import com.fr.design.actions.replace.action.setting.SettingController;
import com.fr.design.data.datapane.TableDataComboBox;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -16,11 +21,17 @@ import javax.swing.Icon;
import javax.swing.JCheckBox; import javax.swing.JCheckBox;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.ScrollPaneConstants; import javax.swing.ScrollPaneConstants;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.CardLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List;
/** /**
* 上面板 * 上面板
@ -30,20 +41,41 @@ import java.util.Collections;
* created by Destiny.Lin on 2022-09-01 * created by Destiny.Lin on 2022-09-01
*/ */
public class ITReplaceNorthPanel { public class ITReplaceNorthPanel {
private JPanel upPanel; private JPanel upContentPanel;
private JPanel upSettingPanel;
private static JPanel cardPanel;
private static CardLayout cardLayout;
//content
private UILabel findLabel; private UILabel findLabel;
private UILabel rangeLabel; private UILabel rangeLabel;
private UILabel resultLabel; private UILabel resultLabel;
private UIComboBox findCombobox; private UIComboBox findCombobox;
private UIComboBox rangeCombobox; private UIComboBox rangeCombobox;
private JCheckBox matchRadioButton; private UICheckBox matchRadioButton;
private UILabel iconLabel; private UILabel iconLabel;
private UIComboBox findInputCombobox; private UIComboBox findInputCombobox;
private UIComboBox replaceInputCombobox; private UIComboBox replaceInputCombobox;
private UIScrollPane scrollPane; private UIScrollPane contentScrollPane;
private UIScrollPane settingScrollPane;
private UIButton replaceButton; private UIButton replaceButton;
private UIButton searchButton; private UIButton searchButton;
//setting
private UILabel iconSettingLabel;
private UILabel findSettingLabel;
private UILabel rangeSettingLabel;
private UILabel settingResultLabel;
private UIComboBox rangeSettingComboBox;
private UIComboBox findSettingComboBox;
private UIComboBox findSettingInputComboBox;
private UIComboBox replaceSettingInputComboBox;
private UIComboBox findExtraSettingComboBox;
private UIComboBox replaceExtraSettingComboBox;
private TableDataComboBox tableDataComboBox;
private UIButton replaceSettingButton;
private UIButton searchSettingButton;
private static double rate = 1.00; private static double rate = 1.00;
//存储的5次最近输入 //存储的5次最近输入
@ -59,6 +91,10 @@ public class ITReplaceNorthPanel {
private static final int FIRST_X = 20, SECOND_X = 80; private static final int FIRST_X = 20, SECOND_X = 80;
private static final int LABEL_WIDTH = 60; private static final int LABEL_WIDTH = 60;
private static final Icon CHANGE_ICON = IconUtils.readIcon("/com/fr/design/images/replace/change_normal.svg"); private static final Icon CHANGE_ICON = IconUtils.readIcon("/com/fr/design/images/replace/change_normal.svg");
private static final String[] RANGE_ITEMS = new String[]{Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")};
public static final String CARD_CONTENT = "Content";
public static final String CARD_SETTING = "setting";
private int findLabelX, findLabelY, findLabelWidth, findLabelHeight; private int findLabelX, findLabelY, findLabelWidth, findLabelHeight;
@ -74,9 +110,14 @@ public class ITReplaceNorthPanel {
private int iconX, iconY, iconWidth, iconHeight; private int iconX, iconY, iconWidth, iconHeight;
private int inputLength; private int inputLength;
public static ArrayList<String> findItems = new ArrayList<>(); public static List<String> findItems = new ArrayList<>();
public static ArrayList<String> findInputItems = new ArrayList<>(); public static List<String> findSettingItems = new ArrayList<>();
public static ArrayList<String> replaceInputItems = new ArrayList<>(); public static List<String> findInputItems = new ArrayList<>();
public static List<String> replaceInputItems = new ArrayList<>();
public static List<String> formatItems = new ArrayList<>();
public static List<String> digitItems = new ArrayList<>();
public static List<String> groupItems = new ArrayList<>();
public static List<String> dsColumnItems = new ArrayList<>();
static { static {
findItems.add(Toolkit.i18nText("Fine-Design_Basic_Cell")); findItems.add(Toolkit.i18nText("Fine-Design_Basic_Cell"));
@ -86,20 +127,69 @@ public class ITReplaceNorthPanel {
findItems.add(Toolkit.i18nText("Fine-Design_Replace_Component")); findItems.add(Toolkit.i18nText("Fine-Design_Replace_Component"));
findItems.add(Toolkit.i18nText("Fine-Design_Basic_Widget")); findItems.add(Toolkit.i18nText("Fine-Design_Basic_Widget"));
findItems.add(Toolkit.i18nText("Fine-Design_Basic_Formula")); findItems.add(Toolkit.i18nText("Fine-Design_Basic_Formula"));
findSettingItems.add(SettingContent.CELL_FORMAT_NAME);
findSettingItems.add(SettingContent.CELL_DATA_SETTING_NAME);
findSettingItems.add(SettingContent.CELL_DS_COLUMN_NAME);
findSettingItems.add(SettingContent.DATASOURCE_CONNECTION_NAME);
findSettingItems.add(SettingContent.DATASOURCE_COLLECT_NAME);
formatItems.add(SettingContent.FORMAT_COMMON);
formatItems.add(SettingContent.FORMAT_NUMBER);
formatItems.add(SettingContent.FORMAT_MONEY);
formatItems.add(SettingContent.FORMAT_PERCENT);
formatItems.add(SettingContent.FORMAT_PERMILLAGE);
formatItems.add(SettingContent.FORMAT_SCIENCE);
formatItems.add(SettingContent.FORMAT_DATE);
formatItems.add(SettingContent.FORMAT_TIME);
formatItems.add(SettingContent.FORMAT_TEXT);
digitItems.add(SettingContent.DIGIT_SETTING_GROUP);
digitItems.add(SettingContent.DIGIT_SETTING_LIST);
digitItems.add(SettingContent.DIGIT_SETTING_SUM);
groupItems.add(SettingContent.GROUP_COMMON);
groupItems.add(SettingContent.GROUP_CONTINUUM);
dsColumnItems.add(SettingContent.CONNECTION_TEMPLATE);
} }
public ITReplaceNorthPanel() { public ITReplaceNorthPanel() {
upPanel = new JPanel(null); cardLayout = new CardLayout();
cardPanel = new JPanel(cardLayout);
upContentPanel = new JPanel(null);
upSettingPanel = new JPanel(null);
initContentPanel();
initSettingPanel();
cardPanel.add(contentScrollPane, CARD_CONTENT);
cardPanel.add(settingScrollPane, CARD_SETTING);
}
/**
* 限制尺寸
*
* @param width
*/
public void setLimitSize(int width) {
upContentPanel.setMaximumSize(new Dimension(limit_width, HEIGHT));
upContentPanel.setPreferredSize(new Dimension(limit_width, HEIGHT));
}
/**
* 初始化模板内容查找面板
*/
public void initContentPanel() {
findLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Element")); findLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Element"));
rangeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Range")); rangeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Range"));
iconLabel = new UILabel(CHANGE_ICON); iconLabel = new UILabel(CHANGE_ICON);
resultLabel = new UILabel(); resultLabel = new UILabel();
String[] rangeItems = new String[]{Toolkit.i18nText("Fine-Design_Basic_Export_JS_Template_Current")};
String[] replaceInputItems = new String[]{StringUtils.EMPTY}; String[] replaceInputItems = new String[]{StringUtils.EMPTY};
findCombobox = new UIComboBox(findItems.toArray()); findCombobox = new UIComboBox(findItems.toArray());
rangeCombobox = new UIComboBox(rangeItems); rangeCombobox = new UIComboBox(RANGE_ITEMS);
findInputCombobox = new UIComboBox(findInputItems.toArray()) { findInputCombobox = new UIComboBox(findInputItems.toArray()) {
@Override @Override
public void setEditor(ComboBoxEditor comboBoxEditor) { public void setEditor(ComboBoxEditor comboBoxEditor) {
@ -112,7 +202,7 @@ public class ITReplaceNorthPanel {
super.setEditor(new ITComboBoxEditor()); super.setEditor(new ITComboBoxEditor());
} }
}; };
matchRadioButton = new JCheckBox(Toolkit.i18nText("Fine-Design_Replace_WildCard")); matchRadioButton = new UICheckBox(Toolkit.i18nText("Fine-Design_Replace_WildCard"));
matchRadioButton.addActionListener(new ActionListener() { matchRadioButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
@ -122,32 +212,235 @@ public class ITReplaceNorthPanel {
replaceButton = new UIButton(Toolkit.i18nText("Fine-Design_Replace_Button")); replaceButton = new UIButton(Toolkit.i18nText("Fine-Design_Replace_Button"));
searchButton = new UIButton(Toolkit.i18nText("Fine-Design_Search_Button")); searchButton = new UIButton(Toolkit.i18nText("Fine-Design_Search_Button"));
upPanel.setPreferredSize(new Dimension(limit_width, HEIGHT)); upContentPanel.setPreferredSize(new Dimension(limit_width, HEIGHT));
scrollPane = new UIScrollPane(upPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); contentScrollPane = new UIScrollPane(upContentPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
upPanel.add(findLabel); upContentPanel.add(findLabel);
upPanel.add(rangeLabel); upContentPanel.add(rangeLabel);
upPanel.add(resultLabel); upContentPanel.add(resultLabel);
upPanel.add(findCombobox); upContentPanel.add(findCombobox);
upPanel.add(rangeCombobox); upContentPanel.add(rangeCombobox);
upPanel.add(findInputCombobox); upContentPanel.add(findInputCombobox);
upPanel.add(replaceInputCombobox); upContentPanel.add(replaceInputCombobox);
upPanel.add(matchRadioButton); upContentPanel.add(matchRadioButton);
upPanel.add(replaceButton); upContentPanel.add(replaceButton);
upPanel.add(searchButton); upContentPanel.add(searchButton);
upPanel.add(iconLabel); upContentPanel.add(iconLabel);
scrollPane.setBorder(BorderFactory.createEmptyBorder()); contentScrollPane.setBorder(BorderFactory.createEmptyBorder());
} }
/** /**
* 限制尺寸 * 初始化设置项查找面板
*/
public void initSettingPanel() {
findSettingLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Element"));
rangeSettingLabel = new UILabel(Toolkit.i18nText("Fine-Design_Replace_Search_Range"));
settingResultLabel = new UILabel();
findSettingComboBox = new UIComboBox(findSettingItems.toArray());
rangeSettingComboBox = new UIComboBox(RANGE_ITEMS);
findSettingInputComboBox = new UIComboBox(formatItems.toArray()) {
@Override
public void setEditor(ComboBoxEditor anEditor) {
super.setEditor(new ITComboBoxEditor());
}
};
findSettingInputComboBox.setSelectedIndex(-1);
replaceSettingInputComboBox = new UIComboBox(formatItems.toArray()) {
@Override
public void setEditor(ComboBoxEditor anEditor) {
super.setEditor(new ITComboBoxEditor());
}
};
replaceSettingInputComboBox.setSelectedIndex(-1);
updateSettingPlaceholder(SettingContent.CELL_FORMAT_NAME);
findSettingInputComboBox.setEditable(true);
((UITextField) (findSettingInputComboBox.getEditor().getEditorComponent())).setEditable(false);
replaceSettingInputComboBox.setEditable(true);
((UITextField) (replaceSettingInputComboBox.getEditor().getEditorComponent())).setEditable(false);
iconSettingLabel = new UILabel(CHANGE_ICON);
findExtraSettingComboBox = new UIComboBox(groupItems.toArray());
findExtraSettingComboBox.setVisible(false);
replaceExtraSettingComboBox = new UIComboBox(groupItems.toArray());
replaceExtraSettingComboBox.setVisible(false);
searchSettingButton = new UIButton(Toolkit.i18nText("Fine-Design_Search_Button"));
replaceSettingButton = new UIButton(Toolkit.i18nText("Fine-Design_Replace_Button"));
replaceSettingButton.setEnabled(false);
upSettingPanel.setPreferredSize(new Dimension(limit_width, HEIGHT));
upSettingPanel.add(findSettingLabel);
upSettingPanel.add(rangeSettingLabel);
upSettingPanel.add(findSettingComboBox);
upSettingPanel.add(rangeSettingComboBox);
upSettingPanel.add(findSettingInputComboBox);
upSettingPanel.add(replaceSettingInputComboBox);
upSettingPanel.add(iconSettingLabel);
upSettingPanel.add(findExtraSettingComboBox);
upSettingPanel.add(replaceExtraSettingComboBox);
upSettingPanel.add(searchSettingButton);
upSettingPanel.add(replaceSettingButton);
upSettingPanel.add(settingResultLabel);
settingScrollPane = new UIScrollPane(upSettingPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
settingScrollPane.setBorder(BorderFactory.createEmptyBorder());
initListener();
}
/**
* 初始化事件
*/
private void initListener() {
findSettingComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
replaceSettingInputComboBox.clearBoxItems();
findSettingInputComboBox.clearBoxItems();
String str = GeneralUtils.objectToString(findSettingComboBox.getSelectedItem());
((UITextField) findSettingInputComboBox.getEditor().getEditorComponent()).setText(StringUtils.EMPTY);
refreshSettingComboBox(SettingController.getSettingRefreshItems(str));
setDataSourceComboBoxStatus(isAllow2Replace());
replaceSettingButton.setEnabled(false);
updateSettingPlaceholder(str);
}
});
findSettingInputComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
refreshExtraComboBox(findSettingInputComboBox, findExtraSettingComboBox);
}
});
replaceSettingInputComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
refreshExtraComboBox(replaceSettingInputComboBox, replaceExtraSettingComboBox);
}
});
initInputComboBoxPopupListener(findSettingInputComboBox);
initInputComboBoxPopupListener(replaceSettingInputComboBox);
}
private void initInputComboBoxPopupListener(UIComboBox box) {
box.addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
String str = GeneralUtils.objectToString(findSettingComboBox.getSelectedItem());
int findExtraIndex = findExtraSettingComboBox.getSelectedIndex();
int replaceExtraIndex = replaceExtraSettingComboBox.getSelectedIndex();
box.refreshBoxItems(SettingController.getSettingRefreshItems(str));
dealExtraItemSelect(findExtraSettingComboBox, findExtraIndex);
dealExtraItemSelect(replaceExtraSettingComboBox, replaceExtraIndex);
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
}
});
}
/**
* 重新设置额外下拉框的选中索引
* @param comboBox 额外下拉框
* @param index 索引
*/
private void dealExtraItemSelect(UIComboBox comboBox, int index) {
if (comboBox.getItemCount() > index) {
comboBox.setSelectedIndex(index);
}
}
/**
* 刷新替换按钮状态
*/
public void refreshSettingReplaceButtonStatus() {
replaceSettingButton.setEnabled(isAllChoose());
}
/**
* 是否各个选项都有选中内容
* *
* @param width * @return 是则返回true
*/ */
public void setLimitSize(int width) { public boolean isAllChoose() {
upPanel.setMaximumSize(new Dimension(limit_width, 161)); String str = GeneralUtils.objectToString(findSettingComboBox.getSelectedItem());
upPanel.setPreferredSize(new Dimension(limit_width, 161)); String findInputStr = GeneralUtils.objectToString(findSettingInputComboBox.getSelectedItem());
String replaceInputStr = GeneralUtils.objectToString(replaceSettingInputComboBox.getSelectedItem());
String findExtraStr = GeneralUtils.objectToString(findExtraSettingComboBox.getSelectedItem());
String replaceExtraStr = GeneralUtils.objectToString(replaceExtraSettingComboBox.getSelectedItem());
return (!StringUtils.equals(str, SettingContent.DATASOURCE_COLLECT_NAME) && !StringUtils.equals(str, SettingContent.DATASOURCE_CONNECTION_NAME))
&& StringUtils.isNotEmpty(findInputStr)
&& StringUtils.isNotEmpty(replaceInputStr)
&& StringUtils.isNotEmpty(findExtraStr)
&& StringUtils.isNotEmpty(replaceExtraStr);
}
/**
* 是否支持替换
*
* @return 支持返回true
*/
public boolean isAllow2Replace() {
String str = GeneralUtils.objectToString(findSettingComboBox.getSelectedItem());
return !StringUtils.equals(str, SettingContent.DATASOURCE_CONNECTION_NAME) && !StringUtils.equals(str, SettingContent.DATASOURCE_COLLECT_NAME);
} }
/**
* 设置数据集相关情况下的替换框的状态
*
* @param status
*/
public void setDataSourceComboBoxStatus(boolean status) {
replaceSettingButton.setEnabled(status);
replaceSettingInputComboBox.setEnabled(status);
replaceExtraSettingComboBox.setEnabled(status);
}
/**
* 刷新延展出的下拉框第三层
*
* @param settingComboBox
* @param extraComboBox
*/
public void refreshExtraComboBox(UIComboBox settingComboBox, UIComboBox extraComboBox) {
String str = GeneralUtils.objectToString(findSettingComboBox.getSelectedItem());
String parent = GeneralUtils.objectToString(settingComboBox.getSelectedItem());
if (StringUtils.isNotEmpty(parent) && SettingController.match(str) != null && SettingController.match(str).hasExpand(str, parent)) {
extraComboBox.clearBoxItems();
extraComboBox.setVisible(true);
extraComboBox.refreshBoxItems(SettingController.getSettingExtraRefreshItems(str, parent));
extraComboBox.setSelectedIndex(0);
} else {
extraComboBox.setVisible(false);
}
refreshSettingReplaceButtonStatus();
}
/**
* 刷新用户选择的输入框第二层
*
* @param list
*/
public void refreshSettingComboBox(List<String> list) {
findSettingInputComboBox.clearBoxItems();
findSettingInputComboBox.refreshBoxItems(list);
replaceSettingInputComboBox.clearBoxItems();
replaceSettingInputComboBox.refreshBoxItems(list);
replaceExtraSettingComboBox.setVisible(false);
findExtraSettingComboBox.setVisible(false);
}
/** /**
* 适配屏幕 * 适配屏幕
@ -162,7 +455,50 @@ public class ITReplaceNorthPanel {
templateWidth = templateWidth - ITReplaceWestPanel.LEFT_WIDTH; templateWidth = templateWidth - ITReplaceWestPanel.LEFT_WIDTH;
inputLength = (templateWidth - GAP * 5) / 2; inputLength = (templateWidth - GAP * 5) / 2;
fitContentScreen(templateWidth);
fitSettingScreen(templateWidth);
}
/**
* 适配屏幕
*
* @param templateWidth 当前设计器宽度
*/
private void fitSettingScreen(int templateWidth) {
findSettingLabel.setBounds(FIRST_X, FIRST_Y, LABEL_WIDTH, COMPONENT_HEIGHT);
findSettingComboBox.setBounds(SECOND_X, FIRST_Y, inputLength - 4 * GAP, COMPONENT_HEIGHT);
rangeSettingLabel.setBounds(replaceInputComboBoxX, FIRST_Y, LABEL_WIDTH, COMPONENT_HEIGHT);
rangeSettingComboBox.setBounds(rangeLabelX + rangeLabelWidth, FIRST_Y, inputLength - 3 * GAP, COMPONENT_HEIGHT);
findSettingInputComboBox.setBounds(FIRST_X, SECOND_Y, inputLength - GAP, COMPONENT_HEIGHT);
replaceSettingInputComboBox.setBounds(templateWidth - inputLength - GAP * 2, SECOND_Y, inputLength, COMPONENT_HEIGHT);
iconSettingLabel.setBounds(iconX, iconY, iconWidth, iconHeight);
searchSettingButton.setBounds(searchButtonX, searchButtonY, BUTTON_WIDTH, searchButtonHeight);
replaceSettingButton.setBounds(replaceButtonX, replaceButtonY, BUTTON_WIDTH, replaceButtonHeight);
settingResultLabel.setBounds(resultLabelX, resultLabelY, resultLabelWidth, resultLabelHeight);
setExtraBounds(templateWidth);
}
/**
* 设置额外的输入框
*
* @param templateWidth 当前设计器宽度
*/
private void setExtraBounds(int templateWidth) {
findExtraSettingComboBox.setBounds(FIRST_X, THIRD_Y, inputLength - GAP, COMPONENT_HEIGHT);
replaceExtraSettingComboBox.setBounds(templateWidth - inputLength - GAP * 2, THIRD_Y, inputLength, COMPONENT_HEIGHT);
}
/**
* 模板内容查找面板适配屏幕
*
* @param templateWidth 当前设计器宽度
*/
private void fitContentScreen(int templateWidth) {
setFindLabelBounds(); setFindLabelBounds();
setResultLabelBounds(templateWidth); setResultLabelBounds(templateWidth);
setFindComboboxBounds(); setFindComboboxBounds();
@ -174,7 +510,6 @@ public class ITReplaceNorthPanel {
setReplaceButtonBounds(); setReplaceButtonBounds();
setSearchButtonBounds(); setSearchButtonBounds();
setIconLabelBounds(); setIconLabelBounds();
} }
@ -221,12 +556,12 @@ public class ITReplaceNorthPanel {
} }
public UIScrollPane getScrollPane() { public UIScrollPane getContentScrollPane() {
return scrollPane; return contentScrollPane;
} }
public void setScrollPane(UIScrollPane scrollPane) { public void setContentScrollPane(UIScrollPane contentScrollPane) {
this.scrollPane = scrollPane; this.contentScrollPane = contentScrollPane;
} }
private void setIconLabelBounds() { private void setIconLabelBounds() {
@ -320,12 +655,12 @@ public class ITReplaceNorthPanel {
findLabel.setBounds(findLabelX, findLabelY, findLabelWidth, findLabelHeight); findLabel.setBounds(findLabelX, findLabelY, findLabelWidth, findLabelHeight);
} }
public JPanel getUpPanel() { public JPanel getUpContentPanel() {
return upPanel; return upContentPanel;
} }
public void setUpPanel(JPanel upPanel) { public void setUpContentPanel(JPanel upContentPanel) {
this.upPanel = upPanel; this.upContentPanel = upContentPanel;
} }
public UILabel getFindLabel() { public UILabel getFindLabel() {
@ -368,11 +703,11 @@ public class ITReplaceNorthPanel {
this.rangeCombobox = rangeCombobox; this.rangeCombobox = rangeCombobox;
} }
public JCheckBox getMatchRadioButton() { public UICheckBox getMatchRadioButton() {
return matchRadioButton; return matchRadioButton;
} }
public void setMatchRadioButton(JCheckBox checkBox) { public void setMatchRadioButton(UICheckBox checkBox) {
this.matchRadioButton = checkBox; this.matchRadioButton = checkBox;
} }
@ -407,4 +742,103 @@ public class ITReplaceNorthPanel {
public void setSearchButton(UIButton searchButton) { public void setSearchButton(UIButton searchButton) {
this.searchButton = searchButton; this.searchButton = searchButton;
} }
/**
* 获取CardLayout
* @return CardLayout
*/
public static CardLayout getCardLayout() {
return cardLayout;
}
/**
* 获取表格主界面
*
* @return cardPanel
*/
public static JPanel getCardPanel() {
return cardPanel;
}
public UIButton getReplaceSettingButton() {
return replaceSettingButton;
}
public void setReplaceSettingButton(UIButton replaceSettingButton) {
this.replaceSettingButton = replaceSettingButton;
}
public UIButton getSearchSettingButton() {
return searchSettingButton;
}
public void setSearchSettingButton(UIButton searchSettingButton) {
this.searchSettingButton = searchSettingButton;
}
public UIComboBox getFindSettingInputComboBox() {
return findSettingInputComboBox;
}
public void setFindSettingInputComboBox(UIComboBox findSettingInputComboBox) {
this.findSettingInputComboBox = findSettingInputComboBox;
}
public UIComboBox getReplaceSettingInputComboBox() {
return replaceSettingInputComboBox;
}
public void setReplaceSettingInputComboBox(UIComboBox replaceSettingInputComboBox) {
this.replaceSettingInputComboBox = replaceSettingInputComboBox;
}
public UIComboBox getFindExtraSettingComboBox() {
return findExtraSettingComboBox;
}
public void setFindExtraSettingComboBox(UIComboBox findExtraSettingComboBox) {
this.findExtraSettingComboBox = findExtraSettingComboBox;
}
public UIComboBox getReplaceExtraSettingComboBox() {
return replaceExtraSettingComboBox;
}
public void setReplaceExtraSettingComboBox(UIComboBox replaceExtraSettingComboBox) {
this.replaceExtraSettingComboBox = replaceExtraSettingComboBox;
}
public UIComboBox getFindSettingComboBox() {
return findSettingComboBox;
}
public void setFindSettingComboBox(UIComboBox findSettingComboBox) {
this.findSettingComboBox = findSettingComboBox;
}
public UILabel getSettingResultLabel() {
return settingResultLabel;
}
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);
}
/**
* 清除搜索结果
*/
public void clear() {
settingResultLabel.setText(StringUtils.EMPTY);
resultLabel.setText(StringUtils.EMPTY);
}
} }

20
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java

@ -14,11 +14,11 @@ import java.awt.Color;
*/ */
public class ITReplaceSouthPanel { public class ITReplaceSouthPanel {
ITTableEditorPane tableEditorPane; ITTableEditorPane tableEditorPane;
ITTableEditor itTableEditor; private static ITTableEditor itTableEditor;
//勾选框索引 //勾选框索引
public static final int CHECKBOX_INDEX = 0; public static final int CHECKBOX_INDEX = 0;
//ITContent在表格的列索引 //ITContent在表格的列索引
public static final int CONTENT_INDEX = 6; public static final int CONTENT_INDEX = 7;
public static final int TABLE_GAP = 20; public static final int TABLE_GAP = 20;
public ITReplaceSouthPanel() { public ITReplaceSouthPanel() {
@ -47,11 +47,21 @@ public class ITReplaceSouthPanel {
this.tableEditorPane = tableEditorPane; this.tableEditorPane = tableEditorPane;
} }
public ITTableEditor getItTableEditor() { /**
* 获取表格的editor
*
* @return 表格的editor
*/
public static ITTableEditor getItTableEditor() {
return itTableEditor; return itTableEditor;
} }
public void setItTableEditor(ITTableEditor itTableEditor) { /**
this.itTableEditor = itTableEditor; * 设置表格的editor可用于刷新表格的数据
*
* @param itTableEditor 表格的editor
*/
public static void setItTableEditor(ITTableEditor itTableEditor) {
ITReplaceSouthPanel.itTableEditor = itTableEditor;
} }
} }

62
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceWestPanel.java

@ -1,6 +1,7 @@
package com.fr.design.actions.replace.ui; package com.fr.design.actions.replace.ui;
import com.fr.base.svg.IconUtils; import com.fr.base.svg.IconUtils;
import com.fr.design.actions.replace.info.Info;
import com.fr.design.gui.ibutton.UIToggleButton; import com.fr.design.gui.ibutton.UIToggleButton;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
@ -19,6 +20,7 @@ import java.awt.GridLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.List;
/** /**
* 左侧面板 * 左侧面板
@ -30,33 +32,59 @@ import java.awt.event.MouseEvent;
public class ITReplaceWestPanel { public class ITReplaceWestPanel {
private JPanel leftPanel; private JPanel leftPanel;
private UILabel iconLabel; private UILabel iconLabel;
private UIToggleButton contentButton;
private UIToggleButton settingButton;
private static final Icon HELP_ICON = IconUtils.readIcon("com/fr/design/images/buttonicon/replace_help.svg"); private static final Icon HELP_ICON = IconUtils.readIcon("com/fr/design/images/buttonicon/replace_help.svg");
private static final String HELP_URL = CloudCenter.getInstance().acquireUrlByKind("design.replace.help", "https://help.fanruan.com/finereport/doc-view-4954.html?source=3"); private static final String HELP_URL = CloudCenter.getInstance().acquireUrlByKind("design.replace.help", "https://help.fanruan.com/finereport/doc-view-4954.html?source=3");
private static final int FILL_COUNT = 12; private static final int FILL_COUNT = 11;
public static final int LEFT_WIDTH = 100; public static final int LEFT_WIDTH = 100;
public static final String CONTENT_TEXT = "<html><font color = 'rgb(255,255,255)'>" + Toolkit.i18nText("Fine-Design_Basic_Templates_Content") + "</font></html>"; public static final String CONTENT_TEXT = "<html><font color = 'rgb(255,255,255)'>" + Toolkit.i18nText("Fine-Design_Basic_Templates_Content") + "</font></html>";
public static final String SETTING_TEXT = "<html><font color = 'rgb(255,255,255)'>" + Toolkit.i18nText("Fine-Design_Replace_Setting") + "</font></html>";
public ITReplaceWestPanel() { public ITReplaceWestPanel() {
leftPanel = new JPanel(new GridLayout(15, 1, 0, 0)); leftPanel = new JPanel(new GridLayout(15, 1, 0, 0));
iconLabel = new UILabel("<html><u><font color = 'rgb(61,153,249)'>" + Toolkit.i18nText("Fine-Design_Report_Community_Help") + "</font></u></html>"); iconLabel = new UILabel("<html><u><font color = 'rgb(61,153,249)'>" + Toolkit.i18nText("Fine-Design_Report_Community_Help") + "</font></u></html>");
UIToggleButton contentButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); contentButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Basic_Templates_Content"));
settingButton = new UIToggleButton(Toolkit.i18nText("Fine-Design_Replace_Setting"));
contentButton.setText(CONTENT_TEXT); contentButton.setText(CONTENT_TEXT);
contentButton.addActionListener(new ActionListener() { contentButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (!contentButton.isSelected()) { if (!contentButton.isSelected()) {
contentButton.setText(CONTENT_TEXT); showSelectPanel(ITReplaceNorthPanel.CARD_CONTENT, ITReplaceMainDialog.getSearchContentResultList());
} else { } else {
contentButton.setText(Toolkit.i18nText("Fine-Design_Basic_Templates_Content")); showSelectPanel(ITReplaceNorthPanel.CARD_SETTING, ITReplaceMainDialog.getSearchSettingResultList());
} }
changeColor4SelectContent();
settingButton.setSelected(contentButton.isSelected());
}
});
settingButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!settingButton.isSelected()) {
showSelectPanel(ITReplaceNorthPanel.CARD_SETTING, ITReplaceMainDialog.getSearchSettingResultList());
} else {
showSelectPanel(ITReplaceNorthPanel.CARD_CONTENT, ITReplaceMainDialog.getSearchContentResultList());
}
changeColor4SelectContent();
contentButton.setSelected(settingButton.isSelected());
} }
}); });
leftPanel.setBackground(Color.WHITE); leftPanel.setBackground(Color.WHITE);
//默认选中模板内容
contentButton.setSelected(true); contentButton.setSelected(true);
settingButton.setSelected(false);
//去除按钮的边框
contentButton.setBorderPainted(false); contentButton.setBorderPainted(false);
settingButton.setBorderPainted(false);
leftPanel.add(contentButton); leftPanel.add(contentButton);
leftPanel.add(settingButton);
leftPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, new Color(218, 218, 221))); leftPanel.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 1, new Color(218, 218, 221)));
//填充一下面板 //填充一下面板
for (int i = 0; i < FILL_COUNT; i++) { for (int i = 0; i < FILL_COUNT; i++) {
@ -85,4 +113,30 @@ public class ITReplaceWestPanel {
public void setLeftPanel(JPanel leftPanel) { public void setLeftPanel(JPanel leftPanel) {
this.leftPanel = leftPanel; this.leftPanel = leftPanel;
} }
/**
* 切换面板时改变颜色
*/
public void changeColor4SelectContent() {
if (!contentButton.isSelected()) {
contentButton.setText(CONTENT_TEXT);
settingButton.setText(Toolkit.i18nText("Fine-Design_Replace_Setting"));
} else {
contentButton.setText(Toolkit.i18nText("Fine-Design_Basic_Templates_Content"));
settingButton.setText(SETTING_TEXT);
}
}
/**
* 展示指定的面板
*
* @param str card面板的标签
* @param list 对应的表格数据
*/
public void showSelectPanel(String str, List<? extends Info> list) {
ITReplaceNorthPanel.getCardLayout().show(ITReplaceNorthPanel.getCardPanel(), str);
ITReplaceSouthPanel.getItTableEditor().clear();
ITReplaceSouthPanel.getItTableEditor().add(list);
ITReplaceSouthPanel.getItTableEditor().fireTableDataChanged();
}
} }

7
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java

@ -13,7 +13,6 @@ import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.AbstractCellEditor; import javax.swing.AbstractCellEditor;
import javax.swing.JTable; import javax.swing.JTable;
import javax.swing.table.TableCellEditor; import javax.swing.table.TableCellEditor;
@ -42,7 +41,7 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor
paraButton.addActionListener(new ActionListener() { paraButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
ITContent content = (ITContent) getEditTable().getValueAt(getEditTable().getEditingRow(), 6); ITContent content = (ITContent) getEditTable().getValueAt(getEditTable().getEditingRow(), ITReplaceSouthPanel.CONTENT_INDEX);
if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) { if (StringUtils.isNotEmpty(GeneralUtils.objectToString(content.getTrlString()))) {
ITReplaceMainDialog.setITReplaceFlag(true); ITReplaceMainDialog.setITReplaceFlag(true);
TRL trl = new TRL(GeneralUtils.objectToString(content.getTrlString())); TRL trl = new TRL(GeneralUtils.objectToString(content.getTrlString()));
@ -67,7 +66,7 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor
*/ */
@Override @Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
ITContent content = (ITContent) table.getValueAt(row, 6); ITContent content = (ITContent) table.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX);
paraButton.setEnabled(content.isJumpAble()); paraButton.setEnabled(content.isJumpAble());
return paraButton; return paraButton;
} }
@ -85,7 +84,7 @@ public class ITTableButton extends AbstractCellEditor implements TableCellEditor
*/ */
@Override @Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
ITContent content = (ITContent) table.getValueAt(row, 6); ITContent content = (ITContent) table.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX);
paraButton.setEnabled(content.isJumpAble()); paraButton.setEnabled(content.isJumpAble());
return paraButton; return paraButton;
} }

77
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java

@ -3,6 +3,7 @@ package com.fr.design.actions.replace.ui;
import com.fr.design.actions.replace.info.Info; import com.fr.design.actions.replace.info.Info;
import com.fr.design.actions.replace.info.base.ITContent; import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.UITableEditAction; import com.fr.design.gui.itableeditorpane.UITableEditAction;
import com.fr.design.gui.itableeditorpane.UITableModelAdapter; import com.fr.design.gui.itableeditorpane.UITableModelAdapter;
@ -12,6 +13,14 @@ import com.fr.stable.StringUtils;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.plaf.UIResource;
import javax.swing.table.TableCellRenderer;
import java.awt.Color;
import java.awt.Component;
import java.util.List; import java.util.List;
/** /**
@ -28,6 +37,7 @@ public class ITTableEditor extends UITableModelAdapter {
super(new String[]{ super(new String[]{
StringUtils.BLANK, StringUtils.BLANK,
Toolkit.i18nText("Fine-Design_Replace_Search_Content"), Toolkit.i18nText("Fine-Design_Replace_Search_Content"),
Toolkit.i18nText("Fine-Design_After_Replace"),
Toolkit.i18nText("Fine-Design_Replace_Template_Name"), Toolkit.i18nText("Fine-Design_Replace_Template_Name"),
Toolkit.i18nText("Fine-Design_Replace_Sheet_Name"), Toolkit.i18nText("Fine-Design_Replace_Sheet_Name"),
Toolkit.i18nText("Fine-Design_Replace_Block_Name"), Toolkit.i18nText("Fine-Design_Replace_Block_Name"),
@ -42,11 +52,14 @@ public class ITTableEditor extends UITableModelAdapter {
UILabel.class, UILabel.class,
UILabel.class, UILabel.class,
UILabel.class, UILabel.class,
UILabel.class,
ITTableButton.class, ITTableButton.class,
}); });
this.setDefaultEditor(ITTableButton.class, new ITTableButton()); this.setDefaultEditor(ITTableButton.class, new ITTableButton());
this.setDefaultRenderer(ITTableButton.class, new ITTableButton()); this.setDefaultRenderer(ITTableButton.class, new ITTableButton());
this.setDefaultEditor(Boolean.class, new ITBooleanEditor());
this.setDefaultRenderer(Boolean.class, new ITBooleanRenderer());
this.createTable().getColumnModel().getColumn(ITReplaceSouthPanel.CONTENT_INDEX).setMaxWidth(50); this.createTable().getColumnModel().getColumn(ITReplaceSouthPanel.CONTENT_INDEX).setMaxWidth(50);
this.createTable().getColumnModel().getColumn(ITReplaceSouthPanel.CHECKBOX_INDEX).setMaxWidth(50); this.createTable().getColumnModel().getColumn(ITReplaceSouthPanel.CHECKBOX_INDEX).setMaxWidth(50);
@ -106,6 +119,9 @@ public class ITTableEditor extends UITableModelAdapter {
fireTableDataChanged(); fireTableDataChanged();
} }
/**
* 选择的索引
*/
public enum ChooseIndex { public enum ChooseIndex {
/** /**
* 第一列返回选中情况 * 第一列返回选中情况
@ -127,9 +143,18 @@ public class ITTableEditor extends UITableModelAdapter {
} }
}, },
/** /**
* 第三列展示模板名 * 第三列展示替换后内容
*/ */
INDEX_2(2) { INDEX_2(2) {
@Override
public @Nullable Object returnContentObject(ITContent content) {
return content.getAfterReplaceStr();
}
},
/**
* 第四列展示模板名
*/
INDEX_3(3) {
@Override @Override
public Object returnContentObject(ITContent content) { public Object returnContentObject(ITContent content) {
return " " + content.getTemplateName(); return " " + content.getTemplateName();
@ -137,9 +162,9 @@ public class ITTableEditor extends UITableModelAdapter {
}, },
/** /**
* 展示Sheet * 展示Sheet
*/ */
INDEX_3(3) { INDEX_4(4) {
@Override @Override
public Object returnContentObject(ITContent content) { public Object returnContentObject(ITContent content) {
return " " + content.getSheetName(); return " " + content.getSheetName();
@ -147,18 +172,18 @@ public class ITTableEditor extends UITableModelAdapter {
}, },
/** /**
* 展示块名组件名 * 展示块名组件名
*/ */
INDEX_4(4) { INDEX_5(5) {
@Override @Override
public Object returnContentObject(ITContent content) { public Object returnContentObject(ITContent content) {
return " " + content.getBlockName(); return " " + content.getBlockName();
} }
}, },
/** /**
* 展示路径 * 展示路径
*/ */
INDEX_5(5) { INDEX_6(6) {
@Override @Override
public Object returnContentObject(ITContent content) { public Object returnContentObject(ITContent content) {
return " " + content.getOtherPos(); return " " + content.getOtherPos();
@ -166,9 +191,9 @@ public class ITTableEditor extends UITableModelAdapter {
}, },
/** /**
* 展示定位按钮 * 展示定位按钮
*/ */
INDEX_6(6) { INDEX_7(7) {
@Override @Override
public Object returnContentObject(ITContent content) { public Object returnContentObject(ITContent content) {
return content; return content;
@ -209,4 +234,38 @@ public class ITTableEditor extends UITableModelAdapter {
return null; return null;
} }
} }
/**
* 用于展示指定风格的checkbox的Editor
*/
public class ITBooleanEditor extends DefaultCellEditor {
public ITBooleanEditor() {
super(new UICheckBox());
UICheckBox checkBox = (UICheckBox) getComponent();
checkBox.setHorizontalAlignment(UICheckBox.CENTER);
}
}
/**
* 用于展示指定风格的checkbox的渲染器
*/
public class ITBooleanRenderer extends UICheckBox implements TableCellRenderer, UIResource {
public ITBooleanRenderer() {
super();
setHorizontalAlignment(JLabel.CENTER);
setBorderPainted(true);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
ITContent content = (ITContent) table.getValueAt(row, ITReplaceSouthPanel.CONTENT_INDEX);
setEnabled(!content.isReplaced());
setSelected((value != null && ((Boolean) value).booleanValue()));
setUI(getUICheckBoxUI());
setBorder(BorderFactory.createEmptyBorder());
setBackground(Color.WHITE);
return this;
}
}
} }

46
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java

@ -5,6 +5,7 @@ import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itableeditorpane.UITableEditAction; import com.fr.design.gui.itableeditorpane.UITableEditAction;
@ -14,7 +15,6 @@ import com.fr.design.mainframe.share.ui.base.MouseClickListener;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.JCheckBox;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -85,27 +85,30 @@ public class ITTableEditorPane<T> extends BasicPane {
/** /**
* 改变面板的各个状态替换按钮表头勾选框 * 改变面板的各个状态替换按钮表头勾选框
*
* @param content * @param content
* @param row * @param row
* @param col * @param col
*/ */
public void changeComponentStatus(ITContent content, int row, int col) { public void changeComponentStatus(ITContent content, int row, int col) {
if (content.isSelected()) { if (!content.isReplaced()) {
content.setSelected(false); if (content.isSelected()) {
editTable.setValueAt(content.isSelected(), row, col); content.setSelected(false);
ITReplaceMainDialog.selectCount--; editTable.setValueAt(content.isSelected(), row, col);
//如果没有选中,替换按钮需要置灰 ITReplaceMainDialog.selectCount--;
ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(ITReplaceMainDialog.selectCount > 0); //如果没有选中,替换按钮需要置灰
} else { ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(ITReplaceMainDialog.selectCount > 0);
content.setSelected(true); } else {
editTable.setValueAt(content.isSelected(), row, col); content.setSelected(true);
ITReplaceMainDialog.selectCount++; editTable.setValueAt(content.isSelected(), row, col);
ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(true); ITReplaceMainDialog.selectCount++;
} ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(true);
//更新表头的勾选框状态 }
if (editTable.getTableHeader().getDefaultRenderer() instanceof ITHeaderRenderer) { //更新表头的勾选框状态
ITHeaderRenderer renderer = (ITHeaderRenderer) editTable.getTableHeader().getDefaultRenderer(); if (editTable.getTableHeader().getDefaultRenderer() instanceof ITHeaderRenderer) {
renderer.refreshHeader(editTable, ITReplaceMainDialog.selectCount >= editTable.getRowCount()); ITHeaderRenderer renderer = (ITHeaderRenderer) editTable.getTableHeader().getDefaultRenderer();
renderer.refreshHeader(editTable, ITReplaceMainDialog.selectCount >= editTable.getRowCount());
}
} }
} }
@ -125,11 +128,11 @@ public class ITTableEditorPane<T> extends BasicPane {
*/ */
public static class ITHeaderRenderer implements TableCellRenderer { public static class ITHeaderRenderer implements TableCellRenderer {
JTableHeader tableHeader; JTableHeader tableHeader;
final JCheckBox selectBox; final UICheckBox selectBox;
public ITHeaderRenderer(JTable table) { public ITHeaderRenderer(JTable table) {
this.tableHeader = table.getTableHeader(); this.tableHeader = table.getTableHeader();
selectBox = new JCheckBox(); selectBox = new UICheckBox();
selectBox.setSelected(true); selectBox.setSelected(true);
tableHeader.addMouseListener(new MouseAdapter() { tableHeader.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
@ -217,7 +220,10 @@ public class ITTableEditorPane<T> extends BasicPane {
ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(value); ITReplaceMainDialog.getInstance().getNorthPane().getReplaceButton().setEnabled(value);
} }
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
((ITContent) (getEditTable().getValueAt(i, ITReplaceSouthPanel.CONTENT_INDEX))).setSelected(value); ITContent content = ((ITContent) (getEditTable().getValueAt(i, ITReplaceSouthPanel.CONTENT_INDEX)));
if (!content.isReplaced()) {
content.setSelected(value);
}
} }
} }

77
designer-realize/src/main/java/com/fr/design/actions/replace/utils/CheckUtils.java

@ -0,0 +1,77 @@
package com.fr.design.actions.replace.utils;
import com.fr.design.mainframe.JTemplate;
import com.fr.form.main.Form;
import com.fr.form.main.WidgetGatherAdapter;
import com.fr.form.ui.Widget;
import com.fr.main.impl.WorkBook;
import com.fr.main.impl.WorkBookHelper;
import com.fr.stable.Filter;
import com.fr.stable.StringUtils;
import com.fr.stable.js.WidgetName;
import java.util.ArrayList;
import java.util.List;
/**
* 用于合法性检验相关的工具类
*
* @author Destiny.Lin
* @version 11.0
* created by Destiny.Lin on 2022-10-31
*/
public class CheckUtils {
/**
* 获取需要检测的控件名称
*
* @param jTemplate 模板
* @return 控件名称列表
*/
public static List<WidgetName> getNeed2CheckWidgetsName(JTemplate<?, ?> jTemplate) {
if (jTemplate.getTarget() instanceof WorkBook) {
return getWorkBookNeedWidgetsName((WorkBook) jTemplate.getTarget());
} else if (jTemplate.getTarget() instanceof Form) {
return getFormNeedWidgetsName((Form) jTemplate.getTarget());
}
return new ArrayList<>();
}
private static List<WidgetName> getFormNeedWidgetsName(Form target) {
final List<WidgetName> list = new ArrayList<WidgetName>();
Form.traversalFormWidget(target.getContainer(), new WidgetGatherAdapter() {
@Override
public void dealWith(Widget widget) {
if (widgetAccepted(widget)) {
list.add(new WidgetName(widget.getWidgetName()));
}
}
@Override
public boolean dealWithAllCards() {
return true;
}
});
return list;
}
private static List<WidgetName> getWorkBookNeedWidgetsName(WorkBook wb) {
return WorkBookHelper.listWidgetNamesInWorkBook(wb, new Filter<Widget>() {
@Override
public boolean accept(Widget widget) {
return widgetAccepted(widget);
}
}, new Filter<Widget>() {
@Override
public boolean accept(Widget widget) {
return false;
}
});
}
private static boolean widgetAccepted(Widget widget) {
return widget != null && StringUtils.isNotEmpty(widget.getWidgetName());
}
}

172
designer-realize/src/main/java/com/fr/design/actions/replace/utils/SearchJSUtils.java

@ -2,9 +2,11 @@ package com.fr.design.actions.replace.utils;
import com.fr.chart.base.DataSeriesCondition; import com.fr.chart.base.DataSeriesCondition;
import com.fr.chart.chartattr.ChartCollection; import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.Plot;
import com.fr.chart.chartglyph.ConditionAttr; import com.fr.chart.chartglyph.ConditionAttr;
import com.fr.chart.chartglyph.ConditionCollection; import com.fr.chart.chartglyph.ConditionCollection;
import com.fr.chart.web.ChartHyperPoplink; import com.fr.chart.web.ChartHyperPoplink;
import com.fr.design.actions.replace.action.content.js.JSCheckTag;
import com.fr.design.actions.replace.action.content.js.SearchChartJSAction; import com.fr.design.actions.replace.action.content.js.SearchChartJSAction;
import com.fr.design.actions.replace.info.JSInfo; 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.ITContent;
@ -21,9 +23,14 @@ import com.fr.plugin.chart.attr.plot.VanChartPlot;
import com.fr.plugin.chart.base.AttrLabel; import com.fr.plugin.chart.base.AttrLabel;
import com.fr.plugin.chart.base.AttrTooltip; import com.fr.plugin.chart.base.AttrTooltip;
import com.fr.plugin.chart.base.VanChartHtmlLabel; import com.fr.plugin.chart.base.VanChartHtmlLabel;
import com.fr.plugin.chart.custom.CustomPlotFactory;
import com.fr.plugin.chart.custom.VanChartCustomPlot;
import com.fr.plugin.chart.custom.type.CustomPlotType;
import com.fr.plugin.chart.drillmap.VanChartDrillMapPlot;
import com.fr.plugin.chart.map.VanChartMapPlot; import com.fr.plugin.chart.map.VanChartMapPlot;
import com.fr.plugin.chart.map.attr.AttrMapLabel; import com.fr.plugin.chart.map.attr.AttrMapLabel;
import com.fr.plugin.chart.map.attr.AttrMapTooltip; import com.fr.plugin.chart.map.attr.AttrMapTooltip;
import com.fr.plugin.chart.type.MapType;
import com.fr.plugin.chart.vanchart.VanChart; import com.fr.plugin.chart.vanchart.VanChart;
import com.fr.report.cell.Elem; import com.fr.report.cell.Elem;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
@ -57,6 +64,14 @@ public class SearchJSUtils {
*/ */
public static final String CATEGORY_LABEL = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Style"), Toolkit.i18nText("Fine-Design_Chart_Data_Label"), Toolkit.i18nText("Fine-Design_Chart_Category_Label")); public static final String CATEGORY_LABEL = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Basic_Style"), Toolkit.i18nText("Fine-Design_Chart_Data_Label"), Toolkit.i18nText("Fine-Design_Chart_Category_Label"));
/**
* 条件属性
*/
public static final String CONDITION = ShowValueUtils.joinStr4Position(
Toolkit.i18nText("Fine-Design_Chart_Chart"),
Toolkit.i18nText("Fine-Design_Chart_Animation_Special"),
Toolkit.i18nText("Fine-Design_Chart_Interactive"));
/** /**
* 从Listener中获取JS * 从Listener中获取JS
*/ */
@ -68,7 +83,7 @@ public class SearchJSUtils {
ITContent newContent = ITContent.copy(content); ITContent newContent = ITContent.copy(content);
newContent.setReplaceObject(listener); newContent.setReplaceObject(listener);
SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent)); SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent));
} else if (javaScript instanceof Commit2DBJavaScript){ } else if (javaScript instanceof Commit2DBJavaScript) {
dealCommit2DBJS(jsInfos, content, (Commit2DBJavaScript) javaScript); dealCommit2DBJS(jsInfos, content, (Commit2DBJavaScript) javaScript);
} }
} }
@ -90,7 +105,7 @@ public class SearchJSUtils {
if (javaScript instanceof JavaScriptImpl) { if (javaScript instanceof JavaScriptImpl) {
newContent.setReplaceObject(javaScript); newContent.setReplaceObject(javaScript);
jsInfos.add(new JSInfo(newContent)); jsInfos.add(new JSInfo(newContent));
} else if (javaScript instanceof Commit2DBJavaScript){ } else if (javaScript instanceof Commit2DBJavaScript) {
dealCommit2DBJS(jsInfos, newContent, (Commit2DBJavaScript) javaScript); dealCommit2DBJS(jsInfos, newContent, (Commit2DBJavaScript) javaScript);
} }
} }
@ -118,16 +133,60 @@ public class SearchJSUtils {
for (int i = 0; i < collection.getChartCount(); i++) { for (int i = 0; i < collection.getChartCount(); i++) {
if (collection.getChart(i) instanceof VanChart) { if (collection.getChart(i) instanceof VanChart) {
VanChart chart = ((VanChart) collection.getChart(i)); VanChart chart = ((VanChart) collection.getChart(i));
int size = chart.getPlot().getConditionCollection().getConditionAttrSize(); //如果是组合图
ConditionCollection conditionCollection = chart.getPlot().getConditionCollection(); if (chart.getPlot() instanceof VanChartCustomPlot) {
VanChartCustomPlot plot = chart.getPlot();
for (VanChartPlot vanChartPlot : plot.getCustomPlotList()) {
dealPlotHtmlLabel(arrayList, vanChartPlot);
}
} else if (chart.getPlot() instanceof VanChartPlot){
dealPlotHtmlLabel(arrayList, chart.getPlot());
}
addAttrLabelHtmlLabel(chart, arrayList); addAttrLabelHtmlLabel(chart, arrayList);
for (int j = 0; j < size; j++) {
searchConditionCollection(arrayList, conditionCollection.getConditionAttr(j));
}
} }
} }
} }
private static void dealPlotHtmlLabel(List<Pair<VanChartHtmlLabel, String>> arrayList, VanChartPlot plot) {
//如果是组合地图
if (plot instanceof VanChartMapPlot) {
dealMapPlotHtmlLabel(arrayList, (VanChartMapPlot) plot);
} else {
dealCommonPlotHtmlLabel(arrayList, plot);
}
}
private static void dealMapPlotHtmlLabel(List<Pair<VanChartHtmlLabel, String>> arrayList, VanChartMapPlot plot) {
ConditionCollection area = plot.getConditionCollection();
ConditionCollection line = plot.getLineConditionCollection();
ConditionCollection point = plot.getPointConditionCollection();
dealMapCollectionHtmlLabel(arrayList, area, Toolkit.i18nText("Fine-Design_Chart_Region_Map"));
dealMapCollectionHtmlLabel(arrayList, line, Toolkit.i18nText("Fine-Design_Chart_LineMap"));
dealMapCollectionHtmlLabel(arrayList, point, Toolkit.i18nText("Fine-Design_Chart_PointMap"));
}
private static void dealMapCollectionHtmlLabel(List<Pair<VanChartHtmlLabel, String>> arrayList, ConditionCollection collection, String i18nText) {
for (int i = 0, size = collection.getConditionAttrSize(); i < size; i++) {
searchConditionCollection(arrayList, collection.getConditionAttr(i), i18nText);
}
}
private static void dealCommonPlotHtmlLabel(List<Pair<VanChartHtmlLabel, String>> arrayList, VanChartPlot plot) {
int size = plot.getConditionCollection().getConditionAttrSize();
CustomPlotType plotType = CustomPlotFactory.getCustomType(plot);
ConditionCollection conditionCollection = plot.getConditionCollection();
for (int j = 0; j < size; j++) {
if (plotType != null) {
searchConditionCollection(arrayList, conditionCollection.getConditionAttr(j), CustomPlotFactory.getTitle(plotType));
} else {
searchConditionCollection(arrayList, conditionCollection.getConditionAttr(j), StringUtils.EMPTY);
}
}
}
/** /**
* 将图表-样式-标签以及图表-样式-提示中的HtmlLabel加入数组 * 将图表-样式-标签以及图表-样式-提示中的HtmlLabel加入数组
* *
@ -139,15 +198,26 @@ public class SearchJSUtils {
//如果是地图类型要特殊处理 //如果是地图类型要特殊处理
if (plot instanceof VanChartMapPlot) { if (plot instanceof VanChartMapPlot) {
addMapJS2Array((VanChartMapPlot) plot, arrayList); addMapJS2Array((VanChartMapPlot) plot, arrayList);
} else { } else if(plot instanceof VanChartCustomPlot){
addAttrToolTipCondition2Array(plot, arrayList); for (VanChartPlot vanChartPlot : ((VanChartCustomPlot) plot).getCustomPlotList()) {
if (isAttrLabelExist(plot)) { CustomPlotType plotType = CustomPlotFactory.getCustomType(vanChartPlot);
addAttrLabelDetail2Array(plot, arrayList); dealAttrLabelHtml4VanChartPlot(vanChartPlot, arrayList, CustomPlotFactory.getTitle(plotType));
addAttrSecondLabelDetail2Array(plot, arrayList);
} }
} else {
dealAttrLabelHtml4VanChartPlot(plot, arrayList, StringUtils.EMPTY);
}
}
private static void dealAttrLabelHtml4VanChartPlot(VanChartPlot plot, List<Pair<VanChartHtmlLabel, String>> arrayList, String str) {
addAttrToolTipCondition2Array(plot, arrayList, str);
if (isAttrLabelExist(plot)) {
addAttrLabelDetail2Array(plot, arrayList, str);
addAttrSecondLabelDetail2Array(plot, arrayList, str);
} }
} }
/** /**
* 用于处理地图类型图表中的样式中的JSAttrMapTooltip AttrMapLabel * 用于处理地图类型图表中的样式中的JSAttrMapTooltip AttrMapLabel
* *
@ -194,9 +264,9 @@ public class SearchJSUtils {
} }
} }
private static void addAttrToolTipCondition2Array(VanChartPlot plot, List<Pair<VanChartHtmlLabel, String>> arrayList) { private static void addAttrToolTipCondition2Array(VanChartPlot plot, List<Pair<VanChartHtmlLabel, String>> arrayList, String str) {
if (isToolTipValid(plot.getAttrTooltipFromConditionCollection())) { if (isToolTipValid(plot.getAttrTooltipFromConditionCollection())) {
arrayList.add(new Pair<>(((AttrTooltip) plot.getAttrTooltipFromConditionCollection()).getContent().getHtmlLabel(), STYLE_TOOLTIP_CUSTOM)); arrayList.add(new Pair<>(((AttrTooltip) plot.getAttrTooltipFromConditionCollection()).getContent().getHtmlLabel(), ShowValueUtils.getChartOtherPos(STYLE_TOOLTIP_CUSTOM, str)));
} }
} }
@ -204,9 +274,9 @@ public class SearchJSUtils {
return tooltip instanceof AttrTooltip && ((AttrTooltip) tooltip).isEnable() && ((AttrTooltip) tooltip).getContent() != null && ((AttrTooltip) tooltip).getContent().getHtmlLabel() != null; return tooltip instanceof AttrTooltip && ((AttrTooltip) tooltip).isEnable() && ((AttrTooltip) tooltip).getContent() != null && ((AttrTooltip) tooltip).getContent().getHtmlLabel() != null;
} }
private static void addAttrLabelDetail2Array(VanChartPlot plot, List<Pair<VanChartHtmlLabel, String>> arrayList) { private static void addAttrLabelDetail2Array(VanChartPlot plot, List<Pair<VanChartHtmlLabel, String>> arrayList, String str) {
if (isLabelDetailValid(plot)) { if (isLabelDetailValid(plot)) {
arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel(), STYLE_LABEL)); arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel(), ShowValueUtils.getChartOtherPos(STYLE_LABEL, str)));
} }
} }
@ -216,9 +286,9 @@ public class SearchJSUtils {
&& plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel() != null; && plot.getAttrLabelFromConditionCollection().getAttrLabelDetail().getContent().getHtmlLabel() != null;
} }
private static void addAttrSecondLabelDetail2Array(VanChartPlot plot, List<Pair<VanChartHtmlLabel, String>> arrayList) { private static void addAttrSecondLabelDetail2Array(VanChartPlot plot, List<Pair<VanChartHtmlLabel, String>> arrayList, String str) {
if (isSecondLabelDetailValid(plot)) { if (isSecondLabelDetailValid(plot)) {
arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getSecondLabelDetail().getContent().getHtmlLabel(), CATEGORY_LABEL)); arrayList.add(new Pair<>(plot.getAttrLabelFromConditionCollection().getSecondLabelDetail().getContent().getHtmlLabel(), ShowValueUtils.getChartOtherPos(CATEGORY_LABEL, str)));
} }
} }
@ -238,21 +308,22 @@ public class SearchJSUtils {
* @param arrayList * @param arrayList
* @param conditionAttr * @param conditionAttr
*/ */
private static void searchConditionCollection(List<Pair<VanChartHtmlLabel, String>> arrayList, ConditionAttr conditionAttr) { private static void searchConditionCollection(List<Pair<VanChartHtmlLabel, String>> arrayList, ConditionAttr conditionAttr, String name) {
int conditionSize = conditionAttr.getDataSeriesConditionCount(); int conditionSize = conditionAttr.getDataSeriesConditionCount();
for (int t = 0; t < conditionSize; t++) { for (int t = 0; t < conditionSize; t++) {
DataSeriesCondition condition = conditionAttr.getDataSeriesCondition(t); DataSeriesCondition condition = conditionAttr.getDataSeriesCondition(t);
String str = Toolkit.i18nText("Fine-Design_Chart_Animation_Special") + "-" + Toolkit.i18nText("Fine-Design_Chart_Condition_Display"); String str = ShowValueUtils.joinStr4Position(Toolkit.i18nText("Fine-Design_Chart_Animation_Special"), Toolkit.i18nText("Fine-Design_Chart_Condition_Display"));
if (StringUtils.isNotEmpty(conditionAttr.getName())) { if (StringUtils.isNotEmpty(conditionAttr.getName())) {
str += "-" + conditionAttr.getName(); str = ShowValueUtils.joinStr4Position(str, conditionAttr.getName());
} }
str = ShowValueUtils.joinStr4Position(str, name);
if (condition instanceof AttrTooltip) { if (condition instanceof AttrTooltip) {
arrayList.add(new Pair<>(((AttrTooltip) condition).getContent().getHtmlLabel(), str + "-" + Toolkit.i18nText("Fine-Design_Chart_Data_Point_Tooltip"))); arrayList.add(new Pair<>(((AttrTooltip) condition).getContent().getHtmlLabel(), ShowValueUtils.joinStr4Position(str, Toolkit.i18nText("Fine-Design_Chart_Data_Point_Tooltip"))));
} }
if (condition instanceof AttrLabel) { if (condition instanceof AttrLabel) {
AttrLabel label = (AttrLabel) condition; AttrLabel label = (AttrLabel) condition;
if (isAttrLabelValid(label)) { if (isAttrLabelValid(label)) {
arrayList.add(new Pair<>(label.getContent().getHtmlLabel(), str + "-" + Toolkit.i18nText("Fine-Design_Chart_Label"))); arrayList.add(new Pair<>(label.getContent().getHtmlLabel(), ShowValueUtils.joinStr4Position(str, Toolkit.i18nText("Fine-Design_Chart_Label"))));
} }
} }
@ -269,18 +340,65 @@ public class SearchJSUtils {
* @param chartCollection * @param chartCollection
* @return * @return
*/ */
public static List<NameJavaScript> getNameJavaScript(ChartCollection chartCollection) { public static List<NameJavaScript> getNameJavaScript(ChartCollection chartCollection, ITContent content, List<JSInfo> jsInfos) {
ArrayList<NameJavaScript> nameJavaScriptArrayList = new ArrayList<>(); ArrayList<NameJavaScript> nameJavaScriptArrayList = new ArrayList<>();
for (int i = 0; i < chartCollection.getChartCount(); i++) { for (int i = 0; i < chartCollection.getChartCount(); i++) {
if (chartCollection.getChart(i) instanceof VanChart) { if (chartCollection.getChart(i) instanceof VanChart) {
VanChart chart = ((VanChart) chartCollection.getChart(i)); VanChart chart = ((VanChart) chartCollection.getChart(i));
NameJavaScriptGroup nameJavaScriptGroup = chart.getPlot().getHotHyperLink(); if (isCustomMapPlot(chart.getPlot())) {
addNameJavaScript2Array(nameJavaScriptArrayList, nameJavaScriptGroup); dealMapNameJavaScript(content, chart.getPlot(), jsInfos);
} else if (chart.getPlot() instanceof VanChartDrillMapPlot) {
dealDrillNameJavaScript(content, chart.getPlot(), jsInfos);
} else {
NameJavaScriptGroup nameJavaScriptGroup = chart.getPlot().getHotHyperLink();
addNameJavaScript2Array(nameJavaScriptArrayList, nameJavaScriptGroup);
}
} }
} }
return nameJavaScriptArrayList; return nameJavaScriptArrayList;
} }
private static void dealDrillNameJavaScript(ITContent content, VanChartDrillMapPlot plot, List<JSInfo> jsInfos) {
ITContent chartContent = ITContent.copy(content);
chartContent.addOtherPos(
CONDITION,
Toolkit.i18nText("Fine-Design_Chart_Drill_Dir")
);
List<NameJavaScript> list = new ArrayList<>();
addNameJavaScript2Array(list, plot.getDrillUpHyperLink());
addJSInfosFromNameJS(chartContent, list, jsInfos);
}
/**
* 是否是组合地图
* @param plot 图表的plot
* @return 是则返回true
*/
public static boolean isCustomMapPlot(Plot plot) {
return plot instanceof VanChartMapPlot && ((VanChartMapPlot) plot).getMapType() == MapType.CUSTOM;
}
/**
* 处理图表的交互属性可能存在多种地图
* @param content 存储信息的数据结构
* @param plot 图表的VanChartMapPlot
*/
private static void dealMapNameJavaScript(ITContent content, VanChartMapPlot plot, List<JSInfo> jsInfos) {
List<NameJavaScript> areaJavaScriptList = new ArrayList<>();
List<NameJavaScript> lineJavaScriptList = new ArrayList<>();
List<NameJavaScript> pointJavaScriptList = new ArrayList<>();
ITContent chartContent = ITContent.copy(content);
chartContent.addOtherPos(CONDITION);
addNameJavaScript2Array(areaJavaScriptList, plot.getAreaHotHyperLink());
addNameJavaScript2Array(lineJavaScriptList, plot.getLineHotHyperLink());
addNameJavaScript2Array(pointJavaScriptList, plot.getPointHotHyperLink());
addJSInfosFromNameJS(ShowValueUtils.getCustomMapContent(chartContent, Toolkit.i18nText("Fine-Design_Chart_Region_Map")), areaJavaScriptList, jsInfos);
addJSInfosFromNameJS(ShowValueUtils.getCustomMapContent(chartContent, Toolkit.i18nText("Fine-Design_Chart_LineMap")), lineJavaScriptList, jsInfos);
addJSInfosFromNameJS(ShowValueUtils.getCustomMapContent(chartContent, Toolkit.i18nText("Fine-Design_Chart_PointMap")), pointJavaScriptList, jsInfos);
}
private static void addNameJavaScript2Array(List<NameJavaScript> nameJavaScriptArrayList, NameJavaScriptGroup nameJavaScriptGroup) { private static void addNameJavaScript2Array(List<NameJavaScript> nameJavaScriptArrayList, NameJavaScriptGroup nameJavaScriptGroup) {
if (isNameJavaScriptGroupExist(nameJavaScriptGroup)) { if (isNameJavaScriptGroupExist(nameJavaScriptGroup)) {
for (int j = 0; j < nameJavaScriptGroup.size(); j++) { for (int j = 0; j < nameJavaScriptGroup.size(); j++) {
@ -362,6 +480,8 @@ public class SearchJSUtils {
newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Hyperlink")); newContent.addOtherPos(Toolkit.i18nText("Fine-Design_Report_Hyperlink"));
newContent.setReplaceObject(nameJavaScript); newContent.setReplaceObject(nameJavaScript);
newContent.addOtherPos(nameJavaScript.getName()); newContent.addOtherPos(nameJavaScript.getName());
newContent.setHoldObject(elem);
newContent.setTag(JSCheckTag.CELL_HYPERLINK);
SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent)); SearchJSUtils.addJSInfos(jsInfos, new JSInfo(newContent));
} else if (isChartHyperPopLinkValid(javaScript)) { } else if (isChartHyperPopLinkValid(javaScript)) {
ITContent chartContent = ITContent.copy(content); ITContent chartContent = ITContent.copy(content);

120
designer-realize/src/main/java/com/fr/design/actions/replace/utils/ShowValueUtils.java

@ -1,7 +1,10 @@
package com.fr.design.actions.replace.utils; package com.fr.design.actions.replace.utils;
import com.fr.design.actions.replace.info.Info;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.actions.replace.ui.ITReplaceMainDialog; import com.fr.design.actions.replace.ui.ITReplaceMainDialog;
import com.fr.design.i18n.Toolkit;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.collections.combination.Pair; import com.fr.stable.collections.combination.Pair;
@ -97,6 +100,22 @@ public class ShowValueUtils {
} }
} }
/**
* 获取高亮后用于展示的搜索后内容
*
* @param str 原内容
* @param searchStr 搜索内容
* @param replaceStr 替换内容
* @return 处理完的文本
*/
public static String getReplaceString(String str, String searchStr, String replaceStr) {
if (StringUtils.isEmpty(searchStr)) {
return str;
} else {
return updateReplaceHighlight(str, searchStr, replaceStr);
}
}
/** /**
* 替换策略 * 替换策略
* *
@ -187,6 +206,40 @@ public class ShowValueUtils {
} }
} }
/**
* 更新替换后的高亮
*
* @param str
* @param searchStr
* @param replaceStr
* @return
*/
public static String updateReplaceHighlight(String str, String searchStr, String replaceStr) {
if (ITReplaceMainDialog.isMatched()) {
String result = str;
Pattern pattern = containPattern;
Matcher matcher = pattern.matcher(str);
int size = FONT_HEAD.length() + FONT_TAIL.length();
int different = getDifferent(searchStr.length(), replaceStr.length());
int index = 0;
StringBuilder builder = new StringBuilder(str);
while (matcher.find()) {
builder.replace(matcher.start() + index, matcher.end() + index, FONT_HEAD + changeHtmlStr(replaceStr) + FONT_TAIL);
index += getDifferent(size, different);
index += getIncreaseCount(replaceStr);
}
return changeOriginHtmlStr(HEAD + builder.toString() + TAIL);
} else {
String ans = HEAD + replaceAll(str, searchStr, FONT_HEAD + changeHtmlStr(replaceStr) + FONT_TAIL) + TAIL;
return changeOriginHtmlStr(ans);
}
}
private static int getDifferent(int searchLength, int replaceLength) {
return searchLength - replaceLength;
}
/** /**
* 用于处理原字符串中的尖括号 * 用于处理原字符串中的尖括号
*/ */
@ -315,4 +368,71 @@ public class ShowValueUtils {
public static String joinStr4Position(String... strings) { public static String joinStr4Position(String... strings) {
return StableUtils.join(strings, JOIN_GAP_STRING); return StableUtils.join(strings, JOIN_GAP_STRING);
} }
/**
* 更新替换后内容的高亮
*
* @param info 存储信息的数据结构
* @param str 原内容
* @param searchStr 搜索内容
* @param replacedStr 替换内容
*/
public static void updateAfterReplaceStr(Info info, String str, String searchStr, String replacedStr) {
info.getContent().setAfterReplaceStr(ShowValueUtils.getReplaceString(str, searchStr, replacedStr));
}
/**
* 获取搜索或替换后的提示
*
* @param findCount
* @param replaceCount
* @param failedCount
* @return
*/
public static String getResultTip(int findCount, int replaceCount, int failedCount) {
StringBuilder str = new StringBuilder();
str.append("<html>").append(Toolkit.i18nText("Fine-Design_Replace_Search_Finish", "<font color = 'rgb(61,153,249)'>" + findCount+ "</font>"));
if (replaceCount != 0) {
str.append(Toolkit.i18nText("Fine-Design_Replace_Also_Finish", "<font color = 'rgb(61,153,249)'>" + replaceCount + "</font>"));
if (failedCount != 0) {
str.append(Toolkit.i18nText("Fine-Design_Replace_Have", "<font color = 'rgb(236,124,125)'>" + failedCount + "</font>"));
}
} else {
if (failedCount != 0) {
str.append(Toolkit.i18nText("Fine-Design_Replace_Also_Finish", "<font color = 'rgb(61,153,249)'>" + replaceCount + "</font>"));
str.append(Toolkit.i18nText("Fine-Design_Replace_Have", "<font color = 'rgb(236,124,125)'>" + failedCount + "</font>"));
}
}
return str.toString();
}
/**
* 返回图表类型的位置信息组合图就需要加上对应的类型名称
* @param str 基础信息
* @param customStyle 组合图的类型信息
* @return 组合后的位置信息
*/
public static String getChartOtherPos(String str, String customStyle) {
if (StringUtils.isNotEmpty(customStyle)) {
return joinStr4Position(str, customStyle);
} else {
return str;
}
}
/**
* 用于获取增加指定地图后缀的ITContent
* @param content 原ITContent
* @param str 后缀
* @return 处理后的新的ITContent
*/
public static ITContent getCustomMapContent(ITContent content, String str) {
ITContent resultContent = ITContent.copy(content);
resultContent.addOtherPos(str);
return resultContent;
}
} }

80
designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java

@ -8,7 +8,6 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.CustomVariableResolver;
import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula; import com.fr.design.formula.UIFormula;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
@ -16,7 +15,6 @@ import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
@ -52,7 +50,6 @@ public class DSColumnAdvancedPane extends BasicPane {
private SortPane sortPane; private SortPane sortPane;
private SelectCountPane selectCountPane; private SelectCountPane selectCountPane;
private ValuePane valuePane; private ValuePane valuePane;
private FormatAttrPane formatAttrPane;
private UICheckBox horizontalExtendableCheckBox; private UICheckBox horizontalExtendableCheckBox;
private UICheckBox verticalExtendableCheckBox; private UICheckBox verticalExtendableCheckBox;
private UICheckBox useMultiplyNumCheckBox; private UICheckBox useMultiplyNumCheckBox;
@ -89,10 +86,6 @@ public class DSColumnAdvancedPane extends BasicPane {
valuePane = new ValuePane(); valuePane = new ValuePane();
valuePane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Custom_Data_Appearance"))); valuePane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Custom_Data_Appearance")));
formatAttrPane = new FormatAttrPane();
JPanel titleBorderedFormatPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format"));
titleBorderedFormatPane.add(formatAttrPane, BorderLayout.NORTH);
JPanel extendablePane = null; JPanel extendablePane = null;
if (setting > DSColumnPane.SETTING_DSRELATED) { if (setting > DSColumnPane.SETTING_DSRELATED) {
// extendableDirectionPane // extendableDirectionPane
@ -130,7 +123,6 @@ public class DSColumnAdvancedPane extends BasicPane {
{sortPane}, {sortPane},
{selectCountPane}, {selectCountPane},
{valuePane}, {valuePane},
{titleBorderedFormatPane},
{extendablePane}, {extendablePane},
{multiNumPane} {multiNumPane}
}; };
@ -138,7 +130,6 @@ public class DSColumnAdvancedPane extends BasicPane {
components = new Component[][]{ components = new Component[][]{
{sortPane}, {sortPane},
{valuePane}, {valuePane},
{titleBorderedFormatPane}
}; };
} }
@ -161,7 +152,6 @@ public class DSColumnAdvancedPane extends BasicPane {
sortPane.populateBean(cellElement); sortPane.populateBean(cellElement);
valuePane.populate(cellElement); valuePane.populate(cellElement);
formatAttrPane.populate(cellElement);
if (selectCountPane != null) { if (selectCountPane != null) {
selectCountPane.populate(cellElement); selectCountPane.populate(cellElement);
@ -211,7 +201,6 @@ public class DSColumnAdvancedPane extends BasicPane {
sortPane.updateBean(cellElement); sortPane.updateBean(cellElement);
valuePane.update(cellElement); valuePane.update(cellElement);
formatAttrPane.update(cellElement);
if (selectCountPane != null) { if (selectCountPane != null) {
selectCountPane.update(cellElement); selectCountPane.update(cellElement);
@ -518,75 +507,6 @@ public class DSColumnAdvancedPane extends BasicPane {
} }
} }
public static class ReLayoutTextFormatPane extends TextFormatPane {
protected void initLayout() {
JComponent[][] components = new JComponent[][] { {typeComboBox, textField, roundingBox} };
double[] rowSize = new double[] { TableLayout.FILL };
double[] columnSize = {TableLayout.PREFERRED, 200, TableLayout.PREFERRED};
JPanel settingPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 4, 0);
addComponents(4, new JComponent[]{settingPane, previewLabel});
}
@Override
protected void setRoundingBoxVisible(boolean visible) {
roundingBox.setVisible(visible);
}
public void populate(CellElement cellElement) {
if (cellElement != null) {
populateBean(cellElement.getStyle());
}
}
public void update(CellElement cellElement) {
if (cellElement != null) {
cellElement.setStyle(update(cellElement.getStyle()));
}
}
}
public static class FormatAttrPane extends AbstractAttrNoScrollPane {
private TextFormatPane formatPane;
@Override
protected JPanel createContentPane() {
this.formatPane = new ReLayoutTextFormatPane();
return this.formatPane;
}
@Override
public Dimension getPreferredSize() {
if (formatPane == null) {
return super.getPreferredSize();
}
return formatPane.getPreferredSize();
}
protected void initContentPane() {
leftContentPane = createContentPane();
if (leftContentPane != null) {
leftContentPane.setBorder(BorderFactory.createEmptyBorder());
this.add(leftContentPane, BorderLayout.CENTER);
}
}
public void populate(CellElement cellElement) {
if (cellElement != null && formatPane != null) {
formatPane.populateBean(cellElement.getStyle());
}
}
public void update(CellElement cellElement) {
if (cellElement != null && formatPane != null) {
cellElement.setStyle(formatPane.update(cellElement.getStyle()));
}
}
}
private void checkButtonEnabled() { private void checkButtonEnabled() {
if (useMultiplyNumCheckBox.isSelected()) { if (useMultiplyNumCheckBox.isSelected()) {
multiNumSpinner.setEnabled(true); multiNumSpinner.setEnabled(true);

22
designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupDockingPane.java

@ -26,6 +26,7 @@ import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.Set;
/** /**
* 这个pane是选中数据列后在上方QuickRegion处显示的pane * 这个pane是选中数据列后在上方QuickRegion处显示的pane
@ -167,6 +168,11 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane {
@Override @Override
public void update() { public void update() {
updateCellElement(cellElement);
}
private void updateCellElement(TemplateCellElement cellElement) {
if (isNPE(cellElement)) { if (isNPE(cellElement)) {
return; return;
} }
@ -222,9 +228,6 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane {
this.listener = listener; this.listener = listener;
} }
void fireTargetChanged() {
listener.itemStateChanged(null);
}
@Override @Override
public void setRecordGrouper(RecordGrouper recordGrouper) { public void setRecordGrouper(RecordGrouper recordGrouper) {
@ -242,4 +245,17 @@ public class ResultSetGroupDockingPane extends ResultSetGroupPane {
groupComboBox.removeItemListener(this.listener); groupComboBox.removeItemListener(this.listener);
functionComboBox.removeItemListener(this.listener); functionComboBox.removeItemListener(this.listener);
} }
public void update(Set<TemplateCellElement> cellElements) {
cellElements.forEach(this::updateCellElement);
}
@Override
public Dimension getPreferredSize() {
if (this.isVisible()) {
return super.getPreferredSize();
} else {
return new Dimension();
}
}
} }

27
designer-realize/src/main/java/com/fr/design/dscolumn/ResultSetGroupPane.java

@ -1,17 +1,10 @@
package com.fr.design.dscolumn; package com.fr.design.dscolumn;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.core.group.CustomGrouper; import com.fr.report.cell.cellattr.core.group.CustomGrouper;
@ -19,6 +12,12 @@ import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.cell.cellattr.core.group.FunctionGrouper; import com.fr.report.cell.cellattr.core.group.FunctionGrouper;
import com.fr.report.cell.cellattr.core.group.RecordGrouper; import com.fr.report.cell.cellattr.core.group.RecordGrouper;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Set;
//august:1:31 我又改回以前的样子了 neil那个方法还是有bug 9922 //august:1:31 我又改回以前的样子了 neil那个方法还是有bug 9922
public abstract class ResultSetGroupPane extends JPanel { public abstract class ResultSetGroupPane extends JPanel {
@ -38,10 +37,15 @@ public abstract class ResultSetGroupPane extends JPanel {
abstract void update(); abstract void update();
abstract void setRecordGrouper(RecordGrouper recordGrouper); /**
* 批量更新数据设置
*
* @param cellElements 需要更新的单元格
*/
public void update(Set<TemplateCellElement> cellElements) {
}
void fireTargetChanged() { abstract void setRecordGrouper(RecordGrouper recordGrouper);
};
ActionListener groupAdvancedListener = new ActionListener() { ActionListener groupAdvancedListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
@ -68,7 +72,6 @@ public abstract class ResultSetGroupPane extends JPanel {
dSColumn.setGrouper(rg); dSColumn.setGrouper(rg);
} }
setRecordGrouper(rg); setRecordGrouper(rg);
fireTargetChanged();
JTemplate targetComponent = DesignerContext.getDesignerFrame().getSelectedJTemplate(); JTemplate targetComponent = DesignerContext.getDesignerFrame().getSelectedJTemplate();
if (targetComponent != null) { if (targetComponent != null) {
targetComponent.fireTargetModified(); targetComponent.fireTargetModified();

10
designer-realize/src/main/java/com/fr/design/dscolumn/SelectedDataColumnPane.java

@ -392,4 +392,14 @@ public class SelectedDataColumnPane extends BasicPane {
} }
return new ArrayList<>(); return new ArrayList<>();
} }
@Override
public Dimension getPreferredSize() {
if (this.isVisible()) {
return super.getPreferredSize();
}
else {
return new Dimension();
}
}
} }

79
designer-realize/src/main/java/com/fr/design/report/ReportEnginePane.java

@ -12,12 +12,14 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.widget.FRWidgetFactory;
import com.fr.general.SiteCenter; import com.fr.general.SiteCenter;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.report.core.ReportUtils; import com.fr.report.core.ReportUtils;
import com.fr.report.stable.LayerReportAttr; import com.fr.report.stable.LayerReportAttr;
import com.fr.report.worksheet.WorkSheet; import com.fr.report.worksheet.WorkSheet;
import com.fr.stable.ProductConstants; import com.fr.stable.ProductConstants;
import javax.swing.AbstractButton; import javax.swing.AbstractButton;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.ButtonGroup; import javax.swing.ButtonGroup;
@ -26,13 +28,11 @@ import javax.swing.JLayeredPane;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JRadioButton; import javax.swing.JRadioButton;
import javax.swing.SwingConstants;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Desktop; import java.awt.Desktop;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
@ -86,7 +86,7 @@ public class ReportEnginePane extends BasicBeanPane<LayerReportAttr> {
outAdvicePane.add(createAdvicePane()); outAdvicePane.add(createAdvicePane());
} }
private JPanel createReportEnginePane(){ private JPanel createReportEnginePane() {
JPanel reportEnginePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); JPanel reportEnginePane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane();
JPanel clientPagingPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel clientPagingPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
clientPaging = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Enable_Client_Page")); clientPaging = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Enable_Client_Page"));
@ -102,7 +102,7 @@ public class ReportEnginePane extends BasicBeanPane<LayerReportAttr> {
return reportEnginePane; return reportEnginePane;
} }
private JPanel createPagingEngineSelectPane(){ private JPanel createPagingEngineSelectPane() {
engineSettingPane = new JLayeredPane(); engineSettingPane = new JLayeredPane();
engineSettingPane.setPreferredSize(new Dimension(570, 240)); engineSettingPane.setPreferredSize(new Dimension(570, 240));
engineSettingPane.setBounds(0, 0, 570, 240); engineSettingPane.setBounds(0, 0, 570, 240);
@ -121,8 +121,8 @@ public class ReportEnginePane extends BasicBeanPane<LayerReportAttr> {
/** /**
* 目前先屏蔽后面新引擎显示页码再加上相关代码 * 目前先屏蔽后面新引擎显示页码再加上相关代码
* */ */
private void createEngineXSettingPane(){ private void createEngineXSettingPane() {
outEngineXSettingPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_New_Engine")); outEngineXSettingPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_New_Engine"));
outEngineXSettingPane.setBounds(0, 0, 570, 240); outEngineXSettingPane.setBounds(0, 0, 570, 240);
JPanel engineXSettingPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); JPanel engineXSettingPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane();
@ -146,7 +146,7 @@ public class ReportEnginePane extends BasicBeanPane<LayerReportAttr> {
outEngineXSettingPane.add(engineXSettingPane); outEngineXSettingPane.add(engineXSettingPane);
} }
private void createLineEngineSettingPane(){ private void createLineEngineSettingPane() {
outLineEngineSettingPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Line_Engine")); outLineEngineSettingPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Line_Engine"));
outLineEngineSettingPane.setBounds(0, 0, 570, 240); outLineEngineSettingPane.setBounds(0, 0, 570, 240);
JPanel lineEngineSettingPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane(); JPanel lineEngineSettingPane = FRGUIPaneFactory.createY_AXISBoxInnerContainer_M_Pane();
@ -166,9 +166,9 @@ public class ReportEnginePane extends BasicBeanPane<LayerReportAttr> {
outLineEngineSettingPane.add(lineEngineSettingPane); outLineEngineSettingPane.add(lineEngineSettingPane);
} }
private JPanel createTipPane(String tipText){ private JPanel createTipPane(String tipText) {
JPanel tipPane = new JPanel(); JPanel tipPane = new JPanel();
UILabel tip = new UILabel(tipText, SwingConstants.LEFT); UILabel tip = FRWidgetFactory.createLineWrapLabel(tipText, 420);
tip.setForeground(new Color(128, 128, 128)); tip.setForeground(new Color(128, 128, 128));
tipPane.add(tip); tipPane.add(tip);
return tipPane; return tipPane;
@ -184,20 +184,19 @@ public class ReportEnginePane extends BasicBeanPane<LayerReportAttr> {
return pageQueryPane; return pageQueryPane;
} }
private JPanel createAdvicePane(){ private JPanel createAdvicePane() {
JPanel advicePane = new JPanel(new BorderLayout()); JPanel advicePane = new JPanel(FRGUIPaneFactory.create1ColumnGridLayout());
FRExplainLabel topExplainLabel = new FRExplainLabel(Toolkit.i18nText("Fine-Design_Report_Report_Engine_Warnning_Info")); // 上侧文字
advicePane.add(topExplainLabel, BorderLayout.NORTH); UILabel topExplainLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Report_Engine_Warnning_Info"), 480);
topExplainLabel.setForeground(new Color(0, 0, 0)); topExplainLabel.setForeground(new Color(0, 0, 0));
FlowLayout flowLayout = new FlowLayout(FlowLayout.LEADING); advicePane.add(topExplainLabel);
flowLayout.setHgap(0); // 下侧文字及链接
flowLayout.setVgap(0); JPanel adviceDownPane = FRGUIPaneFactory.createLeftFlowZeroGapBorderPane();
JPanel adviceDownPane = new JPanel(flowLayout); advicePane.add(adviceDownPane);
advicePane.add(adviceDownPane, BorderLayout.CENTER); UILabel downExplainLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_Report_Detail_Reference"));
FRExplainLabel downExplainLabel = new FRExplainLabel(Toolkit.i18nText("Fine-Design_Report_Report_Detail_Reference"));
adviceDownPane.add(downExplainLabel); adviceDownPane.add(downExplainLabel);
downExplainLabel.setForeground(new Color(0, 0, 0)); downExplainLabel.setForeground(new Color(0, 0, 0));
JLabel helper = new FRExplainLabel( com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Community_Help")); JLabel helper = new FRExplainLabel(Toolkit.i18nText("Fine-Design_Report_Community_Help"));
helper.setForeground(new Color(1, 159, 222)); helper.setForeground(new Color(1, 159, 222));
adviceDownPane.add(helper); adviceDownPane.add(helper);
helper.addMouseListener(new MouseAdapter() { helper.addMouseListener(new MouseAdapter() {
@ -213,7 +212,7 @@ public class ReportEnginePane extends BasicBeanPane<LayerReportAttr> {
return advicePane; return advicePane;
} }
private JPanel createPagingEngineRadioPanel(){ private JPanel createPagingEngineRadioPanel() {
UIRadioButton newEngine = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_New_Engine"), true); UIRadioButton newEngine = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_New_Engine"), true);
UIRadioButton lineEngine = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Line_Engine"), false); UIRadioButton lineEngine = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Line_Engine"), false);
ButtonGroup buttonGroup = new ButtonGroup(); ButtonGroup buttonGroup = new ButtonGroup();
@ -225,7 +224,7 @@ public class ReportEnginePane extends BasicBeanPane<LayerReportAttr> {
double[] rowSize = {p}; double[] rowSize = {p};
double[] columnSize = {p, p, p, p, p}; double[] columnSize = {p, p, p, p, p};
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[] { new Component[]{
newEngine, newEngine,
lineEngine lineEngine
} }
@ -243,7 +242,7 @@ public class ReportEnginePane extends BasicBeanPane<LayerReportAttr> {
@Override @Override
public void populateBean(LayerReportAttr ob) { public void populateBean(LayerReportAttr ob) {
if (ob == null){ if (ob == null) {
setDefaultAttr(); setDefaultAttr();
return; return;
} }
@ -252,14 +251,14 @@ public class ReportEnginePane extends BasicBeanPane<LayerReportAttr> {
engineSettingPane.setVisible(true); engineSettingPane.setVisible(true);
radioButtons.get(0).setSelected(ob.getEngineState() == LayerReportAttr.ENGINE_X); radioButtons.get(0).setSelected(ob.getEngineState() == LayerReportAttr.ENGINE_X);
radioButtons.get(1).setSelected(ob.getEngineState() == LayerReportAttr.LINE_ENGINE); radioButtons.get(1).setSelected(ob.getEngineState() == LayerReportAttr.LINE_ENGINE);
if (ob.getEngineState() == LayerReportAttr.ENGINE_X){ if (ob.getEngineState() == LayerReportAttr.ENGINE_X) {
engineSettingPane.moveToFront(outEngineXSettingPane); engineSettingPane.moveToFront(outEngineXSettingPane);
outEngineXSettingPane.setVisible(true); outEngineXSettingPane.setVisible(true);
outLineEngineSettingPane.setVisible(false); outLineEngineSettingPane.setVisible(false);
engineXCountPerPageEditor.setValue(new Integer(ob.getCountPerPage())); engineXCountPerPageEditor.setValue(new Integer(ob.getCountPerPage()));
engineXPageQueryBox.setSelected(ob.isPageQuery()); engineXPageQueryBox.setSelected(ob.isPageQuery());
engineXPageQueryPane.setVisible(ob.isPageQuery()); engineXPageQueryPane.setVisible(ob.isPageQuery());
}else { } else {
engineSettingPane.moveToFront(outLineEngineSettingPane); engineSettingPane.moveToFront(outLineEngineSettingPane);
outEngineXSettingPane.setVisible(false); outEngineXSettingPane.setVisible(false);
outLineEngineSettingPane.setVisible(true); outLineEngineSettingPane.setVisible(true);
@ -275,16 +274,16 @@ public class ReportEnginePane extends BasicBeanPane<LayerReportAttr> {
//这里注意一下怎么更新的,后续可能存在判断为空的调用,从而对老引擎造成影响。 //这里注意一下怎么更新的,后续可能存在判断为空的调用,从而对老引擎造成影响。
LayerReportAttr attr = new LayerReportAttr(); LayerReportAttr attr = new LayerReportAttr();
attr.setClientPaging(clientPaging.isSelected()); attr.setClientPaging(clientPaging.isSelected());
for (int i = 0; i < radioButtons.size(); i++){ for (int i = 0; i < radioButtons.size(); i++) {
if (radioButtons.get(i).isSelected()){ if (radioButtons.get(i).isSelected()) {
attr.setEngineState(i); attr.setEngineState(i);
} }
} }
if (attr.getEngineState() == LayerReportAttr.ENGINE_X){ if (attr.getEngineState() == LayerReportAttr.ENGINE_X) {
attr.setEnableRowCount(rowCountBox.isSelected()); attr.setEnableRowCount(rowCountBox.isSelected());
attr.setCountPerPage(engineXCountPerPageEditor.getValue().intValue()); attr.setCountPerPage(engineXCountPerPageEditor.getValue().intValue());
attr.setPageQuery(engineXPageQueryBox.isSelected()); attr.setPageQuery(engineXPageQueryBox.isSelected());
}else { } else {
attr.setPageQuery(lineEnginePageQueryBox.isSelected()); attr.setPageQuery(lineEnginePageQueryBox.isSelected());
attr.setCountPerPage(lineEngineCountPerPageEditor.getValue()); attr.setCountPerPage(lineEngineCountPerPageEditor.getValue());
} }
@ -304,7 +303,8 @@ public class ReportEnginePane extends BasicBeanPane<LayerReportAttr> {
} }
} }
} }
public void setDefaultAttr(){
public void setDefaultAttr() {
clientPaging.setSelected(false); clientPaging.setSelected(false);
lineEngineCountPerPageEditor.setValue(30); lineEngineCountPerPageEditor.setValue(30);
lineEnginePageQueryBox.setSelected(false); lineEnginePageQueryBox.setSelected(false);
@ -315,26 +315,29 @@ public class ReportEnginePane extends BasicBeanPane<LayerReportAttr> {
private class SelectActionListener implements ActionListener { private class SelectActionListener implements ActionListener {
private AbstractButton source; private AbstractButton source;
private JPanel target; private JPanel target;
private SelectActionListener(AbstractButton source, JPanel target){
private SelectActionListener(AbstractButton source, JPanel target) {
this.source = source; this.source = source;
this.target = target; this.target = target;
} }
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (source.isSelected()){ if (source.isSelected()) {
target.setVisible(true); target.setVisible(true);
}else { } else {
target.setVisible(false); target.setVisible(false);
} }
} }
} }
private class EngineSelectActionListener implements ActionListener{ private class EngineSelectActionListener implements ActionListener {
private AbstractButton source; private AbstractButton source;
private JLayeredPane target; private JLayeredPane target;
private JPanel showTarget; private JPanel showTarget;
private JPanel notShowTarget; private JPanel notShowTarget;
private EngineSelectActionListener(AbstractButton source, JLayeredPane target, JPanel showTarget, JPanel notShowTarget){
private EngineSelectActionListener(AbstractButton source, JLayeredPane target, JPanel showTarget, JPanel notShowTarget) {
this.source = source; this.source = source;
this.target = target; this.target = target;
this.showTarget = showTarget; this.showTarget = showTarget;
@ -344,15 +347,15 @@ public class ReportEnginePane extends BasicBeanPane<LayerReportAttr> {
/** /**
* 由于屏蔽了新引擎设置由于新引擎设置界面是空的行式引擎的设置界面会显示出来因此每次界面转换时将不需要显示的界面屏蔽 * 由于屏蔽了新引擎设置由于新引擎设置界面是空的行式引擎的设置界面会显示出来因此每次界面转换时将不需要显示的界面屏蔽
* 不需要屏蔽新引擎设置时就不需要showTarget.setVisible(true);notShowTarget.setVisible(false);这两行代码了 * 不需要屏蔽新引擎设置时就不需要showTarget.setVisible(true);notShowTarget.setVisible(false);这两行代码了
* **/ **/
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (source.isSelected()){ if (source.isSelected()) {
target.setVisible(true); target.setVisible(true);
showTarget.setVisible(true); showTarget.setVisible(true);
notShowTarget.setVisible(false); notShowTarget.setVisible(false);
target.moveToFront(showTarget); target.moveToFront(showTarget);
}else { } else {
target.setVisible(false); target.setVisible(false);
} }
} }

76
designer-realize/src/main/java/com/fr/grid/selection/CellSelection.java

@ -34,6 +34,7 @@ import com.fr.design.report.RowColumnPane;
import com.fr.design.selection.QuickEditor; import com.fr.design.selection.QuickEditor;
import com.fr.grid.GridUtils; import com.fr.grid.GridUtils;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.DefaultTemplateCellElement;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellGUIAttr; import com.fr.report.cell.cellattr.CellGUIAttr;
import com.fr.report.elementcase.TemplateElementCase; import com.fr.report.elementcase.TemplateElementCase;
@ -46,8 +47,10 @@ import javax.swing.JOptionPane;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
* the cell selection (columnrow)是所选单元格中左上角的位置 这个数据结构就是一个Rectangle * the cell selection (columnrow)是所选单元格中左上角的位置 这个数据结构就是一个Rectangle
@ -67,6 +70,7 @@ public class CellSelection extends Selection {
private Rectangle editRectangle = new Rectangle(0, 0, 1, 1); private Rectangle editRectangle = new Rectangle(0, 0, 1, 1);
private List cellRectangleList = new ArrayList(); private List cellRectangleList = new ArrayList();
private Set<TemplateCellElement> cellElements = new HashSet<>();
public CellSelection() { public CellSelection() {
this(0, 0, 1, 1); this(0, 0, 1, 1);
@ -739,16 +743,82 @@ public class CellSelection extends Selection {
TemplateElementCase tplEC = ePane.getEditingElementCase(); TemplateElementCase tplEC = ePane.getEditingElementCase();
TemplateCellElement cellElement = tplEC.getTemplateCellElement(column, row); TemplateCellElement cellElement = tplEC.getTemplateCellElement(column, row);
Object value = null; Object value = null;
boolean b = ePane.isSelectedOneCell(); if (cellElement != null) {
if (cellElement != null && b) {
value = cellElement.getValue(); value = cellElement.getValue();
} }
value = value == null ? StringUtils.EMPTY : value;
cellElements = getAllCellElements(tplEC);
boolean sameType = checkSameType(cellElements);
// 多选时,多元格元素类型
value = sameType && value != null ? value : StringUtils.EMPTY;
//之前是少了个bigInteger,刚kunsnat又发现少了个bigDecimal,数字类型的都用stringEditor,没必要那个样子 //之前是少了个bigInteger,刚kunsnat又发现少了个bigDecimal,数字类型的都用stringEditor,没必要那个样子
QuickEditor editor = ActionFactory.getCellEditor((value instanceof Number) ? (Number.class) : (value.getClass())); QuickEditor editor = ActionFactory.getCellEditor((value instanceof Number) ? (Number.class) : (value.getClass()));
return editor; return editor;
} }
/**
* 选中的单元格插入元素类型是否相同
*
* @param cellElements 单元格
* @return true: 相同
*/
public boolean checkSameType(Set<TemplateCellElement> cellElements) {
Class lastType = null;
for (TemplateCellElement cellElement : cellElements) {
Object value = cellElement.getValue();
if (value == null) {
value = StringUtils.EMPTY;
}
Class<?> type = value.getClass();
if (lastType != null && lastType != type) {
return false;
}
lastType = type;
}
return true;
}
/**
* 获取当前选中的所有单元格若选中未编辑状态的单元格暂时不添加为编辑状态
*
* @param elementCase
* @return 获取当前选中的所有单元格
*/
public Set<TemplateCellElement> getAllCellElements(TemplateElementCase elementCase) {
Set<TemplateCellElement> cellElements = new HashSet<>();
// 遍历选择的rect
for (int rect = 0; rect < getCellRectangleCount(); rect++) {
Rectangle cellRectangle = getCellRectangle(rect);
// 遍历rect中每个ce
for (int j = 0; j < cellRectangle.height; j++) {
for (int i = 0; i < cellRectangle.width; i++) {
int column = i + cellRectangle.x;
int row = j + cellRectangle.y;
TemplateCellElement cellElement = elementCase.getTemplateCellElement(column, row);
if (cellElement == null) {
cellElement = new DefaultTemplateCellElement(column, row);
}
cellElements.add(cellElement);
}
}
}
return cellElements;
}
public Set<TemplateCellElement> getCellElements() {
return cellElements;
}
@Override @Override
public void populatePropertyPane(ElementCasePane ePane) { public void populatePropertyPane(ElementCasePane ePane) {
CellElementPropertyPane.getInstance().reInit(ePane); CellElementPropertyPane.getInstance().reInit(ePane);

6
designer-realize/src/main/java/com/fr/nx/app/designer/JStreamBook.java

@ -14,11 +14,11 @@ import com.fr.general.ComparatorUtils;
import com.fr.locale.InterProviderFactory; import com.fr.locale.InterProviderFactory;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.main.impl.WorkBook; import com.fr.main.impl.WorkBook;
import com.fr.nx.cptx.entry.metadata.CptxMetadata;
import com.fr.nx.app.designer.menu.CalculateAttrAction; import com.fr.nx.app.designer.menu.CalculateAttrAction;
import com.fr.nx.app.designer.toolbar.TemplateTransformer; import com.fr.nx.app.designer.toolbar.TemplateTransformer;
import com.fr.nx.app.designer.toolbar.TransformResult; import com.fr.nx.app.designer.toolbar.TransformResult;
import com.fr.nx.app.designer.toolbar.TransformResultInfo; import com.fr.nx.app.designer.toolbar.TransformResultInfo;
import com.fr.nx.cptx.entry.metadata.CptxMetadata;
import com.fr.nx.cptx.utils.CptxFileUtils; import com.fr.nx.cptx.utils.CptxFileUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
@ -27,6 +27,7 @@ import com.fr.third.jodd.util.ArraysUtil;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.nio.file.Paths;
public class JStreamBook extends JWorkBook { public class JStreamBook extends JWorkBook {
@ -103,7 +104,8 @@ public class JStreamBook extends JWorkBook {
} }
private String getSuffix() { private String getSuffix() {
CptxMetadata metadata = CptxFileUtils.getMetadata(this.getEditingFILE().getPath()); String path = this.getEditingFILE().getPath();
CptxMetadata metadata = Paths.get(path).isAbsolute() ? null : CptxFileUtils.getMetadata(path);
if (metadata != null && metadata.isForceCpt()) { if (metadata != null && metadata.isForceCpt()) {
return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Compatibility_Mode"); return InterProviderFactory.getProvider().getLocText("Fine-Plugin_Engine_Compatibility_Mode");
} }

226
designer-realize/src/main/java/com/fr/quickeditor/CellQuickEditor.java

@ -1,13 +1,16 @@
package com.fr.quickeditor; package com.fr.quickeditor;
import com.fr.base.GraphHelper; import com.fr.base.GraphHelper;
import com.fr.base.Style;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.actions.core.ActionFactory; import com.fr.design.actions.core.ActionFactory;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.style.TextFormatPaneContainer;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
@ -23,6 +26,7 @@ import com.fr.design.widget.FRWidgetFactory;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.quickeditor.cellquick.layout.CellElementBarLayout; import com.fr.quickeditor.cellquick.layout.CellElementBarLayout;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.elementcase.TemplateElementCase;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
@ -30,6 +34,7 @@ import javax.swing.JComponent;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JScrollBar; import javax.swing.JScrollBar;
import javax.swing.SwingUtilities;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Component; import java.awt.Component;
import java.awt.Container; import java.awt.Container;
@ -40,7 +45,10 @@ import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener; import java.awt.event.AdjustmentListener;
import java.awt.event.MouseWheelEvent; import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener; import java.awt.event.MouseWheelListener;
import java.text.Format;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects;
import java.util.Set;
/** /**
* @author zhou, yaoh.wu * @author zhou, yaoh.wu
@ -59,6 +67,8 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
private static final int CONTENT_PANE_WIDTH_GAP = 3; private static final int CONTENT_PANE_WIDTH_GAP = 3;
private static final int MOUSE_WHEEL_SPEED = 5; private static final int MOUSE_WHEEL_SPEED = 5;
private static final int SCROLLBAR_WIDTH = 7; private static final int SCROLLBAR_WIDTH = 7;
private UILabel cellLabel;
private int maxHeight = 280; private int maxHeight = 280;
private static final int TITLE_HEIGHT = 50; private static final int TITLE_HEIGHT = 50;
@ -67,11 +77,17 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
*/ */
protected UITextField columnRowTextField; protected UITextField columnRowTextField;
protected TemplateCellElement cellElement; protected TemplateCellElement cellElement;
private TextFormatPaneContainer formatPane;
private JPanel topContentContainer;
private JComponent centerBodyContainer;
private UILabel multipleLabelTip;
// 占位label // 占位label
protected final UILabel EMPTY_LABEL = new UILabel(); protected final UILabel EMPTY_LABEL = new UILabel();
private UIComboBox comboBox; private UIComboBox comboBox;
private UpdateAction[] cellInsertActions; private UpdateAction[] cellInsertActions;
private int selectedIndex; private int selectedIndex;
private int currentSelectedIndex; private int currentSelectedIndex;
@ -80,20 +96,38 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
private ActionListener comboBoxActionListener; private ActionListener comboBoxActionListener;
public CellQuickEditor() { public CellQuickEditor() {
initComponents();
createPanelBody();
}
private void initComponents() {
EMPTY_LABEL.setPreferredSize(LABEL_DIMENSION); EMPTY_LABEL.setPreferredSize(LABEL_DIMENSION);
topContentContainer = initTopContent();
formatPane = createFormatPane();
centerBodyContainer = createCenterBody();
multipleLabelTip = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Cell_Element_Multiple_Tip"));
multipleLabelTip.setEnabled(false);
}
private void createPanelBody() {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = {p, f}; double[] columnSize = {f};
JComponent centerBody = createCenterBody();
JPanel topContent = initTopContent();
if (isScrollAll()) { if (isScrollAll()) {
double[] scrollAllRowSize = {p, p}; double[] scrollAllRowSize = {p, p, p, p};
prepareScrollBar(); prepareScrollBar();
topContent.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 0, this.getBackground())); multipleLabelTip.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 0, this.getBackground()));
centerBody.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground())); topContentContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground()));
formatPane.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground()));
centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 0, this.getBackground()));
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{topContent, null}, new Component[]{multipleLabelTip},
new Component[]{centerBody, null} new Component[]{topContentContainer},
new Component[]{formatPane},
new Component[]{centerBodyContainer}
}; };
leftContentPane = TableLayoutHelper.createGapTableLayoutPane(components, scrollAllRowSize, columnSize, HGAP, VGAP); leftContentPane = TableLayoutHelper.createGapTableLayoutPane(components, scrollAllRowSize, columnSize, HGAP, VGAP);
this.setLayout(new CellElementBarLayout(leftContentPane) { this.setLayout(new CellElementBarLayout(leftContentPane) {
@ -122,12 +156,16 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
this.add(scrollBar); this.add(scrollBar);
this.add(leftContentPane); this.add(leftContentPane);
} else { } else {
double[] scrollContentRowSize = {p, f}; double[] scrollContentRowSize = {p, p, p, f};
topContent.setBorder(BorderFactory.createMatteBorder(10, 10, 0, 10, this.getBackground())); multipleLabelTip.setBorder(BorderFactory.createMatteBorder(5, 10, 0, 0, this.getBackground()));
centerBody.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, this.getBackground())); topContentContainer.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 10, this.getBackground()));
formatPane.setBorder(BorderFactory.createMatteBorder(0, 10, 0, 10, this.getBackground()));
centerBodyContainer.setBorder(BorderFactory.createMatteBorder(0, 0, 0, 0, this.getBackground()));
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{topContent, null}, new Component[]{multipleLabelTip},
new Component[]{centerBody, null} new Component[]{topContentContainer},
new Component[]{formatPane},
new Component[]{centerBodyContainer}
}; };
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
this.add(TableLayoutHelper.createGapTableLayoutPane(components, scrollContentRowSize, columnSize, HGAP, VGAP), BorderLayout.CENTER); this.add(TableLayoutHelper.createGapTableLayoutPane(components, scrollContentRowSize, columnSize, HGAP, VGAP), BorderLayout.CENTER);
@ -156,13 +194,51 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
*/ */
public abstract Object getComboBoxSelected(); public abstract Object getComboBoxSelected();
/** /**
* 刷新 * 刷新
*/ */
@Override @Override
protected void refresh() { protected void refresh() {
refreshPanel();
refreshFormatPanel();
refreshDetails();
refreshMultipleDetails();
}
/**
* 多选时默认隐藏与插入元素类型相关的所有面板
* 若其他面板需要扩展多选时可修改的内容
* 通过重写改方法实现显示/隐藏部分组件
*/
public void refreshMultipleDetails() {
centerBodyContainer.setVisible(tc.isSelectedOneCell());
}
private void refreshFormatPanel() {
// 在populate的时候会多次触发AttributeChangeListener事件,
// 导致不断更新单元格格式,因此populate的时候暂时删除listener
formatPane.removeAttributeChangeListener();
if (cellElement != null) {
formatPane.populateBean(cellElement.getStyle());
} else {
formatPane.populateBean(Style.DEFAULT_STYLE);
}
formatPane.restoreAttributeChangeListener();
}
private void refreshPanel() {
changeVisiableState();
CellSelection cs = (CellSelection) tc.getSelection(); CellSelection cs = (CellSelection) tc.getSelection();
ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow()); ColumnRow columnRow = ColumnRow.valueOf(cs.getColumn(), cs.getRow());
columnRowTextField.setText(columnRow.toString()); columnRowTextField.setText(columnRow.toString());
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow()); cellElement = tc.getEditingElementCase().getTemplateCellElement(cs.getColumn(), cs.getRow());
@ -197,7 +273,24 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
}; };
comboBox.addActionListener(comboBoxActionListener); comboBox.addActionListener(comboBoxActionListener);
} }
refreshDetails(); }
/**
* 单选多选时切换部分组件的 隐藏/显示 状态
*/
private void changeVisiableState() {
boolean selectedOneCell = tc.isSelectedOneCell();
comboBox.setEnabled(selectedOneCell);
if (selectedOneCell) {
columnRowTextField.setPreferredSize(null);
cellLabel.setPreferredSize(null);
multipleLabelTip.setPreferredSize(new Dimension());
} else {
columnRowTextField.setPreferredSize(new Dimension());
cellLabel.setPreferredSize(new Dimension());
multipleLabelTip.setPreferredSize(null);
}
} }
/** /**
@ -207,11 +300,12 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
private JPanel initTopContent() { private JPanel initTopContent() {
double p = TableLayout.PREFERRED; double p = TableLayout.PREFERRED;
double f = TableLayout.FILL; double f = TableLayout.FILL;
double[] columnSize = {GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")), f}; double[] columnSize = {GraphHelper.getWidth(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")), f};
double[] rowSize = {p, p}; double[] rowSize = {p, p};
UILabel cellLabel = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Cell")); cellLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Basic_Cell"));
UILabel insertContentLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element")); UILabel insertContentLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Insert_Cell_Element"));
initCellElementEditComboBox(); initCellElementEditComboBox();
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
@ -324,4 +418,106 @@ public abstract class CellQuickEditor extends QuickEditor<ElementCasePane> {
}); });
return columnRowTextField; return columnRowTextField;
} }
/**
* 创建格式化面板
*/
private TextFormatPaneContainer createFormatPane() {
TextFormatPaneContainer formatPane = new TextFormatPaneContainer();
AttributeChangeListener attributeChangeListener = new AttributeChangeListener() {
@Override
public void attributeChange() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
// 耗时任务放线程中,让其他UI组件更新界面,
// 防止多次调用此处每次获取的界面值不同,导致不断更新单元格格式
isEditing = true;
boolean updateStyle = false;
CellSelection cs = (CellSelection) tc.getSelection();
TemplateElementCase editingElementCase = tc.getEditingElementCase();
Set<TemplateCellElement> allCellElements = cs.getCellElements();
Style oldStyle = cellElement == null ? Style.DEFAULT_STYLE : cellElement.getStyle();
Style style = formatPane.update(oldStyle);
for (TemplateCellElement cellElement : allCellElements) {
Format elementFormat = cellElement.getStyle().getFormat();
Format paneFormat = style.getFormat();
if (!Objects.equals(paneFormat, elementFormat)) {
// 点击单元格,但未设置格式时,不将单元格设置为编辑状态,防止将所选的每个单元格都设置为编辑状态
editingElementCase.addCellElement(cellElement);
cellElement.setStyle(style);
updateStyle = true;
}
}
if (updateStyle) {
// 防止频繁触发保存
if (!tc.isSelectedOneCell()) {
record(multipleOperationType.FORMAT);
}
fireTargetModified();
}
isEditing = false;
}
});
}
};
formatPane.addAttributeChangeListener(attributeChangeListener);
return formatPane;
}
/**
* 用于适配记录批量操作的埋点数据
* 真正的埋点提交方案在云端运维插件中
*
* @param type 批量操作修改类型
* @return 批量修改类型名称用于云端运维埋点记录
*/
public static String record(multipleOperationType type) {
return type.getType();
}
/**
* 批量操作的类型
*/
public enum multipleOperationType {
/**
* 批量修改格式
*/
FORMAT("format"),
/**
* 批量修改数据列的数据设置
*/
TYPE_OF_DATA("type-of-data"),
/**
* 批量修改过滤条件
*/
FILTER("filter"),
/**
* 批量修改行高列宽
*/
HEIHT_AND_COLUMN("row-height-and-column-width");
private final String type;
multipleOperationType(String type) {
this.type = type;
}
public String getType() {
return type;
}
}
} }

130
designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

@ -15,10 +15,8 @@ import com.fr.design.foldablepane.UIExpandablePane;
import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.CustomVariableResolver;
import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula; import com.fr.design.formula.UIFormula;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener; import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIHeadGroup; import com.fr.design.gui.ibutton.UIHeadGroup;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
@ -26,7 +24,6 @@ import com.fr.design.gui.ilable.MultilineLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
@ -36,6 +33,7 @@ import com.fr.design.sort.celldscolumn.CellDSColumnSortPane;
import com.fr.design.utils.gui.UIComponentUtils; import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.design.widget.FRWidgetFactory; import com.fr.design.widget.FRWidgetFactory;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.grid.selection.CellSelection;
import com.fr.quickeditor.CellQuickEditor; import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
@ -46,12 +44,9 @@ import com.fr.report.cell.cellattr.core.group.SelectCount;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Color; import java.awt.Color;
@ -63,6 +58,7 @@ import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Set;
import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.BOTTOM; import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.BOTTOM;
import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.EVEN; import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.EVEN;
@ -163,6 +159,10 @@ public class CellDSColumnEditor extends CellQuickEditor {
tabsHeaderIconPane = new UIHeadGroup(iconArray) { tabsHeaderIconPane = new UIHeadGroup(iconArray) {
@Override @Override
public void tabChanged(int index) { public void tabChanged(int index) {
// 由于多选的时候修改了 cellDSColumnBasicPane 中组件的visiable属性,切换时需要将其设置为false
cellDSColumnBasicPane.setVisible(false);
card.show(cardContainer, paneList.get(index).title4PopupWindow()); card.show(cardContainer, paneList.get(index).title4PopupWindow());
paneList.get(index).populate(); paneList.get(index).populate();
} }
@ -188,6 +188,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
super.release(); super.release();
cellDSColumnBasicPane.release(); cellDSColumnBasicPane.release();
cellDSColumnAdvancedPane.release(); cellDSColumnAdvancedPane.release();
} }
/** /**
@ -237,7 +238,10 @@ public class CellDSColumnEditor extends CellQuickEditor {
@Override @Override
public void update() { public void update() {
dataPane.update(cellElement); dataPane.update(cellElement);
groupPane.update();
CellSelection selection = (CellSelection) tc.getSelection();
Set<TemplateCellElement> allCellElements = selection.getCellElements();
groupPane.update(allCellElements);
} }
@Override @Override
@ -282,7 +286,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
private void initComponents(){ private void initComponents(){
dataPane = new SelectedDataColumnPane(true, true); dataPane = new SelectedDataColumnPane(true, true);
groupPane = new ResultSetGroupDockingPane(); groupPane = new ResultSetGroupDockingPane();
initListener(); initListener();
double[] rowSize = {P}, columnSize = {60, F}; double[] rowSize = {P}, columnSize = {60, F};
UILabel uiLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Filter_Conditions")); UILabel uiLabel = FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Report_Filter_Conditions"));
condition = new DSColumnConditionAction(); condition = new DSColumnConditionAction();
@ -299,8 +303,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
conditionPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP); conditionPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, HGAP, VGAP);
this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); this.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
} }
private void initListener() { private void initListener() {
dataPane.setListener(new ItemListener() { dataPane.setListener(new ItemListener() {
@Override @Override
@ -314,30 +317,66 @@ public class CellDSColumnEditor extends CellQuickEditor {
groupPane.setListener(new ItemListener() { groupPane.setListener(new ItemListener() {
@Override @Override
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
if (e == null) { CellSelection selection = (CellSelection) tc.getSelection();
Set<TemplateCellElement> allCellElements = selection.getCellElements();
if (e == null || e.getStateChange() == ItemEvent.DESELECTED) {
//分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存 //分组-高级-自定义点确定的时候传进来null的e,但是这时候应该触发保存
groupPane.update(); groupPane.update(allCellElements);
fireTargetModified(); if (!tc.isSelectedOneCell()) {
return; CellQuickEditor.record(multipleOperationType.TYPE_OF_DATA);
} }
if (e.getStateChange() == ItemEvent.DESELECTED) {
groupPane.update();
fireTargetModified(); fireTargetModified();
} }
} }
}); });
} }
@Override @Override
protected AttributeChangeListener getAttributeChangeListener() { protected AttributeChangeListener getAttributeChangeListener() {
return new AttributeChangeListener() { return new AttributeChangeListener() {
@Override @Override
public void attributeChange() { public void attributeChange() {
update();
fireTargetModified();
} }
}; };
} }
public void setMultipleVisible(boolean selectedOneCell) {
// 数据源面板 需要在单选与多选间切换显示状态
dataPane.setVisible(selectedOneCell);
if (!selectedOneCell) {
// 只有在批量操作的时候才需要判断是否隐藏条件面板
CellSelection selection = (CellSelection) tc.getSelection();
boolean sameDSName = checkSameDSName(selection.getCellElements());
conditionPane.setVisible(sameDSName);
} else {
conditionPane.setVisible(true);
}
}
/**
* 判断是否属于同一个数据集
*
* @param cellElements
* @return
*/
private boolean checkSameDSName(Set<TemplateCellElement> cellElements) {
String lastDSName = StringUtils.EMPTY;
for (TemplateCellElement cellElement : cellElements) {
DSColumn dsColumn = (DSColumn) cellElement.getValue();
String dsName = dsColumn.getDSName();
if (StringUtils.isNotEmpty(lastDSName) && !StringUtils.equals(dsName, lastDSName)) {
return false;
}
lastDSName = dsName;
}
return true;
}
} }
@ -352,10 +391,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
* 自定义值显示 * 自定义值显示
*/ */
private CustomValuePane valuePane; private CustomValuePane valuePane;
/**
* 文本格式
*/
private FormatAttrPane formatAttrPane;
/** /**
* 横向可扩展性 * 横向可扩展性
*/ */
@ -402,7 +437,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
public void update() { public void update() {
if (cellElement != null) { if (cellElement != null) {
valuePane.update(cellElement); valuePane.update(cellElement);
formatAttrPane.update(cellElement);
filterPane.update(cellElement); filterPane.update(cellElement);
//更新单元格扩展属性 //更新单元格扩展属性
updateExtendConfig(); updateExtendConfig();
@ -417,7 +451,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
if (cellElement != null) { if (cellElement != null) {
this.removeAttributeChangeListener(); this.removeAttributeChangeListener();
valuePane.populate(cellElement); valuePane.populate(cellElement);
formatAttrPane.populate(cellElement);
filterPane.populate(cellElement); filterPane.populate(cellElement);
CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr(); CellExpandAttr cellExpandAttr = cellElement.getCellExpandAttr();
if (cellExpandAttr == null) { if (cellExpandAttr == null) {
@ -529,9 +562,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
//自定义值显示 //自定义值显示
valuePane = new CustomValuePane(); valuePane = new CustomValuePane();
// 文本格式
formatAttrPane = new FormatAttrPane();
//可扩展性 //可扩展性
JPanel extendableDirectionPane = FRGUIPaneFactory.createYBoxEmptyBorderPane(); JPanel extendableDirectionPane = FRGUIPaneFactory.createYBoxEmptyBorderPane();
extendableDirectionPane.add(heCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable"))); extendableDirectionPane.add(heCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_ExpandD_Horizontal_Extendable")));
@ -559,7 +589,6 @@ public class CellDSColumnEditor extends CellQuickEditor {
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
{filterPane}, {filterPane},
{valuePane}, {valuePane},
{formatAttrPane},
{extendableDirectionPane}, {extendableDirectionPane},
{multiNumPane} {multiNumPane}
}; };
@ -1030,43 +1059,14 @@ public class CellDSColumnEditor extends CellQuickEditor {
} }
} }
public class FormatAttrPane extends AbstractAttrNoScrollPane { }
private TextFormatPane formatPane;
@Override
protected JPanel createContentPane() {
this.formatPane = new TextFormatPane();
return this.formatPane;
}
@Override
public Dimension getPreferredSize() {
if (formatPane == null) {
return super.getPreferredSize();
}
return formatPane.getPreferredSize();
}
protected void initContentPane() {
leftContentPane = createContentPane();
if (leftContentPane != null) {
leftContentPane.setBorder(BorderFactory.createEmptyBorder());
this.add(leftContentPane, BorderLayout.CENTER);
}
}
public void populate(CellElement cellElement) { @Override
if (cellElement != null && formatPane != null) { public void refreshMultipleDetails() {
formatPane.populateBean(cellElement.getStyle()); tabsHeaderIconPane.setVisible(tc.isSelectedOneCell());
} cellDSColumnAdvancedPane.setVisible(tc.isSelectedOneCell());
}
public void update(CellElement cellElement) { cellDSColumnBasicPane.setMultipleVisible(tc.isSelectedOneCell());
if (cellElement != null && formatPane != null) {
cellElement.setStyle(formatPane.update(cellElement.getStyle()));
}
}
}
} }
@Override @Override

50
designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellFormulaQuickEditor.java

@ -8,17 +8,13 @@ import com.fr.design.actions.insert.cell.FormulaCellAction;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.UIFormula; import com.fr.design.formula.UIFormula;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
import com.fr.quickeditor.CellQuickEditor; import com.fr.quickeditor.CellQuickEditor;
import com.fr.report.ReportHelper; import com.fr.report.ReportHelper;
@ -50,7 +46,6 @@ import java.util.Arrays;
public class CellFormulaQuickEditor extends CellQuickEditor { public class CellFormulaQuickEditor extends CellQuickEditor {
//文本域 //文本域
private UITextField formulaTextField; private UITextField formulaTextField;
private TextFormatPane formatPane;
//编辑状态 //编辑状态
private boolean isEditing = false; private boolean isEditing = false;
@ -144,57 +139,16 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
Component[][] componentLines = new Component[][] { Component[][] componentLines = new Component[][] {
new Component[]{EMPTY_LABEL, content}, new Component[]{EMPTY_LABEL, content},
new Component[]{createFormatPane(), null},
}; };
double[] rowSize = new double[componentLines.length]; double[] rowSize = new double[componentLines.length];
Arrays.fill(rowSize, TableLayout.PREFERRED); Arrays.fill(rowSize, TableLayout.PREFERRED);
double[] columnSize = new double[] {TableLayout.PREFERRED, TableLayout.FILL }; double[] columnSize = new double[] {TableLayout.PREFERRED, TableLayout.FILL };
return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{ return TableLayoutHelper.createGapTableLayoutPane(new Component[][]{
new Component[]{EMPTY_LABEL, content}, new Component[]{EMPTY_LABEL, content},
new Component[]{createFormatPane(), null},
}, },
rowSize, columnSize, HGAP, VGAP); rowSize, columnSize, HGAP, VGAP);
} }
private JPanel createFormatPane() {
formatPane = new TextFormatPane();
AbstractAttrNoScrollPane container = new AbstractAttrNoScrollPane() {
@Override
protected JPanel createContentPane() {
return formatPane;
}
protected void initContentPane() {
leftContentPane = createContentPane();
if (leftContentPane != null) {
leftContentPane.setBorder(BorderFactory.createEmptyBorder());
this.add(leftContentPane, BorderLayout.CENTER);
}
}
};
container.addAttributeChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
isEditing = true;
CellSelection cs1 = (CellSelection) tc.getSelection();
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs1.getColumn(), cs1.getRow());
if (cellElement == null) {
CellSelection cs = (CellSelection) tc.getSelection();
cellElement = DefaultThemedTemplateCellElementCase.createInstance(cs.getColumn(), cs.getRow());
tc.getEditingElementCase().addCellElement(cellElement, false);
}
cellElement.setStyle(formatPane.update(cellElement.getStyle()));
fireTargetModified();
isEditing = false;
}
});
return container;
}
@Override @Override
public Object getComboBoxSelected() { public Object getComboBoxSelected() {
@ -257,10 +211,6 @@ public class CellFormulaQuickEditor extends CellQuickEditor {
showText(str); showText(str);
formulaTextField.setEditable(tc.isSelectedOneCell()); formulaTextField.setEditable(tc.isSelectedOneCell());
if (cellElement != null) {
Style style = cellElement.getStyle();
formatPane.populateBean(style);
}
} }
/** /**

52
designer-realize/src/main/java/com/fr/quickeditor/cellquick/CellStringQuickEditor.java

@ -4,10 +4,7 @@ import com.fr.base.BaseFormula;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.base.TextFormat; import com.fr.base.TextFormat;
import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.IntervalConstants;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.frpane.AttributeChangeListener;
import com.fr.design.gui.itextarea.UITextArea; import com.fr.design.gui.itextarea.UITextArea;
import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase; import com.fr.design.mainframe.theme.utils.DefaultThemedTemplateCellElementCase;
import com.fr.grid.GridKeyListener; import com.fr.grid.GridKeyListener;
import com.fr.grid.selection.CellSelection; import com.fr.grid.selection.CellSelection;
@ -16,7 +13,6 @@ import com.fr.report.ReportHelper;
import com.fr.stable.ColumnRow; import com.fr.stable.ColumnRow;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JComponent; import javax.swing.JComponent;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
@ -31,7 +27,6 @@ import java.awt.event.KeyEvent;
public class CellStringQuickEditor extends CellQuickEditor { public class CellStringQuickEditor extends CellQuickEditor {
//文本域 直接可以自适应大小 //文本域 直接可以自适应大小
private UITextArea stringTextArea; private UITextArea stringTextArea;
private TextFormatPane formatPane;
//编辑状态 //编辑状态
private boolean isEditing = false; private boolean isEditing = false;
@ -95,51 +90,9 @@ public class CellStringQuickEditor extends CellQuickEditor {
}); });
content.add(stringTextArea, BorderLayout.NORTH); content.add(stringTextArea, BorderLayout.NORTH);
content.add(createFormatPane(), BorderLayout.CENTER);
return content; return content;
} }
private JPanel createFormatPane() {
formatPane = new TextFormatPane();
AbstractAttrNoScrollPane container = new AbstractAttrNoScrollPane() {
@Override
protected JPanel createContentPane() {
return formatPane;
}
protected void initContentPane() {
leftContentPane = createContentPane();
if (leftContentPane != null) {
leftContentPane.setBorder(BorderFactory.createEmptyBorder());
this.add(leftContentPane, BorderLayout.CENTER);
}
}
};
container.addAttributeChangeListener(new AttributeChangeListener() {
@Override
public void attributeChange() {
isEditing = true;
CellSelection cs1 = (CellSelection) tc.getSelection();
cellElement = tc.getEditingElementCase().getTemplateCellElement(cs1.getColumn(), cs1.getRow());
if (cellElement == null) {
CellSelection cs = (CellSelection) tc.getSelection();
cellElement = DefaultThemedTemplateCellElementCase.createInstance(cs.getColumn(), cs.getRow());
tc.getEditingElementCase().addCellElement(cellElement, false);
}
cellElement.setStyle(formatPane.update(cellElement.getStyle()));
fireTargetModified();
isEditing = false;
}
});
return container;
}
@Override @Override
public boolean isScrollAll() { public boolean isScrollAll() {
return true; return true;
@ -200,11 +153,6 @@ public class CellStringQuickEditor extends CellQuickEditor {
} }
showText(str); showText(str);
stringTextArea.setEditable(tc.isSelectedOneCell()); stringTextArea.setEditable(tc.isSelectedOneCell());
if (cellElement != null) {
Style style = cellElement.getStyle();
formatPane.populateBean(style);
}
} }
/** /**

Loading…
Cancel
Save