From d6c2f9fa849a43b8915f484533583888223820c4 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Fri, 8 Jul 2022 14:11:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?REPORT-38523=20fix:=20=E5=8F=B3=E4=BE=A7?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=A0=BC=E5=B1=9E=E6=80=A7=E8=A1=A8=E9=BC=A0?= =?UTF-8?q?=E6=A0=87=E4=BA=8B=E4=BB=B6=E6=9C=89=E8=AF=AF=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E4=BA=86mouseReleased=E4=BA=8B=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../design/gui/icontainer/UIEastResizableContainer.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java index 125cd3aa16..dcd33498a4 100644 --- a/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java +++ b/designer-base/src/main/java/com/fr/design/gui/icontainer/UIEastResizableContainer.java @@ -296,10 +296,9 @@ public class UIEastResizableContainer extends JPanel { model = UIConstants.MODEL_NORMAL; refreshContainer(); } - @Override - public void mouseClicked(MouseEvent e) { - if (e.getX() <= ARROW_RANGE) { + public void mouseReleased(MouseEvent e) { + if (isInPane(e)) { if (containerWidth == leftPaneWidth) { showContainer(); } else { @@ -309,7 +308,9 @@ public class UIEastResizableContainer extends JPanel { } }); } - + public boolean isInPane(MouseEvent e){ + return e.getX() <= ARROW_RANGE && e.getX() >= 0 && e.getY() <= topToolPaneHeight && e.getY() >= 0; + } @Override public void paint(Graphics g) { Image button; From 878470d77d151c3b80117edd333ae6fb45e9f2ff Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 11 Jul 2022 18:19:51 +0800 Subject: [PATCH 2/3] =?UTF-8?q?REPORT-38555=20fix:=E6=95=B0=E5=AD=97?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E4=B8=AD=E5=86=85=E5=AE=B9=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E7=A9=BA=E6=A0=BC=E5=92=8C=E5=87=8F=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/ispinner/UISpinner.java | 17 +------ .../design/gui/itextfield/UINumberField.java | 12 ++++- .../component/NumberEditorValidatePane.java | 25 +++++++++-- .../gui/itextfield/UINumberFieldTest.java | 44 +++++++++++++++++++ 4 files changed, 77 insertions(+), 21 deletions(-) create mode 100644 designer-base/src/test/java/com/fr/design/gui/itextfield/UINumberFieldTest.java diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java index 22f6cb246e..10e6e58376 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java @@ -22,19 +22,8 @@ import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.plaf.ButtonUI; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Graphics; -import java.awt.Graphics2D; -import java.awt.GridLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.FocusAdapter; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.awt.event.MouseWheelEvent; -import java.awt.event.MouseWheelListener; +import java.awt.*; +import java.awt.event.*; public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver { @@ -72,7 +61,6 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver init(minValue, maxValue, dierta); textField.setValue(defaultValue); } - protected void init(double minValue, double maxValue, double dierta) { this.minValue = minValue; this.maxValue = maxValue; @@ -411,7 +399,6 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver public boolean shouldResponseNameListener() { return true; } - /** * 程序入口 测试 * diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java index 0d1287d8c0..5a2bda66eb 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java @@ -4,6 +4,8 @@ import com.fr.base.Utils; import com.fr.general.ComparatorUtils; import com.fr.stable.CoreConstants; import com.fr.stable.StringUtils; +import org.gradle.internal.impldep.org.junit.Test; + import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; import javax.swing.text.PlainDocument; @@ -164,10 +166,16 @@ public class UINumberField extends UITextField { || ComparatorUtils.equals(s, "D") || ComparatorUtils.equals(s, "d") || (ComparatorUtils.equals(str.trim(), "0") && !ComparatorUtils.equals(s.substring(0, 1), ".") && offset != 0)// 第一位是0时,第二位只能为小数点 - || (ComparatorUtils.equals(s, ".") && maxDecimalLength == 0)); + || (ComparatorUtils.equals(s, ".") && maxDecimalLength == 0)) + || s.contains(" ")//不允许空格 + || (ComparatorUtils.equals(s.substring(0, 1),"-") && offset != 0)//负号只允许出现在第一位 + || (ComparatorUtils.equals(s.substring(0, 1),".") && offset == 0)//小数点不能在第一位 + || s.contains("-.") + || s.contains(".-")//不能包含-.或.-非法格式 + || (str.startsWith("-") && ComparatorUtils.equals(s.substring(0, 1), ".") && offset == 1 )//负号不能接小数点 + || (s.contains("-") && !ComparatorUtils.equals(s.substring(0,1), "-"));//输入的字符串如果包含负号,负号必须在第一位 } - public void insertString(int offset, String s, AttributeSet a) throws BadLocationException { String str = getText(0, getLength()); diff --git a/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java b/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java index 7fd88dd957..23e9d30771 100644 --- a/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java +++ b/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java @@ -21,11 +21,16 @@ import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.BorderLayout; -import java.awt.Component; -import java.awt.Dimension; +import javax.swing.text.AttributeSet; +import javax.swing.text.BadLocationException; +import javax.swing.text.PlainDocument; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.util.regex.Matcher; +import java.util.regex.Pattern; /** * Created by kerry on 2017/9/10. @@ -102,8 +107,20 @@ public class NumberEditorValidatePane extends JPanel { int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}, {1, 1}}; JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, IntervalConstants.INTERVAL_L2, IntervalConstants.INTERVAL_L1); this.add(panel); + decimalLength.getTextField().addKeyListener(new KeyAdapter() { + @Override + public void keyTyped(KeyEvent e) { + // Digit only + if (isDigit(e)) { + } else { + e.consume(); + } + } + }); + } + private boolean isDigit(KeyEvent e){ + return e.getKeyChar() >= KeyEvent.VK_0 && e.getKeyChar() <= KeyEvent.VK_9; } - private void initErrorMsgPane() { TextFieldAdapterProvider provider = ExtraDesignClassManager.getInstance().getSingle(TextFieldAdapterProvider.XML_TAG); if (provider != null) { diff --git a/designer-base/src/test/java/com/fr/design/gui/itextfield/UINumberFieldTest.java b/designer-base/src/test/java/com/fr/design/gui/itextfield/UINumberFieldTest.java new file mode 100644 index 0000000000..17b0f547cc --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/gui/itextfield/UINumberFieldTest.java @@ -0,0 +1,44 @@ +package com.fr.design.gui.itextfield; + +import org.junit.Assert; +import org.junit.Test; + +/** + * @author Destiny.Lin + * @version 10.0 + * created by Destiny.Lin on 2022-07-11 + */ +public class UINumberFieldTest { + + @Test + public void testUINumberFieldTest(){ + UINumberField uiNumberField = new UINumberField(); + uiNumberField.setFieldDocument(); + //异常输入测试 + uiNumberField.setText("-.1"); + Assert.assertEquals("",uiNumberField.getText()); + uiNumberField.setText(".-1"); + Assert.assertEquals("",uiNumberField.getText()); + uiNumberField.setText("1-"); + Assert.assertEquals("",uiNumberField.getText()); + uiNumberField.setText("1-1"); + Assert.assertEquals("",uiNumberField.getText()); + uiNumberField.setText("1 "); + Assert.assertEquals("",uiNumberField.getText()); + uiNumberField.setText(".1"); + Assert.assertEquals("",uiNumberField.getText()); + uiNumberField.setText("1 -"); + Assert.assertEquals("",uiNumberField.getText()); + + //正常输入测试 + uiNumberField.setText("0.1"); + Assert.assertEquals("0.1",uiNumberField.getText()); + uiNumberField.setText("1"); + Assert.assertEquals("1",uiNumberField.getText()); + uiNumberField.setText("-1.5"); + Assert.assertEquals("-1.5",uiNumberField.getText()); + uiNumberField.setText("-123.123"); + Assert.assertEquals("-123.123",uiNumberField.getText()); + + } +} From 8d26f1b05807986f00e2d320fa94b37003c1a192 Mon Sep 17 00:00:00 2001 From: "Destiny.Lin" Date: Mon, 11 Jul 2022 18:30:57 +0800 Subject: [PATCH 3/3] =?UTF-8?q?REPORT-38555=20fix:=E6=95=B0=E5=AD=97?= =?UTF-8?q?=E6=8E=A7=E4=BB=B6=E4=B8=AD=E5=86=85=E5=AE=B9=E5=8F=AF=E4=BB=A5?= =?UTF-8?q?=E8=BE=93=E5=85=A5=E7=A9=BA=E6=A0=BC=E5=92=8C=E5=87=8F=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/fr/design/gui/ispinner/UISpinner.java | 17 +++++++++++++++-- .../fr/design/gui/itextfield/UINumberField.java | 1 - .../component/NumberEditorValidatePane.java | 10 ++++------ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java index 10e6e58376..22f6cb246e 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java @@ -22,8 +22,19 @@ import javax.swing.event.ChangeListener; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.plaf.ButtonUI; -import java.awt.*; -import java.awt.event.*; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GridLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusAdapter; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.MouseWheelEvent; +import java.awt.event.MouseWheelListener; public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver { @@ -61,6 +72,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver init(minValue, maxValue, dierta); textField.setValue(defaultValue); } + protected void init(double minValue, double maxValue, double dierta) { this.minValue = minValue; this.maxValue = maxValue; @@ -399,6 +411,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver public boolean shouldResponseNameListener() { return true; } + /** * 程序入口 测试 * diff --git a/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java b/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java index 5a2bda66eb..f40237659c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java +++ b/designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java @@ -4,7 +4,6 @@ import com.fr.base.Utils; import com.fr.general.ComparatorUtils; import com.fr.stable.CoreConstants; import com.fr.stable.StringUtils; -import org.gradle.internal.impldep.org.junit.Test; import javax.swing.text.AttributeSet; import javax.swing.text.BadLocationException; diff --git a/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java b/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java index 23e9d30771..d10f58e185 100644 --- a/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java +++ b/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java @@ -21,16 +21,14 @@ import javax.swing.BorderFactory; import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.PlainDocument; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.Dimension; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; -import java.util.regex.Matcher; -import java.util.regex.Pattern; + /** * Created by kerry on 2017/9/10.