Browse Source

Merge branch 'release/10.0' of https://code.fineres.com/scm/~yvan/design into feature/10.0

feature/10.0
Yvan 4 years ago
parent
commit
adbdcdc895
  1. 42
      designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java
  2. 8
      designer-base/src/main/resources/com/fr/design/images/control/edit_disable.svg
  3. 11
      designer-base/src/main/resources/com/fr/design/images/control/remove_disable.svg

42
designer-base/src/main/java/com/fr/design/gui/itextfield/UINumberField.java

@ -5,11 +5,15 @@ import com.fr.general.ComparatorUtils;
import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.InputMethodEvent;
import java.awt.event.InputMethodListener;
/**
* Number Field.
@ -35,6 +39,11 @@ public class UINumberField extends UITextField {
private boolean isContentChanged = false;
private boolean fillNegativeNumber = true;
/**
* 输入法输入完成一个字符输入过程的标记开始输入的时候是true输入完矫正光标后为false
*/
private boolean isInputMethodOnceInserting = false;
private int insertOffset = 0;
public UINumberField() {
this(MAX_INTEGERLENGTH_32, MAX_DECIMALLENGTH);
@ -55,6 +64,7 @@ public class UINumberField extends UITextField {
this.minValue = minValue;
this.maxValue = maxValue;
setFieldDocument();
initFieldListener();
}
public void setFieldDocument() {
@ -62,6 +72,31 @@ public class UINumberField extends UITextField {
initListener();
}
private void initFieldListener() {
addInputMethodListener(new InputMethodListener() {
@Override
public void inputMethodTextChanged(InputMethodEvent event) {
isInputMethodOnceInserting = true;
}
@Override
public void caretPositionChanged(InputMethodEvent event) {
}
});
addCaretListener(new CaretListener() {
@Override
public void caretUpdate(CaretEvent e) {
if (isInputMethodOnceInserting) {
isInputMethodOnceInserting = false;
setCaretPosition(insertOffset);
} else {
insertOffset = e.getDot();
}
}
});
}
public void canFillNegativeNumber(boolean fillNegativeNumber) {
this.fillNegativeNumber = fillNegativeNumber;
}
@ -186,6 +221,13 @@ public class UINumberField extends UITextField {
super.insertString(offset, s, a);
}
public void remove(int offs, int len) throws BadLocationException {
if (isInputMethodOnceInserting) {
return;
}
super.remove(offs, len);
}
// kunsnat: 这种限制输入 有个不好的地方, 比如删除时: 10.1 最大值限定100, 那么就删除中间的小数点之后变为101, 超出了100.
// 但是直接限制不能删除中间类似小数点, 那么也可能遇到: 最小值10 , 从100变化到其中的19, 就很难..
private boolean notChange(String strNew) {

8
designer-base/src/main/resources/com/fr/design/images/control/edit_disable.svg

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon_编辑_disable</title>
<g id="icon_编辑_disable" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" opacity="0.299107143">
<path d="M9.95422984,2.34704298 L13.4897637,5.88257688 L6.18790578,13.1844348 L0.884604926,14.9522018 L2.65237188,9.64890094 L9.95422984,2.34704298 Z M13.4897637,1.6399362 L14.1968705,2.34704298 C14.9368113,3.08698374 14.9757555,4.2624679 14.3137033,5.04825533 L14.1968705,5.1754701 L10.6613366,1.6399362 C11.4423852,0.858887612 12.7087152,0.858887612 13.4897637,1.6399362 Z" id="形状结合" fill="#333334"></path>
<rect id="矩形" fill="#333334" x="7" y="14" width="7" height="1"></rect>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 864 B

11
designer-base/src/main/resources/com/fr/design/images/control/remove_disable.svg

@ -1,11 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="14px" height="14px" viewBox="0 0 14 14" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon_删除_normal</title>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" opacity="0.3">
<g id="工具栏/导入数据集" transform="translate(-78.000000, -7.000000)" fill="#333334">
<g id="icon_删除_normal" transform="translate(77.000000, 6.000000)">
<path d="M11,1 L11,3 L15,3 L15,4 L13,4 L13,15 L3,15 L3,4 L1,4 L1,3 L5,3 L5,1 L11,1 Z M12,4 L4,4 L4,14 L12,14 L12,4 Z M7,6 L7,12 L6,12 L6,6 L7,6 Z M10,6 L10,12 L9,12 L9,6 L10,6 Z M10,2 L6,2 L6,3 L10,3 L10,2 Z" id="Combined-Shape"></path>
</g>
</g>
</g>
</svg>

Before

Width:  |  Height:  |  Size: 804 B

Loading…
Cancel
Save