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 ff62c6fb81..600f9721ed 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 d2fdc32291..4c081a66da 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 a885c51883..8f2021c696 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 0000000000..acd47a3c11 --- /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