From 91523213fdcfdd34b4097b1515c106cbcaf24f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=96=B9=E7=A3=8A?= <294531121@qq.com> Date: Fri, 29 Oct 2021 14:31:17 +0800 Subject: [PATCH] REPORT-58584 --- .../gui/controlpane/JListControlPane.java | 33 +++++++++++++++++++ .../design/parameter/ParameterArrayPane.java | 24 +------------- .../fr/design/widget/WidgetConfigPane.java | 24 ++------------ 3 files changed, 36 insertions(+), 45 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java index 82cba758b..8401ffad5 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java @@ -1,10 +1,14 @@ package com.fr.design.gui.controlpane; +import com.fr.base.Parameter; +import com.fr.base.ParameterConfig; import com.fr.design.beans.BasicBeanPane; +import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.ilist.JNameEdList; import com.fr.design.gui.ilist.ListModelElement; import com.fr.design.gui.ilist.ModNameActionListener; +import com.fr.design.i18n.Toolkit; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.form.event.Listener; import com.fr.general.ComparatorUtils; @@ -12,6 +16,7 @@ import com.fr.general.IOUtils; import com.fr.invoke.Reflect; import com.fr.stable.ArrayUtils; import com.fr.stable.Nameable; +import com.fr.stable.StringUtils; import com.fr.stable.core.PropertyChangeAdapter; import javax.swing.DefaultListCellRenderer; @@ -23,12 +28,16 @@ import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import java.util.Arrays; import java.util.Collection; import java.awt.BorderLayout; import java.awt.Component; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; +import java.util.List; + +import static javax.swing.JOptionPane.WARNING_MESSAGE; public abstract class JListControlPane extends JControlPane implements ListControlPaneProvider { private static final String LIST_NAME = "JControl_List"; @@ -424,4 +433,28 @@ public abstract class JListControlPane extends JControlPane implements ListContr } + public void showTipWithIllegalName(String tip) { + Parameter[] parameters = ParameterConfig.getInstance().getGlobalParameters(); + String[] allListNames = nameableList.getAllNames(); + allListNames[editingIndex] = StringUtils.EMPTY; + String tempName = getEditingName(); + if (StringUtils.isEmpty(tempName)) { + nameableList.stopEditing(); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(JListControlPane.this), + Toolkit.i18nText("Fine-Design_Basic_Empty_Parameter_Name")); + setIllegalIndex(editingIndex); + return; + } + + if (!ComparatorUtils.equals(tempName, selectedName) + && isNameRepeated(new List[]{Arrays.asList(parameters), Arrays.asList(allListNames)}, tempName)) { + nameableList.stopEditing(); + FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(JListControlPane.this), + tip, + Toolkit.i18nText("Fine-Design_Basic_Alert"), + WARNING_MESSAGE); + setIllegalIndex(editingIndex); + } + } + } diff --git a/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java b/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java index 2703a2a2b..c5c7a12c9 100644 --- a/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java +++ b/designer-base/src/main/java/com/fr/design/parameter/ParameterArrayPane.java @@ -1,21 +1,15 @@ package com.fr.design.parameter; import com.fr.base.Parameter; -import com.fr.base.ParameterConfig; -import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.controlpane.NameableSelfCreator; import com.fr.design.gui.controlpane.UnrepeatedNameHelper; import com.fr.design.i18n.Toolkit; -import com.fr.general.ComparatorUtils; import com.fr.stable.Nameable; -import com.fr.stable.StringUtils; import com.fr.stable.core.PropertyChangeAdapter; -import javax.swing.*; import java.util.Arrays; -import java.util.List; public class ParameterArrayPane extends JListControlPane { @@ -29,23 +23,7 @@ public class ParameterArrayPane extends JListControlPane { this.addModNameActionListener((index, oldName, newName) -> populateSelectedValue()); this.addEditingListener(new PropertyChangeAdapter() { public void propertyChange() { - Parameter[] parameters = ParameterConfig.getInstance().getGlobalParameters(); - String[] allListNames = nameableList.getAllNames(); - allListNames[editingIndex] = StringUtils.EMPTY; - String tempName = getEditingName(); - if (StringUtils.isEmpty(tempName)) { - nameableList.stopEditing(); - FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Empty_Parameter_Name")); - setIllegalIndex(editingIndex); - return; - } - if (!ComparatorUtils.equals(tempName, selectedName) - && isNameRepeated(new List[]{Arrays.asList(parameters), Arrays.asList(allListNames)}, tempName)) { - nameableList.stopEditing(); - FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ParameterArrayPane.this), - Toolkit.i18nText("Fine-Design_Basic_Duplicate_Parameter_Name")); - setIllegalIndex(editingIndex); - } + showTipWithIllegalName(Toolkit.i18nText("Fine-Design_Basic_Duplicate_Parameter_Name")); } }); } diff --git a/designer-realize/src/main/java/com/fr/design/widget/WidgetConfigPane.java b/designer-realize/src/main/java/com/fr/design/widget/WidgetConfigPane.java index 78fd57d5d..9ec4a1caf 100644 --- a/designer-realize/src/main/java/com/fr/design/widget/WidgetConfigPane.java +++ b/designer-realize/src/main/java/com/fr/design/widget/WidgetConfigPane.java @@ -1,8 +1,5 @@ package com.fr.design.widget; -import com.fr.base.Parameter; -import com.fr.base.ParameterConfig; -import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameObjectCreator; import com.fr.design.gui.controlpane.NameableCreator; @@ -11,41 +8,24 @@ import com.fr.design.i18n.Toolkit; import com.fr.form.ui.UserDefinedWidgetConfig; import com.fr.form.ui.WidgetConfig; import com.fr.form.ui.WidgetInfoConfig; -import com.fr.general.ComparatorUtils; import com.fr.general.NameObject; import com.fr.stable.Nameable; -import com.fr.stable.StringUtils; import com.fr.stable.core.PropertyChangeAdapter; -import javax.swing.SwingUtilities; import java.util.ArrayList; -import java.util.Arrays; import java.util.Iterator; import java.util.List; -import static javax.swing.JOptionPane.WARNING_MESSAGE; - /** * Widget配置面板 */ public class WidgetConfigPane extends JListControlPane { public WidgetConfigPane() { + super(); this.addEditingListener(new PropertyChangeAdapter() { public void propertyChange() { - Parameter[] parameters = ParameterConfig.getInstance().getGlobalParameters(); - String[] allListNames = nameableList.getAllNames(); - allListNames[editingIndex] = StringUtils.EMPTY; - String tempName = getEditingName(); - if (!ComparatorUtils.equals(tempName, selectedName) - && isNameRepeated(new List[]{Arrays.asList(parameters), Arrays.asList(allListNames)}, tempName)) { - nameableList.stopEditing(); - FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(WidgetConfigPane.this), - Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure"), - Toolkit.i18nText("Fine-Design_Basic_Alert"), - WARNING_MESSAGE); - setIllegalIndex(editingIndex); - } + showTipWithIllegalName(Toolkit.i18nText("Fine-Design_Form_Widget_Rename_Failure")); } }); }