From 70aba8428818b06fd58a14e0c2beb41711ad7d25 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" <3166887LjL> Date: Fri, 21 Jul 2023 00:15:06 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-100954=20=E3=80=90=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E4=B8=89=E6=9C=9F=E3=80=91=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E5=BC=B9=E7=AA=97=E4=BA=A4=E4=BA=92=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/AbstractSupportSelectTablePane.java | 20 +++++++++++-- .../vcs/ui/ToolTipTableCellRenderer.java | 28 +++++++++++++++++++ .../mainframe/vcs/ui/VcsCenterPane.java | 6 ++++ .../design/mainframe/vcs/ui/VcsNewPane.java | 6 ++++ .../standard/vcslist/vcs_sort_normal.svg | 4 +++ 5 files changed, 62 insertions(+), 2 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ToolTipTableCellRenderer.java create mode 100644 designer-base/src/main/resources/com/fr/design/standard/vcslist/vcs_sort_normal.svg diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/AbstractSupportSelectTablePane.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/AbstractSupportSelectTablePane.java index 7c2d56b509..a4ee2623c2 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/AbstractSupportSelectTablePane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/AbstractSupportSelectTablePane.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.vcs.ui; +import com.fr.base.svg.IconUtils; import com.fr.design.data.tabledata.tabledatapane.loading.TipsPane; import com.fr.design.dialog.BasicPane; import com.fr.design.gui.icheckbox.UICheckBox; @@ -242,6 +243,7 @@ public abstract class AbstractSupportSelectTablePane exte public HeaderRenderer(JTable table) { this.tableHeader = table.getTableHeader(); + tableHeader.setCursor(new Cursor(Cursor.HAND_CURSOR)); selectBox = new UICheckBox(); selectBox.setSelected(false); tableHeader.addMouseListener(new MouseAdapter() { @@ -290,8 +292,12 @@ public abstract class AbstractSupportSelectTablePane exte tableHeader = table.getTableHeader(); tableHeader.setReorderingAllowed(false); String valueStr = (String) value; - JLabel label = new JLabel(valueStr); - label.setHorizontalAlignment(SwingConstants.LEFT); + UILabel label = new UILabel(valueStr); + if (needIcon4Head(column)) { + label.setIcon(IconUtils.readIcon("/com/fr/design/standard/vcslist/vcs_sort")); + label.setHorizontalTextPosition(JLabel.LEFT); + label.setHorizontalAlignment(SwingConstants.LEFT); + } selectBox.setHorizontalAlignment(SwingConstants.CENTER); selectBox.setBorderPainted(true); JComponent component = (column == 0) ? selectBox : label; @@ -320,6 +326,7 @@ public abstract class AbstractSupportSelectTablePane exte setColumnClass(classes); this.setDefaultEditor(Boolean.class, new BooleanEditor()); this.setDefaultRenderer(Boolean.class, new BooleanRenderer()); + this.setDefaultRenderer(UILabel.class, new ToolTipTableCellRenderer()); } @Override @@ -375,5 +382,14 @@ public abstract class AbstractSupportSelectTablePane exte } + /** + * 表头的某列是否需要icon + * + * @param col 列 + * @return + */ + protected boolean needIcon4Head(int col) { + return col != 0; + } } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ToolTipTableCellRenderer.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ToolTipTableCellRenderer.java new file mode 100644 index 0000000000..9e2dca1054 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/ToolTipTableCellRenderer.java @@ -0,0 +1,28 @@ +package com.fr.design.mainframe.vcs.ui; + +import com.fr.general.GeneralUtils; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import javax.swing.table.DefaultTableCellRenderer; +import java.awt.*; + + +/** + * 带ToolTip的UILabel的表格渲染类 + * + */ +public class ToolTipTableCellRenderer extends DefaultTableCellRenderer { + + @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); + } + } + return component; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java index 5c2520ce1e..d1ac7ad31e 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCenterPane.java @@ -125,6 +125,12 @@ public class VcsCenterPane extends VcsNewPane { }); } + + @Override + protected boolean needIcon4Head(int col) { + return col != 0 && col != OPERATOR_COL; + } + private void initOpenListener() { open.addMouseListener(new MouseAdapter() { @Override diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java index 42b5f15db0..e65726bc68 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsNewPane.java @@ -113,6 +113,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()); } @@ -339,4 +340,9 @@ public class VcsNewPane extends RecyclePane { }; dialog.setVisible(true); } + + @Override + protected boolean needIcon4Head(int col) { + return col != 0 && col != OPERATOR_COL; + } } diff --git a/designer-base/src/main/resources/com/fr/design/standard/vcslist/vcs_sort_normal.svg b/designer-base/src/main/resources/com/fr/design/standard/vcslist/vcs_sort_normal.svg new file mode 100644 index 0000000000..01d9ffeb5f --- /dev/null +++ b/designer-base/src/main/resources/com/fr/design/standard/vcslist/vcs_sort_normal.svg @@ -0,0 +1,4 @@ + + + +