From f45634e3bb790274280ddd51091b706180e66998 Mon Sep 17 00:00:00 2001 From: pengda Date: Mon, 2 Nov 2020 14:05:06 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-39772=20=E6=8F=90=E7=A4=BA=E6=8E=A7?= =?UTF-8?q?=E4=BB=B6/=E7=BB=84=E4=BB=B6=E5=90=8D=E7=A7=B0=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../creator/CRPropertyDescriptorPane.java | 16 ++++++++++++++-- .../mainframe/widget/ui/FormWidgetCardPane.java | 5 ++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptorPane.java b/designer-form/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptorPane.java index be4a81d4ec..5e5558e800 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptorPane.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/CRPropertyDescriptorPane.java @@ -6,15 +6,18 @@ import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.xtable.TableUtils; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.FormDesigner; import com.fr.design.mainframe.WidgetPropertyPane; import com.fr.design.mainframe.widget.editors.ExtendedPropertyEditor; import com.fr.design.mainframe.widget.editors.StringEditor; import com.fr.form.ui.Widget; import com.fr.general.ComparatorUtils; +import com.fr.general.IOUtils; import com.fr.log.FineLoggerFactory; import javax.swing.BorderFactory; +import javax.swing.JOptionPane; import javax.swing.JPanel; import java.awt.Component; import java.beans.PropertyChangeEvent; @@ -31,7 +34,6 @@ public class CRPropertyDescriptorPane { private PropertyEditor propertyEditor; private boolean isPopulate = true; private FormDesigner designer; - public CRPropertyDescriptorPane(CRPropertyDescriptor crPropertyDescriptor, XCreator xCreator, FormDesigner designer) { this.crPropertyDescriptor = crPropertyDescriptor; this.xCreator = xCreator; @@ -136,8 +138,18 @@ public class CRPropertyDescriptorPane { try { Object value = propertyEditor.getValue(); Method m = crPropertyDescriptor.getWriteMethod(); + if (ComparatorUtils.equals(m.getName(), "setWidgetName")) { + String toSetWidgetName = value.toString(); + String currentWidgetName = widget.getWidgetName(); + boolean exist = designer.getTarget().isNameExist(toSetWidgetName) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName); + if (toSetWidgetName.isEmpty()) { + value = currentWidgetName; + } else if (exist) { + 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; + } + } m.invoke(widget, value); - crPropertyDescriptor.firePropertyChanged(); } catch (Exception e) { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java index 5e57557e7f..59c62c9993 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/widget/ui/FormWidgetCardPane.java @@ -219,7 +219,10 @@ public class FormWidgetCardPane extends AbstractAttrNoScrollPane { String toSetWidgetName = widgetNameField.getText(); String currentWidgetName = widget.getWidgetName(); boolean exist = designer.getTarget().isNameExist(toSetWidgetName) && !ComparatorUtils.equals(toSetWidgetName, currentWidgetName); - if (exist) { + if (toSetWidgetName.isEmpty()) { + widgetNameField.setText(currentWidgetName); + return; + } else if (exist) { widgetNameField.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;