Browse Source

REPORT-64011 优化大文本 - 回退后复原

feature/x
Bruce.Deng 3 years ago
parent
commit
2625e624d1
  1. 169
      designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java

169
designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/CellOtherSetPane.java

@ -12,8 +12,10 @@ import com.fr.design.gui.ibutton.UIRadioButton;
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;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ispinner.UISpinner;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
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.layout.VerticalFlowLayout; import com.fr.design.layout.VerticalFlowLayout;
@ -58,6 +60,8 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
private static final int HEAD_HEIGTH = 24; private static final int HEAD_HEIGTH = 24;
private static final int COMBO_WIDTH = 154; private static final int COMBO_WIDTH = 154;
private static final int BUTTON_GROUP_WIDTH = 140; private static final int BUTTON_GROUP_WIDTH = 140;
private static final double f = TableLayout.FILL;
private static final double p = TableLayout.PREFERRED;
// normal // normal
private UIButtonGroup autoshrik; private UIButtonGroup autoshrik;
@ -67,8 +71,20 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
private UIComboBox showContent; private UIComboBox showContent;
//内容提示
private UIButtonGroup tooltipButtonGroup;
private CardLayout tooltipLayout;
private JPanel tooltipPane;
private UITextField tooltipTextField; private UITextField tooltipTextField;
//文本超出时隐藏
private UICheckBox textOverflowCheckBox;
private UIComboBox showPartComboBox;
private CardLayout showPartLayout;
private JPanel showPartPane;
private UISpinner showCharNums;
private UIComboBox textOverflowTypeComboBox;
private UITextField fileNameTextField; private UITextField fileNameTextField;
// 分页 // 分页
@ -214,17 +230,16 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
private JPanel seniorUpPane() { private JPanel seniorUpPane() {
JPanel pane = new JPanel(new BorderLayout()); JPanel pane = new JPanel(new BorderLayout());
// TODO: 方法之间的耦合还比较严重。现在必须先执行 createShowContentPane,再执行 createSeniorCheckPane。否则出现 npe。 // TODO: 方法之间的耦合还比较严重。现在必须先执行 createShowContentPane,再执行 createSeniorCheckPane。否则出现 npe。
pane.add(createTextOverflowPane(), BorderLayout.SOUTH);
pane.add(createShowContentPane(), BorderLayout.CENTER); pane.add(createShowContentPane(), BorderLayout.CENTER);
pane.add(createSeniorCheckPane(), BorderLayout.NORTH); pane.add(createSeniorCheckPane(), BorderLayout.NORTH);
return pane; return pane;
} }
private JPanel createShowContentPane() { private JPanel createShowContentPane() {
double f = TableLayout.FILL; double[] rowSize = {p, p, p, p};
double p = TableLayout.PREFERRED;
double[] rowSize = {p, p, p};
double[] colSize = {f, COMBO_WIDTH}; double[] colSize = {f, COMBO_WIDTH};
int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}}; int[][] rowCount = {{1, 1}, {1, 1}, {1, 1}, {1, 1}};
JPanel fileNamePane = createNormal(); JPanel fileNamePane = createNormal();
fileNamePane.setBorder(BorderFactory.createEmptyBorder(0,12,0,0)); fileNamePane.setBorder(BorderFactory.createEmptyBorder(0,12,0,0));
@ -233,21 +248,96 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
UIComponentUtils.setLineWrap(showContentLabel); UIComponentUtils.setLineWrap(showContentLabel);
UILabel toolTipLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip")); UILabel toolTipLabel = FRWidgetFactory.createLineWrapLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip"));
JPanel toolTipTextFieldWrapper = new JPanel(new BorderLayout()); tooltipLayout = new CardLayout();
toolTipTextFieldWrapper.add(tooltipTextField, BorderLayout.NORTH); tooltipPane = new JPanel(tooltipLayout);
tooltipPane.add(new JPanel(), "none");
tooltipPane.add(tooltipTextField, "content");
tooltipPane.setPreferredSize(new Dimension(0, 0));
tooltipButtonGroup = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip_Custom"), Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip_CellValue")});
tooltipButtonGroup.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (tooltipButtonGroup.getSelectedIndex() == 0) {
tooltipPane.setPreferredSize(new Dimension(154, 20));
tooltipLayout.show(tooltipPane, "content");
} else {
tooltipLayout.show(tooltipPane, "none");
tooltipPane.setPreferredSize(new Dimension(0, 0));
}
}
});
Component[][] components = new Component[][]{ Component[][] components = new Component[][]{
new Component[]{showContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(showContent)}, new Component[]{showContentLabel, UIComponentUtils.wrapWithBorderLayoutPane(showContent)},
new Component[]{fileNamePane, null}, // 选择"用下载连接显示二进制内容"时,会显示这一行的面板 new Component[]{fileNamePane, null}, // 选择"用下载连接显示二进制内容"时,会显示这一行的面板
new Component[]{toolTipLabel, toolTipTextFieldWrapper} new Component[]{toolTipLabel, tooltipButtonGroup}, // “自定义”or"单元格值"
new Component[]{null, tooltipPane} // 选择“自定义”时显示这一行
}; };
JPanel showContentPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, colSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM); JPanel showContentPane = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, colSize, rowCount, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_MEDIUM);
showContentPane.setBorder(BorderFactory.createEmptyBorder(6, 0, 12, 0)); showContentPane.setBorder(BorderFactory.createEmptyBorder(6, 0, 6, 0));
return showContentPane; return showContentPane;
} }
private JPanel createTextOverflowPane() {
showPartLayout = new CardLayout();
showPartPane = new JPanel(showPartLayout);
showCharNums = new UISpinner(0, Integer.MAX_VALUE, 1, 10);
JPanel showPartNumPane = new JPanel(new BorderLayout(4, 0));
showPartNumPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Nums")), BorderLayout.WEST);
showPartNumPane.add(showCharNums, BorderLayout.CENTER);
showPartPane.add(new JPanel(), "none");
showPartPane.add(showPartNumPane, "content");
showPartComboBox = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_CharNum"), Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_CellWidth")});
showPartComboBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (showPartComboBox.getSelectedIndex() == 0) {
showPartPane.setPreferredSize(new Dimension(70, 20));
showPartLayout.show(showPartPane, "content");
} else {
showPartLayout.show(showPartPane, "none");
showPartPane.setPreferredSize(new Dimension(0, 0));
}
}
});
textOverflowTypeComboBox = new UIComboBox(new String[]{Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Ellipsis"), Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_NoneSymbol")});
UILabel showPartLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_ShowPart") + ":");
UILabel hideTypeLabel = new UILabel(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideType") + ":");
Component[][] textOverflowComponents = new Component[][]{
new Component[]{showPartLabel, showPartComboBox, showPartPane},
new Component[]{hideTypeLabel, textOverflowTypeComboBox, null}
};
JPanel textOverflowComPane = TableLayoutHelper.createTableLayoutPane(textOverflowComponents, new double[]{p, p}, new double[]{p, f, p});
textOverflowComPane.setVisible(false);
textOverflowCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideWhenOverflow"));
textOverflowCheckBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
textOverflowComPane.setVisible(e.getStateChange() == ItemEvent.SELECTED);
if (e.getStateChange() == ItemEvent.SELECTED) {
if (showPartComboBox.getSelectedIndex() == 0) {
showPartPane.setPreferredSize(new Dimension(70, 20));
showPartLayout.show(showPartPane, "content");
} else {
showPartLayout.show(showPartPane, "none");
showPartPane.setPreferredSize(new Dimension(0, 0));
}
noAutoRadioButton.setSelected(true);
}
}
});
JPanel dynamicPaneWrapper = FRGUIPaneFactory.createBorderLayout_S_Pane();
dynamicPaneWrapper.add(textOverflowComPane);
JPanel textOverflowPane = FRGUIPaneFactory.createBorderLayout_S_Pane();
textOverflowPane.add(textOverflowCheckBox, BorderLayout.NORTH);
textOverflowPane.add(dynamicPaneWrapper, BorderLayout.CENTER);
textOverflowPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 10, 0));
return textOverflowPane;
}
private JPanel createSeniorCheckPane() { private JPanel createSeniorCheckPane() {
previewCellContent.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); previewCellContent.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
printAndExportContent.setBorder(UIConstants.CELL_ATTR_ZEROBORDER); printAndExportContent.setBorder(UIConstants.CELL_ATTR_ZEROBORDER);
@ -371,6 +461,11 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
insertRowPolicyButtonGroup.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_InsertRow_Policy")); insertRowPolicyButtonGroup.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_InsertRow_Policy"));
valueEditor.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_InsertRow_Policy")); valueEditor.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_InsertRow_Policy"));
pageFixedRowDataCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_Page_Fixed_Row_Cell")); pageFixedRowDataCheckBox.setGlobalName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_Page_Fixed_Row_Cell"));
tooltipButtonGroup.setGlobalName(Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip_Button_Group"));
textOverflowCheckBox.setGlobalName(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideWhenOverflow"));
showPartComboBox.setGlobalName(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_ShowPart"));
showCharNums.setGlobalName(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Nums"));
textOverflowTypeComboBox.setGlobalName(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideType"));
} }
@ -429,7 +524,40 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
} else { } else {
showContent.setSelectedItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default")); showContent.setSelectedItem(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default"));
} }
if (cellGUIAttr.isCustomTooltip()) {
tooltipButtonGroup.setSelectedIndex(0);
tooltipTextField.setText(cellGUIAttr.getTooltipText()); tooltipTextField.setText(cellGUIAttr.getTooltipText());
} else {
tooltipButtonGroup.setSelectedIndex(1);
}
if (tooltipButtonGroup.getSelectedIndex() == 0) {
tooltipPane.setPreferredSize(new Dimension(100, 20));
tooltipLayout.show(tooltipPane, "content");
} else {
tooltipLayout.show(tooltipPane, "none");
tooltipPane.setPreferredSize(new Dimension(0, 0));
}
tooltipPane.setVisible(true);
if (cellGUIAttr.isHideTextWhenOverflow()) {
textOverflowCheckBox.setSelected(true);
if (cellGUIAttr.isShowCharNum()) {
showPartComboBox.setSelectedIndex(0);
showCharNums.setValue(cellGUIAttr.getShowCharNums());
} else {
showPartComboBox.setSelectedIndex(1);
}
showPartPane.setVisible(true);
if (cellGUIAttr.isTextOverflowEllipsis()) {
textOverflowTypeComboBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Ellipsis"));
} else {
textOverflowTypeComboBox.setSelectedItem(Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_NoneSymbol"));
}
} else {
showPartComboBox.setSelectedIndex(0);
showCharNums.setValue(cellGUIAttr.getShowCharNums());
textOverflowTypeComboBox.setSelectedIndex(0);
textOverflowCheckBox.setSelected(false);
}
CellPageAttr cellPageAttr = cellElement.getCellPageAttr(); // 分页 CellPageAttr cellPageAttr = cellElement.getCellPageAttr(); // 分页
if (cellPageAttr == null) { if (cellPageAttr == null) {
cellPageAttr = new CellPageAttr(); cellPageAttr = new CellPageAttr();
@ -521,7 +649,18 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
cellGUIAttr.setFileName(fileNameTextField.getText()); cellGUIAttr.setFileName(fileNameTextField.getText());
} }
} }
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip_Button_Group"))) {
cellGUIAttr.setCustomTooltip(tooltipButtonGroup.getSelectedIndex() == 0);
if (tooltipButtonGroup.getSelectedIndex() == 0) {
if (tooltipTextField.getText() == null || tooltipTextField.getText().trim().length() <= 0) {
cellGUIAttr.setTooltipText(fieldName);
} else {
cellGUIAttr.setTooltipText(tooltipTextField.getText());
}
} else if (tooltipButtonGroup.getSelectedIndex() == 1) {
cellGUIAttr.setTooltipText("=$$$");
}
}
if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip"))) { if (ComparatorUtils.equals(getGlobalName(), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_CellWrite_ToolTip"))) {
if (tooltipTextField.getText() == null || tooltipTextField.getText().trim().length() <= 0) { if (tooltipTextField.getText() == null || tooltipTextField.getText().trim().length() <= 0) {
cellGUIAttr.setTooltipText(fieldName); cellGUIAttr.setTooltipText(fieldName);
@ -529,6 +668,18 @@ public class CellOtherSetPane extends AbstractCellAttrPane {
cellGUIAttr.setTooltipText(tooltipTextField.getText()); cellGUIAttr.setTooltipText(tooltipTextField.getText());
} }
} }
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideWhenOverflow"))) {
cellGUIAttr.setHideTextWhenOverflow(textOverflowCheckBox.isSelected());
}
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_ShowPart"))) {
cellGUIAttr.setShowCharNum(showPartComboBox.getSelectedIndex() == 0);
}
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_Nums"))) {
cellGUIAttr.setShowCharNums((int) showCharNums.getValue());
}
if (ComparatorUtils.equals(getGlobalName(), Toolkit.i18nText("Fine-Design_Report_CellWrite_TextOverflow_HideType"))) {
cellGUIAttr.setTextOverflowEllipsis(textOverflowTypeComboBox.getSelectedIndex() == 0);
}
// 如果与默认的CellGUIAttr相同,就不用保存这个属性了 // 如果与默认的CellGUIAttr相同,就不用保存这个属性了
if (ComparatorUtils.equals(cellGUIAttr, CellGUIAttr.DEFAULT_CELLGUIATTR)) { if (ComparatorUtils.equals(cellGUIAttr, CellGUIAttr.DEFAULT_CELLGUIATTR)) {
cellElement.setCellGUIAttr(cellNullGUIAttr); cellElement.setCellGUIAttr(cellNullGUIAttr);

Loading…
Cancel
Save