Browse Source

REPORT-116247 【NewUI】单元格属性-文字样式面板问题处理

newui
Levy.Xie-解安森 2 months ago
parent
commit
74b1c75fc8
  1. 74
      designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java

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

@ -1,8 +1,5 @@
package com.fr.design.gui.style;
import com.fine.swing.ui.layout.Column;
import com.fine.swing.ui.layout.Layouts;
import com.fine.swing.ui.layout.Row;
import com.fine.theme.utils.FineUIUtils;
import com.fr.base.CoreDecimalFormat;
import com.fr.base.GraphHelper;
@ -16,7 +13,6 @@ import com.fr.design.constants.UIConstants;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.gui.core.ReactiveCardPane;
import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.TextFontComboBox;
import com.fr.design.gui.icombobox.UIComboBox;
@ -43,9 +39,11 @@ import java.math.RoundingMode;
import java.text.Format;
import java.text.SimpleDateFormat;
import static com.fine.swing.ui.layout.Layouts.Cell;
import static com.fine.swing.ui.layout.Layouts.cell;
import static com.fine.swing.ui.layout.Layouts.column;
import static com.fine.swing.ui.layout.Layouts.row;
import static com.fr.design.constants.LayoutConstants.LEFT_WEIGHT;
import static com.fr.design.constants.LayoutConstants.RIGHT_WEIGHT;
/**
* @author Starryi
@ -79,7 +77,6 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
private boolean isRightFormat;
private boolean isDate = false;
private GlobalNameListener globalNameListener = null;
protected ReactiveCardPane cardPane;
public TextFormatPane() {
@ -89,6 +86,10 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
initPreviewLabel4GeneralFormat();
initLayout();
setTextFieldVisible(false);
setRoundingBoxVisible(false);
setPreviewLabelVisible(false);
}
private void initFormatTypesComboBox() {
@ -136,43 +137,33 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
protected void initLayout() {
this.setLayout(new BorderLayout());
cardPane = ReactiveCardPane.create()
.addSupplier("normal", () -> Layouts.column(LayoutConstants.VERTICAL_GAP,
createTypeRow()
).getComponent())
.addSupplier("preview", () -> Layouts.column(LayoutConstants.VERTICAL_GAP,
createTypeRow(),
createPreviewRow()
).getComponent())
.addSupplier("previewAndCheck", () -> Layouts.column(LayoutConstants.VERTICAL_GAP,
createTypeRow(),
createPreviewRow(),
createRoundBoxRow()
).getComponent());
cardPane.select("normal").populate();
this.add(cardPane);
this.add(column(LayoutConstants.VERTICAL_GAP,
row(
cell(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format"))).weight(LEFT_WEIGHT),
cell(typeComboBox).weight(RIGHT_WEIGHT)
),
cell(textField),
row(
cell(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Option"))).weight(LEFT_WEIGHT),
cell(roundingBox).weight(RIGHT_WEIGHT)
),
cell(previewLabel)
).getComponent());
}
private Cell<Row> createTypeRow() {
return row(
cell(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format"))).weight(1.2),
cell(typeComboBox).weight(3)
);
protected void setTextFieldVisible(boolean visible) {
textField.setVisible(visible);
}
private Cell<Row> createRoundBoxRow() {
return row(
cell(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Option"))).weight(1.2),
cell(roundingBox).with(it -> it.setBorder(null)).weight(3)
);
protected void setRoundingBoxVisible(boolean visible) {
roundingBox.getParent().setVisible(visible);
}
private Cell<Row> createPreviewRow() {
return row(
cell(previewLabel).weight(1)
);
protected void setPreviewLabelVisible(boolean visible) {
previewLabel.setVisible(visible);
}
protected UIComboBoxRenderer createComBoxRender() {
return new UIComboBoxRenderer() {
@Override
@ -314,11 +305,6 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
return contents == FormatContents.TEXT || contents == FormatContents.NULL;
}
private boolean isRoundFormat() {
int contents = getFormatContents();
return contents == FormatContents.PERCENT || contents == FormatContents.THOUSANDTHS;
}
/**
* Radio selection listener.
*/
@ -328,16 +314,16 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
int contents = getFormatContents();
Column contentContainer;
if (!isTextOrNull()) {
textField.removeAllItems();
String[] items = FormatField.getInstance().getFormatArray(contents, false);
textField.setItemArray(items);
textField.setSelectedIndex(0);
cardPane.select(isRoundFormat() ? "previewAndCheck" : "preview").populate();
} else {
cardPane.select("normal").populate();
}
setTextFieldVisible(!isTextOrNull());
setPreviewLabelVisible(!isTextOrNull());
setRoundingBoxVisible(getFormatContents() == FormatContents.PERCENT || getFormatContents() == FormatContents.THOUSANDTHS);
}
}

Loading…
Cancel
Save