Browse Source

REPORT-100458 【版本管理二期】迁移弹窗,保留版本的输入框没有非法值校验

newui
Destiny.Lin 1 year ago
parent
commit
4a77907e08
  1. 9
      designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java
  2. 10
      designer-base/src/main/java/com/fr/design/editor/editor/NumberEditor.java
  3. 59
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/UIPositiveIntEditor.java
  4. 39
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/UIPositiveIntSpinner.java
  5. 4
      designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java

9
designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java

@ -36,6 +36,7 @@ import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.mainframe.vcs.VcsConfigManager;
import com.fr.design.mainframe.vcs.common.VcsHelper;
import com.fr.design.mainframe.vcs.ui.UIPositiveIntEditor;
import com.fr.design.mainframe.vcs.ui.VcsMovePanel;
import com.fr.design.os.impl.SupportOSImpl;
import com.fr.design.unit.UnitConvertUtil;
@ -225,7 +226,7 @@ public class PreferencePane extends BasicPane {
private UIComboBox autoCleanIntervalComboBox;
private UIComboBox autoCleanRetainIntervalComboBox;
private IntegerEditor autoSaveIntervalEditor;
private UIPositiveIntEditor autoSaveIntervalEditor;
private UICheckBox saveCommitCheckBox;
private UICheckBox useIntervalCheckBox;
private VcsMovePanel movePanel;
@ -235,7 +236,7 @@ public class PreferencePane extends BasicPane {
private JPanel gcControlPane;
private UICheckBox startupPageEnabledCheckBox;
private IntegerEditor saveIntervalEditor;
private UIPositiveIntEditor saveIntervalEditor;
private UICheckBox gcEnableCheckBox;
private UIButton gcButton;
private UILabel remindVcsLabel;
@ -430,7 +431,7 @@ public class PreferencePane extends BasicPane {
saveIntervalPane = createSaveIntervalPane();
saveCommitCheckBox = new UICheckBox(i18nText("Fine-Design_Vcs_No_Delete"));
saveIntervalEditor = new IntegerEditor(60);
saveIntervalEditor = new UIPositiveIntEditor(60);
useIntervalCheckBox = new UICheckBox();
savePane.add(vcsEnableCheckBox);
savePane.add(saveIntervalPane);
@ -556,7 +557,7 @@ public class PreferencePane extends BasicPane {
private JPanel createSaveIntervalPane() {
JPanel saveIntervalPane = new JPanel(FRGUIPaneFactory.createLeftZeroLayout());
useVcsAutoSaveScheduleCheckBox = new UICheckBox();
autoSaveIntervalEditor = new IntegerEditor(60);
autoSaveIntervalEditor = new UIPositiveIntEditor(60);
saveIntervalPane.add(useVcsAutoSaveScheduleCheckBox);
saveIntervalPane.add(new UILabel(i18nText("Fine-Design_Vcs_Every")));
saveIntervalPane.add(autoSaveIntervalEditor);

10
designer-base/src/main/java/com/fr/design/editor/editor/NumberEditor.java

@ -38,7 +38,7 @@ public abstract class NumberEditor<T extends Number> extends Editor<T> {
*/
public NumberEditor(T value, String name) {
this.setLayout(FRGUIPaneFactory.createBorderLayout());
numberField = new UINumberField();
numberField = createNumberField();
this.add(numberField, BorderLayout.CENTER);
this.numberField.addKeyListener(textKeyListener);
this.numberField.setHorizontalAlignment(UITextField.RIGHT);
@ -46,6 +46,14 @@ public abstract class NumberEditor<T extends Number> extends Editor<T> {
this.setName(name);
}
/**
* 创建NumberField对象
*
*/
protected UINumberField createNumberField() {
return new UINumberField();
}
/**
* 给numberField加键盘事件
*

59
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/UIPositiveIntEditor.java

@ -0,0 +1,59 @@
package com.fr.design.mainframe.vcs.ui;
import com.fr.design.editor.editor.IntegerEditor;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UINumberField;
import com.fr.stable.StringUtils;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
/**
* 正整数输入框
*
* @author Destiny.Lin
* @since 11.0
* Created on 2023/7/25
*/
public class UIPositiveIntEditor extends IntegerEditor {
private static final int DEFAULT_COLUMNS = 4;
private static final int MIN = 1;
private static final int MAX = 99999;
private static final int DEFAULT_VALUE = 60;
public UIPositiveIntEditor(Integer value) {
super(value);
numberField.setMaxValue(MAX);
numberField.setMinValue(MIN);
initNumberFieldListener();
}
public UIPositiveIntEditor(Integer value, Integer min, Integer max) {
super(value);
numberField.setMaxValue(max);
numberField.setMinValue(min);
initNumberFieldListener();
}
private void initNumberFieldListener() {
numberField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
if (StringUtils.isEmpty(numberField.getTextValue())) {
numberField.setValue(DEFAULT_VALUE);
}
}
});
}
@Override
protected UINumberField createNumberField() {
UIIntNumberField field = new UIIntNumberField();
field.setColumns(DEFAULT_COLUMNS);
return field;
}
}

39
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/UIPositiveIntSpinner.java

@ -0,0 +1,39 @@
package com.fr.design.mainframe.vcs.ui;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UIIntNumberField;
import com.fr.design.gui.itextfield.UINumberField;
/**
* 只允许输入正整数的Spinner
*
* @author Destiny.Lin
* @since 11.0
* Created on 2023/7/25
*/
public class UIPositiveIntSpinner extends UISpinner {
private static final int DEFAULT_COLUMNS = 5;
public UIPositiveIntSpinner() {
}
public UIPositiveIntSpinner(double minValue, double maxValue, double dierta) {
super(minValue, maxValue, dierta);
}
public UIPositiveIntSpinner(double minValue, double maxValue, double dierta, double defaultValue) {
super(minValue, maxValue, dierta, defaultValue);
}
public UIPositiveIntSpinner(double minValue, double maxValue, double dierta, double defaultValue, boolean fillNegativeNumber) {
super(minValue, maxValue, dierta, defaultValue, fillNegativeNumber);
}
@Override
protected UINumberField initNumberField() {
UIIntNumberField field = new UIIntNumberField();
field.setColumns(DEFAULT_COLUMNS);
return field;
}
}

4
designer-base/src/main/java/com/fr/design/mainframe/vcs/ui/VcsMovePanel.java

@ -112,7 +112,7 @@ public class VcsMovePanel extends BasicPane {
//全部放弃
private UIRadioButton moveNothingButton;
private UISpinner spinner;
private UIPositiveIntSpinner spinner;
private MoveCallBack callBack;
@ -238,7 +238,7 @@ public class VcsMovePanel extends BasicPane {
moveAllPane.add(moveAllButton);
moveDefaultPanel.add(moveDefaultButton);
moveDefaultPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Default_Text_Left")));
spinner = new UISpinner(MIN_VALUE, MAX_VALUE, STEP, DEFAULT_VALUE);
spinner = new UIPositiveIntSpinner(MIN_VALUE, MAX_VALUE, STEP, DEFAULT_VALUE);
moveDefaultPanel.add(spinner);
moveDefaultPanel.add(new UILabel(Toolkit.i18nText("Fine-Design_Vcs_Move_Default_Text_Right")));
moveNothingPane.add(moveNothingButton);

Loading…
Cancel
Save