Browse Source

REPORT-83849 && REPORT-89327

修改代码质量
release/11.0
Leo.Qin 2 years ago
parent
commit
2e97b45328
  1. 2
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTablePane.java
  2. 12
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/DesensitizationCellEditor.java
  3. 42
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/DesensitizationCellPane.java
  4. 47
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/UpdateDataWorker.java

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

@ -91,7 +91,7 @@ public class TableDataDesensitizationTablePane extends JPanel {
// 获取当前数据集的所有列名
columnNames.addAll(TableDataPreviewDesensitizeManager.getInstance().getColumnNamesByTableData(tableData));
// 获取当前所有用户组
roleMap.putAll(WorkContext.getCurrent().get(OrganizationOperator.class).getAllRoles());
roleMap.putAll(WorkContext.getCurrent().get(OrganizationOperator.class).getAllRoles4Desensitization());
// 获取当前最新的所有规则
latestRules.putAll(DesensitizationRuleManager.getInstance().getAllRules());
return null;

12
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/DesensitizationCellEditor.java

@ -10,6 +10,7 @@ import javax.swing.border.LineBorder;
import javax.swing.table.TableCellEditor;
import java.awt.Color;
import java.awt.Component;
import java.util.Map;
/**
* 脱敏规则设置cellEditor
@ -24,18 +25,11 @@ public class DesensitizationCellEditor extends AbstractCellEditor implements Tab
editPane = new DesensitizationCellPane(parent, model);
}
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
// 点击脱敏设置时刷新用户组信息和所有规则
new SwingWorker<Void, Void>(){
@Override
protected Void doInBackground() throws Exception {
editPane.refresh();
return null;
}
}.execute();
SwingWorker<Map<String, Object>, Void> updateDateWorker = new UpdateDataWorker();
updateDateWorker.execute();
editPane.populate((CellDesensitizationBean) value, row);

42
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/DesensitizationCellPane.java

@ -10,6 +10,7 @@ import com.fr.design.data.datapane.preview.desensitization.view.rule.Desensitiza
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.event.UIObserverListener;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombocheckbox.UIComboCheckBox;
import com.fr.design.gui.ilable.UILabel;
@ -19,6 +20,8 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.JTemplateActionListener;
import com.fr.report.cell.desensitization.CellDesensitizationBean;
import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.collections4.map.HashedMap;
@ -27,6 +30,7 @@ import com.fr.workspace.WorkContext;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@ -39,6 +43,7 @@ import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
/**
* 单元格脱敏规则设置面板
@ -60,6 +65,7 @@ public class DesensitizationCellPane extends BasicBeanPane {
private static Map<String, String> roleMap;
private static Map<DesensitizationRuleSource, Map<String, DesensitizationRule>> latestRules;
private CellDesensitizationTableModel model;
private static final CellDesensitizationBean EMPTY_BEAN = CellDesensitizationBean.createEmptyBean();
DesensitizationCellPane(Component parent, CellDesensitizationTableModel model) {
@ -149,10 +155,6 @@ public class DesensitizationCellPane extends BasicBeanPane {
rule = rulePane.updateBean();
if (Objects.nonNull(selectBean) && Objects.nonNull(rule) && !selectBean.getDesensitizationRule().equals(rule)) {
selectBean.setDesensitizationRule(rule);
ruleTextField.setText(rule.getRuleName());
// 非正常状态需要颜色修改为红色
refreshRuleState(selectBean);
model.fireTableDataChanged();
}
@ -203,28 +205,42 @@ public class DesensitizationCellPane extends BasicBeanPane {
public void populate(CellDesensitizationBean value, int row) {
refreshRoles();
String ruleName = value.getDesensitizationRule().getRuleName();
ruleTextField.setText(ruleName);
refreshRuleText(value);
// 非正常状态需要颜色修改为红色
refreshRuleState(value);
Map<Object, Boolean> map = generateRolesCheckBoxSelectedValues(value);
rolesComboBox.setSelectedValues(map);
label.setText(Toolkit.i18nText("Fine-Design_Report_Desensitization_Setting") + row);
label.setText(Toolkit.i18nText("Fine-Design_Report_Desensitization_Setting") + (row + 1));
}
/**
* 刷新规则文本
*
* @param value
*/
private void refreshRuleText(CellDesensitizationBean value) {
ruleTextField.setText(StringUtils.EMPTY);
DesensitizationRule desensitizationRule = value.getDesensitizationRule();
if (desensitizationRule != null) {
String ruleName = desensitizationRule.getRuleName();
ruleTextField.setText(ruleName);
}
}
/**
* combobox组件刷新用户组信息
*/
private void refreshRoles() {
rolesComboBox.clearText();
rolesComboBox.refreshCombo(roleMap.values().toArray());
}
private void refreshRuleState(CellDesensitizationBean value) {
DesensitizationRuleStatus ruleStatus = DesensitizationRuleManager.getInstance().getRuleStatus(value.getDesensitizationRule(), latestRules);
if (value.equals(CellDesensitizationBean.createEmptyBean())) {
if (EMPTY_BEAN.equals(value)) {
ruleTextField.setForeground(Color.GRAY);
} else if (ruleStatus != DesensitizationRuleStatus.NORMAL) {
ruleTextField.setForeground(Color.RED);
@ -306,13 +322,11 @@ public class DesensitizationCellPane extends BasicBeanPane {
}
/**
* 新用户组和平台规则
* 新用户组和平台规则
*/
public void refresh() {
roleMap = WorkContext.getCurrent().get(OrganizationOperator.class).getAllRoles();
latestRules = DesensitizationRuleManager.getInstance().getAllRules();
public static void updateData(Map<String, String> roleMap, Map<DesensitizationRuleSource, Map<String, DesensitizationRule>> latestRules) {
DesensitizationCellPane.roleMap = roleMap;
DesensitizationCellPane.latestRules = latestRules;
}
}

47
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/UpdateDataWorker.java

@ -0,0 +1,47 @@
package com.fr.design.mainframe.cell.settingpane.desensitization.model;
import com.fr.base.operator.org.OrganizationOperator;
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.workspace.WorkContext;
import javax.swing.SwingWorker;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ExecutionException;
/**
* 刷新脱敏设置全局 roles rules SwingWorker
*
* @author Leo.Qin
* @version 11.0
* Created by Leo.Qin on 2023/1/5
*/
public class UpdateDataWorker extends SwingWorker<Map<String, Object>, Void> {
private final String ROLE_KEY = "Roles";
private final String RULE_KEY = "Rules";
@Override
protected Map<String, Object> doInBackground() {
Map<String, Object> result = new HashMap<>();
Map<String, String> allRoles = WorkContext.getCurrent().get(OrganizationOperator.class).getAllRoles4Desensitization();
Map<DesensitizationRuleSource, Map<String, DesensitizationRule>> allRules = DesensitizationRuleManager.getInstance().getAllRules();
result.put(ROLE_KEY, allRoles);
result.put(RULE_KEY, allRules);
return result;
}
@Override
protected void done() {
try {
Map<String, Object> result = get();
DesensitizationCellPane.updateData((Map<String, String>) result.get(ROLE_KEY), (Map<DesensitizationRuleSource, Map<String, DesensitizationRule>>) result.get(RULE_KEY));
} catch (InterruptedException | ExecutionException e) {
throw new RuntimeException(e);
}
}
}
Loading…
Cancel
Save