Browse Source

REPORT-70955 许多场景不支持千分比样式

feature/x
pengda 3 years ago
parent
commit
bb28d112b9
  1. 17
      designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java
  2. 7
      designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java
  3. 15
      designer-base/src/main/java/com/fr/design/style/FormatPane.java

17
designer-base/src/main/java/com/fr/design/gui/style/FormatPane.java

@ -24,12 +24,22 @@ import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import java.math.BigDecimal; import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.math.RoundingMode; import java.math.RoundingMode;
import javax.swing.*; import javax.swing.BorderFactory;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager;
import javax.swing.border.Border; import javax.swing.border.Border;
import javax.swing.border.TitledBorder; import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.event.ItemEvent; import java.awt.event.ItemEvent;
import java.awt.event.ItemListener; import java.awt.event.ItemListener;
import java.text.Format; import java.text.Format;
@ -54,6 +64,7 @@ public class FormatPane extends AbstractBasicStylePane implements GlobalNameObse
private static final Integer[] TYPES = new Integer[]{ private static final Integer[] TYPES = new Integer[]{
FormatContents.NULL, FormatContents.NUMBER, FormatContents.NULL, FormatContents.NUMBER,
FormatContents.CURRENCY, FormatContents.PERCENT, FormatContents.CURRENCY, FormatContents.PERCENT,
FormatContents.THOUSANDTHS,
FormatContents.SCIENTIFIC, FormatContents.DATE, FormatContents.SCIENTIFIC, FormatContents.DATE,
FormatContents.TIME, FormatContents.TEXT}; FormatContents.TIME, FormatContents.TEXT};

7
designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java

@ -58,7 +58,7 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
private static final Integer[] TYPES = new Integer[]{ private static final Integer[] TYPES = new Integer[]{
FormatContents.NULL, FormatContents.NUMBER, FormatContents.NULL, FormatContents.NUMBER,
FormatContents.CURRENCY, FormatContents.PERCENT, FormatContents.CURRENCY, FormatContents.PERCENT,
FormatContents.SCIENTIFIC, FormatContents.THOUSANDTHS, FormatContents.SCIENTIFIC,
FormatContents.DATE, FormatContents.TIME, FormatContents.DATE, FormatContents.TIME,
FormatContents.TEXT}; FormatContents.TEXT};
@ -228,6 +228,9 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
this.roundingBox.setSelected(((CoreDecimalFormat) format).getRoundingMode().equals(RoundingMode.HALF_UP)); this.roundingBox.setSelected(((CoreDecimalFormat) format).getRoundingMode().equals(RoundingMode.HALF_UP));
} else if (pattern.indexOf("E") > 0) { } else if (pattern.indexOf("E") > 0) {
setPatternComboBoxAndList(FormatContents.SCIENTIFIC, pattern); setPatternComboBoxAndList(FormatContents.SCIENTIFIC, pattern);
} else if (pattern.indexOf("‰") > 0) {
setPatternComboBoxAndList(FormatContents.THOUSANDTHS, pattern);
this.roundingBox.setSelected(((CoreDecimalFormat) format).getRoundingMode().equals(RoundingMode.HALF_UP));
} else { } else {
setPatternComboBoxAndList(FormatContents.NUMBER, pattern); setPatternComboBoxAndList(FormatContents.NUMBER, pattern);
} }
@ -345,7 +348,7 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
} }
setTextFieldVisible(!isTextOrNull()); setTextFieldVisible(!isTextOrNull());
setPreviewLabelVisible(!isTextOrNull()); setPreviewLabelVisible(!isTextOrNull());
setRoundingBoxVisible(getFormatContents() == FormatContents.PERCENT); setRoundingBoxVisible(getFormatContents() == FormatContents.PERCENT || getFormatContents() == FormatContents.THOUSANDTHS);
} }
} }

15
designer-base/src/main/java/com/fr/design/style/FormatPane.java

@ -52,6 +52,7 @@ public class FormatPane extends BasicPane {
private UIRadioButton numberRadioButton; private UIRadioButton numberRadioButton;
private UIRadioButton currencyRadioButton; private UIRadioButton currencyRadioButton;
private UIRadioButton percentRadioButton; private UIRadioButton percentRadioButton;
private UIRadioButton thousandthsRadioButton;
private UIRadioButton scientificRadioButton; private UIRadioButton scientificRadioButton;
private UIRadioButton dateRadioButton; private UIRadioButton dateRadioButton;
private UIRadioButton timeRadioButton; private UIRadioButton timeRadioButton;
@ -99,6 +100,7 @@ public class FormatPane extends BasicPane {
categoryButtonGroup.add(numberRadioButton); categoryButtonGroup.add(numberRadioButton);
categoryButtonGroup.add(currencyRadioButton); categoryButtonGroup.add(currencyRadioButton);
categoryButtonGroup.add(percentRadioButton); categoryButtonGroup.add(percentRadioButton);
categoryButtonGroup.add(thousandthsRadioButton);
categoryButtonGroup.add(scientificRadioButton); categoryButtonGroup.add(scientificRadioButton);
categoryButtonGroup.add(dateRadioButton); categoryButtonGroup.add(dateRadioButton);
categoryButtonGroup.add(timeRadioButton); categoryButtonGroup.add(timeRadioButton);
@ -108,6 +110,7 @@ public class FormatPane extends BasicPane {
leftControlPane.add(this.createRadioCenterPane(numberRadioButton)); leftControlPane.add(this.createRadioCenterPane(numberRadioButton));
leftControlPane.add(this.createRadioCenterPane(currencyRadioButton)); leftControlPane.add(this.createRadioCenterPane(currencyRadioButton));
leftControlPane.add(this.createRadioCenterPane(percentRadioButton)); leftControlPane.add(this.createRadioCenterPane(percentRadioButton));
leftControlPane.add(this.createRadioCenterPane(thousandthsRadioButton));
leftControlPane.add(this.createRadioCenterPane(scientificRadioButton)); leftControlPane.add(this.createRadioCenterPane(scientificRadioButton));
leftControlPane.add(this.createRadioCenterPane(dateRadioButton)); leftControlPane.add(this.createRadioCenterPane(dateRadioButton));
leftControlPane.add(this.createRadioCenterPane(timeRadioButton)); leftControlPane.add(this.createRadioCenterPane(timeRadioButton));
@ -136,6 +139,8 @@ public class FormatPane extends BasicPane {
currencyRadioButton.setMnemonic('C'); currencyRadioButton.setMnemonic('C');
percentRadioButton = new UIRadioButton(FormatField.getInstance().getName(FormatContents.PERCENT)); percentRadioButton = new UIRadioButton(FormatField.getInstance().getName(FormatContents.PERCENT));
percentRadioButton.setMnemonic('P'); percentRadioButton.setMnemonic('P');
thousandthsRadioButton = new UIRadioButton(FormatField.getInstance().getName(FormatContents.THOUSANDTHS));
thousandthsRadioButton.setMnemonic('Q');
scientificRadioButton = new UIRadioButton(FormatField.getInstance().getName(FormatContents.SCIENTIFIC)); scientificRadioButton = new UIRadioButton(FormatField.getInstance().getName(FormatContents.SCIENTIFIC));
scientificRadioButton.setMnemonic('S'); scientificRadioButton.setMnemonic('S');
dateRadioButton = new UIRadioButton(FormatField.getInstance().getName(FormatContents.DATE)); dateRadioButton = new UIRadioButton(FormatField.getInstance().getName(FormatContents.DATE));
@ -149,6 +154,7 @@ public class FormatPane extends BasicPane {
numberRadioButton.addActionListener(radioActionListener); numberRadioButton.addActionListener(radioActionListener);
currencyRadioButton.addActionListener(radioActionListener); currencyRadioButton.addActionListener(radioActionListener);
percentRadioButton.addActionListener(radioActionListener); percentRadioButton.addActionListener(radioActionListener);
thousandthsRadioButton.addActionListener(radioActionListener);
scientificRadioButton.addActionListener(radioActionListener); scientificRadioButton.addActionListener(radioActionListener);
dateRadioButton.addActionListener(radioActionListener); dateRadioButton.addActionListener(radioActionListener);
timeRadioButton.addActionListener(radioActionListener); timeRadioButton.addActionListener(radioActionListener);
@ -234,6 +240,9 @@ public class FormatPane extends BasicPane {
} else if (pattern.endsWith("%")) { } else if (pattern.endsWith("%")) {
this.percentRadioButton.setSelected(true); this.percentRadioButton.setSelected(true);
this.applyRadioActionListener(this.percentRadioButton); this.applyRadioActionListener(this.percentRadioButton);
} else if (pattern.equals("‰")){
this.thousandthsRadioButton.setSelected(true);
this.applyRadioActionListener(this.thousandthsRadioButton);
} else if (pattern.indexOf("E") > 0) { } else if (pattern.indexOf("E") > 0) {
this.scientificRadioButton.setSelected(true); this.scientificRadioButton.setSelected(true);
this.applyRadioActionListener(this.scientificRadioButton); this.applyRadioActionListener(this.scientificRadioButton);
@ -259,6 +268,7 @@ public class FormatPane extends BasicPane {
scientificRadioButton.setEnabled(false); scientificRadioButton.setEnabled(false);
textRadioButton.setEnabled(false); textRadioButton.setEnabled(false);
percentRadioButton.setEnabled(false); percentRadioButton.setEnabled(false);
thousandthsRadioButton.setEnabled(false);
nullRadioButton.setEnabled(false); nullRadioButton.setEnabled(false);
dateRadioButton.setEnabled(false); dateRadioButton.setEnabled(false);
timeRadioButton.setEnabled(false); timeRadioButton.setEnabled(false);
@ -285,6 +295,7 @@ public class FormatPane extends BasicPane {
numberRadioButton.setEnabled(false); numberRadioButton.setEnabled(false);
currencyRadioButton.setEnabled(false); currencyRadioButton.setEnabled(false);
percentRadioButton.addActionListener(radioActionListener); percentRadioButton.addActionListener(radioActionListener);
thousandthsRadioButton.setEnabled(false);
scientificRadioButton.setEnabled(false); scientificRadioButton.setEnabled(false);
dateRadioButton.setEnabled(false); dateRadioButton.setEnabled(false);
timeRadioButton.setEnabled(false); timeRadioButton.setEnabled(false);
@ -333,6 +344,8 @@ public class FormatPane extends BasicPane {
return FormatContents.CURRENCY; return FormatContents.CURRENCY;
else if (percentRadioButton.isSelected()) else if (percentRadioButton.isSelected())
return FormatContents.PERCENT; return FormatContents.PERCENT;
else if (thousandthsRadioButton.isSelected())
return FormatContents.THOUSANDTHS;
else if (scientificRadioButton.isSelected()) else if (scientificRadioButton.isSelected())
return FormatContents.SCIENTIFIC; return FormatContents.SCIENTIFIC;
else if (dateRadioButton.isSelected()) else if (dateRadioButton.isSelected())
@ -453,6 +466,8 @@ public class FormatPane extends BasicPane {
contents = FormatContents.CURRENCY; contents = FormatContents.CURRENCY;
} else if (ComparatorUtils.equals(source,percentRadioButton)) { } else if (ComparatorUtils.equals(source,percentRadioButton)) {
contents = FormatContents.PERCENT; contents = FormatContents.PERCENT;
}else if (ComparatorUtils.equals(source,thousandthsRadioButton)){
contents = FormatContents.THOUSANDTHS;
} else if (ComparatorUtils.equals(source,scientificRadioButton)) { } else if (ComparatorUtils.equals(source,scientificRadioButton)) {
contents = FormatContents.SCIENTIFIC; contents = FormatContents.SCIENTIFIC;
} else if (ComparatorUtils.equals(source,dateRadioButton)) { } else if (ComparatorUtils.equals(source,dateRadioButton)) {

Loading…
Cancel
Save