Browse Source

REPORT-127437 fix: 调整 jtable 滚动条/UI布局/表身组件 的一些样式

newui
lemon 3 months ago
parent
commit
18a2dcf5fc
  1. 107
      designer-base/src/main/java/com/fine/theme/light/ui/FineTableHeaderUI.java
  2. 53
      designer-base/src/main/java/com/fine/theme/light/ui/FineTableScrollBarPaneUI.java
  3. 2
      designer-base/src/main/java/com/fine/theme/utils/FineUIStyle.java
  4. 3
      designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java
  5. 12
      designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java
  6. 14
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/PreviewTableDesensitizationPane.java
  7. 50
      designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/setting/TableDataDesensitizationTableModel.java
  8. 35
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java
  9. 3
      designer-base/src/main/java/com/fr/design/gui/itable/SortableJTable.java
  10. 4
      designer-base/src/main/java/com/fr/design/gui/itable/TableSorter.java
  11. 14
      designer-base/src/main/java/com/fr/design/gui/itableeditorpane/ParameterTableModel.java
  12. 105
      designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableEditorPane.java
  13. 2
      designer-base/src/main/java/com/fr/design/mainframe/DottedLine.java
  14. 1
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/AbstractSupportSelectTablePane.java
  15. 4
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ToolTipTableCellRenderer.java
  16. 1
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java
  17. 44
      designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java
  18. 12
      designer-base/src/main/resources/com/fine/theme/light/ui/laf/FineLightLaf.properties
  19. 111
      designer-base/src/test/java/com/fr/design/gui/storybook/components/TableStoryBoard.java
  20. 1
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java
  21. 13
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java
  22. 1
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java
  23. 30
      designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java
  24. 5
      designer-realize/src/main/java/com/fr/design/cell/smartaction/SmartJTablePane.java
  25. 8
      designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java

107
designer-base/src/main/java/com/fine/theme/light/ui/FineTableHeaderUI.java

@ -0,0 +1,107 @@
package com.fine.theme.light.ui;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIStyle;
import com.formdev.flatlaf.ui.FlatTableHeaderUI;
import com.fr.stable.StringUtils;
import sun.swing.DefaultLookup;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.plaf.ComponentUI;
import javax.swing.plaf.UIResource;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
/**
* 应用于 JTable 的UI
*
* @author lemon
* @since
* Created on
*/
public class FineTableHeaderUI extends FlatTableHeaderUI {
@Override
public void installUI(JComponent c) {
super.installUI(c);
JTableHeader header = (JTableHeader) c;
header.setDefaultRenderer(new TableHeaderRenderer());
JTable table = header.getTable();
FineUIStyle.setStyle(table, FineUIStyle.DEFAULT_TABLE);
table.getTableHeader().getTable().setDefaultRenderer(Object.class, new TableRenderer());
}
@Override
public void paint(Graphics g, JComponent c) {
super.paint(g, c);
}
/**
* 表头 render
*/
public static class TableHeaderRenderer extends DefaultTableCellRenderer implements UIResource {
public TableHeaderRenderer() {
setPreferredSize(new Dimension(this.getWidth(), FineUIScale.scale(24)));
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Border var13 = null;
if (hasFocus) {
var13 = DefaultLookup.getBorder(this, this.ui, "TableHeader.focusCellBorder");
}
if (var13 == null) {
var13 = DefaultLookup.getBorder(this, this.ui, "TableHeader.cellBorder");
}
this.setText(value == null ? "" : value.toString());
this.setHorizontalAlignment(SwingConstants.LEFT);
this.setBorder(var13);
return this;
}
}
/**
* UI
* @param c
* @return
*/
public static ComponentUI createUI(JComponent c) {
return new FineTableHeaderUI();
}
/**
* 表身 render
*/
public static class TableRenderer extends DefaultTableCellRenderer {
public TableRenderer() {
setHorizontalAlignment(SwingConstants.LEFT);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
if (column == table.getColumnCount() - 1) {
this.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager.getColor("defaultBorderColor")),
UIManager.getBorder("Table.cellNoFocusBorder")));
} else {
this.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, UIManager.getColor("defaultBorderColor")),
UIManager.getBorder("Table.cellNoFocusBorder")));
}
setBackground(UIManager.getColor("Table.background"));
setText(value == null ? StringUtils.BLANK : String.valueOf(value));
return this;
}
}
}

53
designer-base/src/main/java/com/fine/theme/light/ui/FineTableScrollBarPaneUI.java

@ -0,0 +1,53 @@
package com.fine.theme.light.ui;
import com.formdev.flatlaf.ui.FlatScrollBarUI;
import javax.swing.JComponent;
import javax.swing.JTable;
import javax.swing.UIManager;
import java.awt.BasicStroke;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
/**
* 应用于 JTable 的垂直滚动条UI
*
* @author lemon
* @since
* Created on 2024/08/11
*/
public class FineTableScrollBarPaneUI extends FlatScrollBarUI {
private final JTable table;
public FineTableScrollBarPaneUI(JTable table) {
this.table = table;
}
@Override
protected void paintTrack(Graphics g, JComponent c, Rectangle trackBounds) {
super.paintTrack(g, c, trackBounds);
// 获取表头的高度
int gridLineThickness = 1;
Rectangle headerRect = table.getTableHeader().getBounds();
int headerBottomY = headerRect.y + headerRect.height - gridLineThickness;
// 在滚动条上限(表头的下边框位置)绘制一条线
Graphics2D g2d = (Graphics2D) g;
g2d.setColor(UIManager.getColor("defaultBorderColor")); // 设置线条颜色
g2d.setStroke(new BasicStroke(1)); // 设置线条宽度
g2d.drawLine(trackBounds.x, headerBottomY, trackBounds.x + trackBounds.width, headerBottomY);
}
@Override
protected void paintThumb(Graphics g, JComponent c, Rectangle thumbBounds) {
// 确保滚动条滑块不会超过表头区域
Rectangle headerRect = table.getTableHeader().getBounds();
int headerHeight = headerRect.height;
thumbBounds.y = Math.max(thumbBounds.y, headerHeight);
super.paintThumb(g, c, thumbBounds);
}
}

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

@ -42,6 +42,8 @@ public interface FineUIStyle {
String PURE_TREE = "pureTree";
String PASTEL_BUTTON = "pastelButton";
String DEFAULT_TABLE = "defaultTable";
/**
* 添加组件的样式类类似css该方法会接在原样式后方

3
designer-base/src/main/java/com/fr/design/data/datapane/preview/CopyableJTable.java

@ -7,7 +7,6 @@ import com.fr.log.FineLoggerFactory;
import com.fr.stable.os.OperatingSystem;
import javax.swing.*;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumnModel;
@ -211,8 +210,6 @@ public class CopyableJTable extends SortableJTable {
Component comp = super.prepareRenderer(renderer, row, column);
if (isChoose(row, column)) {
comp.setBackground(selectBackGround);
} else {
comp.setBackground(this.getBackground());
}
return comp;
}

12
designer-base/src/main/java/com/fr/design/data/datapane/preview/PreviewTablePane.java

@ -4,6 +4,8 @@
package com.fr.design.data.datapane.preview;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineTableHeaderUI;
import com.fine.theme.light.ui.FineTableScrollBarPaneUI;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.fr.base.TableData;
@ -308,8 +310,10 @@ public class PreviewTablePane extends BasicPane {
private JComponent initCenterPane() {
preveiwTable = new CopyableJTable(new TableSorter());
preveiwTable.setRowSelectionAllowed(false);
preveiwTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
return new JScrollPane(preveiwTable);
preveiwTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
JScrollPane scrollPane = new JScrollPane(preveiwTable);
scrollPane.getVerticalScrollBar().setUI(new FineTableScrollBarPaneUI(preveiwTable));
return scrollPane;
}
private void initDialog() {
@ -403,7 +407,7 @@ public class PreviewTablePane extends BasicPane {
public static void resetPreviewTable() {
getInstance().preveiwTable = new SortableJTable(new TableSorter());
getInstance().preveiwTable.setRowSelectionAllowed(false);
getInstance().preveiwTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
getInstance().preveiwTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
PreviewTablePane.progressBar.close();
getInstance().repaint();
}
@ -511,7 +515,7 @@ public class PreviewTablePane extends BasicPane {
* @return
*/
private DefaultTableCellRenderer getDefaultTableCellRenderer() {
return new DefaultTableCellRenderer() {
return new FineTableHeaderUI.TableRenderer() {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JComponent comp = (JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

14
designer-base/src/main/java/com/fr/design/data/datapane/preview/desensitization/view/PreviewTableDesensitizationPane.java

@ -1,18 +1,19 @@
package com.fr.design.data.datapane.preview.desensitization.view;
import com.fine.theme.icon.LazyIcon;
import com.formdev.flatlaf.ui.FlatUIUtils;
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.ibutton.UIButton;
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.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@ -47,7 +48,7 @@ public class PreviewTableDesensitizationPane extends JPanel {
/**
* 脱敏效果预览按钮
*/
private UIToggleButton previewToggle;
private UIButton previewToggle;
public PreviewTableDesensitizationPane(PreviewTablePane previewTablePane) {
@ -100,10 +101,13 @@ public class PreviewTableDesensitizationPane extends JPanel {
*
* @return
*/
private UIToggleButton initPreviewButton() {
previewToggle = new UIToggleButton(new Icon[]{new LazyIcon("preview"), new LazyIcon("preview")}, true);
private UIButton initPreviewButton() {
previewToggle = new UIButton();
previewToggle.setIcon(new LazyIcon("preview"));
previewToggle.setToolTipText(Toolkit.i18nText("Fine-Design_Report_Desensitization_Preview"));
previewToggle.setSelected(false);
previewToggle.setBackground(FlatUIUtils.getUIColor("default.background", new Color(246, 248, 250, 255)));
previewToggle.setBorder(null);
previewToggle.addActionListener(e -> {
// 切换TableModel的脱敏状态
previewTablePane.togglePreviewTableModelDesensitizeStatus();

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

@ -1,6 +1,8 @@
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;
import com.fr.data.desensitize.base.TableDataDesensitizationItem;
@ -346,26 +348,10 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
*/
private class EffectedRolesChooser extends AbstractCellEditor implements TableCellEditor {
private UIComboCheckBox rolesCheckBox;
private EffectedRolesComboBox rolesCheckBox;
EffectedRolesChooser() {
this.rolesCheckBox = new UIComboCheckBox(roleMap.values().toArray(), true) {
@Override
protected void setLayoutAndAddComponents() {
// 使用BorderLayout,否则默认使用的FlowLayout会让整个下拉选框使用最小Size,然后TableCell这边会出现空白
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(getEditor(), BorderLayout.CENTER);
this.add(getArrowButton(), BorderLayout.EAST);
}
@Override
protected void setEditorToolTipText(JComponent editor, String text) {
// 选项过多时,已选中的值会做省略显示处理,此处添加一个Tooltips,显示完整值
if (text != null) {
editor.setToolTipText(text);
}
}
};
rolesCheckBox = new EffectedRolesComboBox();
this.addCellEditorListener(new CellEditorListener() {
@Override
public void editingStopped(ChangeEvent e) {
@ -385,10 +371,8 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
}
private void setBoxStyle() {
this.rolesCheckBox.getEditor().setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE));
this.rolesCheckBox.getEditor().setOpaque(true);
this.rolesCheckBox.getArrowButton().setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE));
this.rolesCheckBox.getArrowButton().setOpaque(true);
this.rolesCheckBox.setBorder(new FineRoundBorder());
FineUIStyle.setStyle(this.rolesCheckBox.getEditor(), FineUIStyle.TRANSPARENT_TEXT_FIELD);
}
@Override
@ -439,6 +423,28 @@ public class TableDataDesensitizationTableModel extends UITableModelAdapter<Tabl
public Object getCellEditorValue() {
return rolesCheckBox.getSelectedValues();
}
private class EffectedRolesComboBox extends UIComboCheckBox {
public EffectedRolesComboBox() {
super(roleMap.values().toArray(), true);
}
@Override
protected void setLayoutAndAddComponents() {
// 使用BorderLayout,否则默认使用的FlowLayout会让整个下拉选框使用最小Size,然后TableCell这边会出现空白
this.setLayout(FRGUIPaneFactory.createBorderLayout());
this.add(getEditor(), BorderLayout.CENTER);
this.add(getLabel(), BorderLayout.EAST);
}
@Override
protected void setEditorToolTipText(JComponent editor, String text) {
// 选项过多时,已选中的值会做省略显示处理,此处添加一个Tooltips,显示完整值
if (text != null) {
editor.setToolTipText(text);
}
}
}
}
/**

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

@ -1,24 +1,23 @@
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.fr.base.BaseUtils;
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.icon.IconPathConstants;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.event.PopupMenuEvent;
import javax.swing.event.PopupMenuListener;
import java.awt.BorderLayout;
@ -42,8 +41,12 @@ import java.util.Map;
* 支持全选半选
* 可以设置悬停颜色一页最多显示单选框个数
* 可以省略显示
*
* @author
* @since
* Created on
*/
public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNameObserver {
public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNameObserver, HoverAware {
//下拉框的值
private Object[] values;
//已经选中的值
@ -53,6 +56,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
private UICheckListPopup popup;
private UITextField editor;
private UIButton arrowButton;
private UILabel label;
//选中的值之间显示的分隔符
private String valueSperator;
private static final String DEFAULT_VALUE_SPERATOR = ",";
@ -121,8 +125,13 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
this.popup.addActionListener(new PopupAction());
this.editor = createEditor();
this.arrowButton = createArrowButton();
this.label = new UILabel(getIcon());
label.setPreferredSize(FineUIScale.scale(new Dimension(24, 24)));
setLayoutAndAddComponents();
setText();
addPopupListener(this);
}
/**
@ -155,12 +164,14 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
return arrowButton;
}
public UILabel getLabel() {
return label;
}
private UIButton createArrowButton() {
final UIButton arrowBtn = new UIButton();
arrowBtn.setNormalPainted(false);
arrowBtn.setPreferredSize(FineUIScale.scale(new Dimension(20, 5)));
arrowBtn.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, UIManager.getColor("defaultBorderColor")));
arrowBtn.setOpaque(true);
arrowBtn.setIcon(getIcon());
arrowBtn.setExtraPainted(false);
addPopupListener(arrowBtn);
@ -171,8 +182,6 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
private UITextField createEditor() {
UITextField editor = new TextField();
editor.setEditable(false);
editor.setPreferredSize(FineUIScale.scale(new Dimension(110, 20)));
editor.setBorder(BorderFactory.createMatteBorder(1, 1, 1, 0, UIManager.getColor("defaultBorderColor")));
addPopupListener(editor);
return editor;
@ -213,6 +222,11 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
return popup.getSelectedValues();
}
@Override
public boolean isHovered() {
return true;
}
private class PopupAction implements ActionListener {
@Override
@ -229,7 +243,6 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
private void togglePopup() {
if (this.arrowButton.isEnabled()) {
popup.setBorder(new FineRoundBorder());
popup.setPreferredSize(new Dimension(FineUIScale.scale(this.getWidth()), (int) popup.getPreferredSize().getHeight()));
popup.show(this, 0, getHeight());
}
}
@ -352,7 +365,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
}
private Icon getIcon() {
return BaseUtils.readIcon(IconPathConstants.ARROW_ICON_PATH);
return new LazyIcon("down_arrow");
}
/**

3
designer-base/src/main/java/com/fr/design/gui/itable/SortableJTable.java

@ -1,5 +1,7 @@
package com.fr.design.gui.itable;
import com.fine.theme.light.ui.FineTableHeaderUI;
import javax.swing.JTable;
public class SortableJTable extends JTable{
@ -7,5 +9,6 @@ public class SortableJTable extends JTable{
super(tableModel);
tableModel.setTableHeader(getTableHeader());
setShowGrid(true);
getTableHeader().setUI(new FineTableHeaderUI());
}
}

4
designer-base/src/main/java/com/fr/design/gui/itable/TableSorter.java

@ -14,10 +14,10 @@ import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.swing.Icon;
import com.fr.common.inputevent.InputEventBaseOnOS;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.Icon;
import javax.swing.JTable;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;

14
designer-base/src/main/java/com/fr/design/gui/itableeditorpane/ParameterTableModel.java

@ -1,7 +1,7 @@
package com.fr.design.gui.itableeditorpane;
import com.fine.theme.light.ui.FineTableHeaderUI;
import com.fine.theme.utils.FineUIStyle;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.base.Parameter;
import com.fr.design.editor.ValueEditorPane;
import com.fr.design.editor.ValueEditorPaneFactory;
@ -14,7 +14,6 @@ import com.fr.stable.StringUtils;
import javax.swing.*;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import java.awt.*;
import java.awt.event.ActionEvent;
@ -231,11 +230,10 @@ public class ParameterTableModel extends UITableModelAdapter<ParameterProvider>
}
private class ParameterValueRenderer extends DefaultTableCellRenderer {
private class ParameterValueRenderer extends FineTableHeaderUI.TableRenderer {
private static final long serialVersionUID = 1L;
private ValueEditorPane editor;
private UILabel disableLable;
public ParameterValueRenderer(int paraUseType) {
this(ValueEditorPaneFactory.createVallueEditorPaneWithUseType(paraUseType));
}
@ -243,15 +241,13 @@ public class ParameterTableModel extends UITableModelAdapter<ParameterProvider>
public ParameterValueRenderer(ValueEditorPane valueEditorPane) {
disableLable = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Paramete_Name"));
FineUIStyle.setStyle(disableLable, FineUIStyle.LABEL_WARNING_TIP);
disableLable.setHorizontalAlignment(SwingConstants.LEFT);
disableLable.setOpaque(true);
disableLable.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE));
disableLable.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager.getColor("defaultBorderColor")));
disableLable.setHorizontalAlignment(SwingConstants.LEFT);
editor = valueEditorPane;
}
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
JComponent component = ((JComponent) super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column));
if (table.isCellEditable(row, column)) {
if (value == null) {
editor.populate("");
@ -260,6 +256,8 @@ public class ParameterTableModel extends UITableModelAdapter<ParameterProvider>
}
return editor;
} else {
disableLable.setBorder(component.getBorder());
disableLable.setBackground(component.getBackground());
return disableLable;
}
}

105
designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableEditorPane.java

@ -1,40 +1,26 @@
package com.fr.design.gui.itableeditorpane;
import com.fine.theme.light.ui.FineRoundBorder;
import com.fine.theme.light.ui.FineTableHeaderUI;
import com.fine.theme.light.ui.FineTableScrollBarPaneUI;
import com.fine.theme.utils.FineUIScale;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.formdev.flatlaf.util.ScaledEmptyBorder;
import com.fr.design.dialog.BasicPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.event.TableModelListener;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.event.AdjustmentEvent;
import java.awt.event.AdjustmentListener;
import java.util.List;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.column;
import static com.fine.swing.ui.layout.Layouts.row;
/**
* 表格编辑面板,一般是两列.- 用泛型实现用的时候请定义T.model里面的T要一样
@ -47,7 +33,7 @@ public class UITableEditorPane<T> extends BasicPane {
*
*/
private static final long serialVersionUID = 6855793816972735815L;
protected static JTable editTable;
protected JTable editTable;
// 放置action 的按钮.
protected UITableModelAdapter<T> tableModel;
private String leftLabelName;
@ -91,39 +77,12 @@ public class UITableEditorPane<T> extends BasicPane {
controlPane.add(buttonPane, BorderLayout.EAST);
controlPane.add(content == null ? l : content, BorderLayout.WEST);
pane.add(column(cell(controlPane), cell(buildScrollTablePane(scrollPane)).weight(1)).getComponent());
this.editTable.getTableHeader().setDefaultRenderer(new TableHeaderRenderer());
this.editTable.setDefaultRenderer(Object.class, new TableRenderer());
scrollPane.getVerticalScrollBar().setUI(new FineTableScrollBarPaneUI(editTable));
pane.add(column(10, cell(controlPane), cell(scrollPane).weight(1)).getComponent());
this.editTable.getTableHeader().setUI(new FineTableHeaderUI());
this.editTable.setRowHeight(FineUIScale.scale(24));
}
/**
* 组合 jtable 和垂直滚动条
* @param scrollPane
* @return
*/
protected JPanel buildScrollTablePane(JScrollPane scrollPane) {
verticalScrollBar = column(
cell(new UILabel()).with(it -> {
it.setBorder(BorderFactory.createMatteBorder(1, 0, 0, 1, UIManager.getColor("defaultBorderColor")));
it.setPreferredSize(new Dimension(scrollPane.getVerticalScrollBar().getWidth(), (int) editTable.getTableHeader().getPreferredSize().getHeight()));
}),
cell(scrollPane.getVerticalScrollBar()).weight(1).with(it -> {
it.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 1, UIManager.getColor("defaultBorderColor")));
})
).getComponent();
scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
@Override
public void adjustmentValueChanged(AdjustmentEvent e) {
verticalScrollBar.setVisible(editTable.getHeight() > scrollPane.getViewport().getHeight());
verticalScrollBar.repaint();
}
});
return row(cell(scrollPane).weight(1), cell(verticalScrollBar)).getComponent();
}
public UITableModelAdapter<T> getTableModel() {
return tableModel;
}
@ -211,7 +170,7 @@ public class UITableEditorPane<T> extends BasicPane {
/**
* @return jTable
*/
public static JTable getEditTable() {
public JTable getEditTable() {
return editTable;
}
@ -234,54 +193,4 @@ public class UITableEditorPane<T> extends BasicPane {
editTable.getTableHeader().setResizingAllowed(resizingAllowed);
}
/**
* 设置 TableHeader 文字左对齐
*/
public static class TableHeaderRenderer extends DefaultTableCellRenderer {
public TableHeaderRenderer() {
setHorizontalAlignment(SwingConstants.LEFT);
setPreferredSize(new Dimension(this.getWidth(), FineUIScale.scale(24)));
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (column == table.getColumnCount() - 1) {
((JComponent) component).setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager.getColor("defaultBorderColor")));
} else {
((JComponent) component).setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, UIManager.getColor("defaultBorderColor")));
}
return component;
}
}
/**
* 设置 Table 表身格式
*/
public static class TableRenderer extends DefaultTableCellRenderer {
public TableRenderer() {
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
Component component = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if(component instanceof JLabel) {
String toolTipText = GeneralUtils.objectToString(value);
if (StringUtils.isNotEmpty(toolTipText)) {
((JLabel) component).setToolTipText(toolTipText);
}
}
if (column == table.getColumnCount() - 1) {
((JComponent) component).setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager.getColor("defaultBorderColor")),
new ScaledEmptyBorder(0,4,0,0)));
} else {
((JComponent) component).setBorder(BorderFactory.createCompoundBorder(
BorderFactory.createMatteBorder(0, 0, 1, 1, UIManager.getColor("defaultBorderColor")),
new ScaledEmptyBorder(0,4,0,0)));
}
component.setBackground(FlatUIUtils.getUIColor("background.normal", Color.WHITE));
return component;
}
}
}

2
designer-base/src/main/java/com/fr/design/mainframe/DottedLine.java

@ -1 +1 @@
package com.fr.design.mainframe; import com.fr.design.constants.UIConstants; import com.fr.design.gui.iscrollbar.UIScrollBar; import javax.swing.*; import java.awt.*; import java.awt.geom.GeneralPath; import java.awt.geom.Path2D; /** * Author : daisy * Date: 13-9-11 * Time: 上午10:14 */ public class DottedLine extends JPanel { public static final int HEIGHT = 3; private static final int BLUE_WIDTH = 12;//蓝色线长度,白色线长度是其半 private int direction = UIScrollBar.HORIZONTAL; public DottedLine(int direction, int width) { //水平方向的虚线框 if (direction == UIScrollBar.HORIZONTAL) { this.setPreferredSize(new Dimension(width, HEIGHT)); } else { this.setPreferredSize(new Dimension(HEIGHT, width)); } this.direction = direction; this.setBackground(new Color(255, 255, 255));//设置白色背景 } public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; //如果是水平方向的 if (direction == UIScrollBar.HORIZONTAL) { paintHorizontal(g2d); } else { paintVertical(g2d); } } private void paintHorizontal(Graphics2D g2d) { int totalWidth = getWidth(); int paintX = 0; while (paintX < totalWidth) { int endX = paintX + BLUE_WIDTH; if (endX > totalWidth) { endX = totalWidth; } int[] x = new int[]{paintX, endX, endX, paintX, paintX}; int[] y = new int[]{0, 0, HEIGHT, HEIGHT, 0}; paintBlueArea(g2d, x, y); paintX += BLUE_WIDTH + BLUE_WIDTH / 2; } } private void paintVertical(Graphics2D g2d) { int totalHeight = getHeight(); int paintY = 0; while (paintY < totalHeight) { int endY = paintY + BLUE_WIDTH; if (endY > totalHeight) { endY = totalHeight; } int[] x = new int[]{0, HEIGHT, HEIGHT, 0, 0}; int[] y = new int[]{paintY, paintY, endY, endY, paintY}; paintBlueArea(g2d, x, y); paintY += BLUE_WIDTH + BLUE_WIDTH / 2; } } private void paintBlueArea(Graphics2D g2d, int[] x, int[] y) { g2d.setPaint(UIConstants.DOTTED_LINE_COLOR); GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, x.length); generalPath.moveTo(x[0], y[0]); for (int index = 1; index < x.length; index++) { generalPath.lineTo(x[index], y[index]); } generalPath.closePath(); g2d.fill(generalPath); } }
package com.fr.design.mainframe; import com.formdev.flatlaf.ui.FlatUIUtils; import com.fr.design.constants.UIConstants; import com.fr.design.gui.iscrollbar.UIScrollBar; import javax.swing.*; import java.awt.*; import java.awt.geom.GeneralPath; import java.awt.geom.Path2D; /** * Author : daisy * Date: 13-9-11 * Time: 上午10:14 */ public class DottedLine extends JPanel { public static final int HEIGHT = 3; private static final int BLUE_WIDTH = 12;//蓝色线长度,白色线长度是其半 private int direction = UIScrollBar.HORIZONTAL; public DottedLine(int direction, int width) { //水平方向的虚线框 if (direction == UIScrollBar.HORIZONTAL) { this.setPreferredSize(new Dimension(width, HEIGHT)); } else { this.setPreferredSize(new Dimension(HEIGHT, width)); } this.direction = direction; this.setBackground(new Color(255, 255, 255));//设置白色背景 } public void paint(Graphics g) { Graphics2D g2d = (Graphics2D) g; //如果是水平方向的 if (direction == UIScrollBar.HORIZONTAL) { paintHorizontal(g2d); } else { paintVertical(g2d); } } private void paintHorizontal(Graphics2D g2d) { int totalWidth = getWidth(); int paintX = 0; while (paintX < totalWidth) { int endX = paintX + BLUE_WIDTH; if (endX > totalWidth) { endX = totalWidth; } int[] x = new int[]{paintX, endX, endX, paintX, paintX}; int[] y = new int[]{0, 0, HEIGHT, HEIGHT, 0}; paintBlueArea(g2d, x, y); paintX += BLUE_WIDTH + BLUE_WIDTH / 2; } } private void paintVertical(Graphics2D g2d) { int totalHeight = getHeight(); int paintY = 0; while (paintY < totalHeight) { int endY = paintY + BLUE_WIDTH; if (endY > totalHeight) { endY = totalHeight; } int[] x = new int[]{0, HEIGHT, HEIGHT, 0, 0}; int[] y = new int[]{paintY, paintY, endY, endY, paintY}; paintBlueArea(g2d, x, y); paintY += BLUE_WIDTH + BLUE_WIDTH / 2; } } private void paintBlueArea(Graphics2D g2d, int[] x, int[] y) { g2d.setPaint(FlatUIUtils.getUIColor("DottedLine.defaultColor", new Color(37,118,239,1))); GeneralPath generalPath = new GeneralPath(Path2D.WIND_EVEN_ODD, x.length); generalPath.moveTo(x[0], y[0]); for (int index = 1; index < x.length; index++) { generalPath.lineTo(x[index], y[index]); } generalPath.closePath(); g2d.fill(generalPath); } }

1
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/AbstractSupportSelectTablePane.java

@ -366,6 +366,7 @@ public abstract class AbstractSupportSelectTablePane<T extends TableEntity> exte
setColumnClass(classes);
this.setDefaultEditor(Boolean.class, new BooleanEditor());
this.setDefaultRenderer(Boolean.class, new BooleanRenderer());
this.setDefaultRenderer(UILabel.class, new ToolTipTableCellRenderer());
this.createTable().getColumnModel().getColumn(0).setCellRenderer(new BooleanRenderer());
}

4
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ToolTipTableCellRenderer.java

@ -1,11 +1,11 @@
package com.fr.design.mainframe.vcs.ui;
import com.fine.theme.light.ui.FineTableHeaderUI;
import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils;
import javax.swing.JTable;
import javax.swing.JLabel;
import javax.swing.table.DefaultTableCellRenderer;
import java.awt.*;
@ -16,7 +16,7 @@ import java.awt.*;
* @since 11.0
* Created on 2023/7/21
*/
public class ToolTipTableCellRenderer extends DefaultTableCellRenderer {
public class ToolTipTableCellRenderer extends FineTableHeaderUI.TableRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

1
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java

@ -127,6 +127,7 @@ public class VcsNewPane extends RecyclePane {
this.operatorPane = createOperatorPane();
this.model.setDefaultEditor(VcsOperatorPane.class, new VcsCellEditor(createOperatorPane()));
this.model.setDefaultRenderer(VcsOperatorPane.class, new VcsCellRender(createOperatorPane()));
this.model.setDefaultRenderer(UILabel.class, new ToolTipTableCellRenderer());
}

44
designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java

@ -3,6 +3,7 @@ package com.fr.design.write.submit;
import com.fine.swing.ui.layout.Layouts;
import com.fine.theme.icon.LazyIcon;
import com.fine.swing.ui.layout.Spacer;
import com.fine.theme.light.ui.FineTableHeaderUI;
import com.fine.theme.utils.FineUIScale;
import com.fine.theme.utils.FineUIUtils;
import com.fr.base.BaseFormula;
@ -54,12 +55,15 @@ import com.fr.write.config.InsertConfig;
import com.fr.write.config.IntelliDMLConfig;
import com.fr.write.config.UpdateConfig;
import java.awt.*;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.AbstractCellEditor;
import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor;
import javax.swing.DefaultComboBoxModel;
import javax.swing.Icon;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
@ -69,17 +73,14 @@ import javax.swing.JTree;
import javax.swing.ListSelectionModel;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.plaf.UIResource;
import javax.swing.table.AbstractTableModel;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.tree.DefaultTreeCellRenderer;
import javax.swing.tree.DefaultTreeModel;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Window;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter;
@ -169,9 +170,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
keyColumnValuesTable.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
keyColumnValuesTable.setPreferredScrollableViewportSize(FineUIScale.scale(new Dimension(280, 150)));
keyColumnValuesTable.setShowHorizontalLines(true);
DefaultTableCellRenderer headerRenderer = new DefaultTableCellRenderer();
headerRenderer.setHorizontalAlignment(SwingConstants.LEFT);
keyColumnValuesTable.getTableHeader().setDefaultRenderer(headerRenderer);
keyColumnValuesTable.getTableHeader().setUI(new FineTableHeaderUI());
northPane.add(column(10,
cell(FineUIUtils.wrapComponentWithTitle(typePane, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Submit_Type"))),
@ -697,7 +696,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
private void initJTableColumn() {
TableColumn column0 = this.keyColumnValuesTable.getColumnModel().getColumn(0);
column0.setMaxWidth(50);
column0.setCellRenderer(new ColumnNameTableCellRenderer());
column0.setCellRenderer(new BooleanRenderer());
TableColumn column1 = this.keyColumnValuesTable.getColumnModel().getColumn(1);
column1.setCellRenderer(new ColumnNameTableCellRenderer());
@ -1183,7 +1182,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
/*
* ColumnNameTableCellRenderer
*/
public static class ColumnNameTableCellRenderer extends DefaultTableCellRenderer {
public static class ColumnNameTableCellRenderer extends FineTableHeaderUI.TableRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
@ -1199,7 +1198,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
/*
* ColumnValueTableCellRenderer
*/
private static class ColumnValueTableCellRenderer extends DefaultTableCellRenderer {
private static class ColumnValueTableCellRenderer extends FineTableHeaderUI.TableRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
@ -1220,4 +1219,25 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
return this;
}
}
/**
* checkBox cellRender
*/
public static class BooleanRenderer extends UICheckBox implements TableCellRenderer, UIResource {
public BooleanRenderer() {
super();
setHorizontalAlignment(JLabel.CENTER);
setBorderPainted(true);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
setSelected((value != null && ((Boolean) value).booleanValue()));
setUI(getUICheckBoxUI());
setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, UIManager.getColor("defaultBorderColor")));
setBackground(Color.WHITE);
return this;
}
}
}

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

@ -893,7 +893,7 @@ Table.scrollPaneBorder = com.formdev.flatlaf.ui.FlatBorder
Table.ascendingSortIcon = com.formdev.flatlaf.icons.FlatAscendingSortIcon
Table.descendingSortIcon = com.formdev.flatlaf.icons.FlatDescendingSortIcon
Table.sortIconColor = @icon
Table.cellMargins = 2,3,2,3
Table.cellMargins = 2,6,2,3
Table.cellFocusColor = @cellFocusColor
Table.cellNoFocusBorder = com.formdev.flatlaf.ui.FlatTableCellBorder$Default
Table.focusCellHighlightBorder = com.formdev.flatlaf.ui.FlatTableCellBorder$Focused
@ -908,13 +908,14 @@ Table.dropCellForeground = @dropCellForeground
Table.dropLineColor = @dropLineColor
Table.dropLineShortColor = @dropLineShortColor
Table.gridColor = darken($Table.background,8%)
Table.default.background = $default.background
#---- TableHeader ----
TableHeader.height = 25
TableHeader.cellBorder = com.formdev.flatlaf.ui.FlatTableHeaderBorder
TableHeader.cellMargins = 2,3,2,3
TableHeader.cellMargins = 2,6,2,3
TableHeader.focusCellBackground = $TableHeader.background
TableHeader.background = @componentBackground
TableHeader.showTrailingVerticalLine = false
@ -1143,6 +1144,10 @@ Tree.icon.closedColor = @icon
Tree.icon.openColor = @icon
Tree.hash = darken($Tree.background,10%)
# ---- DottedLine ----
DottedLine.defaultColor=@BrandColor
#---- West ----
West.border = $defaultBorderColor
#---- ExpandablePane ----
@ -1333,3 +1338,6 @@ CellOtherSetPane.height=$Component.defaultHeight
[style]Tree.pureTree = \
background: $fill.normal
[style]Table.defaultTable = \
background: $Table.default.background

111
designer-base/src/test/java/com/fr/design/gui/storybook/components/TableStoryBoard.java

@ -0,0 +1,111 @@
package com.fr.design.gui.storybook.components;
import com.fine.theme.light.ui.FineRoundBorder;
import com.fine.theme.light.ui.FineTableHeaderUI;
import com.fine.theme.light.ui.FineTableScrollBarPaneUI;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.storybook.StoryBoard;
import javax.swing.BorderFactory;
import javax.swing.JCheckBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.plaf.UIResource;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.column;
public class TableStoryBoard extends StoryBoard {
public TableStoryBoard() {
super("表格");
DefaultTableModel model1 = new DefaultTableModel(new Object[][] {
{"1", "Alice", "Female", "Engineering"},
{"2", "Bob", "Male", "Marketing"},
{"3", "Carol", "Female", "Design"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"},
{"4", "Dave", "Male", "Finance"}
}, new String[] {"ID", "Name", "Gender", "Department"});
JTable table1 = new JTable(model1);
table1.getTableHeader().setUI(new FineTableHeaderUI());
DefaultTableModel model2 = new DefaultTableModel(new Object[][] {
{"1", "Alice", "Female", "Engineering"},
{"2", "Bob", "Male", "Marketing"},
{"3", "Carol", "Female", "Design"},
{"4", "Dave", "Male", "Finance"}
}, new String[] {"ID", "Name", "Gender", "Department"});
JTable table2 = new JTable(model2);
table2.getTableHeader().setUI(new FineTableHeaderUI());
DefaultTableModel model3 = new DefaultTableModel(new Object[][] {
{false, "1", "Alice", "Female", "Engineering"},
{false, "2", "Bob", "Male", "Marketing"},
{false, "3", "Carol", "Female", "Design"},
{false, "4", "Dave", "Male", "Finance"}
}, new String[] {"选中", "ID", "Name", "Gender", "Department"}) {
private static final long serialVersionUID = 1L;
Class<?>[] types = new Class<?>[]{Boolean.class, UILabel.class, UILabel.class, UILabel.class, UILabel.class};
public Class<?> getColumnClass(int columnIndex) {
return types[columnIndex];
}
};
JTable table3 = new JTable(model3);
table3.getTableHeader().setUI(new FineTableHeaderUI());
table3.getTableHeader().getColumnModel().getColumn(0).setCellRenderer(new BooleanRenderer());
add(column(20, cell(new UIScrollPane(table1)).with(this::setFixSize).with(it -> it.getVerticalScrollBar().setUI(new FineTableScrollBarPaneUI(table1))),
cell(new UIScrollPane(table2)).with(this::setFixSize),
cell(new UIScrollPane(table3)).with(this::setFixSize)).getComponent());
}
private void setFixSize(JComponent component) {
component.setPreferredSize(new Dimension(component.getWidth(), 150));
component.setBorder(new FineRoundBorder());
}
public static class BooleanRenderer extends JCheckBox implements TableCellRenderer, UIResource {
public BooleanRenderer() {
super();
setHorizontalAlignment(JLabel.CENTER);
setOpaque(false);
}
@Override
public Component getTableCellRendererComponent(JTable table, Object value,
boolean isSelected, boolean hasFocus, int row, int column) {
setSelected((value != null && ((Boolean) value).booleanValue()));
setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, UIManager.getColor("defaultBorderColor")));
setBackground(Color.WHITE);
return this;
}
}
}

1
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITReplaceSouthPanel.java

@ -3,7 +3,6 @@ package com.fr.design.actions.replace.ui;
import javax.swing.BorderFactory;
import javax.swing.RowSorter;
import javax.swing.table.TableRowSorter;
import java.awt.Color;
/**
* 下面板

13
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableButton.java

@ -1,17 +1,8 @@
package com.fr.design.actions.replace.ui;
import com.fine.theme.icon.LazyIcon;
import com.fr.base.TRL;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate;
import com.fr.file.FILE;
import com.fr.file.FILEFactory;
import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils;
import javax.swing.AbstractCellEditor;
@ -21,10 +12,6 @@ import javax.swing.UIManager;
import javax.swing.table.TableCellEditor;
import javax.swing.table.TableCellRenderer;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import static com.fr.design.actions.replace.ui.ITTableEditorPane.getEditTable;
/**
* 放进表格中的定位按钮

1
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditor.java

@ -60,7 +60,6 @@ public class ITTableEditor extends UITableModelAdapter {
});
this.setDefaultRenderer(UILabel.class, new UITableEditorPane.TableRenderer());
this.setDefaultEditor(ITTableButton.class, new ITTableButton());
this.setDefaultRenderer(ITTableButton.class, new ITTableButton());
this.setDefaultEditor(Boolean.class, new ITBooleanEditor());

30
designer-realize/src/main/java/com/fr/design/actions/replace/ui/ITTableEditorPane.java

@ -1,21 +1,25 @@
package com.fr.design.actions.replace.ui;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineTableHeaderUI;
import com.fine.theme.light.ui.FineTableScrollBarPaneUI;
import com.fine.theme.utils.FineUIStyle;
import com.formdev.flatlaf.ui.FlatUIUtils;
import com.fr.base.TRL;
import com.fr.design.actions.replace.info.base.ITContent;
import com.fr.design.dialog.BasicPane;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.itableeditorpane.UITableEditAction;
import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.gui.itableeditorpane.UITableModelAdapter;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.share.ui.base.MouseClickListener;
import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils;
import sun.swing.DefaultLookup;
import javax.swing.BorderFactory;
@ -28,10 +32,8 @@ import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.table.JTableHeader;
import javax.swing.table.TableCellRenderer;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.List;
@ -47,13 +49,15 @@ import static com.fine.swing.ui.layout.Layouts.cell;
* @since
* Created On
*/
public class ITTableEditorPane<T> extends UITableEditorPane<T> {
public class ITTableEditorPane<T> extends BasicPane {
public static JTable editTable;
private UITableModelAdapter<T> tableModel;
private String leftLabelName;
private JPanel buttonPane;
public ITTableEditorPane(UITableModelAdapter<T> model) {
super(model);
this.tableModel = model;
this.initComponent(model.createAction());
}
@ -65,6 +69,7 @@ public class ITTableEditorPane<T> extends UITableEditorPane<T> {
public void initComponent(UITableEditAction[] action) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
editTable = tableModel.createTable();
FineUIStyle.setStyle(editTable, FineUIStyle.DEFAULT_TABLE);
editTable.addMouseListener(new MouseClickListener() {
@Override
public void mouseClicked(MouseEvent e) {
@ -88,9 +93,10 @@ public class ITTableEditorPane<T> extends UITableEditorPane<T> {
}
});
UIScrollPane scrollPane = new UIScrollPane(editTable);
add(cell(buildScrollTablePane(scrollPane)).weight(1).getComponent());
UIScrollPane scrollPane = new UIScrollPane(editTable);
scrollPane.getVerticalScrollBar().setUI(new FineTableScrollBarPaneUI(editTable));
add(cell(scrollPane).weight(1).getComponent());
}
/**
@ -136,7 +142,7 @@ public class ITTableEditorPane<T> extends UITableEditorPane<T> {
/**
* 表头渲染
*/
public static class ITHeaderRenderer implements TableCellRenderer {
public static class ITHeaderRenderer extends FineTableHeaderUI.TableHeaderRenderer {
JTableHeader tableHeader;
final UICheckBox selectBox;
private boolean ascSort = true;
@ -221,8 +227,8 @@ public class ITTableEditorPane<T> extends UITableEditorPane<T> {
component.setForeground(tableHeader.getForeground());
component.setBackground(tableHeader.getBackground());
component.setFont(tableHeader.getFont());
if (column == table.getColumnCount() - 1) {
component.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 0, UIManager.getColor("defaultBorderColor")));
if (column != ITReplaceSouthPanel.CHECKBOX_INDEX) {
component.setBorder(DefaultLookup.getBorder(this, this.ui, "TableHeader.cellBorder"));
} else {
component.setBorder(BorderFactory.createMatteBorder(0, 0, 1, 1, UIManager.getColor("defaultBorderColor")));
}
@ -239,7 +245,7 @@ public class ITTableEditorPane<T> extends UITableEditorPane<T> {
* @param table
*/
public static void makeFace(JTable table) {
table.getTableHeader().setBackground(FlatUIUtils.getUIColor("TableHeader.background", Color.WHITE));
table.getTableHeader().setUI(new FineTableHeaderUI());
table.getTableHeader().setDefaultRenderer(new ITHeaderRenderer(table));
}

5
designer-realize/src/main/java/com/fr/design/cell/smartaction/SmartJTablePane.java

@ -3,6 +3,7 @@ package com.fr.design.cell.smartaction;
import java.awt.BorderLayout;
import java.awt.Window;
import com.fine.theme.light.ui.FineTableHeaderUI;
import com.fr.design.gui.ilable.UILabel;
import javax.swing.JScrollPane;
@ -73,9 +74,7 @@ public abstract class SmartJTablePane extends BasicPane {
}
}
});
DefaultTableCellRenderer headerRenderer = new DefaultTableCellRenderer();
headerRenderer.setHorizontalAlignment(SwingConstants.LEFT);
table.getTableHeader().setDefaultRenderer(headerRenderer);
table.getTableHeader().setUI(new FineTableHeaderUI());
setCellRenderer();
actionReportPane.addSelectionChangeListener(gridSelectionChangeL);

8
designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java

@ -1,6 +1,7 @@
package com.fr.design.write.submit;
import com.fine.theme.icon.LazyIcon;
import com.fine.theme.light.ui.FineTableHeaderUI;
import com.fr.cache.list.IntList;
import com.fr.data.ClassSubmitJob;
import com.fr.design.actions.UpdateAction;
@ -40,7 +41,6 @@ import javax.swing.JTable;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;
import java.awt.BorderLayout;
import java.awt.Component;
@ -355,7 +355,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
column0.setMaxWidth(LEFT_COLUMN_MAX_WIDTH);
ColumnNameTableCellRenderer cellRenderer = new ColumnNameTableCellRenderer();
cellRenderer.setHorizontalAlignment(SwingConstants.LEFT);
column0.setCellRenderer(cellRenderer);
column0.setCellRenderer(new BooleanRenderer());
/*
* 设置Column 1的Renderer
*/
@ -554,7 +554,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
/*
* ColumnValueTableCellRenderer
*/
private class SelectedColumnValueTableCellRenderer extends DefaultTableCellRenderer {
private class SelectedColumnValueTableCellRenderer extends FineTableHeaderUI.TableRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
@ -577,7 +577,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
}
}
private class ColumnRowGroupCellRenderer2 extends DefaultTableCellRenderer {
private class ColumnRowGroupCellRenderer2 extends FineTableHeaderUI.TableRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

Loading…
Cancel
Save