|
|
@ -10,6 +10,7 @@ import com.fr.design.gui.ispinner.UIBasicSpinner; |
|
|
|
import com.fr.design.gui.itextfield.UINumberField; |
|
|
|
import com.fr.design.gui.itextfield.UINumberField; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.layout.FRGUIPaneFactory; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
|
|
|
|
import com.fr.general.GeneralUtils; |
|
|
|
import com.fr.stable.AssistUtils; |
|
|
|
import com.fr.stable.AssistUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
|
@ -27,7 +28,8 @@ import java.math.BigDecimal; |
|
|
|
* For input Number. |
|
|
|
* For input Number. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public abstract class UnitInputPane extends BasicPane { |
|
|
|
public abstract class UnitInputPane extends BasicPane { |
|
|
|
private static final double NUM_POINT = 0.000001; |
|
|
|
private static final double MAX_NUM = 3000.0D; |
|
|
|
|
|
|
|
private static final double NUM_POINT = 0.000001; |
|
|
|
private int scale = -1; |
|
|
|
private int scale = -1; |
|
|
|
String title; |
|
|
|
String title; |
|
|
|
|
|
|
|
|
|
|
@ -46,7 +48,7 @@ public abstract class UnitInputPane extends BasicPane { |
|
|
|
centerPane.add(titleLabel); |
|
|
|
centerPane.add(titleLabel); |
|
|
|
|
|
|
|
|
|
|
|
// Denny:在对话框中加入JSpinner对象
|
|
|
|
// Denny:在对话框中加入JSpinner对象
|
|
|
|
numberFieldSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, 999, 1)); |
|
|
|
numberFieldSpinner = new UIBasicSpinner(new SpinnerNumberModel(0, 0, MAX_NUM, 1)); |
|
|
|
GUICoreUtils.setColumnForSpinner(numberFieldSpinner, 24); |
|
|
|
GUICoreUtils.setColumnForSpinner(numberFieldSpinner, 24); |
|
|
|
numberFieldSpinner.setPreferredSize(new Dimension(60, 20)); |
|
|
|
numberFieldSpinner.setPreferredSize(new Dimension(60, 20)); |
|
|
|
numberFieldSpinner.setMinimumSize(new Dimension(60, 20)); |
|
|
|
numberFieldSpinner.setMinimumSize(new Dimension(60, 20)); |
|
|
@ -71,17 +73,17 @@ public abstract class UnitInputPane extends BasicPane { |
|
|
|
|
|
|
|
|
|
|
|
public void populate(float floatValue) { |
|
|
|
public void populate(float floatValue) { |
|
|
|
popValue = floatValue; |
|
|
|
popValue = floatValue; |
|
|
|
numberFieldSpinner.setModel(new SpinnerNumberModel(0.00, 0.00, 999.00, 0.01)); |
|
|
|
numberFieldSpinner.setModel(new SpinnerNumberModel(0.00, 0.00, MAX_NUM, 0.01)); |
|
|
|
|
|
|
|
|
|
|
|
JFormattedTextField temp = GUICoreUtils.getSpinnerTextField(numberFieldSpinner); |
|
|
|
JFormattedTextField temp = GUICoreUtils.getSpinnerTextField(numberFieldSpinner); |
|
|
|
addChangeListener(temp); |
|
|
|
addChangeListener(temp); |
|
|
|
BigDecimal de = new BigDecimal(floatValue + ""); |
|
|
|
BigDecimal de = new BigDecimal(GeneralUtils.objectToString(floatValue)); |
|
|
|
if (scale > 0) { |
|
|
|
if (scale > 0) { |
|
|
|
floatValue = de.setScale(scale, BigDecimal.ROUND_DOWN).floatValue(); |
|
|
|
floatValue = de.setScale(scale, BigDecimal.ROUND_DOWN).floatValue(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
floatValue = de.floatValue(); |
|
|
|
floatValue = de.floatValue(); |
|
|
|
} |
|
|
|
} |
|
|
|
//选中多列, 并且列宽不完全一致的话, 就不显示值了.
|
|
|
|
//选中多列, 并且列宽不完全一致的话, 就不显示值了.
|
|
|
|
temp.setText(AssistUtils.equals(floatValue, 0) ? StringUtils.EMPTY : Utils.convertNumberStringToString(new Float(floatValue))); |
|
|
|
temp.setText(AssistUtils.equals(floatValue, 0) ? StringUtils.EMPTY : Utils.convertNumberStringToString(new Float(floatValue))); |
|
|
|
|
|
|
|
|
|
|
|
// denny:默认应该为选中,方便用户修改
|
|
|
|
// denny:默认应该为选中,方便用户修改
|
|
|
@ -99,8 +101,8 @@ public abstract class UnitInputPane extends BasicPane { |
|
|
|
public double update() throws ValueNotChangeException { |
|
|
|
public double update() throws ValueNotChangeException { |
|
|
|
// 值没变就不改
|
|
|
|
// 值没变就不改
|
|
|
|
if (!changed) { |
|
|
|
if (!changed) { |
|
|
|
throw vncExp; |
|
|
|
throw vncExp; |
|
|
|
} |
|
|
|
} |
|
|
|
// Denny: get numberFieldSpinner 的 TextField
|
|
|
|
// Denny: get numberFieldSpinner 的 TextField
|
|
|
|
JFormattedTextField temp = GUICoreUtils.getSpinnerTextField(numberFieldSpinner); |
|
|
|
JFormattedTextField temp = GUICoreUtils.getSpinnerTextField(numberFieldSpinner); |
|
|
|
|
|
|
|
|
|
|
@ -108,7 +110,8 @@ public abstract class UnitInputPane extends BasicPane { |
|
|
|
if (temp.getText().length() == 0) { |
|
|
|
if (temp.getText().length() == 0) { |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
|
} |
|
|
|
} |
|
|
|
BigDecimal de = new BigDecimal(temp.getText()); |
|
|
|
|
|
|
|
|
|
|
|
BigDecimal de = new BigDecimal(GeneralUtils.objectToString(temp.getValue())); |
|
|
|
if (scale > 0) { |
|
|
|
if (scale > 0) { |
|
|
|
return de.setScale(scale, BigDecimal.ROUND_DOWN).floatValue(); |
|
|
|
return de.setScale(scale, BigDecimal.ROUND_DOWN).floatValue(); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|