Browse Source

REPORT-37100 数据集-刷新参数界面后,复制的关联数据集的参数修改会影响原数据集

feature/big-screen
Yyming 4 years ago
parent
commit
f6840df761
  1. 107
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java
  2. 7
      designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java

107
designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/MultiTDTableDataPane.java

@ -19,6 +19,7 @@ import com.fr.design.gui.itableeditorpane.UITableEditorPane;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.script.Calculator;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
@ -95,9 +96,8 @@ public class MultiTDTableDataPane extends AbstractTableDataPane<MultiTDTableData
centerPanel.setLayout(new GridLayout(len < MIN_BAR_NUMBER ? MIN_BAR_NUMBER : len + 1, 1));
centerPanel.add(headLabel);
Iterator<Entry<String, TableDataWrapper>> entryIt = resMap.entrySet().iterator();
while (entryIt.hasNext()) {
TableDataWrapper tableDataWrappe = entryIt.next().getValue();
for (Entry<String, TableDataWrapper> stringTableDataWrapperEntry : resMap.entrySet()) {
TableDataWrapper tableDataWrappe = stringTableDataWrapperEntry.getValue();
String tmp = tableDataWrappe.getTableDataName();
if (!ComparatorUtils.equals(tableDataWrappe.getTableDataName(), multiName)) {
centerPanel.add(new BarPanel(tmp, tableDataWrappe.getIcon()));
@ -111,13 +111,10 @@ public class MultiTDTableDataPane extends AbstractTableDataPane<MultiTDTableData
}
private ActionListener getPreviewActionListener() {
return new ActionListener() {
public void actionPerformed(ActionEvent e) {
MultiTDTableData td = MultiTDTableDataPane.this.updateBean();
td.setTableDataSource(DesignTableDataManager.getEditingTableDataSource());
new TemplateTableDataWrapper(td).previewData();
}
return e -> {
MultiTDTableData td = MultiTDTableDataPane.this.updateBean();
td.setTableDataSource(DesignTableDataManager.getEditingTableDataSource());
new TemplateTableDataWrapper(td).previewData();
};
}
@ -126,12 +123,12 @@ public class MultiTDTableDataPane extends AbstractTableDataPane<MultiTDTableData
jpanel.setPreferredSize(new Dimension(-1, 150));
jpanel.setLayout(new BorderLayout());
editorPane = new UITableEditorPane<ParameterProvider>(new ParameterTableModel() {
editorPane = new UITableEditorPane<>(new ParameterTableModel() {
@Override
public UITableEditAction[] createAction() {
return new UITableEditAction[]{new RefreshAction()};
}
}, " " + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Default_Parameter"));
}, StringUtils.BLANK + com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tabledata_Default_Parameter"));
jpanel.add(editorPane, BorderLayout.CENTER);
@ -162,29 +159,31 @@ public class MultiTDTableDataPane extends AbstractTableDataPane<MultiTDTableData
for (int i = 0; i < size; i++) {
paramTexts[i] = (String) object[i];
}
List<ParameterProvider> existParameterList = new ArrayList<ParameterProvider>();
Iterator<Entry<String, String>> dataItera = choosenTableData.entrySet().iterator();
List<String> parameterName = new ArrayList<String>();
while (dataItera.hasNext()) {
Entry<String, String> entry = dataItera.next();
TableData td = resMap.get(entry.getKey()).getTableData();
ParameterProvider[] currentparameters = td.getParameters(Calculator.createCalculator());
for (int i=0; i<currentparameters.length; i++){
if (parameterName.contains(currentparameters[i].getName())){
continue;
}
parameterName.add(currentparameters[i].getName());
existParameterList.add(currentparameters[i]);
}
List<ParameterProvider> existParameterList = new ArrayList<>();
List<String> parameterName = new ArrayList<>();
for (Entry<String, String> entry : choosenTableData.entrySet()) {
TableData td = resMap.get(entry.getKey()).getTableData();
ParameterProvider[] currentParameters = td.getParameters(Calculator.createCalculator());
for (ParameterProvider currentParameter : currentParameters) {
if (parameterName.contains(currentParameter.getName())) {
continue;
}
parameterName.add(currentParameter.getName());
try {
existParameterList.add((ParameterProvider) currentParameter.clone());
} catch (CloneNotSupportedException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
}
ParameterProvider[] texts = ParameterHelper.analyze4Parameters(paramTexts, true);
for (int i=0; i<texts.length; i++) {
if (parameterName.contains(texts[i].getName())){
continue;
}
existParameterList.add(texts[i]);
for (ParameterProvider text : texts) {
if (parameterName.contains(text.getName())) {
continue;
}
existParameterList.add(text);
}
Parameter[] ps = existParameterList.toArray(new Parameter[existParameterList.size()]);
ParameterProvider[] ps = existParameterList.toArray(new ParameterProvider[0]);
editorPane.populate(ps);
existParameterList.clear();
parameterName.clear();
@ -217,7 +216,7 @@ public class MultiTDTableDataPane extends AbstractTableDataPane<MultiTDTableData
String name;
for (int i = 0; i < ob.getTableDataCount(); i++) {
name = ob.getTableDataName(i);
choosenTableData.put(name, "");
choosenTableData.put(name, StringUtils.EMPTY);
}
}
}
@ -236,15 +235,13 @@ public class MultiTDTableDataPane extends AbstractTableDataPane<MultiTDTableData
@Override
public MultiTDTableData updateBean() {
ConditionTableData td = new ConditionTableData();
Iterator<Entry<String, String>> it = choosenTableData.entrySet().iterator();
while (it.hasNext()) {
Entry<String, String> entry = it.next();
for (Entry<String, String> entry : choosenTableData.entrySet()) {
td.addTableData(entry.getKey(), entry.getValue());
}
List<ParameterProvider> paramList = editorPane.update();
if (paramList != null) {
td.setDefineParameters(paramList.toArray(new Parameter[paramList.size()]));
td.setDefineParameters(paramList.toArray(new Parameter[0]));
}
return td;
@ -348,9 +345,7 @@ public class MultiTDTableDataPane extends AbstractTableDataPane<MultiTDTableData
chekbox.setSelected(false);
formulaContentTextField.setEnabled(false);
formulaButton.setEnabled(false);
if (choosenTableData.containsKey(name)) {
choosenTableData.remove(name);
}
choosenTableData.remove(name);
} else {
formulaButton.setEnabled(true);
formulaContentTextField.setEnabled(true);
@ -372,9 +367,7 @@ public class MultiTDTableDataPane extends AbstractTableDataPane<MultiTDTableData
} else {
formulaButton.setEnabled(false);
formulaContentTextField.setEnabled(false);
if (choosenTableData.containsKey(name)) {
choosenTableData.remove(name);
}
choosenTableData.remove(name);
}
}
@ -388,22 +381,20 @@ public class MultiTDTableDataPane extends AbstractTableDataPane<MultiTDTableData
}
private ActionListener getFormulaActionListener() {
return new ActionListener() {
public void actionPerformed(ActionEvent e) {
final UIFormula formulaPane = FormulaFactory.createFormulaPane();
formulaPane.populate(BaseFormula.createFormulaBuilder().build(formulaContentTextField.getText()));
formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(MultiTDTableDataPane.this), new DialogActionAdapter() {
public void doOk() {
BaseFormula formula = formulaPane.update();
if (formula == null) {
formulaContentTextField.setText("");
} else {
formulaContentTextField.setText(formula.getContent().substring(1));
}
MultiTDTableDataPane.this.refresh();
return e -> {
final UIFormula formulaPane = FormulaFactory.createFormulaPane();
formulaPane.populate(BaseFormula.createFormulaBuilder().build(formulaContentTextField.getText()));
formulaPane.showLargeWindow(SwingUtilities.getWindowAncestor(MultiTDTableDataPane.this), new DialogActionAdapter() {
public void doOk() {
BaseFormula formula = formulaPane.update();
if (formula == null) {
formulaContentTextField.setText(StringUtils.EMPTY);
} else {
formulaContentTextField.setText(formula.getContent().substring(1));
}
}).setVisible(true);
}
MultiTDTableDataPane.this.refresh();
}
}).setVisible(true);
};
}
}

7
designer-base/src/main/java/com/fr/design/gui/itableeditorpane/UITableModelAdapter.java

@ -23,7 +23,7 @@ import java.util.List;
* @editor zhou
* @since 2012-3-28下午3:07:44
*/
public abstract class UITableModelAdapter<T extends Object> extends AbstractTableModel implements UITableEditorLoader {
public abstract class UITableModelAdapter<T> extends AbstractTableModel implements UITableEditorLoader {
/**
*
@ -37,7 +37,6 @@ public abstract class UITableModelAdapter<T extends Object> extends AbstractTabl
// list里放的是一行数据
private List<T> list = new ArrayList<T>();
@SuppressWarnings({ "unchecked", "rawtypes" })
protected UITableModelAdapter(String[] columnNames) {
this.columnNames = columnNames;
table = new JTable(this);
@ -101,8 +100,8 @@ public abstract class UITableModelAdapter<T extends Object> extends AbstractTabl
}
}
public void setRowAt(T value, int rowIndwx) {
this.list.set(rowIndwx, value);
public void setRowAt(T value, int rowIndex) {
this.list.set(rowIndex, value);
}
/**

Loading…
Cancel
Save