From 219b1574e098179ea88838a21f02d785bb9b49fe Mon Sep 17 00:00:00 2001 From: Yyming Date: Fri, 25 Sep 2020 17:25:07 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-39642=20=E8=AE=BE=E8=AE=A1=E5=99=A8?= =?UTF-8?q?=E8=8F=9C=E5=8D=95=E6=A0=8F-=E6=9C=8D=E5=8A=A1=E5=99=A8-?= =?UTF-8?q?=E9=A2=84=E5=AE=9A=E4=B9=89=E6=A0=B7=E5=BC=8F-=E6=A0=BC?= =?UTF-8?q?=E5=BC=8F=E4=BF=AE=E6=94=B9=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/fr/design/style/FormatPane.java | 46 +++++++++++-------- .../cell/settingpane/style/StylePane.java | 2 +- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/style/FormatPane.java b/designer-base/src/main/java/com/fr/design/style/FormatPane.java index 255efe78c..d1679561d 100644 --- a/designer-base/src/main/java/com/fr/design/style/FormatPane.java +++ b/designer-base/src/main/java/com/fr/design/style/FormatPane.java @@ -45,7 +45,7 @@ import java.util.Date; */ public class FormatPane extends BasicPane { private static final long serialVersionUID = 724330854437726751L; - + private Format format; private UILabel sampleLabel; //preview label. private UIRadioButton nullRadioButton; @@ -59,14 +59,14 @@ public class FormatPane extends BasicPane { //content pane. private UITextField patternTextField = null; private JList patternList = null; - + /** * Constructor. */ public FormatPane() { this.initComponents(); } - + public UILabel getSampleLabel() { return sampleLabel; } @@ -74,7 +74,7 @@ public class FormatPane extends BasicPane { public void setSampleLabel(UILabel sampleLabel) { this.sampleLabel = sampleLabel; } - + protected void initComponents() { this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); @@ -172,7 +172,7 @@ public class FormatPane extends BasicPane { protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style"); } - + /** * Populate */ @@ -185,17 +185,17 @@ public class FormatPane extends BasicPane { } else { if (format instanceof DecimalFormat) { checkDecimalFormat(); - } else if (format instanceof SimpleDateFormat) { + } else if (format instanceof SimpleDateFormat) { //date and time - checkDateFormat(); - } else if (format instanceof TextFormat) { + checkDateFormat(); + } else if (format instanceof TextFormat) { //Text this.textRadioButton.setSelected(true); this.applyRadioActionListener(this.textRadioButton); } } } - + private void checkDateFormat() { String pattern = ((SimpleDateFormat) format).toPattern(); if(pattern == null) { @@ -276,7 +276,7 @@ public class FormatPane extends BasicPane { } } } - + /** * 百分比面板 */ @@ -296,7 +296,7 @@ public class FormatPane extends BasicPane { /** * 是否属于数组中的列表样式 - * + * * @param stringArray 格式数组 * @param pattern 输入的格式 * @return 返回在数组中的位置 @@ -323,7 +323,7 @@ public class FormatPane extends BasicPane { } return FormatField.getInstance().getFormat(getFormatContents(), text); } - + private int getFormatContents(){ if (nullRadioButton.isSelected()) return FormatContents.NULL; @@ -335,7 +335,7 @@ public class FormatPane extends BasicPane { return FormatContents.PERCENT; else if (scientificRadioButton.isSelected()) return FormatContents.SCIENTIFIC; - else if (dateRadioButton.isSelected()) + else if (dateRadioButton.isSelected()) return FormatContents.DATE; else if (timeRadioButton.isSelected()) return FormatContents.TIME; @@ -380,7 +380,7 @@ public class FormatPane extends BasicPane { ActionEvent evt = new ActionEvent(radioButton, 100, ""); this.radioActionListener.actionPerformed(evt); } - + /** * Radio selection listener. */ @@ -393,6 +393,7 @@ public class FormatPane extends BasicPane { patternTextField.setEditable(true); patternList.setEnabled(true); + int contents = getContents(source); String[] patternArray = FormatField.getInstance().getFormatArray(contents); @@ -407,6 +408,7 @@ public class FormatPane extends BasicPane { //maybe need to select the first item. String text = patternTextField.getText(); + if (hasPattenText(text, patternModel)) { String pattern = null; if (format instanceof DecimalFormat) { @@ -418,6 +420,10 @@ public class FormatPane extends BasicPane { if (pattern != null) { patternList.setSelectedValue(pattern, true); + if (patternList.getSelectedIndex() == -1) { + //patten不在下拉框里面 + patternList.setSelectedIndex(0); + } } else { patternList.setSelectedIndex(0); } @@ -426,13 +432,13 @@ public class FormatPane extends BasicPane { }; private boolean hasPattenText (String text, DefaultListModel patternModel) { - return (text == null || text.length() <= 0) && patternModel.size() > 0; + return StringUtils.isEmpty(text) && patternModel.size() > 0; } - + private void setPatternTextEnable() { patternTextField.setEnabled(false); patternTextField.setEditable(false); - patternTextField.setText(""); + patternTextField.setText(StringUtils.EMPTY); patternList.setEnabled(false); } @@ -459,7 +465,7 @@ public class FormatPane extends BasicPane { } return contents; } - + /** * text pattern document listener. */ @@ -477,7 +483,7 @@ public class FormatPane extends BasicPane { refreshPreviewLabel(); } }; - + /** * Pattern list selection listener. */ @@ -487,5 +493,5 @@ public class FormatPane extends BasicPane { patternTextField.setText((String) patternList.getSelectedValue()); } }; - + } diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java index 2fdf1e5a6..f1f916e05 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java @@ -61,7 +61,7 @@ public class StylePane extends UIComboBoxPane