Yvan-欧阳帆
2 years ago
2 changed files with 156 additions and 79 deletions
@ -0,0 +1,120 @@
|
||||
package com.fr.design.data.datapane.preview.desensitization.view; |
||||
|
||||
import com.fr.base.svg.IconUtils; |
||||
import com.fr.design.constants.UIConstants; |
||||
import com.fr.design.data.datapane.preview.PreviewTablePane; |
||||
import com.fr.design.gui.ibutton.UIToggleButton; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.itoolbar.UIToolbar; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.menu.SeparatorDef; |
||||
import com.fr.design.menu.ToolBarDef; |
||||
|
||||
import javax.swing.Icon; |
||||
import javax.swing.JPanel; |
||||
import java.awt.Component; |
||||
import java.awt.FlowLayout; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
|
||||
/** |
||||
* 数据集预览-脱敏配置面板,主要展示当前脱敏开启状态、当前脱敏设定数量等 |
||||
* |
||||
* @author Yvan |
||||
* @version 11.0 |
||||
* Created by Yvan on 2022/11/14 |
||||
*/ |
||||
public class PreviewTableDesensitizationPane extends JPanel { |
||||
|
||||
private static final String DATA_DESENSITIZATION_CONFIG = Toolkit.i18nText("Fine-Design_Report_Desensitization_Config"); |
||||
private static final String LEFT_BRACKET = "("; |
||||
private static final String RIGHT_BRACKET = ")"; |
||||
private static final String COUNT = Toolkit.i18nText("Fine-Design_Report_Desensitization_Count"); |
||||
|
||||
/** |
||||
* 预览面板 |
||||
*/ |
||||
private PreviewTablePane previewTablePane; |
||||
|
||||
/** |
||||
* "数据脱敏设置"-标签 |
||||
*/ |
||||
private UILabel desensitizationLabel; |
||||
|
||||
/** |
||||
* 脱敏效果预览按钮 |
||||
*/ |
||||
private UIToggleButton previewToggle; |
||||
|
||||
|
||||
public PreviewTableDesensitizationPane(PreviewTablePane previewTablePane) { |
||||
this.previewTablePane = previewTablePane; |
||||
initComponents(); |
||||
} |
||||
|
||||
/** |
||||
* 初始化面板 |
||||
*/ |
||||
private void initComponents() { |
||||
this.setLayout(new FlowLayout(FlowLayout.LEFT)); |
||||
this.add(initDesensitizationLabel()); |
||||
this.add(initToolBar()); |
||||
this.add(initPreviewButton()); |
||||
} |
||||
|
||||
/** |
||||
* 初始化Label |
||||
* |
||||
* @return |
||||
*/ |
||||
private Component initDesensitizationLabel() { |
||||
// 初始化Label
|
||||
desensitizationLabel = new UILabel(DATA_DESENSITIZATION_CONFIG); |
||||
desensitizationLabel.setForeground(UIConstants.NORMAL_BLUE); |
||||
desensitizationLabel.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseClicked(MouseEvent e) { |
||||
previewTablePane.clickDesensitizationLabel(); |
||||
} |
||||
}); |
||||
return desensitizationLabel; |
||||
} |
||||
|
||||
/** |
||||
* 初始化分隔符 |
||||
* |
||||
* @return |
||||
*/ |
||||
private UIToolbar initToolBar() { |
||||
ToolBarDef toolbarDef = new ToolBarDef(); |
||||
toolbarDef.addShortCut(SeparatorDef.DEFAULT); |
||||
UIToolbar toolBar = ToolBarDef.createJToolBar(); |
||||
toolBar.setBorderPainted(false); |
||||
toolbarDef.updateToolBar(toolBar); |
||||
return toolBar; |
||||
} |
||||
|
||||
/** |
||||
* 初始化脱敏效果预览按钮 |
||||
* |
||||
* @return |
||||
*/ |
||||
private UIToggleButton initPreviewButton() { |
||||
previewToggle = new UIToggleButton(new Icon[]{IconUtils.readIcon("/com/fr/design/images/m_file/preview"), IconUtils.readIcon("/com/fr/design/images/m_file/preview")}, true); |
||||
previewToggle.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Desensitization_Preview")); |
||||
previewToggle.setSelected(false); |
||||
previewToggle.addActionListener(e -> { |
||||
// 切换TableModel的脱敏状态
|
||||
previewTablePane.togglePreviewTableModelDesensitizeStatus(); |
||||
// 刷新预览页面,展示
|
||||
previewTablePane.refreshTable(); |
||||
}); |
||||
return previewToggle; |
||||
} |
||||
|
||||
public void setDesensitizationCount(boolean desensitizeOpen, int count) { |
||||
desensitizationLabel.setText(desensitizeOpen ? |
||||
DATA_DESENSITIZATION_CONFIG + LEFT_BRACKET + count + RIGHT_BRACKET + COUNT : |
||||
DATA_DESENSITIZATION_CONFIG); |
||||
} |
||||
} |
Loading…
Reference in new issue