Browse Source

Merge remote-tracking branch 'origin/fbp/release' into fbp/release

fbp/release
Destiny.Lin 2 months ago
parent
commit
6c750089c7
  1. 37
      designer-base/src/main/java/com/fine/theme/light/ui/FineComboCheckBoxUI.java
  2. 2
      designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java
  3. 17
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java
  4. 11
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java
  5. 135
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java
  6. 1
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties
  7. 18
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties
  8. 119
      designer-base/src/main/resources/com/fr/design/data/tabledata/datacenter/web/data-choose.main.js
  9. 46
      designer-base/src/test/java/com/fr/design/gui/storybook/components/ComboCheckBoxStoryBoard.java
  10. 7
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/desensitization/model/DesensitizationCellPane.java

37
designer-base/src/main/java/com/fine/theme/light/ui/FineComboCheckBoxUI.java

@ -0,0 +1,37 @@
package com.fine.theme.light.ui;
import com.formdev.flatlaf.ui.FlatComboBoxUI;
import javax.swing.JComponent;
import javax.swing.UIManager;
import javax.swing.plaf.ComponentUI;
/**
* {@link com.fr.design.gui.icombocheckbox.UIComboCheckBox} UI 样式
*
* @author lemon
* @since 12.0
* Created on 2024/09/27
*/
public class FineComboCheckBoxUI extends FlatComboBoxUI {
public FineComboCheckBoxUI() {
super();
}
/**
* 创建UI
*/
public static ComponentUI createUI(JComponent c) {
return new FineComboCheckBoxUI();
}
@Override
public void installUI(JComponent c) {
super.installUI(c);
c.setBackground(UIManager.getColor("ComboCheckBox.background"));
c.setBorder(UIManager.getBorder("ComboCheckBox.border"));
}
}

2
designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java

@ -41,6 +41,7 @@ public interface FineUIStyle {
String POPUP_MENU_TOOL_BAR = "popupMenuToolBar";
String POPUP_MENU_DROPDOWN = "dropdownPopupMenu";
String TRANSPARENT_TEXT_FIELD = "transparentTextField";
String OFFET_LEFT_TEXT_FIELD = "offsetLeftText";
String TRANSPARENT_BACKGROUND = "transparentBackground";
String PURE_LIST = "pureList";
String NO_BORDER_LIST = "noBorderList";
@ -51,6 +52,7 @@ public interface FineUIStyle {
String DEFAULT_TABLE = "defaultTable";
String WHITE_BUTTON = "whiteButton";
String ORIGINAL_BUTTON = "originalButton";
String PLAIN_ARROW_BUTTON = "plainArrowButton";
String GRAY_BUTTON = "grayButton";
String DETAIL_LABEL = "detailLabel";
String WIDGET_EVENT_LABEL = "widgetEventLabel";

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

@ -1,7 +1,6 @@
package com.fr.design.data.datapane.preview.desensitization.view.setting;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineRoundBorder;
import com.fine.theme.utils.FineUIStyle;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.data.desensitize.base.DesensitizationTableData;
@ -14,7 +13,6 @@ 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.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.ComboCheckBox;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombocheckbox.UIComboCheckBox;
import com.fr.design.gui.ilable.UILabel;
@ -39,7 +37,6 @@ import javax.swing.UIManager;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
@ -57,6 +54,8 @@ import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import static com.fine.theme.utils.FineUIStyle.setStyle;
/**
* 处理TableDataDesensitizationTablePane中TableEditPane的Model
*
@ -367,12 +366,6 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
}
});
setBoxStyle();
}
private void setBoxStyle() {
this.rolesCheckBox.setBorder(new FineRoundBorder());
FineUIStyle.setStyle(this.rolesCheckBox.getEditor(), FineUIStyle.TRANSPARENT_TEXT_FIELD);
}
@Override
@ -433,7 +426,9 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
protected void setLayoutAndAddComponents() {
// 使用BorderLayout,否则默认使用的FlowLayout会让整个下拉选框使用最小Size,然后TableCell这边会出现空白
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(getLabel(), BorderLayout.EAST);
JPanel pane = getClickPane();
pane.setOpaque(false);
this.add(pane, BorderLayout.CENTER);
}
@Override
@ -457,7 +452,7 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
// 规则状态
this.ruleStatusLabel = new UILabel();
this.ruleStatusLabel.setOpaque(true);
FineUIStyle.setStyle(ruleStatusLabel, FineUIStyle.LABEL_WARNING_TIP);
setStyle(ruleStatusLabel, FineUIStyle.LABEL_WARNING_TIP);
}
/**

11
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java

@ -31,6 +31,10 @@ import java.awt.event.ItemListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.fix;
import static com.fine.swing.ui.layout.Layouts.row;
public class UICheckListPopup extends UIPopupMenu {
private List<ActionListener> listeners = new ArrayList<ActionListener>();
private List<JCheckBox> checkBoxList = new ArrayList<JCheckBox>();
@ -120,15 +124,12 @@ public class UICheckListPopup extends UIPopupMenu {
}
private void addOneCheckValue(Object checkValue) {
JPanel checkPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane();
checkPane.setPreferredSize(FineUIScale.scale(new Dimension(144, CHECKBOX_HEIGHT)));
JPanel checkPane = new JPanel(new BorderLayout());
final JCheckBox temp = createCheckbox();
final UILabel label = new UILabel(checkValue.toString());
label.setBackground(Color.WHITE);
label.setPreferredSize(FineUIScale.scale(new Dimension(100, 20)));
checkPane.setBackground(Color.WHITE);
checkPane.add(temp);
checkPane.add(label);
checkPane.add(row(fix(4), cell(temp), cell(label)).getComponent());
if (labelNeedToolTips) {
// 设置每项Label的tooltips为其省略前的内容
label.setToolTipText(checkValue.toString());

135
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java

@ -2,19 +2,20 @@ package com.fr.design.gui.icombocheckbox;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineRoundBorder;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.util.ScaledEmptyBorder;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.HoverAware;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
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.layout.FRGUIPaneFactory;
import com.fr.stable.StringUtils;
import javax.swing.Icon;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
@ -36,6 +37,11 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import static com.fine.theme.utils.FineUIStyle.OFFET_LEFT_TEXT_FIELD;
import static com.fine.theme.utils.FineUIStyle.PLAIN_ARROW_BUTTON;
import static com.fine.theme.utils.FineUIStyle.TRANSPARENT_TEXT_FIELD;
import static com.fine.theme.utils.FineUIStyle.setStyle;
/**
* 设计器下拉复选框组件
* 支持全选半选
@ -43,10 +49,10 @@ import java.util.Map;
* 可以省略显示
*
* @author
* @since
* Created on
* @since Created on
*/
public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNameObserver, HoverAware {
public class UIComboCheckBox extends JComboBox implements UIObserver, GlobalNameObserver, HoverAware {
private static final String UI_CLASS_ID = "ComboCheckBoxUI";
//下拉框的值
private Object[] values;
//已经选中的值
@ -55,8 +61,8 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
private List<ActionListener> listeners = new ArrayList<ActionListener>();
private UICheckListPopup popup;
private UITextField editor;
private final JPanel clickPane = new JPanel(new BorderLayout());
private UIButton arrowButton;
private UILabel label;
//选中的值之间显示的分隔符
private String valueSperator;
private static final String DEFAULT_VALUE_SPERATOR = ",";
@ -71,6 +77,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
private String placeHolder = StringUtils.EMPTY;
private boolean rollOver;
private boolean popupVisible = false;
public UIComboCheckBox(Object[] value) {
this(value, DEFAULT_VALUE_SPERATOR, true);
@ -123,19 +130,22 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
}
private void initComponent() {
this.popup = new UICheckListPopup(values, supportSelectAll);
this.popup = new UICheckListPopup(values, supportSelectAll) {
@Override
public Dimension getPreferredSize() {
Dimension size = super.getPreferredSize();
size.width = UIComboCheckBox.this.getWidth();
return size;
}
};
this.popup.setBorder(new FineRoundBorder());
this.popup.addActionListener(new PopupAction());
this.editor = createEditor();
this.arrowButton = createArrowButton();
this.label = new UILabel(getIcon());
label.setPreferredSize(FineUIScale.scale(new Dimension(24, 24)));
initClickPane();
setLayoutAndAddComponents();
setText();
addPopupListener(this);
setBackground(Color.WHITE);
setOpaque(true);
}
/**
@ -152,8 +162,8 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
return popup;
}
public UITextField getEditor() {
return editor;
public JPanel getClickPane() {
return clickPane;
}
public String getPlaceHolder() {
@ -164,31 +174,37 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
this.placeHolder = placeHolder;
}
public UIButton getArrowButton() {
return arrowButton;
}
private void initClickPane() {
editor = new TextField();
editor.setEditable(false);
setStyle(editor, OFFET_LEFT_TEXT_FIELD);
public UILabel getLabel() {
return label;
}
arrowButton = new UIButton(getIcon());
setStyle(arrowButton, PLAIN_ARROW_BUTTON);
private UIButton createArrowButton() {
final UIButton arrowBtn = new UIButton();
arrowBtn.setNormalPainted(false);
arrowBtn.setPreferredSize(FineUIScale.scale(new Dimension(20, 5)));
arrowBtn.setIcon(getIcon());
arrowBtn.setExtraPainted(false);
addPopupListener(arrowBtn);
clickPane.add(editor, BorderLayout.CENTER);
clickPane.add(arrowButton, BorderLayout.EAST);
return arrowBtn;
addPopupListener(editor);
addPopupListener(arrowButton);
addHoverStatusListener(editor);
addHoverStatusListener(arrowButton);
}
private UITextField createEditor() {
UITextField editor = new TextField();
editor.setEditable(false);
addPopupListener(editor);
protected void addHoverStatusListener(JComponent component) {
component.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
rollOver = true;
repaint();
}
return editor;
@Override
public void mouseExited(MouseEvent e) {
rollOver = popup.isVisible();
repaint();
}
});
}
/**
@ -202,18 +218,6 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
public void mouseClicked(MouseEvent e) {
togglePopup();
}
@Override
public void mouseEntered(MouseEvent e) {
rollOver = true;
repaint();
}
@Override
public void mouseExited(MouseEvent e) {
rollOver = false;
repaint();
}
});
}
@ -240,7 +244,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
@Override
public boolean isHovered() {
return rollOver || this.popup.isShowing();
return rollOver;
}
private class PopupAction implements ActionListener {
@ -258,12 +262,34 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
private void togglePopup() {
if (this.arrowButton.isEnabled()) {
popup.setBorder(new FineRoundBorder());
popup.setPreferredSize(new Dimension(getWidth(), this.popup.getPreferredSize().height));
popup.show(this, 0, getHeight());
if (popupVisible) {
hidePopup();
} else {
showPopup();
}
}
}
/**
* 展示 popup
*/
public void showPopup() {
this.popup.show(this, 0, getHeight());
arrowButton.setIcon(new LazyIcon("up_arrow"));
arrowButton.repaint();
popupVisible = true;
}
/**
* 隐藏 popup
*/
public void hidePopup() {
popup.setVisible(false);
arrowButton.setIcon(new LazyIcon("down_arrow"));
arrowButton.repaint();
popupVisible = false;
}
/**
* 清除文本框
*/
@ -301,6 +327,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
/**
* 为为添加placeholder
*
* @param editor
*/
protected void setEditorPlaceHolder(UITextField editor) {
@ -335,7 +362,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
for (int i = 1; i <= chars.length; i++) {
//如果原文本+省略号长度超过文本框
if (fontMetrics.charsWidth(chars, 0, i) + omitLength > textEditor.getPreferredSize().getWidth()) {
if (fontMetrics.charsWidth(chars, 0, i) + omitLength > textEditor.getWidth()) {
//从第i-1的位置截断再拼上省略号
omitText = text.substring(0, i - 2) + OMIT_TEXT;
break;
@ -466,8 +493,14 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
}
}
@Override
public String getUIClassID() {
return UI_CLASS_ID;
}
/**
* 简单的测试demo
*
* @param args
*/
public static void main(String args[]) {

1
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLaf.properties

@ -5,6 +5,7 @@ CheckBoxUI=com.fine.theme.light.ui.FineCheckBoxUI
CheckBoxMenuItemUI=com.formdev.flatlaf.ui.FlatCheckBoxMenuItemUI
ColorChooserUI=com.formdev.flatlaf.ui.FlatColorChooserUI
ComboBoxUI=com.fine.theme.light.ui.FineComboBoxUI
ComboCheckBoxUI=com.fine.theme.light.ui.FineComboCheckBoxUI
DesktopIconUI=com.formdev.flatlaf.ui.FlatDesktopIconUI
DesktopPaneUI=com.formdev.flatlaf.ui.FlatDesktopPaneUI
CalendarPaneUI=com.fine.theme.light.ui.FineCalendarPaneUI

18
designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties

@ -324,6 +324,10 @@ ComboBox.comboHeight = 24
ComboBox.selectBox.button.height = 22
ComboBox.renderInset = 0,6,0,6
#---- ComboCheckBox ----
ComboCheckBox.background = $fill.normal
ComboCheckBox.border = com.fine.theme.light.ui.FineRoundBorder
#---- Component ----
Component.focusWidth = 0
@ -1276,6 +1280,15 @@ chart.selectedBorderColor = #2576EF
borderWidth : 0; \
disabledBackground : fade($Button.background,0%);
[style]Button.plainArrowButton=\
background : fade($Button.background,0%); \
margin: 4,4,4,4; \
borderWidth : 0; \
disabledBackground : fade($Button.background,0%); \
hoverBackground : null; \
selectedBackground : null; \
pressedBackground : null
[style]CombinationButton.primary = \
background : @BrandColor; \
arc : 3
@ -1328,6 +1341,11 @@ chart.selectedBorderColor = #2576EF
[style]TextField.transparentTextField=\
background: fade(@background, 0%); \
border: null;
[style]TextField.offsetLeftText=\
background: fade(@background, 0%); \
border: 0,6,0,0;
[style]PopupMenu.dropdownPopupMenu=\
background: fade(@background, 0%); \
borderInsets: 0,0,0,0;

119
designer-base/src/main/resources/com/fr/design/data/tabledata/datacenter/web/data-choose.main.js

File diff suppressed because one or more lines are too long

46
designer-base/src/test/java/com/fr/design/gui/storybook/components/ComboCheckBoxStoryBoard.java

@ -0,0 +1,46 @@
package com.fr.design.gui.storybook.components;
import com.fr.design.gui.icombocheckbox.UIComboCheckBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.storybook.StoryBoard;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.stable.ArrayUtils;
import javax.swing.JPanel;
import java.awt.BorderLayout;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.flex;
public class ComboCheckBoxStoryBoard extends StoryBoard {
public ComboCheckBoxStoryBoard() {
super("下拉多选框");
add(
cell(new UILabel("普通状态")).with(this::h3),
cell(getComboCheckBox(ArrayUtils.toArray("测试1", "测试2", "测试3", "测试4"))),
cell(new UILabel("长文字状态")).with(this::h3),
cell(getComboCheckBox(ArrayUtils.toArray("测试长文字1测试长文字1测试长文字1测试长文字1测试长文字1测试长文字1测试长文字1",
"测试长文字2测试长文字2测试长文字2测试长文字2测试长文字2测试长文字2测试长文字2",
"测试长文字3测试长文字3测试长文字3测试长文字3测试长文字3测试长文字3测试长文字3",
"测试长文字4测试长文字4测试长文字4测试长文字4测试长文字4测试长文字4测试长文字4"))),
flex()
);
}
private UIComboCheckBox getComboCheckBox(Object[] array) {
return new UIComboCheckBox(array, true) {
protected void setLayoutAndAddComponents() {
// 使用BorderLayout,否则默认使用的FlowLayout会让整个下拉选框使用最小Size,然后TableCell这边会出现空白
this.setLayout(FRGUIPaneFactory.createBorderLayout());
JPanel pane = getClickPane();
pane.setOpaque(false);
this.add(pane, BorderLayout.CENTER);
}
};
}
}

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

@ -292,12 +292,7 @@ public class DesensitizationCellPane extends BasicBeanPane {
protected void setLayoutAndAddComponents() {
// 使用BorderLayout,否则默认使用的FlowLayout会让整个下拉选框使用最小Size,然后TableCell这边会出现空白
this.setLayout(FRGUIPaneFactory.createBorderLayout());
UITextField editor = getEditor();
UIButton arrowButton = getArrowButton();
setStyle(editor, TRANSPARENT_TEXT_FIELD);
setStyle(arrowButton, PLAIN_BUTTON);
this.add(editor, BorderLayout.CENTER);
this.add(arrowButton, BorderLayout.EAST);
this.add(getClickPane(), BorderLayout.CENTER);
}
@Override

Loading…
Cancel
Save