From 8dab3123df3b85728ac055601bbbd2eaf9dd82ee Mon Sep 17 00:00:00 2001 From: Starryi Date: Sat, 28 Aug 2021 14:25:12 +0800 Subject: [PATCH 1/4] =?UTF-8?q?REPORT-58301=20=E3=80=90=E5=86=B3=E7=AD=96?= =?UTF-8?q?=E6=8A=A5=E8=A1=A8=E3=80=91=E5=B8=83=E5=B1=80=E5=88=87=E6=8D=A2?= =?UTF-8?q?=E4=BB=A5=E5=90=8E=EF=BC=8Cbody=E8=83=8C=E6=99=AF=E6=A0=B7?= =?UTF-8?q?=E5=BC=8F=E4=B8=8D=E4=BF=9D=E7=95=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 切换布局类型时,保留body背景样式 【改动思路】 同上 --- .../ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java | 7 +++++++ .../widget/ui/designer/layout/FRFitLayoutDefinePane.java | 4 ++++ 2 files changed, 11 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java index 6e5a2296b9..1c2bee33e0 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java @@ -24,6 +24,8 @@ import com.fr.form.ui.LayoutBorderStyle; import com.fr.form.ui.container.WAbsoluteBodyLayout; import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WBodyLayoutType; +import com.fr.form.ui.container.WFitLayout; +import com.fr.general.act.BorderPacker; import com.fr.report.core.ReportUtils; import javax.swing.BorderFactory; @@ -150,6 +152,11 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane { if (state == WBodyLayoutType.FIT.getTypeValue()) { XWFitLayout xwFitLayout = ((XWFitLayout)creator.getBackupParent()); xwFitLayout.switch2FitBodyLayout(creator); + WFitLayout wFitLayout = xwFitLayout.toData(); + // 切换布局类型时,保留body背景样式 + if (wFitLayout != null) { + wFitLayout.setBorderStyle(layout.getBorderStyle()); + } copyLayoutAttr(layout, xwFitLayout.toData()); } } diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java index 1615861285..104123941c 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java @@ -34,6 +34,7 @@ import com.fr.form.ui.container.WAbsoluteLayout; import com.fr.form.ui.container.WBodyLayoutType; import com.fr.form.ui.container.WFitLayout; import com.fr.general.ComparatorUtils; +import com.fr.general.act.BorderPacker; import com.fr.log.FineLoggerFactory; import com.fr.report.core.ReportUtils; @@ -191,9 +192,12 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane Date: Tue, 14 Sep 2021 15:41:24 +0800 Subject: [PATCH 2/4] =?UTF-8?q?REPORT-57551=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=EF=BC=8C=E8=87=AA=E9=80=82=E5=BA=94=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E4=B8=8Bbody=E8=83=8C=E6=99=AF=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=BB=A5=E5=90=8E=EF=BC=8C=E7=94=BB=E5=B8=83=E4=B8=AD=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=AE=9E=E6=97=B6=E6=98=BE=E7=A4=BA=E8=83=8C=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 重命名组件样式预览效果的相关方法 【改动思路】 同标题 --- .../designer/creator/XBorderStyleWidgetCreator.java | 8 ++++---- .../com/fr/design/designer/creator/XChartEditor.java | 6 +++--- .../com/fr/design/designer/creator/XElementCase.java | 6 +++--- .../fr/design/designer/creator/XLayoutContainer.java | 6 +++--- .../design/designer/creator/XWAbsoluteBodyLayout.java | 8 ++++---- .../fr/design/designer/creator/XWAbsoluteLayout.java | 2 +- .../com/fr/design/designer/creator/XWTitleLayout.java | 2 +- .../designer/creator/cardlayout/XWCardLayout.java | 10 +++++----- .../creator/cardlayout/XWCardMainBorderLayout.java | 2 +- 9 files changed, 25 insertions(+), 25 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java index 485c73b164..882a540a42 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java @@ -88,12 +88,12 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ super.addToWrapper(parentPanel, width, minHeight); // REPORT-53175: 新创建的图表组件默认显示标题 since 10.0.18 // 将当前对象添加到父容器后,初始化默认样式的效果 - initStyle(); + refreshStylePreviewEffect(); } - protected void initStyle() { + public void refreshStylePreviewEffect() { BorderPacker style = toData().getBorderStyle(); - initBorderAndBackgroundStyle(); + refreshBorderAndBackgroundStylePreviewEffect(); if (ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)) { initTitleStyle(style); } else { @@ -104,7 +104,7 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ reshuffleBorderAndBackgroundPaintingEffectIfTitleExists(); } - protected void initBorderAndBackgroundStyle() { + public void refreshBorderAndBackgroundStylePreviewEffect() { BorderPacker style = toData().getBorderStyle(); LineBorder DEFAULT_LINE_BORDER = (LineBorder) DEFALUTBORDER; diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java index eeb74155a3..3d1550af67 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java @@ -122,7 +122,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator { @Override public void propertyChange() { - initStyle(); + refreshStylePreviewEffect(); } }), }; @@ -165,7 +165,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator { @Override protected void initXCreatorProperties() { super.initXCreatorProperties(); - initBorderAndBackgroundStyle(); + refreshBorderAndBackgroundStylePreviewEffect(); BaseChartCollection collection = ((BaseChartEditor) data).getChartCollection(); isRefreshing = true; ((MiddleChartComponent) designerEditor.getEditorTarget()).populate(collection); @@ -341,7 +341,7 @@ public class XChartEditor extends XBorderStyleWidgetCreator { * data属性改变触发其他操作 */ public void firePropertyChange() { - initStyle(); + refreshStylePreviewEffect(); } @Override diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java index 8df20d4050..cf8b7a7661 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XElementCase.java @@ -58,7 +58,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme super.initXCreatorProperties(); // 报表块初始化时要加载对应的borderStyle - initBorderAndBackgroundStyle(); + refreshBorderAndBackgroundStylePreviewEffect(); } /** @@ -94,7 +94,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme @Override public void propertyChange() { - initStyle(); + refreshStylePreviewEffect(); } }), new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) @@ -342,7 +342,7 @@ public class XElementCase extends XBorderStyleWidgetCreator implements FormEleme * */ public void firePropertyChange() { - initStyle(); + refreshStylePreviewEffect(); } /** diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java b/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java index 50c5967c55..f1d4c4f6d3 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XLayoutContainer.java @@ -75,7 +75,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme @Override public void propertyChange() { - initStyle(); + refreshStylePreviewEffect(); } }), new CRPropertyDescriptor("margin", this.data.getClass()).setEditorClass(PaddingMarginEditor.class) @@ -118,7 +118,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme @Override protected void initXCreatorProperties() { super.initXCreatorProperties(); - initBorderAndBackgroundStyle(); + refreshBorderAndBackgroundStylePreviewEffect(); this.initLayoutManager(); this.convert(); } @@ -547,7 +547,7 @@ public abstract class XLayoutContainer extends XBorderStyleWidgetCreator impleme * */ public void firePropertyChange(){ - initStyle(); + refreshStylePreviewEffect(); } /** diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java index aa5612c09f..b00f6710bf 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteBodyLayout.java @@ -78,7 +78,7 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { @Override public void propertyChange() { - initStyle(); + XWAbsoluteBodyLayout.this.refreshStylePreviewEffect(); } }) }; @@ -105,8 +105,8 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { } @Override - protected void initStyle() { - initBorderAndBackgroundStyle(); + public void refreshStylePreviewEffect() { + refreshBorderAndBackgroundStylePreviewEffect(); } /** @@ -114,7 +114,7 @@ public class XWAbsoluteBodyLayout extends XWAbsoluteLayout { * */ public void firePropertyChange(){ - initStyle(); + this.refreshStylePreviewEffect(); } @Override diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java index 44d1588dfa..fe27467f49 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -305,7 +305,7 @@ public class XWAbsoluteLayout extends XLayoutContainer { } @Override - protected void initStyle() { + public void refreshStylePreviewEffect() { // do nothing } diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java index 71129bed46..6e67c9ff8a 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWTitleLayout.java @@ -63,7 +63,7 @@ public class XWTitleLayout extends DedicateLayoutContainer { } @Override - protected void initBorderAndBackgroundStyle() { + public void refreshBorderAndBackgroundStylePreviewEffect() { setBorder(null); setBorderImage4Painting(null, 0.0); setBackground4Painting(null, 0.0); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java index 4fb422c0aa..e1d4a416e7 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java @@ -160,7 +160,7 @@ public class XWCardLayout extends XLayoutContainer { */ @Override protected XLayoutContainer getCreatorWrapper(String widgetName) { - initStyle(); + refreshStylePreviewEffect(); Dimension dimension = new Dimension(); //主结构是一个borderlayout, 标签部分是north, card部分为center WCardMainBorderLayout border = new WCardMainBorderLayout(); @@ -389,7 +389,7 @@ public class XWCardLayout extends XLayoutContainer { @Override public void propertyChange() { - initStyle(); + refreshStylePreviewEffect(); } }) }; @@ -397,10 +397,10 @@ public class XWCardLayout extends XLayoutContainer { //初始化样式 @Override - protected void initStyle() { + public void refreshStylePreviewEffect() { BorderPacker style = toData().getBorderStyle(); initBorderTitleStyle(style); - initBorderAndBackgroundStyle(); + refreshBorderAndBackgroundStylePreviewEffect(); clearOrShowTitleLayout(ComparatorUtils.equals(style.getType(), LayoutBorderStyle.TITLE)); } @@ -484,7 +484,7 @@ public class XWCardLayout extends XLayoutContainer { */ @Override public void firePropertyChange() { - initStyle(); + refreshStylePreviewEffect(); } public void resetTabBackground(TemplateStyle templateStyle) { diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java index 2f7200acf6..0db348a399 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardMainBorderLayout.java @@ -417,7 +417,7 @@ public class XWCardMainBorderLayout extends XWBorderLayout { public void firePropertyChange(){ XWCardLayout cardLayout = this.getCardPart(); if (cardLayout != null && cardLayout.toData() != null) { - cardLayout.initStyle(); + cardLayout.refreshStylePreviewEffect(); } } From 324b8d4db32cf62ac0df2e7f2b5c5c1ba8a2ef27 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 14 Sep 2021 16:16:01 +0800 Subject: [PATCH 3/4] =?UTF-8?q?REPORT-57551=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=EF=BC=8C=E8=87=AA=E9=80=82=E5=BA=94=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E4=B8=8Bbody=E8=83=8C=E6=99=AF=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=BB=A5=E5=90=8E=EF=BC=8C=E7=94=BB=E5=B8=83=E4=B8=AD=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=AE=9E=E6=97=B6=E6=98=BE=E7=A4=BA=E8=83=8C=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 Body Creator的swing Background遮挡了样式背景导致. 需要将swing背景的绘制放置到样式背景的下方, 避免遮挡样式背景 【改动思路】 同标题 --- .../creator/XBorderStyleWidgetCreator.java | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java index 882a540a42..df84109463 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XBorderStyleWidgetCreator.java @@ -21,6 +21,8 @@ import com.fr.stable.StringUtils; import javax.swing.*; import javax.swing.border.Border; import javax.swing.border.LineBorder; +import javax.swing.plaf.PanelUI; +import javax.swing.plaf.basic.BasicPanelUI; import java.awt.*; import java.awt.geom.Rectangle2D; import java.awt.geom.RoundRectangle2D; @@ -42,12 +44,23 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ public XBorderStyleWidgetCreator(Widget widget, Dimension initSize) { super(widget, initSize); + setUI(new NoBackgroundPaneUI()); + setOpaque(false); + setBackupBound(null); + ExtendSharableAttrMark sharableAttrMark = this.toData().getWidgetAttrMark(ExtendSharableAttrMark.XML_TAG); if (sharableAttrMark != null) { this.setShareId(sharableAttrMark.getShareId()); } } + @Override + public void setUI(PanelUI ui) { + if (ui instanceof NoBackgroundPaneUI) { + super.setUI(ui); + } + } + public Background getBackground4Painting() { return this.background4Painting; } @@ -263,6 +276,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ } + @Override + public void setBackground(Color bg) { + super.setBackground(bg); + } + // 根据当前组件边框裁剪内容,如果当前组件存在圆角,则应当按圆角裁剪内容 private void clipByRoundedBorder(Graphics2D g2d) { Border currentBorder = getBorder(); @@ -280,6 +298,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ // 设计器预览界面中绘制组件背景效果 public void paintBackground(Graphics2D g2d) { + if (isOpaque()) { + g2d.setColor(getBackground()); + g2d.fillRect(0, 0, getWidth(), getHeight()); + } + Background background4Painting = getBackground4Painting(); if (background4Painting != null) { Composite oldComposite = g2d.getComposite(); @@ -303,12 +326,12 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ } public void paintForeground(Graphics2D g2d) { - super.paint(g2d); + super.paintComponent(g2d); super.paintBorder(g2d); } @Override - public void paint(Graphics g) { + public void paintComponent(Graphics g) { this.clipByRoundedBorder((Graphics2D) g); this.paintBackground((Graphics2D) g); this.paintBorderImage((Graphics2D) g); @@ -370,4 +393,11 @@ public class XBorderStyleWidgetCreator extends XWidgetCreator{ g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); } } + + public static class NoBackgroundPaneUI extends BasicPanelUI { + @Override + public void update(Graphics g, JComponent c) { + paint(g, c); + } + } } \ No newline at end of file From 943be0333386306199a67dc04d6f78cfa0ffdce0 Mon Sep 17 00:00:00 2001 From: Starryi Date: Tue, 14 Sep 2021 16:16:58 +0800 Subject: [PATCH 4/4] =?UTF-8?q?REPORT-57551=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=EF=BC=8C=E8=87=AA=E9=80=82=E5=BA=94=E5=B8=83?= =?UTF-8?q?=E5=B1=80=E4=B8=8Bbody=E8=83=8C=E6=99=AF=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E4=BB=A5=E5=90=8E=EF=BC=8C=E7=94=BB=E5=B8=83=E4=B8=AD=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E5=AE=9E=E6=97=B6=E6=98=BE=E7=A4=BA=E8=83=8C=E6=99=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 【问题原因】 body布局切换时,除了要重新设置body widget样式数据模型,还要 刷新样式预览效果 【改动思路】 同标题 --- .../layout/FRAbsoluteBodyLayoutDefinePane.java | 1 + .../ui/designer/layout/FRFitLayoutDefinePane.java | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java index 1c2bee33e0..f740991456 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRAbsoluteBodyLayoutDefinePane.java @@ -158,6 +158,7 @@ public class FRAbsoluteBodyLayoutDefinePane extends FRAbsoluteLayoutDefinePane { wFitLayout.setBorderStyle(layout.getBorderStyle()); } copyLayoutAttr(layout, xwFitLayout.toData()); + xwFitLayout.refreshStylePreviewEffect(); } } layout.setBorderStyle(stylePane.updateBean()); diff --git a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java index 104123941c..6afdad367e 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/layout/FRFitLayoutDefinePane.java @@ -39,6 +39,7 @@ import com.fr.log.FineLoggerFactory; import com.fr.report.core.ReportUtils; import javax.swing.*; +import javax.swing.border.Border; import java.awt.*; /** @@ -219,6 +220,15 @@ public class FRFitLayoutDefinePane extends AbstractFRLayoutDefinePane