From 6ce46d57e2132851d49dec173c26bdfdbbf58450 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 23 Mar 2021 16:50:45 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-50030=20=E5=8D=95=E5=85=83=E6=A0=BC?= =?UTF-8?q?=E5=A4=96=E8=BE=B9=E6=A1=86=E8=AE=BE=E7=BD=AE=E5=85=B6=E4=BB=96?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=E8=AE=BE=E8=AE=A1=E5=99=A8=E5=86=85=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=B8=8E=E9=BB=91=E8=89=B2=E4=B8=8D=E4=B8=80=E6=A0=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 选中表格中区域后,设置边框颜色为黑色,勾选右侧外边框,表格中选中区域的 单元格都出现右边框,正确的效果是只有选中区域右侧的单元格有右边框。 目前代码中更新单元格边框的逻辑是 1. 首先将边框面板的单元格样式直接写入每个单元格中(此时单元格边样式对象值是不对的,需要进行修正) 2. 根据选中区域的单元格样式(旧样式)和边框面板中的样式(新样式)进行比较 3. 决定指定单元格边框是否使用新样式 问题出现在: 1. 无法获取当前选中区域的单元格样式(旧样式),因为已经被污染了. 2. 获取到的边框面板样式不对,导致比较结果出错 3. 只在单元格边框使用新样式时,才重写单元格边框样式对象,不使用新样式时,会继续使用被污染的值. 问题 【改动思路】 1. 在更新边框前,获取选中区域的单元格样式 2. 修改边框面板样式对象的创建逻辑 3. 不使用新样式时,重写单元格边框为旧样式 --- .../com/fr/design/gui/style/BorderPane.java | 30 +++++++++++++++---- .../cell/settingpane/CellStylePane.java | 5 +++- .../settingpane/style/CustomStylePane.java | 4 +-- .../cell/settingpane/style/StylePane.java | 5 ++-- .../java/com/fr/design/style/BorderUtils.java | 23 +++++++++++++- 5 files changed, 54 insertions(+), 13 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java b/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java index 0dcfe4c217..9f948e7a18 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/BorderPane.java @@ -217,18 +217,36 @@ public class BorderPane extends AbstractBasicStylePane implements GlobalNameObse int lineStyle = currentLineCombo.getSelectedLineStyle(); Color lineColor = currentLineColorPane.getSelectObject(); CellBorderStyle cellBorderStyle = new CellBorderStyle(); - cellBorderStyle.setTopColor(lineColor); + if (topToggleButton.isSelected()) { + cellBorderStyle.setTopColor(lineColor); + } cellBorderStyle.setTopStyle(topToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE); - cellBorderStyle.setBottomColor(lineColor); + + if (bottomToggleButton.isSelected()) { + cellBorderStyle.setBottomColor(lineColor); + } cellBorderStyle.setBottomStyle(bottomToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE); - cellBorderStyle.setLeftColor(lineColor); + + if (leftToggleButton.isSelected()) { + cellBorderStyle.setLeftColor(lineColor); + } cellBorderStyle.setLeftStyle(leftToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE); - cellBorderStyle.setRightColor(lineColor); + + if (rightToggleButton.isSelected()) { + cellBorderStyle.setRightColor(lineColor); + } cellBorderStyle.setRightStyle(rightToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE); - cellBorderStyle.setVerticalColor(lineColor); + + if (verticalToggleButton.isSelected()) { + cellBorderStyle.setVerticalColor(lineColor); + } cellBorderStyle.setVerticalStyle(verticalToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE); - cellBorderStyle.setHorizontalColor(lineColor); + + if (horizontalToggleButton.isSelected()) { + cellBorderStyle.setHorizontalColor(lineColor); + } cellBorderStyle.setHorizontalStyle(horizontalToggleButton.isSelected() ? lineStyle : Constants.LINE_NONE); + if (leftToggleButton.isSelected() && bottomToggleButton.isSelected() && rightToggleButton.isSelected() && topToggleButton.isSelected()) { outerToggleButton.setSelected(true); } else { diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java index 3706778609..4bfd9fa46c 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellStylePane.java @@ -3,6 +3,7 @@ package com.fr.design.mainframe.cell.settingpane; import com.fr.base.Style; import com.fr.design.constants.UIConstants; import com.fr.design.mainframe.cell.settingpane.style.StylePane; +import com.fr.design.style.BorderUtils; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.report.cell.DefaultTemplateCellElement; @@ -67,6 +68,7 @@ public class CellStylePane extends AbstractCellAttrPane { @Override public void updateBeans() { + Object[] selectionCellBorderObjects = BorderUtils.createCellBorderObject(elementCasePane); if (stylePane.getSelectedIndex() == 1) { Style s = stylePane.updateBean(); TemplateElementCase elementCase = elementCasePane.getEditingElementCase(); @@ -110,7 +112,8 @@ public class CellStylePane extends AbstractCellAttrPane { } } } - stylePane.updateBorder();// border必须特别处理 + // border必须特别处理 + stylePane.updateBorder(selectionCellBorderObjects); } } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java index 2d72772399..268dbebe6a 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/CustomStylePane.java @@ -136,8 +136,8 @@ public class CustomStylePane extends MultiTabPane