From bddf7c69e8a8507695ec4c71dfb390fdfdfe4cd3 Mon Sep 17 00:00:00 2001 From: pengda Date: Thu, 19 Nov 2020 16:10:55 +0800 Subject: [PATCH 1/2] =?UTF-8?q?REPORT-42734=20&&=20REPORT-42730=20?= =?UTF-8?q?=E8=81=9A=E5=90=88=E6=8A=A5=E8=A1=A8block=E5=9D=97=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/poly/PolyBlockProperPane.java | 4 +++ .../com/fr/poly/PolyBlockProperTable.java | 29 ++++++++++++++++++- .../main/java/com/fr/poly/PolyDesigner.java | 3 ++ 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/designer-realize/src/main/java/com/fr/poly/PolyBlockProperPane.java b/designer-realize/src/main/java/com/fr/poly/PolyBlockProperPane.java index f6803a90f..316e86c28 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyBlockProperPane.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyBlockProperPane.java @@ -40,6 +40,10 @@ public class PolyBlockProperPane extends DockingView { polyBlockProperTable.populate(designer); } + public void update(){ + polyBlockProperTable.update(); + } + @Override public String getViewTitle() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Property_Table"); diff --git a/designer-realize/src/main/java/com/fr/poly/PolyBlockProperTable.java b/designer-realize/src/main/java/com/fr/poly/PolyBlockProperTable.java index 452b4d7f6..6ffcb004f 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyBlockProperTable.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyBlockProperTable.java @@ -4,9 +4,12 @@ import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.foldablepane.UIExpandablePane; import com.fr.design.gui.ispinner.UISpinner; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.widget.BasicPropertyPane; import com.fr.design.widget.WidgetBoundsPaneFactory; +import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; import com.fr.poly.group.PolyBoundsGroup; import com.fr.report.poly.TemplateBlock; @@ -104,7 +107,12 @@ public class PolyBlockProperTable extends JPanel { if (isPopulating || block == null) { return; } - block.setBlockName(blockPropertyPane.getWidgetNameField().getText()); + if (blockPropertyPane.getWidgetNameField() != null) { + String toSetWidgetName = blockPropertyPane.getWidgetNameField().getText(); + if (isBlockNameValid(toSetWidgetName, block.getBlockName())) { + block.setBlockName(toSetWidgetName); + } + } PolyBoundsGroup boundsgroup = new PolyBoundsGroup(block, designer.getTarget()); boundsgroup.setValue(x.getValue(), 0, 1); boundsgroup.setValue(y.getValue(), 1, 1); @@ -112,4 +120,23 @@ public class PolyBlockProperTable extends JPanel { boundsgroup.setValue(height.getValue(), 3, 1); firePropertyEdit(); } + + /** + *校验一下要设置的名称,不能为空,不能重名 + * + */ + private boolean isBlockNameValid(String toSetWidgetName, String currentWidgetName) { + if (toSetWidgetName == null || toSetWidgetName.isEmpty()) { + blockPropertyPane.getWidgetNameField().setText(currentWidgetName); + return false; + } + for (int i = 0; i < this.designer.getTarget().getBlockCount(); i++) { + if (!ComparatorUtils.equals(currentWidgetName, toSetWidgetName) && ComparatorUtils.equals(toSetWidgetName, this.designer.getTarget().getBlock(i).getBlockName())) { + blockPropertyPane.getWidgetNameField().setText(currentWidgetName); + JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), JOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png")); + return false; + } + } + return true; + } } diff --git a/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java b/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java index 99d9b77b4..437cb8ea1 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyDesigner.java @@ -623,6 +623,9 @@ public class PolyDesigner extends ReportComponent Date: Fri, 20 Nov 2020 09:18:13 +0800 Subject: [PATCH 2/2] =?UTF-8?q?REPORT-42734=20&&=20REPORT-42730=20?= =?UTF-8?q?=E8=81=9A=E5=90=88=E6=8A=A5=E8=A1=A8block=E5=9D=97=E5=91=BD?= =?UTF-8?q?=E5=90=8D=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/fr/poly/PolyBlockProperTable.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/designer-realize/src/main/java/com/fr/poly/PolyBlockProperTable.java b/designer-realize/src/main/java/com/fr/poly/PolyBlockProperTable.java index 6ffcb004f..cd98e6622 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyBlockProperTable.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyBlockProperTable.java @@ -1,5 +1,6 @@ package com.fr.poly; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.event.UIObserver; import com.fr.design.event.UIObserverListener; import com.fr.design.foldablepane.UIExpandablePane; @@ -12,9 +13,12 @@ import com.fr.general.ComparatorUtils; import com.fr.general.IOUtils; import com.fr.poly.group.PolyBoundsGroup; import com.fr.report.poly.TemplateBlock; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Container; +import javax.swing.BorderFactory; +import javax.swing.JPanel; -import javax.swing.*; -import java.awt.*; public class PolyBlockProperTable extends JPanel { private PolyDesigner designer; @@ -133,7 +137,7 @@ public class PolyBlockProperTable extends JPanel { for (int i = 0; i < this.designer.getTarget().getBlockCount(); i++) { if (!ComparatorUtils.equals(currentWidgetName, toSetWidgetName) && ComparatorUtils.equals(toSetWidgetName, this.designer.getTarget().getBlock(i).getBlockName())) { blockPropertyPane.getWidgetNameField().setText(currentWidgetName); - JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), JOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png")); + FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News"), FineJOptionPane.ERROR_MESSAGE, IOUtils.readIcon("com/fr/design/form/images/joption_failure.png")); return false; } }