From adbc055b2946ad418c7ee237149f2f91af0fbd2b Mon Sep 17 00:00:00 2001 From: Starryi Date: Wed, 29 Dec 2021 17:33:56 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-65125=20=E3=80=90=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E3=80=91=E5=8F=8C=E5=87=BB=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=88=97=E8=AE=BE=E7=BD=AE=E6=A0=BC=E5=BC=8F=EF=BC=8C=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E4=BF=9D=E5=AD=98=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 格式面板必须注册GlobalNameListener才能正常updateBean,所以需要使用 AbstractAttrNoScrollPane包装格式面板 【改动思路】 同上 --- .../design/dscolumn/DSColumnAdvancedPane.java | 58 +++++++++++++++++-- 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java index 31e81eb9a..b943778bf 100644 --- a/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java +++ b/designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java @@ -3,7 +3,6 @@ package com.fr.design.dscolumn; import com.fr.base.BaseFormula; import com.fr.data.util.SortOrder; import com.fr.design.border.UITitledBorder; -import com.fr.design.constants.LayoutConstants; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; @@ -11,10 +10,10 @@ import com.fr.design.formula.CustomVariableResolver; import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.SortFormulaPane; import com.fr.design.formula.UIFormula; +import com.fr.design.gui.frpane.AbstractAttrNoScrollPane; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icombobox.UIComboBox; -import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.itextfield.UITextField; @@ -29,11 +28,19 @@ import com.fr.report.cell.cellattr.CellExpandAttr; import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.cell.cellattr.core.group.SelectCount; -import javax.swing.*; -import java.awt.*; +import javax.swing.BorderFactory; +import javax.swing.Box; +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Font; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; -import java.util.Arrays; import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.BOTTOM; import static com.fr.report.cell.cellattr.core.group.FilterTypeEnum.SPECIFY; @@ -541,7 +548,7 @@ public class DSColumnAdvancedPane extends BasicPane { } } - public static class FormatAttrPane extends TextFormatPane { + public static class ReLayoutTextFormatPane extends TextFormatPane { protected void initLayout() { JComponent[][] components = new JComponent[][] { {typeComboBox, textField, roundingBox} }; @@ -571,6 +578,45 @@ public class DSColumnAdvancedPane extends BasicPane { } } + + public static class FormatAttrPane extends AbstractAttrNoScrollPane { + private TextFormatPane formatPane; + + @Override + protected JPanel createContentPane() { + this.formatPane = new ReLayoutTextFormatPane(); + return this.formatPane; + } + + @Override + public Dimension getPreferredSize() { + if (formatPane == null) { + return super.getPreferredSize(); + } + return formatPane.getPreferredSize(); + } + + protected void initContentPane() { + leftContentPane = createContentPane(); + if (leftContentPane != null) { + leftContentPane.setBorder(BorderFactory.createEmptyBorder()); + this.add(leftContentPane, BorderLayout.CENTER); + } + } + + public void populate(CellElement cellElement) { + if (cellElement != null && formatPane != null) { + formatPane.populateBean(cellElement.getStyle()); + } + } + + public void update(CellElement cellElement) { + if (cellElement != null && formatPane != null) { + cellElement.setStyle(formatPane.update(cellElement.getStyle())); + } + } + } + private void checkButtonEnabled() { if (useMultiplyNumCheckBox.isSelected()) { multiNumSpinner.setEnabled(true); From e1beb6c99d37059e39feef82776141255958cb70 Mon Sep 17 00:00:00 2001 From: Starryi Date: Wed, 29 Dec 2021 17:57:34 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-65124=20=E3=80=90=E6=A8=A1=E6=9D=BF?= =?UTF-8?q?=E4=B8=BB=E9=A2=98=E3=80=91=E5=8D=95=E5=85=83=E6=A0=BC=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E7=BC=96=E8=BE=91=E7=9A=84=E6=95=88=E6=9E=9C=E6=9C=89?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 虽然ListCellRenderer中去除了icon,但是JNamedList实现还使用了icon的宽度来绘制内容,导致 渲染出来的编辑框有问题 【改动思路】 重新实现一个图表宽度为0的JNamedList --- .../theme/edit/CellStyleListEditPane.java | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java index 0b5c7b61e..3f198f230 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/theme/edit/CellStyleListEditPane.java @@ -30,9 +30,11 @@ import com.fr.stable.Nameable; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; +import javax.swing.DefaultListModel; import javax.swing.JList; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.ListModel; import javax.swing.SwingUtilities; import java.awt.BorderLayout; import java.awt.Component; @@ -101,7 +103,7 @@ public class CellStyleListEditPane extends JListControlPane { @Override protected JNameEdList createJNameList() { - JNameEdList nameEdList = super.createJNameList(); + JNameEdList nameEdList = new NoIconNamedList(new DefaultListModel()); nameEdList.setCellEditor(new UnEditableListCellEditor(new UITextField())); nameEdList.setCellRenderer(new NoIconNameableListCellRenderer()); return nameEdList; @@ -294,6 +296,17 @@ public class CellStyleListEditPane extends JListControlPane { return component; } } + private class NoIconNamedList extends JNameEdList { + + public NoIconNamedList(ListModel dataModel) { + super(dataModel); + } + + @Override + public int getIconWidth() { + return 0; + } + } private class UnEditableListCellEditor extends DefaultListCellEditor { public UnEditableListCellEditor(UITextField textField) {