Browse Source

REPORT-3348 复用添加数据列对话框代码,保留原始对话框布局

master
yaoh.wu 7 years ago
parent
commit
e8df144eaf
  1. 42
      designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java
  2. 23
      designer/src/com/fr/design/dscolumn/DSColumnBasicPane.java
  3. 16
      designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java
  4. 57
      designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java
  5. 2
      designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

42
designer/src/com/fr/design/dscolumn/DSColumnAdvancedEditorPane.java

@ -2,6 +2,7 @@ package com.fr.design.dscolumn;
import com.fr.base.Formula;
import com.fr.data.TableDataSource;
import com.fr.design.constants.LayoutConstants;
import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.formula.CustomVariableResolver;
@ -19,6 +20,7 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.cell.CellEditorPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.IOUtils;
import com.fr.general.Inter;
import com.fr.report.cell.CellElement;
@ -270,21 +272,26 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane {
if (selectIndex == 1) {
setCardPaneLayout.show(setCardPane, FilterType.TOP.name());
tipCardPaneLayout.show(tipCardPane, FilterType.TOP.name());
//隐藏tip
} else if (selectIndex == 2) {
setCardPaneLayout.show(setCardPane, FilterType.BOTTOM.name());
tipCardPaneLayout.show(tipCardPane, FilterType.BOTTOM.name());
//隐藏tip
} else if (selectIndex == 3) {
setCardPaneLayout.show(setCardPane, FilterType.ODD.name());
tipCardPaneLayout.show(tipCardPane, FilterType.ODD.name());
//隐藏set
} else if (selectIndex == 4) {
setCardPaneLayout.show(setCardPane, FilterType.EVEN.name());
tipCardPaneLayout.show(tipCardPane, FilterType.EVEN.name());
//隐藏set
} else if (selectIndex == 5) {
setCardPaneLayout.show(setCardPane, FilterType.SPECIFY.name());
tipCardPaneLayout.show(tipCardPane, FilterType.SPECIFY.name());
} else {
setCardPaneLayout.show(setCardPane, FilterType.UNDEFINE.name());
tipCardPaneLayout.show(tipCardPane, FilterType.UNDEFINE.name());
//隐藏set和tip
}
}
});
@ -413,18 +420,29 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane {
private String defaultValue;
public JFormulaField(String defaultValue) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f};
double[] rowSize = {p};
this.defaultValue = defaultValue;
this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
formulaTextField = new UITextField(11);
this.add(formulaTextField);
formulaTextField = new UITextField();
formulaTextField.setText(defaultValue);
UIButton formulaButton = new UIButton(IOUtils.readIcon("/com/fr/design/images/m_insert/formula.png"));
this.add(formulaButton);
formulaButton.setToolTipText(Inter.getLocText("Formula") + "...");
formulaButton.setPreferredSize(new Dimension(20, formulaTextField.getPreferredSize().height));
formulaButton.setPreferredSize(new Dimension(24, formulaTextField.getPreferredSize().height));
formulaButton.addActionListener(formulaButtonActionListener);
Component[] buttonComponent = new Component[]{
formulaButton
};
JPanel pane = new JPanel(new BorderLayout(0, 0));
pane.add(formulaTextField, BorderLayout.CENTER);
pane.add(GUICoreUtils.createFlowPane(buttonComponent, FlowLayout.LEFT, LayoutConstants.HGAP_LARGE), BorderLayout.EAST);
Component[][] components = new Component[][]{
new Component[]{pane}
};
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout());
this.add(panel, BorderLayout.CENTER);
}
public void populate(String formulaContent) {
@ -485,13 +503,17 @@ public class DSColumnAdvancedEditorPane extends CellEditorPane {
* @see DSColumnAdvancedPane.ValuePane
*/
private static class CustomValuePane extends JPanel {
private DSColumnAdvancedEditorPane.JFormulaField formulaField;
private JFormulaField formulaField;
public CustomValuePane() {
double p = TableLayout.PREFERRED, f = TableLayout.FILL;
this.setLayout(FRGUIPaneFactory.createBoxFlowLayout());
UILabel customValueLabel = new UILabel("显示值");
this.add(Box.createHorizontalStrut(2));
this.add((formulaField = new DSColumnAdvancedEditorPane.JFormulaField("$$$")));
formulaField = new JFormulaField("$$$");
formulaField.setPreferredSize(new Dimension(159, 20));
this.add(TableLayoutHelper.createTableLayoutPane(new Component[][]{
{customValueLabel, formulaField},
}, new double[]{p}, new double[]{p, f}), BorderLayout.CENTER);
}
public void populate(CellElement cellElement) {

23
designer/src/com/fr/design/dscolumn/DSColumnBasicPane.java

@ -1,25 +1,23 @@
package com.fr.design.dscolumn;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.BorderFactory;
import com.fr.data.TableDataSource;
import com.fr.design.dialog.BasicPane;
import com.fr.design.expand.ConditionParentPane;
import com.fr.design.expand.ExpandDirectionPane;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.dialog.BasicPane;
import com.fr.general.Inter;
import com.fr.design.mainframe.ElementCasePane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.Inter;
import com.fr.report.cell.CellElement;
import com.fr.report.cell.TemplateCellElement;
import com.fr.report.cell.cellattr.CellExpandAttr;
import com.fr.design.utils.gui.GUICoreUtils;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class DSColumnBasicPane extends BasicPane {
@ -135,6 +133,7 @@ public class DSColumnBasicPane extends BasicPane {
}
resultSetGroupPane.update();
}
ActionListener summary_direction_ActionListener = new ActionListener() {
public void actionPerformed(ActionEvent evt) {
@ -157,11 +156,13 @@ public class DSColumnBasicPane extends BasicPane {
selectDataColumnPane.update(cellElement);
}
};
public void putElementcase(ElementCasePane t){
public void putElementcase(ElementCasePane t) {
if (conditionParentPane != null) {
conditionParentPane.putElementcase(t);
}
}
public void putCellElement(TemplateCellElement tplEC2) {
if (conditionParentPane != null) {
conditionParentPane.putCellElement(tplEC2);

16
designer/src/com/fr/design/dscolumn/SelectedConfirmedDataColumnPane.java

@ -1,20 +1,20 @@
package com.fr.design.dscolumn;
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Iterator;
import com.fr.data.TableDataSource;
import com.fr.design.data.datapane.TableDataComboBox;
import com.fr.design.data.tabledata.wrapper.TemplateTableDataWrapper;
import com.fr.main.impl.WorkBook;
import com.fr.report.cell.TemplateCellElement;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Iterator;
public class SelectedConfirmedDataColumnPane extends SelectedDataColumnPane {
public SelectedConfirmedDataColumnPane () {
super(false);
public SelectedConfirmedDataColumnPane() {
super(false, false);
}
protected void initTableNameComboBox() {
@ -35,7 +35,7 @@ public class SelectedConfirmedDataColumnPane extends SelectedDataColumnPane {
super.populate(source, cell);
try {
Iterator it = source.getTableDataNameIterator();
String name = (String)it.next();
String name = (String) it.next();
TemplateTableDataWrapper wrapper = new TemplateTableDataWrapper(source.getTableData(name), name);
tableNameComboBox.setSelectedItem(wrapper);
tableNameComboBox.getModel().setSelectedItem(wrapper);

57
designer/src/com/fr/design/dscolumn/SelectedDataColumnPane.java

@ -39,8 +39,8 @@ import java.util.regex.Pattern;
* 数据集列动态参数设置组件
*
* @author yaoh.wu
* @version 2017年7月26
* 9.0设计器更新修改动态参数注入按钮部分,使其显示动态参数按钮时能在右侧边栏正常显示
* @version 2017年8月3
* 复用对话框代码保留对话框原始布局
* @since 8.0
*/
public class SelectedDataColumnPane extends BasicPane {
@ -54,12 +54,16 @@ public class SelectedDataColumnPane extends BasicPane {
private UIButton paramButton;
public SelectedDataColumnPane() {
this(true);
this(true, false);
}
SelectedDataColumnPane(boolean showParameterButton) {
public SelectedDataColumnPane(boolean showParameterButton, boolean verticalLayout) {
if (verticalLayout) {
initComponentVerticalLayout(true);
} else {
initComponent(showParameterButton);
}
}
/**
* 初始化组件
@ -67,6 +71,51 @@ public class SelectedDataColumnPane extends BasicPane {
* @param showParameterButton 是否显示参数按钮
*/
public void initComponent(boolean showParameterButton) {
initTableNameComboBox();
if (showParameterButton) {
initWithParameterButton();
}
columnNameComboBox = new LazyComboBox() {
@Override
public Object[] load() {
List<String> l = calculateColumnNameList();
return l.toArray(new String[l.size()]);
}
};
columnNameComboBox.setEditable(true);
double p = TableLayout.PREFERRED;
UILabel label1 = new UILabel(Inter.getLocText("TableData") + ":");
UILabel label2 = new UILabel(Inter.getLocText("DataColumn") + ":");
if (showParameterButton) {
label1.setPreferredSize(new Dimension(200, 25));
label2.setPreferredSize(new Dimension(200, 25));
}
if (showParameterButton) {
Component[][] comps = {{label1, null, label2}, {tableNameComboBox, paramButton, columnNameComboBox}};
this.add(TableLayoutHelper.createTableLayoutPane(comps, new double[]{p, p}, new double[]{p, p, p}));
} else {
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = {p, p};
Component[][] components = new Component[][]{
new Component[]{label1, tableNameComboBox},
new Component[]{label2, columnNameComboBox}
};
JPanel jPanel = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.setLayout(new BorderLayout());
this.add(jPanel, BorderLayout.CENTER);
}
}
/**
* 初始化组件
*
* @param showParameterButton 是否显示参数按钮
*/
public void initComponentVerticalLayout(boolean showParameterButton) {
initTableNameComboBox();
if (showParameterButton) {
initWithParameterButton();

2
designer/src/com/fr/quickeditor/cellquick/CellDSColumnEditor.java

@ -176,7 +176,7 @@ public class CellDSColumnEditor extends CellQuickEditor {
private void createPanes() {
paneList = new ArrayList<>();
/*基本设置面板*/
this.dataPane = new SelectedDataColumnPane();
this.dataPane = new SelectedDataColumnPane(true, true);
this.groupPane = new ResultSetGroupDockingPane(tc);
double p = TableLayout.PREFERRED, f = TableLayout.FILL;
double[] rowSize = {p}, columnSize = {p, f};

Loading…
Cancel
Save