Browse Source
* commit '6514ac64266d41f731c4b2e5226b712ba216fa79': REPORT-134411 DataOperatorProvider接口适配Connection 优化部分写法 REPORT-134498 修复启动页的环境卡片边框问题 REPORT-134411 DataOperatorProvider接口适配Connection 行式放一行 去除包名 去除包名 去掉包名 REPORT-134248 启动页优化 修改注释 当button点击时不转换成字母 基于UISpinner新增字母spinner REPORT-134321 【fr-fbp回归】设计器和服务器网络不通,远程报错未知错误fbp/feature
superman
3 months ago
17 changed files with 363 additions and 245 deletions
@ -0,0 +1,152 @@
|
||||
package com.fr.design.gui.ispinner; |
||||
|
||||
import com.fine.theme.utils.FineUIUtils; |
||||
import com.formdev.flatlaf.util.ScaledEmptyBorder; |
||||
import com.fr.design.gui.itextfield.UITextField; |
||||
import com.fr.stable.StableUtils; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import javax.swing.event.DocumentEvent; |
||||
import javax.swing.event.DocumentListener; |
||||
import javax.swing.text.AbstractDocument; |
||||
import javax.swing.text.AttributeSet; |
||||
import javax.swing.text.BadLocationException; |
||||
import javax.swing.text.DocumentFilter; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Insets; |
||||
import java.awt.event.FocusAdapter; |
||||
import java.awt.event.FocusEvent; |
||||
import java.awt.event.MouseAdapter; |
||||
import java.awt.event.MouseEvent; |
||||
|
||||
/** |
||||
* 字母spinner |
||||
* |
||||
* @author Renekton |
||||
* @since 11.0 |
||||
* @Created on 2024/09/11 |
||||
*/ |
||||
public class FineUpperCaseSpinner extends UISpinner { |
||||
|
||||
private UITextField textField; |
||||
|
||||
public FineUpperCaseSpinner(double minValue, double maxValue, double dierta) { |
||||
super(minValue, maxValue, dierta); |
||||
} |
||||
|
||||
protected void initComponents() { |
||||
setLayout(new BorderLayout()); |
||||
textField = initTextField(); |
||||
Insets insets = FineUIUtils.getUIInsets("InputTextField.borderInsets", defaultInsets); |
||||
textField.setBorder(new ScaledEmptyBorder(insets.top, insets.left, insets.bottom, insets.right)); |
||||
textField.setOpaque(false); |
||||
add(textField, BorderLayout.CENTER); |
||||
setValue(value); |
||||
|
||||
initArrowPane(); |
||||
componentInitListeners(); |
||||
} |
||||
|
||||
protected void setTextField(double value) { |
||||
textField.getDocument().removeDocumentListener(docListener); |
||||
textField.setText(StableUtils.convertIntToABC((int)value).toUpperCase()); |
||||
textField.getDocument().addDocumentListener(docListener); |
||||
} |
||||
|
||||
|
||||
protected UITextField initTextField() { |
||||
int columns = this.numberFieldColumns == 0 ? DEFAULT_NUMBERFIELD_COLUMNS : this.numberFieldColumns; |
||||
UITextField textField = new UITextField(columns) { |
||||
public boolean shouldResponseChangeListener() { |
||||
return false; |
||||
} |
||||
}; |
||||
((AbstractDocument) textField.getDocument()).setDocumentFilter(new DocumentFilter() { |
||||
public void insertString(FilterBypass fb, int offset, String string, AttributeSet attr) throws BadLocationException { |
||||
fb.insertString(offset, string.toUpperCase(), attr); |
||||
} |
||||
|
||||
public void replace(FilterBypass fb, int offset, int length, String string, AttributeSet attr) throws BadLocationException { |
||||
if (string != null) { |
||||
string = string.toUpperCase(); |
||||
} |
||||
fb.replace(offset, length, string, attr); |
||||
} |
||||
}); |
||||
return textField; |
||||
} |
||||
|
||||
protected DocumentListener docListener = new DocumentListener() { |
||||
@Override |
||||
public void removeUpdate(DocumentEvent e) { |
||||
setTextFieldValue(getTextValue()); |
||||
} |
||||
|
||||
@Override |
||||
public void insertUpdate(DocumentEvent e) { |
||||
setTextFieldValue(getTextValue()); |
||||
} |
||||
|
||||
@Override |
||||
public void changedUpdate(DocumentEvent e) { |
||||
setTextFieldValue(getTextValue()); |
||||
} |
||||
}; |
||||
|
||||
|
||||
protected void initTextFiledListeners() { |
||||
textField.getDocument().removeDocumentListener(docListener); |
||||
textField.getDocument().addDocumentListener(docListener); |
||||
textField.addFocusListener(new FocusAdapter() { |
||||
@Override |
||||
public void focusGained(FocusEvent e) { |
||||
textFieldFocus = true; |
||||
} |
||||
|
||||
@Override |
||||
public void focusLost(FocusEvent e) { |
||||
textFieldFocus = false; |
||||
textField.getDocument().removeDocumentListener(docListener); |
||||
if (!preAction && !nextAction) { |
||||
textField.setText(StableUtils.convertIntToABC((int)value).toUpperCase()); |
||||
} |
||||
textField.getDocument().addDocumentListener(docListener); |
||||
preAction = false; |
||||
nextAction = false; |
||||
} |
||||
}); |
||||
} |
||||
|
||||
protected void initTextMouseListener() { |
||||
textField.addMouseListener(new MouseAdapter() { |
||||
@Override |
||||
public void mouseEntered(MouseEvent e) { |
||||
hover = true; |
||||
repaint(); |
||||
} |
||||
|
||||
@Override |
||||
public void mouseExited(MouseEvent e) { |
||||
hover = false; |
||||
repaint(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
public UITextField getTextFieldNew() { |
||||
return textField; |
||||
} |
||||
|
||||
private double getTextValue() { |
||||
try { |
||||
if (StringUtils.isEmpty(textField.getText())) { |
||||
return 1; |
||||
} else if (StringUtils.isNumber(textField.getText())) { |
||||
return Double.parseDouble(textField.getText()); |
||||
} |
||||
return StableUtils.convertABCToInt(textField.getText()); |
||||
} catch (NumberFormatException numberFormatException) { |
||||
return 1; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue