From 0c3d167b0fc076c69a039935ae89c6b1bc91e2e2 Mon Sep 17 00:00:00 2001 From: hades Date: Mon, 27 Apr 2020 15:54:06 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-26837=20=E9=9D=9E=E6=B3=95=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E9=9B=86=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/actions/TableDataSourceAction.java | 6 ++- .../design/data/BasicTableDataTreePane.java | 2 + .../fr/design/data/BasicTableDataUtils.java | 36 +++++++++++++++ .../data/datapane/ReportTableDataPane.java | 4 ++ .../data/datapane/TableDataPaneListPane.java | 9 ++++ .../java/com/fr/design/dialog/UIDialog.java | 5 ++- .../design/data/BasicTableDataUtilsTest.java | 44 +++++++++++++++++++ 7 files changed, 104 insertions(+), 2 deletions(-) create mode 100644 designer-base/src/main/java/com/fr/design/data/BasicTableDataUtils.java create mode 100644 designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java diff --git a/designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java b/designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java index ff62c6fb8..600f9721e 100644 --- a/designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java +++ b/designer-base/src/main/java/com/fr/design/actions/TableDataSourceAction.java @@ -42,11 +42,15 @@ public class TableDataSourceAction extends TemplateComponentAction getDsNameChangedMap() { return tdPane.getDsNameChangedMap(); } + + public boolean isNamePermitted() { + return tdPane.isNamePermitted(); + } } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java index d2fdc3229..4c081a66d 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java @@ -4,6 +4,7 @@ import com.fr.base.TableData; import com.fr.data.TableDataSource; import com.fr.data.api.StoreProcedureAssist; import com.fr.data.impl.storeproc.StoreProcedure; +import com.fr.design.data.BasicTableDataUtils; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.FineJOptionPane; import com.fr.design.gui.controlpane.JListControlPane; @@ -47,6 +48,14 @@ public class TableDataPaneListPane extends JListControlPane implements TableData allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY; String tempName = getEditingName(); Object editingType = getEditingType(); + + if (!BasicTableDataUtils.checkName(tempName)) { + isNamePermitted = false; + nameableList.stopEditing(); + setIllegalIndex(editingIndex); + return; + } + if (StringUtils.isEmpty(tempName)) { isNamePermitted = false; nameableList.stopEditing(); diff --git a/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java b/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java index a885c5188..8f2021c69 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java +++ b/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java @@ -123,8 +123,11 @@ public abstract class UIDialog extends JDialog { // transfer focus to CurrentEditor inputMapAncestor.put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "dialogOK"); actionMap.put("dialogOK", new AbstractAction() { - + @Override public void actionPerformed(ActionEvent evt) { + if (!okButton.isEnabled()) { + return; + } doOK(); } }); diff --git a/designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java b/designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java new file mode 100644 index 000000000..acd47a3c1 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/data/BasicTableDataUtilsTest.java @@ -0,0 +1,44 @@ +package com.fr.design.data; + +import junit.framework.TestCase; +import org.junit.Assert; +import org.junit.Test; + +/** + * @author hades + * @version 10.0 + * Created by hades on 2020/4/27 + */ +public class BasicTableDataUtilsTest extends TestCase { + + @Test + public void testIsInValidName() { + + boolean result1 = BasicTableDataUtils.isInValidName("a.b"); + boolean result2 = BasicTableDataUtils.isInValidName("a.b.c"); + boolean result3 = BasicTableDataUtils.isInValidName("a..b"); + boolean result4 = BasicTableDataUtils.isInValidName("a."); + boolean result5 = BasicTableDataUtils.isInValidName("a.b."); + boolean result6 = BasicTableDataUtils.isInValidName("abc"); + boolean result7 = BasicTableDataUtils.isInValidName(".abc"); + boolean result8 = BasicTableDataUtils.isInValidName(".ab.c"); + boolean result9 = BasicTableDataUtils.isInValidName("ab.c."); + boolean result10 = BasicTableDataUtils.isInValidName(".abc."); + boolean result11 = BasicTableDataUtils.isInValidName(".ab.c."); + boolean result12 = BasicTableDataUtils.isInValidName(".."); + + Assert.assertTrue(result1); + Assert.assertFalse(result2); + Assert.assertFalse(result3); + Assert.assertFalse(result4); + Assert.assertTrue(result5); + Assert.assertFalse(result6); + Assert.assertTrue(result7); + Assert.assertFalse(result8); + Assert.assertTrue(result9); + Assert.assertTrue(result10); + Assert.assertFalse(result11); + Assert.assertFalse(result12); + } + +} \ No newline at end of file