diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java index 1fbed9f437..5c2b42c257 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/TableDataPreviewDesensitizeManager.java @@ -2,6 +2,7 @@ package com.fr.design.data.datapane.preview.desensitization; import com.fr.base.TableData; +import com.fr.data.TableDataSource; import com.fr.data.desensitize.TableDataDesensitizeManager; import com.fr.data.desensitize.base.DesensitizationTableData; import com.fr.data.desensitize.base.TableDataDesensitizationItem; @@ -15,11 +16,14 @@ 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.esd.query.StrategicTableData; import com.fr.general.ComparatorUtils; import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; +import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.Comparator; import java.util.LinkedHashMap; import java.util.List; @@ -107,13 +111,17 @@ public class TableDataPreviewDesensitizeManager implements DesensitizationManage } /** - * 通过TableData获取其列名 + * 通过TableData获取其列名,理论上一定存在缓存值 * * @param tableData * @return */ public List getColumnNamesByTableData(TableData tableData) { - return DesignTableDataManager.getColumnNamesByTableData(tableData); + TableDataSource editingTableDataSource = DesignTableDataManager.getEditingTableDataSource(); + if (editingTableDataSource != null && tableData instanceof StrategicTableData) { + return Arrays.asList(DesignTableDataManager.getSelectedColumnNames(editingTableDataSource, ((StrategicTableData) tableData).getDsName())); + } + return Collections.EMPTY_LIST; } /** diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java index c1d958bf9f..375f280bdf 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java @@ -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.dialog.BasicDialog; import com.fr.design.dialog.DialogActionAdapter; -import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icombobox.UIComboBox; 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.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.log.FineLoggerFactory; import com.fr.stable.StringUtils; import org.jetbrains.annotations.Nullable; @@ -29,6 +29,7 @@ import javax.swing.JComponent; import javax.swing.JPanel; import javax.swing.JTable; import javax.swing.SwingUtilities; +import javax.swing.SwingWorker; import javax.swing.event.CellEditorListener; import javax.swing.event.ChangeEvent; import javax.swing.table.TableCellEditor; @@ -38,9 +39,11 @@ import java.awt.Color; 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.Iterator; +import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -61,17 +64,15 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter columnNames; + private List columnNames = new ArrayList<>(); /** * key为用户组唯一标识(id拼接),value为用户组名称 */ - private Map roleMap; + private final Map roleMap = new LinkedHashMap<>(); private Component parent; @@ -84,12 +85,6 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter() { + + @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 @@ -210,6 +231,10 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter