Browse Source

Pull request #7152: REPORT-63808 【主题优化】格式单独拿出来以后,发现数据列的弹窗配置中没有格式项

Merge in DESIGN/design from ~STARRYI/design:feature/x to feature/x

* commit '19954cabfd990c5e51821c8716e6e6b61be9ec88':
  REPORT-63808 【主题优化】格式单独拿出来以后,发现数据列的弹窗配置中没有格式项
feature/x
starryi 3 years ago
parent
commit
320a5ac5c9
  1. 217
      designer-base/src/main/java/com/fr/design/gui/style/TextFormatPane.java
  2. 54
      designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java

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

@ -7,7 +7,6 @@ import com.fr.base.TextFormat;
import com.fr.data.core.FormatField; import com.fr.data.core.FormatField;
import com.fr.data.core.FormatField.FormatContents; import com.fr.data.core.FormatField.FormatContents;
import com.fr.design.border.UIRoundedBorder; import com.fr.design.border.UIRoundedBorder;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.event.GlobalNameListener; import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver; import com.fr.design.event.GlobalNameObserver;
@ -18,21 +17,18 @@ import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer; import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingConstants;
import javax.swing.UIManager; 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.BorderLayout; import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
@ -43,7 +39,6 @@ import java.awt.event.ItemListener;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.text.Format; import java.text.Format;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays;
/** /**
* @author Starryi * @author Starryi
@ -68,69 +63,45 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
private static final Integer[] DATE_TYPES = new Integer[]{FormatContents.NULL, FormatContents.DATE, FormatContents.TIME}; private static final Integer[] DATE_TYPES = new Integer[]{FormatContents.NULL, FormatContents.DATE, FormatContents.TIME};
private Format format; protected UIComboBox typeComboBox;
protected TextFontComboBox<String> textField;
private UIComboBox typeComboBox; protected UICheckBox roundingBox;
private TextFontComboBox textField; protected UILabel previewLabel;
private UILabel sampleLabel;
private JPanel contentPane;
private JPanel txtCenterPane;
private JPanel centerPane;
private JPanel optionPane;
private UICheckBox roundingBox;
private JPanel formatFontPane;
private boolean isRightFormat; private boolean isRightFormat;
private boolean isDate = false; private boolean isDate = false;
private GlobalNameListener globalNameListener = null; private GlobalNameListener globalNameListener = null;
/**
* Constructor.
*/
public TextFormatPane() { public TextFormatPane() {
this.initComponents(TYPES);
}
protected UIComboBox getTypeComboBox() { initFormatTypesComboBox();
return typeComboBox; initTextFontComboBox4GeneralFormats();
initRoundingCheckBox4PercentFormat();
initPreviewLabel4GeneralFormat();
initLayout();
setTextFieldVisible(false);
setRoundingBoxVisible(false);
setPreviewLabelVisible(false);
} }
protected void initComponents(Integer[] types) { private void initFormatTypesComboBox() {
this.setLayout(new BorderLayout(0, 4)); typeComboBox = new UIComboBox(TextFormatPane.TYPES);
initSampleLabel(); typeComboBox.setRenderer(createComBoxRender());
contentPane = new JPanel(new BorderLayout(0, 4)) {
@Override
public Dimension getPreferredSize() {
return new Dimension(super.getPreferredSize().width, 65);
}
};
typeComboBox = new UIComboBox(types);
UIComboBoxRenderer render = createComBoxRender();
typeComboBox.setRenderer(render);
typeComboBox.addItemListener(itemListener); typeComboBox.addItemListener(itemListener);
typeComboBox.setGlobalName("typeComboBox"); typeComboBox.setGlobalName("typeComboBox");
contentPane.add(sampleLabel, BorderLayout.NORTH); typeComboBox.setPreferredSize(new Dimension(155,20));
}
txtCenterPane = new JPanel(new BorderLayout()); private void initTextFontComboBox4GeneralFormats() {
textField = new TextFontComboBox(); textField = new TextFontComboBox<>();
textField.addItemListener(textFieldItemListener); textField.addItemListener(textFieldItemListener);
textField.setEditable(true); textField.setEditable(true);
textField.setGlobalName("textField"); textField.setGlobalName("textField");
txtCenterPane.add(textField, BorderLayout.NORTH); }
contentPane.add(txtCenterPane, BorderLayout.CENTER);
centerPane = new JPanel(new CardLayout());
centerPane.add(new JPanel(), "hide");
centerPane.setPreferredSize(new Dimension(0, 0));
centerPane.add(contentPane, "show");
typeComboBox.setPreferredSize(new Dimension(155,20));
JPanel typePane = new JPanel(new BorderLayout());
typePane.add(typeComboBox, BorderLayout.CENTER);
typePane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
JPanel option = new JPanel(new BorderLayout()); private void initRoundingCheckBox4PercentFormat() {
option.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Option"), SwingConstants.LEFT), BorderLayout.WEST);
roundingBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Base_Option_Half_Up")); roundingBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_Base_Option_Half_Up"));
roundingBox.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0)); roundingBox.setBorder(BorderFactory.createEmptyBorder(0, 30, 0, 0));
roundingBox.addItemListener(new ItemListener() { roundingBox.addItemListener(new ItemListener() {
@ -139,54 +110,13 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
} }
}); });
roundingBox.setGlobalName("roundingBox"); roundingBox.setGlobalName("roundingBox");
option.add(roundingBox, BorderLayout.CENTER);
optionPane = new JPanel(new CardLayout());
optionPane.add(new JPanel(), "hide");
optionPane.setPreferredSize(new Dimension(0, 0));
optionPane.add(option, "show");
Component[][] components = getComponent(centerPane, typePane);
this.add(createContentPane(components), BorderLayout.CENTER);
} }
protected JPanel createContentPane (Component[][] components) { private void initPreviewLabel4GeneralFormat() {
double f = TableLayout.FILL;
double p = TableLayout.PREFERRED;
double[] rowSize = new double[components.length];
Arrays.fill(rowSize, p);
double[] columnSize = {p, f};
int[][] rowCount = new int[components.length][2];
Arrays.fill(rowCount, new int[] {1, 1});
return TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM);
}
protected Component[][] getComponent (JPanel centerPane, JPanel typePane) {
return new Component[][]{
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format"), SwingConstants.LEFT), typePane},
new Component[]{centerPane, null},
new Component[]{optionPane, null},
};
}
protected UIComboBoxRenderer createComBoxRender() {
return new UIComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Integer) {
label.setText(" " + FormatField.getInstance().getName((Integer) value));
}
return label;
}
};
}
private void initSampleLabel() {
Border interBorder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4); Border interBorder = new UIRoundedBorder(UIConstants.LINE_COLOR, 1, 4);
String title = Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample"); String title = Toolkit.i18nText("Fine-Design_Report_Base_StyleFormat_Sample");
Border border = BorderFactory.createTitledBorder(interBorder, title, TitledBorder.LEFT, 0, null, UIConstants.LINE_COLOR); Border border = BorderFactory.createTitledBorder(interBorder, title, TitledBorder.LEFT, 0, null, UIConstants.LINE_COLOR);
sampleLabel = new UILabel(FormatField.getInstance().getFormatValue()) { previewLabel = new UILabel(FormatField.getInstance().getFormatValue()) {
@Override @Override
public void paint(Graphics g) { public void paint(Graphics g) {
@ -198,12 +128,65 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
g.setColor(UIConstants.LINE_COLOR); g.setColor(UIConstants.LINE_COLOR);
FontMetrics cellFM = g.getFontMetrics(); FontMetrics cellFM = g.getFontMetrics();
int textWidth = cellFM.stringWidth(getText()); int textWidth = cellFM.stringWidth(getText());
GraphHelper.drawString(g, getText(), (width - textWidth) / 2, 26); GraphHelper.drawString(g, getText(), (width - textWidth) / 2F, 26);
g.setColor(original); g.setColor(original);
} }
}; };
sampleLabel.setHorizontalAlignment(UILabel.CENTER); previewLabel.setHorizontalAlignment(UILabel.CENTER);
sampleLabel.setBorder(border); previewLabel.setBorder(border);
}
protected void initLayout() {
JPanel labeledFormatTypeComboBoxPane = new JPanel(new BorderLayout(20, 0));
labeledFormatTypeComboBoxPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Format")), BorderLayout.WEST);
labeledFormatTypeComboBoxPane.add(typeComboBox, BorderLayout.CENTER);
JPanel labeledRoundingCheckboxPane = new JPanel(new BorderLayout(0, 0));
labeledRoundingCheckboxPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_Base_Option")), BorderLayout.WEST);
labeledRoundingCheckboxPane.add(roundingBox, BorderLayout.CENTER);
addComponents(4, new JComponent[] { labeledFormatTypeComboBoxPane, textField, labeledRoundingCheckboxPane, previewLabel});
}
protected void setTextFieldVisible(boolean visible) {
textField.setVisible(visible);
}
protected void setRoundingBoxVisible(boolean visible) {
roundingBox.getParent().setVisible(visible);
}
protected void setPreviewLabelVisible(boolean visible) {
previewLabel.setVisible(visible);
}
protected void addComponents(int gap, JComponent[] components) {
JPanel container = this;
container.setLayout(new BorderLayout(0, gap));
for (JComponent component: components) {
if (component != null) {
container.add(component, BorderLayout.NORTH);
JPanel nextContainer = new JPanel(new BorderLayout(0, gap));
container.add(nextContainer, BorderLayout.CENTER);
container = nextContainer;
}
}
if (container.getComponentCount() == 0) {
container.getParent().remove(container);
}
}
protected UIComboBoxRenderer createComBoxRender() {
return new UIComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof Integer) {
label.setText(" " + FormatField.getInstance().getName((Integer) value));
}
return label;
}
};
} }
@ -231,8 +214,6 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
* Populate * Populate
*/ */
public void populateBean(Format format) { public void populateBean(Format format) {
this.format = format;
if (format == null) { if (format == null) {
this.typeComboBox.setSelectedIndex(FormatContents.NULL); this.typeComboBox.setSelectedIndex(FormatContents.NULL);
} else { } else {
@ -325,17 +306,17 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
* Refresh preview label. * Refresh preview label.
*/ */
private void refreshPreviewLabel() { private void refreshPreviewLabel() {
this.sampleLabel.setText(FormatField.getInstance().getFormatValue()); this.previewLabel.setText(FormatField.getInstance().getFormatValue());
this.sampleLabel.setForeground(UIManager.getColor("Label.foreground")); this.previewLabel.setForeground(UIManager.getColor("Label.foreground"));
try { try {
isRightFormat = true; isRightFormat = true;
if (StringUtils.isEmpty(String.valueOf(textField.getSelectedItem()))) { if (StringUtils.isEmpty(String.valueOf(textField.getSelectedItem()))) {
return; return;
} }
this.sampleLabel.setText(FormatField.getInstance().getFormatValue(getFormatContents(), String.valueOf(textField.getSelectedItem()))); this.previewLabel.setText(FormatField.getInstance().getFormatValue(getFormatContents(), String.valueOf(textField.getSelectedItem())));
} catch (Exception e) { } catch (Exception e) {
this.sampleLabel.setForeground(Color.red); this.previewLabel.setForeground(Color.red);
this.sampleLabel.setText(e.getMessage()); this.previewLabel.setText(e.getMessage());
isRightFormat = false; isRightFormat = false;
} }
} }
@ -354,28 +335,16 @@ public class TextFormatPane extends AbstractBasicStylePane implements GlobalName
public void itemStateChanged(ItemEvent e) { public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) { if (e.getStateChange() == ItemEvent.SELECTED) {
int contents = getFormatContents(); int contents = getFormatContents();
String[] items = FormatField.getInstance().getFormatArray(contents, false);
CardLayout cardLayout = (CardLayout) centerPane.getLayout();
if (isTextOrNull()) { if (!isTextOrNull()) {
centerPane.setPreferredSize(new Dimension(0, 0));
cardLayout.show(centerPane, "hide");
} else {
textField.removeAllItems(); textField.removeAllItems();
String[] items = FormatField.getInstance().getFormatArray(contents, false);
textField.setItemArray(items); textField.setItemArray(items);
textField.setSelectedIndex(0); textField.setSelectedIndex(0);
centerPane.setPreferredSize(new Dimension(270, 65));
cardLayout.show(centerPane, "show");
}
CardLayout optionLayout = ((CardLayout) optionPane.getLayout());
if (getFormatContents() == FormatContents.PERCENT) {
optionPane.setPreferredSize(new Dimension(100, 20));
optionLayout.show(optionPane, "show");
} else {
optionPane.setPreferredSize(new Dimension(0, 0));
optionLayout.show(optionPane, "hide");
roundingBox.setSelected(false);
} }
setTextFieldVisible(!isTextOrNull());
setPreviewLabelVisible(!isTextOrNull());
setRoundingBoxVisible(getFormatContents() == FormatContents.PERCENT);
} }
} }

54
designer-realize/src/main/java/com/fr/design/dscolumn/DSColumnAdvancedPane.java

@ -2,6 +2,7 @@ package com.fr.design.dscolumn;
import com.fr.base.BaseFormula; import com.fr.base.BaseFormula;
import com.fr.data.util.SortOrder; import com.fr.data.util.SortOrder;
import com.fr.design.border.UITitledBorder;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.BasicPane;
import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.DialogActionAdapter;
@ -9,7 +10,6 @@ import com.fr.design.formula.CustomVariableResolver;
import com.fr.design.formula.FormulaFactory; import com.fr.design.formula.FormulaFactory;
import com.fr.design.formula.SortFormulaPane; import com.fr.design.formula.SortFormulaPane;
import com.fr.design.formula.UIFormula; import com.fr.design.formula.UIFormula;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icheckbox.UICheckBox; import com.fr.design.gui.icheckbox.UICheckBox;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
@ -20,14 +20,12 @@ import com.fr.design.gui.style.TextFormatPane;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.style.FormatPane;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.report.cell.CellElement; import com.fr.report.cell.CellElement;
import com.fr.report.cell.TemplateCellElement; import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellExpandAttr; import com.fr.report.cell.cellattr.CellExpandAttr;
import com.fr.report.cell.cellattr.core.group.DSColumn; import com.fr.report.cell.cellattr.core.group.DSColumn;
import com.fr.report.cell.cellattr.core.group.SelectCount; import com.fr.report.cell.cellattr.core.group.SelectCount;
import com.fr.van.chart.designer.component.format.FormatPaneWithOutFont;
import javax.swing.*; import javax.swing.*;
import java.awt.*; import java.awt.*;
@ -59,18 +57,19 @@ public class DSColumnAdvancedPane extends BasicPane {
this.setLayout(FRGUIPaneFactory.createBorderLayout()); this.setLayout(FRGUIPaneFactory.createBorderLayout());
sortPane = new SortPane(); sortPane = new SortPane();
sortPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order"), null)); sortPane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Sort_Sort_Order")));
if (setting > DSColumnPane.SETTING_DSRELATED) { if (setting > DSColumnPane.SETTING_DSRELATED) {
selectCountPane = new SelectCountPane(); selectCountPane = new SelectCountPane();
selectCountPane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Results_Filter"), null)); selectCountPane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Results_Filter")));
} }
valuePane = new ValuePane(); valuePane = new ValuePane();
valuePane.setBorder(GUICoreUtils.createTitledBorder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Custom_Data_Appearance"), null)); valuePane.setBorder(UITitledBorder.createBorderWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Bind_Column_Custom_Data_Appearance")));
formatAttrPane = new FormatAttrPane(); formatAttrPane = new FormatAttrPane();
JPanel titleBorderedFormatPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Base_Format"));
titleBorderedFormatPane.add(formatAttrPane, BorderLayout.NORTH);
JPanel extendablePane = null; JPanel extendablePane = null;
if (setting > DSColumnPane.SETTING_DSRELATED) { if (setting > DSColumnPane.SETTING_DSRELATED) {
@ -109,7 +108,7 @@ public class DSColumnAdvancedPane extends BasicPane {
{sortPane}, {sortPane},
{selectCountPane}, {selectCountPane},
{valuePane}, {valuePane},
{formatAttrPane}, {titleBorderedFormatPane},
{extendablePane}, {extendablePane},
{multiNumPane} {multiNumPane}
}; };
@ -117,7 +116,7 @@ public class DSColumnAdvancedPane extends BasicPane {
components = new Component[][]{ components = new Component[][]{
{sortPane}, {sortPane},
{valuePane}, {valuePane},
{formatAttrPane} {titleBorderedFormatPane}
}; };
} }
@ -538,40 +537,31 @@ public class DSColumnAdvancedPane extends BasicPane {
} }
} }
public class FormatAttrPane extends AbstractAttrNoScrollPane { public static class FormatAttrPane extends TextFormatPane {
private TextFormatPane formatPane;
@Override protected void initLayout() {
protected JPanel createContentPane() { JPanel settingPane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 4, 0);
this.formatPane = new TextFormatPane(); settingPane.add(typeComboBox);
return this.formatPane; settingPane.add(textField);
} settingPane.add(roundingBox);
@Override addComponents(4, new JComponent[] { settingPane, previewLabel});
public Dimension getPreferredSize() {
if (formatPane == null) {
return super.getPreferredSize();
}
return formatPane.getPreferredSize();
} }
protected void initContentPane() { @Override
leftContentPane = createContentPane(); protected void setRoundingBoxVisible(boolean visible) {
if (leftContentPane != null) { roundingBox.setVisible(visible);
leftContentPane.setBorder(BorderFactory.createEmptyBorder());
this.add(leftContentPane, BorderLayout.CENTER);
}
} }
public void populate(CellElement cellElement) { public void populate(CellElement cellElement) {
if (cellElement != null && formatPane != null) { if (cellElement != null) {
formatPane.populateBean(cellElement.getStyle()); populateBean(cellElement.getStyle());
} }
} }
public void update(CellElement cellElement) { public void update(CellElement cellElement) {
if (cellElement != null && formatPane != null) { if (cellElement != null) {
cellElement.setStyle(formatPane.update(cellElement.getStyle())); cellElement.setStyle(update(cellElement.getStyle()));
} }
} }
} }

Loading…
Cancel
Save