From d8192fe60f80b161b915e10b297bd82c9daf65ff Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Thu, 20 Jul 2023 19:47:52 +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 --- .../design/mainframe/vcs/VcsTableEntity.java | 2 +- .../mainframe/vcs/ui/VcsCellEditor.java | 35 ++++++++++++++++++ .../mainframe/vcs/ui/VcsCellRender.java | 29 +++++++++++++++ .../design/mainframe/vcs/ui/VcsNewPane.java | 4 +- .../mainframe/vcs/ui/VcsOperatorPane.java | 37 ++++--------------- 5 files changed, 74 insertions(+), 33 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCellEditor.java create mode 100644 designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCellRender.java diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsTableEntity.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsTableEntity.java index 6911b7a93a..f10b0a12fe 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsTableEntity.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/VcsTableEntity.java @@ -39,7 +39,7 @@ public class VcsTableEntity implements TableEntity{ * @return 版本大小 */ public String getSize() { - return String.format("%.2f",entity.getSize()/MB_SIZE) + MB; + return String.format("%.3f",entity.getSize()/MB_SIZE) + MB; } /** diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCellEditor.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCellEditor.java new file mode 100644 index 0000000000..9baebaebe1 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCellEditor.java @@ -0,0 +1,35 @@ +package com.fr.design.mainframe.vcs.ui; + +import javax.swing.AbstractCellEditor; +import javax.swing.JTable; +import javax.swing.table.TableCellEditor; +import java.awt.*; + +import static com.fr.design.mainframe.vcs.ui.AbstractSupportSelectTablePane.DEFAULT_SELECT_TABLE_ROW_COLOR; + +/** + * Vcs的表格Editor + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2023/7/20 + */ +public class VcsCellEditor extends AbstractCellEditor implements TableCellEditor { + + private final VcsOperatorPane vcsPanel; + + public VcsCellEditor(VcsOperatorPane vcsPanel) { + this.vcsPanel = vcsPanel; + } + + @Override + public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { + vcsPanel.setBackground(isSelected ? DEFAULT_SELECT_TABLE_ROW_COLOR : Color.WHITE); + return vcsPanel; + } + + @Override + public Object getCellEditorValue() { + return vcsPanel; + } +} diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCellRender.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCellRender.java new file mode 100644 index 0000000000..952c52a060 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsCellRender.java @@ -0,0 +1,29 @@ +package com.fr.design.mainframe.vcs.ui; + +import javax.swing.JTable; +import javax.swing.table.TableCellRenderer; +import java.awt.*; + +import static com.fr.design.mainframe.vcs.ui.AbstractSupportSelectTablePane.DEFAULT_SELECT_TABLE_ROW_COLOR; + +/** + * Vcs的表格Render + * + * @author Destiny.Lin + * @since 11.0 + * Created on 2023/7/20 + */ +public class VcsCellRender implements TableCellRenderer { + + private final VcsOperatorPane vcsPanel; + + public VcsCellRender(VcsOperatorPane vcsPanel) { + this.vcsPanel = vcsPanel; + } + + @Override + public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { + vcsPanel.setBackground(isSelected ? DEFAULT_SELECT_TABLE_ROW_COLOR : Color.WHITE); + return vcsPanel; + } +} 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 29b5e9e634..42b5f15db0 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 @@ -111,8 +111,8 @@ public class VcsNewPane extends RecyclePane { } }; this.operatorPane = createOperatorPane(); - this.model.setDefaultEditor(VcsOperatorPane.class, operatorPane); - this.model.setDefaultRenderer(VcsOperatorPane.class, operatorPane); + this.model.setDefaultEditor(VcsOperatorPane.class, new VcsCellEditor(createOperatorPane())); + this.model.setDefaultRenderer(VcsOperatorPane.class, new VcsCellRender(createOperatorPane())); } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsOperatorPane.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsOperatorPane.java index 9da20d8a54..ce4db1e0d7 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsOperatorPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsOperatorPane.java @@ -3,20 +3,15 @@ package com.fr.design.mainframe.vcs.ui; import com.fr.design.layout.FRGUIPaneFactory; - -import javax.swing.AbstractCellEditor; - import javax.swing.JComponent; import javax.swing.JPanel; -import javax.swing.JTable; -import javax.swing.table.TableCellEditor; -import javax.swing.table.TableCellRenderer; + + import java.awt.*; -import java.util.List; +import java.util.List; -import static com.fr.design.mainframe.vcs.ui.AbstractSupportSelectTablePane.DEFAULT_SELECT_TABLE_ROW_COLOR; /** * 操作面板,用于置放常用的操作label @@ -27,37 +22,19 @@ import static com.fr.design.mainframe.vcs.ui.AbstractSupportSelectTablePane.DEFA * @since 11.0 * Created on 2023/7/13 */ -public class VcsOperatorPane extends AbstractCellEditor implements TableCellEditor, TableCellRenderer { - private JPanel contentPane; - - private static final Color DETAIL_FONT_COLOR = new Color(65, 155, 249); +public class VcsOperatorPane extends JPanel { public VcsOperatorPane(List iconJComponentMap) { init(iconJComponentMap); } + private void init(List iconJComponentMap) { - contentPane = new JPanel(FRGUIPaneFactory.createLeftZeroVgapNormalHgapLayout()); + this.setLayout(FRGUIPaneFactory.createLeftZeroVgapNormalHgapLayout()); for (JComponent value : iconJComponentMap) { - value.setForeground(DETAIL_FONT_COLOR); value.setCursor(new Cursor(Cursor.HAND_CURSOR)); - contentPane.add(value); + this.add(value); } } - @Override - public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - return contentPane; - } - - @Override - public Object getCellEditorValue() { - return contentPane; - } - - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { - contentPane.setBackground(isSelected ? DEFAULT_SELECT_TABLE_ROW_COLOR : Color.WHITE); - return contentPane; - } }