|
|
@ -9,7 +9,6 @@ import com.fr.design.data.datapane.preview.desensitization.TableDataPreviewDesen |
|
|
|
import com.fr.design.data.datapane.preview.desensitization.view.rule.DesensitizationRulePane; |
|
|
|
import com.fr.design.data.datapane.preview.desensitization.view.rule.DesensitizationRulePane; |
|
|
|
import com.fr.design.dialog.BasicDialog; |
|
|
|
import com.fr.design.dialog.BasicDialog; |
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
import com.fr.design.dialog.DialogActionAdapter; |
|
|
|
import com.fr.design.dialog.FineJOptionPane; |
|
|
|
|
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.ibutton.UIButton; |
|
|
|
import com.fr.design.gui.icombobox.UIComboBox; |
|
|
|
import com.fr.design.gui.icombobox.UIComboBox; |
|
|
|
import com.fr.design.gui.icombocheckbox.UIComboCheckBox; |
|
|
|
import com.fr.design.gui.icombocheckbox.UIComboCheckBox; |
|
|
@ -21,6 +20,7 @@ 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; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
import com.fr.design.layout.TableLayoutHelper; |
|
|
|
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import org.jetbrains.annotations.Nullable; |
|
|
|
import org.jetbrains.annotations.Nullable; |
|
|
|
|
|
|
|
|
|
|
@ -29,6 +29,7 @@ import javax.swing.JComponent; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JPanel; |
|
|
|
import javax.swing.JTable; |
|
|
|
import javax.swing.JTable; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
import javax.swing.SwingUtilities; |
|
|
|
|
|
|
|
import javax.swing.SwingWorker; |
|
|
|
import javax.swing.event.CellEditorListener; |
|
|
|
import javax.swing.event.CellEditorListener; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.event.ChangeEvent; |
|
|
|
import javax.swing.table.TableCellEditor; |
|
|
|
import javax.swing.table.TableCellEditor; |
|
|
@ -38,9 +39,11 @@ import java.awt.Color; |
|
|
|
import java.awt.Component; |
|
|
|
import java.awt.Component; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionEvent; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
import java.awt.event.ActionListener; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.Iterator; |
|
|
|
import java.util.Iterator; |
|
|
|
|
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.LinkedHashSet; |
|
|
|
import java.util.LinkedHashSet; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
@ -61,17 +64,15 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl |
|
|
|
|
|
|
|
|
|
|
|
private static final String COMMA = ","; |
|
|
|
private static final String COMMA = ","; |
|
|
|
|
|
|
|
|
|
|
|
private DesensitizationTableData tableData; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 当前数据集的所有列名 |
|
|
|
* 当前数据集的所有列名 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private List<String> columnNames; |
|
|
|
private List<String> columnNames = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* key为用户组唯一标识(id拼接),value为用户组名称 |
|
|
|
* key为用户组唯一标识(id拼接),value为用户组名称 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
private Map<String, String> roleMap; |
|
|
|
private final Map<String, String> roleMap = new LinkedHashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
private Component parent; |
|
|
|
private Component parent; |
|
|
|
|
|
|
|
|
|
|
@ -84,12 +85,6 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl |
|
|
|
Toolkit.i18nText("Fine-Design_Report_Desensitization_Effected_Roles"), |
|
|
|
Toolkit.i18nText("Fine-Design_Report_Desensitization_Effected_Roles"), |
|
|
|
Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Status"), |
|
|
|
Toolkit.i18nText("Fine-Design_Report_Desensitization_Rule_Status"), |
|
|
|
}); |
|
|
|
}); |
|
|
|
// 一些数据相关
|
|
|
|
|
|
|
|
this.tableData = tableData; |
|
|
|
|
|
|
|
// 获取当前数据集的所有列名
|
|
|
|
|
|
|
|
this.columnNames = TableDataPreviewDesensitizeManager.getInstance().getColumnNamesByTableData(tableData); |
|
|
|
|
|
|
|
// 获取当前所有用户组
|
|
|
|
|
|
|
|
this.roleMap = TableDataPreviewDesensitizeManager.getInstance().getAllRoles(); |
|
|
|
|
|
|
|
this.parent = parent; |
|
|
|
this.parent = parent; |
|
|
|
this.setColumnClass(new Class[]{ |
|
|
|
this.setColumnClass(new Class[]{ |
|
|
|
// 列名选择
|
|
|
|
// 列名选择
|
|
|
@ -103,15 +98,41 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl |
|
|
|
// 规则状态
|
|
|
|
// 规则状态
|
|
|
|
DesensitizationRuleStatusPane.class |
|
|
|
DesensitizationRuleStatusPane.class |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
ColumnNamesComboBox columnNamesComboBox = new ColumnNamesComboBox(); |
|
|
|
this.setDefaultEditor(ColumnNamesComboBox.class, new ColumnNamesComboBox()); |
|
|
|
this.setDefaultEditor(ColumnNamesComboBox.class, columnNamesComboBox); |
|
|
|
this.setDefaultEditor(DesensitizationRuleChooser.class, new DesensitizationRuleChooser()); |
|
|
|
this.setDefaultEditor(DesensitizationRuleChooser.class, new DesensitizationRuleChooser()); |
|
|
|
this.setDefaultEditor(DesensitizationRuleDescriptionPane.class, new DesensitizationRuleDescriptionPane()); |
|
|
|
this.setDefaultEditor(DesensitizationRuleDescriptionPane.class, new DesensitizationRuleDescriptionPane()); |
|
|
|
this.setDefaultEditor(EffectedRolesChooser.class, new EffectedRolesChooser()); |
|
|
|
EffectedRolesChooser effectedRolesChooser = new EffectedRolesChooser(); |
|
|
|
|
|
|
|
this.setDefaultEditor(EffectedRolesChooser.class, effectedRolesChooser); |
|
|
|
this.setDefaultEditor(DesensitizationRuleStatusPane.class, new DesensitizationRuleStatusPane()); |
|
|
|
this.setDefaultEditor(DesensitizationRuleStatusPane.class, new DesensitizationRuleStatusPane()); |
|
|
|
this.setDefaultRenderer(DesensitizationRuleStatusPane.class, new DesensitizationRuleStatusPane()); |
|
|
|
this.setDefaultRenderer(DesensitizationRuleStatusPane.class, new DesensitizationRuleStatusPane()); |
|
|
|
|
|
|
|
|
|
|
|
this.createTable().getColumnModel().getColumn(TableSequences.DesensitizationRuleStatus.getNum()).setMaxWidth(60); |
|
|
|
this.createTable().getColumnModel().getColumn(TableSequences.DesensitizationRuleStatus.getNum()).setMaxWidth(60); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
new SwingWorker<Void, Void>() { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected Void doInBackground() throws Exception { |
|
|
|
|
|
|
|
// 获取当前数据集的所有列名
|
|
|
|
|
|
|
|
columnNames.addAll(TableDataPreviewDesensitizeManager.getInstance().getColumnNamesByTableData(tableData)); |
|
|
|
|
|
|
|
// 获取当前所有用户组
|
|
|
|
|
|
|
|
roleMap.putAll(TableDataPreviewDesensitizeManager.getInstance().getAllRoles()); |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
protected void done() { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
// 更新列名选择框和生效用户组选择框
|
|
|
|
|
|
|
|
columnNamesComboBox.refresh(); |
|
|
|
|
|
|
|
effectedRolesChooser.refresh(); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
FineLoggerFactory.getLogger().error(e, "[Desensitization] get column names or all roles failed for {}", e.getMessage()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}.execute(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
@ -210,6 +231,10 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void refresh() { |
|
|
|
|
|
|
|
columnNameComboBox.refreshBoxItems(columnNames); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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) { |
|
|
@ -328,7 +353,7 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl |
|
|
|
private UIComboCheckBox rolesCheckBox; |
|
|
|
private UIComboCheckBox rolesCheckBox; |
|
|
|
|
|
|
|
|
|
|
|
EffectedRolesChooser() { |
|
|
|
EffectedRolesChooser() { |
|
|
|
this.rolesCheckBox = new UIComboCheckBox(roleMap.values().toArray(), true) { |
|
|
|
this.rolesCheckBox = new UIComboCheckBox(new String[]{}, true) { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
protected void setLayoutAndAddComponents() { |
|
|
|
protected void setLayoutAndAddComponents() { |
|
|
|
// 使用BorderLayout,否则默认使用的FlowLayout会让整个下拉选框使用最小Size,然后TableCell这边会出现空白
|
|
|
|
// 使用BorderLayout,否则默认使用的FlowLayout会让整个下拉选框使用最小Size,然后TableCell这边会出现空白
|
|
|
@ -362,6 +387,10 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void refresh() { |
|
|
|
|
|
|
|
rolesCheckBox.refreshCombo(roleMap.values().toArray()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@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) { |
|
|
|
rolesCheckBox.setSelectedValues(generateRolesCheckBoxSelectedValues(getList().get(row))); |
|
|
|
rolesCheckBox.setSelectedValues(generateRolesCheckBoxSelectedValues(getList().get(row))); |
|
|
@ -444,36 +473,6 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 标签点击后,处理原规则 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
private void ruleStatusLabelClick(TableDataDesensitizationItem currentItem) { |
|
|
|
|
|
|
|
DesensitizationRuleStatus ruleStatus = DesensitizationRuleManager.getInstance().getRuleStatus(currentItem.getRule()); |
|
|
|
|
|
|
|
if (ruleStatus == DesensitizationRuleStatus.NORMAL) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// 点击Label后,弹窗提示
|
|
|
|
|
|
|
|
int option = FineJOptionPane.showConfirmDialog( |
|
|
|
|
|
|
|
parent, |
|
|
|
|
|
|
|
ruleStatus.getDescription(), |
|
|
|
|
|
|
|
Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), |
|
|
|
|
|
|
|
FineJOptionPane.OK_CANCEL_OPTION, |
|
|
|
|
|
|
|
FineJOptionPane.INFORMATION_MESSAGE); |
|
|
|
|
|
|
|
if (option == FineJOptionPane.OK_OPTION && table.getSelectedRow() != -1) { |
|
|
|
|
|
|
|
int selectedRow = table.getSelectedRow(); |
|
|
|
|
|
|
|
// 点击确定后,根据规则状态对规则做处理
|
|
|
|
|
|
|
|
if (ruleStatus == DesensitizationRuleStatus.REMOVED || ruleStatus == DesensitizationRuleStatus.WRONG) { |
|
|
|
|
|
|
|
// 规则被删除或读取错误时,直接删掉
|
|
|
|
|
|
|
|
removeRow(selectedRow); |
|
|
|
|
|
|
|
} else if (ruleStatus == DesensitizationRuleStatus.MODIFIED) { |
|
|
|
|
|
|
|
// 规则被修改时,用新规则替换
|
|
|
|
|
|
|
|
DesensitizationRule lastedRule = DesensitizationRuleManager.getInstance().getLastedDesentizationRule(currentItem.getRule()); |
|
|
|
|
|
|
|
currentItem.setRule(lastedRule); |
|
|
|
|
|
|
|
setRowAt(currentItem, selectedRow); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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) { |
|
|
|
refreshRuleStatus(getList().get(row)); |
|
|
|
refreshRuleStatus(getList().get(row)); |
|
|
|