Browse Source

REPORT-45095 表单控件设置提交事件,添加字段后编辑字段,事件弹框消失

final/10.0
vito 4 years ago
parent
commit
cb919feb8b
  1. 236
      designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java
  2. 4
      designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java

236
designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java

@ -53,7 +53,6 @@ import javax.swing.BorderFactory;
import javax.swing.DefaultCellEditor; import javax.swing.DefaultCellEditor;
import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultComboBoxModel;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JFrame;
import javax.swing.JList; import javax.swing.JList;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.JPanel; import javax.swing.JPanel;
@ -74,6 +73,7 @@ import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.GridLayout; import java.awt.GridLayout;
import java.awt.Image; import java.awt.Image;
import java.awt.Window;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.FocusAdapter; import java.awt.event.FocusAdapter;
@ -119,13 +119,9 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
protected JavaScriptActionPane parentPane; protected JavaScriptActionPane parentPane;
private int keyColumnWidth = 100;
private int resizeColumnCount = 4;
private int btnWidth = 110;
private int btnHeight = 20;
private String subMitName; private String subMitName;
private static final String[] DML_CONFIG_TYPES = new String[] { private static final String[] DML_CONFIG_TYPES = new String[]{
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Smart_Submit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Smart_Submit"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Delete_Submit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Delete_Submit"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Insert_Submit"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Write_Insert_Submit"),
@ -148,7 +144,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
dmlConfigComboBox = new UIComboBox(DML_CONFIG_TYPES); dmlConfigComboBox = new UIComboBox(DML_CONFIG_TYPES);
JPanel typePane = GUICoreUtils.createFlowPane(new Component[] { new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Choose_Submit_Type") + ":"), dmlConfigComboBox }, JPanel typePane = GUICoreUtils.createFlowPane(new Component[]{new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Choose_Submit_Type") + ":"), dmlConfigComboBox},
FlowLayout.LEFT, 10); FlowLayout.LEFT, 10);
typePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Submit_Type"))); typePane.setBorder(BorderFactory.createTitledBorder(new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Write_Submit_Type")));
northPane.add(typePane, BorderLayout.NORTH); northPane.add(typePane, BorderLayout.NORTH);
@ -179,11 +175,11 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
addListeners(); addListeners();
} }
public void setSubMitName(String subMitName){ public void setSubMitName(String subMitName) {
this.subMitName = subMitName; this.subMitName = subMitName;
} }
public String getSubMitName(){ public String getSubMitName() {
return this.subMitName; return this.subMitName;
} }
@ -194,11 +190,11 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
JPanel controlBtnPane = new JPanel(new GridLayout(actions.length + 1, 1, 4, 4)); JPanel controlBtnPane = new JPanel(new GridLayout(actions.length + 1, 1, 4, 4));
editTablePane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), BorderLayout.EAST); editTablePane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), BorderLayout.EAST);
for (int i = 0; i < actions.length; i++) { for (UpdateAction action : actions) {
controlBtnPane.add(new UIButton(actions[i])); controlBtnPane.add(new UIButton(action));
} }
checkBoxUpdatePane = new JPanel(new BorderLayout(0, 0)); checkBoxUpdatePane = new JPanel(new BorderLayout(0, 0));
checkBoxUpdatePane.setPreferredSize(new Dimension(120,20)); checkBoxUpdatePane.setPreferredSize(new Dimension(120, 20));
controlBtnPane.add(checkBoxUpdatePane); controlBtnPane.add(checkBoxUpdatePane);
UpdateCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_NotChange_Unmodified")); UpdateCheckBox = new UICheckBox(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_NotChange_Unmodified"));
@ -207,21 +203,22 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
helpButton.addActionListener(new ActionListener() { helpButton.addActionListener(new ActionListener() {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
FormatExplanationPane formatExplanation = new FormatExplanationPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Help"),com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Help"), 12f); FormatExplanationPane formatExplanation = new FormatExplanationPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Help"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Help"), 12f);
BasicDialog dlg = formatExplanation.showMediumWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), BasicDialog dlg = formatExplanation.showMediumWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this),
new DialogActionAdapter(){}); new DialogActionAdapter() {
});
dlg.setVisible(true); dlg.setVisible(true);
} }
}); });
helpButton.set4ToolbarButton(); helpButton.set4ToolbarButton();
checkBoxUpdatePane.add(UpdateCheckBox,BorderLayout.WEST); checkBoxUpdatePane.add(UpdateCheckBox, BorderLayout.WEST);
checkBoxUpdatePane.add(helpButton,BorderLayout.EAST); checkBoxUpdatePane.add(helpButton, BorderLayout.EAST);
} }
} }
protected void updateUpdateCheckBoxEnable(){ protected void updateUpdateCheckBoxEnable() {
KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel();
if (model.getRowCount() == 0){ if (model.getRowCount() == 0) {
setUpdateCheckBoxEnable(false); setUpdateCheckBoxEnable(false);
UpdateCheckBox.setSelected(true); UpdateCheckBox.setSelected(true);
return; return;
@ -230,9 +227,8 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
for (int i = 0; i < model.getRowCount(); i++) { for (int i = 0; i < model.getRowCount(); i++) {
columnObjects.add(model.getKeyColumnNameValue(i).cv.getObj()); columnObjects.add(model.getKeyColumnNameValue(i).cv.getObj());
} }
for (int i = 0;i < columnObjects.size();i++){ for (Object ob : columnObjects) {
Object ob = columnObjects.get(i) ; if (!(ob instanceof ColumnRow || ob instanceof ColumnRowGroup)) {
if (!( ob instanceof ColumnRow || ob instanceof ColumnRowGroup)){
setUpdateCheckBoxEnable(false); setUpdateCheckBoxEnable(false);
UpdateCheckBox.setSelected(false); UpdateCheckBox.setSelected(false);
return; return;
@ -241,7 +237,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
setUpdateCheckBoxEnable(true); setUpdateCheckBoxEnable(true);
} }
private void setUpdateCheckBoxEnable( boolean b){ private void setUpdateCheckBoxEnable(boolean b) {
UpdateCheckBox.setEnabled(b); UpdateCheckBox.setEnabled(b);
} }
@ -251,9 +247,9 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
JPanel conditionPane = this.createConditionPane(); JPanel conditionPane = this.createConditionPane();
JPanel btPane =new JPanel( FRGUIPaneFactory.createBorderLayout()); JPanel btPane = new JPanel(FRGUIPaneFactory.createBorderLayout());
btPane.add(eventPane,BorderLayout.CENTER); btPane.add(eventPane, BorderLayout.CENTER);
btPane.add(conditionPane,BorderLayout.NORTH); btPane.add(conditionPane, BorderLayout.NORTH);
this.add(btPane, BorderLayout.SOUTH); this.add(btPane, BorderLayout.SOUTH);
} }
@ -261,6 +257,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
UIButton addSubmitEventButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Event")); UIButton addSubmitEventButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Event"));
addSubmitEventButton.addActionListener(new ActionListener() { addSubmitEventButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
final SubmitJobListPane jobsPane = createSubmitJobListPane(); final SubmitJobListPane jobsPane = createSubmitJobListPane();
@ -293,7 +290,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
DefaultTreeCellRenderer cr = (DefaultTreeCellRenderer) conditionsTree.getCellRenderer(); DefaultTreeCellRenderer cr = (DefaultTreeCellRenderer) conditionsTree.getCellRenderer();
cr.setForeground(UIConstants.NORMAL_BACKGROUND); cr.setForeground(UIConstants.NORMAL_BACKGROUND);
JScrollPane jp = new JScrollPane(conditionsTree); JScrollPane jp = new JScrollPane(conditionsTree);
addComponent(conditionPane,jp); addComponent(conditionPane, jp);
UIButton addSubmitConditionButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Condition")); UIButton addSubmitConditionButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Set_Submit_Condition"));
addSubmitConditionButton.addActionListener(new ActionListener() { addSubmitConditionButton.addActionListener(new ActionListener() {
@ -325,32 +322,32 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
JPanel controlBtnPane = new JPanel(new GridLayout(1, 1, 4, 4)); JPanel controlBtnPane = new JPanel(new GridLayout(1, 1, 4, 4));
controlBtnPane.setPreferredSize(createControlBtnPanePreferredSize()); controlBtnPane.setPreferredSize(createControlBtnPanePreferredSize());
conditionPane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH),setControlBtnPanePosition()); conditionPane.add(GUICoreUtils.createBorderPane(controlBtnPane, BorderLayout.NORTH), setControlBtnPanePosition());
controlBtnPane.add(addSubmitConditionButton); controlBtnPane.add(addSubmitConditionButton);
return conditionPane; return conditionPane;
} }
protected void setBorderAndLayout(JPanel jPanel){ protected void setBorderAndLayout(JPanel jPanel) {
jPanel.setLayout(FRGUIPaneFactory.createBorderLayout()); jPanel.setLayout(FRGUIPaneFactory.createBorderLayout());
jPanel.setBorder(BorderFactory.createTitledBorder( jPanel.setBorder(BorderFactory.createTitledBorder(
new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Submit_Condition"))); new ModLineBorder(ModLineBorder.TOP), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Submit_Condition")));
} }
protected void addComponent(JPanel mainPane,JScrollPane addPane){ protected void addComponent(JPanel mainPane, JScrollPane addPane) {
mainPane.add(addPane,BorderLayout.CENTER); mainPane.add(addPane, BorderLayout.CENTER);
} }
protected Dimension createConditionPanePreferredSize(){ protected Dimension createConditionPanePreferredSize() {
return new Dimension(454, 80); return new Dimension(454, 80);
} }
protected Dimension createControlBtnPanePreferredSize(){ protected Dimension createControlBtnPanePreferredSize() {
return new Dimension(110, 20); return new Dimension(110, 20);
} }
protected String setControlBtnPanePosition(){ protected String setControlBtnPanePosition() {
return BorderLayout.EAST; return BorderLayout.EAST;
} }
@ -409,6 +406,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
*/ */
keyColumnValuesTable.addFocusListener(new FocusAdapter() { keyColumnValuesTable.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
refreshColumnsComboBox(); refreshColumnsComboBox();
} }
@ -417,7 +415,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
} }
protected UpdateAction[] getActions() { protected UpdateAction[] getActions() {
return new UpdateAction[] { new SmartAddFieldsAction(), new AddFieldAction(), new RemoveFieldAction() }; return new UpdateAction[]{new SmartAddFieldsAction(), new AddFieldAction(), new RemoveFieldAction()};
} }
protected SubmitJobListPane createSubmitJobListPane() { protected SubmitJobListPane createSubmitJobListPane() {
@ -438,6 +436,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields")); this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Smart_Add_Fields"));
} }
@Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
BasicPane bPane = new BasicPane() { BasicPane bPane = new BasicPane() {
@ -449,9 +448,10 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
bPane.setLayout(FRGUIPaneFactory.createBorderLayout()); bPane.setLayout(FRGUIPaneFactory.createBorderLayout());
final CheckBoxList list = new CheckBoxList(currentColumnNames(), CheckBoxList.SelectedState.ALL, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Chart_Field_Name")) { final CheckBoxList list = new CheckBoxList(currentColumnNames(), CheckBoxList.SelectedState.ALL, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Chart_Field_Name")) {
@Override
public String value2Text(Object value) { public String value2Text(Object value) {
if (value instanceof ColumnName) { if (value instanceof ColumnName) {
return ((ColumnName)value).name; return ((ColumnName) value).name;
} }
return super.value2Text(value); return super.value2Text(value);
@ -460,6 +460,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
bPane.add(new JScrollPane(list), BorderLayout.CENTER); bPane.add(new JScrollPane(list), BorderLayout.CENTER);
BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() { BasicDialog dlg = bPane.showSmallWindow(SwingUtilities.getWindowAncestor(DBManipulationPane.this), new DialogActionAdapter() {
@Override
public void doOk() { public void doOk() {
addFields(list); addFields(list);
updateUpdateCheckBoxEnable(); updateUpdateCheckBoxEnable();
@ -469,8 +470,8 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
} }
} }
private void addFields (CheckBoxList list) { private void addFields(CheckBoxList list) {
KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel();
List<KeyColumnNameValue> keyColumnNameValueList = new ArrayList<KeyColumnNameValue>(); List<KeyColumnNameValue> keyColumnNameValueList = new ArrayList<KeyColumnNameValue>();
keyColumnNameValueList.clear(); keyColumnNameValueList.clear();
for (int i = 0; i < model.getRowCount(); i++) { for (int i = 0; i < model.getRowCount(); i++) {
@ -481,9 +482,9 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
// Richie:用了存储新的KeyColumnNameValue的List. // Richie:用了存储新的KeyColumnNameValue的List.
List<KeyColumnNameValue> newKeyColumnNameValueList = new ArrayList<KeyColumnNameValue>(); List<KeyColumnNameValue> newKeyColumnNameValueList = new ArrayList<KeyColumnNameValue>();
if (!keyColumnNameValueList.isEmpty()) { if (!keyColumnNameValueList.isEmpty()) {
for (int i = 0; i < selected.length; i++) { for (Object o : selected) {
// Richie:先填上空的. // Richie:先填上空的.
newKeyColumnNameValueList.add(new KeyColumnNameValue(false, (ColumnName)selected[i], new ColumnValue(""), false)); newKeyColumnNameValueList.add(new KeyColumnNameValue(false, (ColumnName) o, new ColumnValue(""), false));
} }
} }
// Richie:初始化 // Richie:初始化
@ -492,17 +493,17 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
if (!keyColumnNameValueList.isEmpty()) { if (!keyColumnNameValueList.isEmpty()) {
//如果存在先前项,设置状态为5 //如果存在先前项,设置状态为5
returnValue = 5 ; returnValue = 5;
} }
for (int i = 0; i < selected.length; i++) { for (int i = 0; i < selected.length; i++) {
if (returnValue == 0 || returnValue == 3) { if (returnValue == 0 || returnValue == 3) {
break; break;
} }
for (int j = 0; j < keyColumnNameValueList.size(); j++) { for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) {
if (ComparatorUtils.equals(selected[i], keyColumnNameValueList.get(j).cn)) { if (ComparatorUtils.equals(selected[i], keyColumnNameValue.cn)) {
Object[] options = { com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Covered_All"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Yes"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_None") }; Object[] options = {com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Covered_All"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Yes"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_No"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_None")};
returnValue = JOptionPane.showOptionDialog(DBManipulationPane.this, returnValue = JOptionPane.showOptionDialog(DBManipulationPane.this,
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_Tips", keyColumnNameValueList.get(j).cn.name), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Cover_Tips", keyColumnNameValue.cn.name),
"", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); "", JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]);
// Richie:全部覆盖 // Richie:全部覆盖
if (returnValue == 0) { if (returnValue == 0) {
@ -514,7 +515,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
} else if (returnValue == 2) { } else if (returnValue == 2) {
coverNumber = i; coverNumber = i;
newKeyColumnNameValueList.remove(i); newKeyColumnNameValueList.remove(i);
newKeyColumnNameValueList.add(i, keyColumnNameValueList.get(j)); newKeyColumnNameValueList.add(i, keyColumnNameValue);
// Richie:全部不覆盖 // Richie:全部不覆盖
} else if (returnValue == 3) { } else if (returnValue == 3) {
coverNumber = i; coverNumber = i;
@ -526,7 +527,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
checkTableModel(returnValue, coverNumber, model, selected, keyColumnNameValueList, newKeyColumnNameValueList); checkTableModel(returnValue, coverNumber, model, selected, keyColumnNameValueList, newKeyColumnNameValueList);
} }
private void checkTableModel (int returnValue, int coverNumber, KeyColumnTableModel model, Object[] selected, List<KeyColumnNameValue> keyColumnNameValueList, List<KeyColumnNameValue> newKeyColumnNameValueList) { private void checkTableModel(int returnValue, int coverNumber, KeyColumnTableModel model, Object[] selected, List<KeyColumnNameValue> keyColumnNameValueList, List<KeyColumnNameValue> newKeyColumnNameValueList) {
if (returnValue == 0) { if (returnValue == 0) {
model.removeAllKeyColumnNameValue(); model.removeAllKeyColumnNameValue();
// Richie:全部覆盖,按selected的长度添加默认的行 // Richie:全部覆盖,按selected的长度添加默认的行
@ -538,10 +539,10 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
model.removeAllKeyColumnNameValue(); model.removeAllKeyColumnNameValue();
// Richie:全部不覆盖,已经存在的就保留,不存在的添加默认行 // Richie:全部不覆盖,已经存在的就保留,不存在的添加默认行
for (int i = coverNumber; i < selected.length; i++) { for (int i = coverNumber; i < selected.length; i++) {
for (int j = 0; j < keyColumnNameValueList.size(); j++) { for (KeyColumnNameValue keyColumnNameValue : keyColumnNameValueList) {
if (ComparatorUtils.equals(selected[i], keyColumnNameValueList.get(j).cn)) { if (ComparatorUtils.equals(selected[i], keyColumnNameValue.cn)) {
newKeyColumnNameValueList.remove(i); newKeyColumnNameValueList.remove(i);
newKeyColumnNameValueList.add(i, keyColumnNameValueList.get(j)); newKeyColumnNameValueList.add(i, keyColumnNameValue);
} }
} }
@ -555,7 +556,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
for (int i = 0; i < selected.length; i++) { for (int i = 0; i < selected.length; i++) {
model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i));
} }
} else if (returnValue == 5){ } else if (returnValue == 5) {
//新选项和原来没有重复项的情况,产品确认:只做全量增加,原有的清除 //新选项和原来没有重复项的情况,产品确认:只做全量增加,原有的清除
for (int i = 0; i < selected.length; i++) { for (int i = 0; i < selected.length; i++) {
model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i)); model.addKeyColumnNameValue(newKeyColumnNameValueList.get(i));
@ -565,8 +566,8 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
// Richie:初始化 // Richie:初始化
if (keyColumnNameValueList.isEmpty()) { if (keyColumnNameValueList.isEmpty()) {
model.removeAllKeyColumnNameValue(); model.removeAllKeyColumnNameValue();
for (int i = 0; i < selected.length; i++) { for (Object o : selected) {
model.addKeyColumnNameValue(new KeyColumnNameValue(false, (ColumnName)selected[i], new ColumnValue(""), false)); model.addKeyColumnNameValue(new KeyColumnNameValue(false, (ColumnName) o, new ColumnValue(""), false));
} }
} }
@ -579,9 +580,10 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Add_Field")); this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Add_Field"));
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
KeyColumnTableModel model = (KeyColumnTableModel)keyColumnValuesTable.getModel(); KeyColumnTableModel model = (KeyColumnTableModel) keyColumnValuesTable.getModel();
model.addKeyColumnNameValue(new KeyColumnNameValue(false, new ColumnName(""), new ColumnValue(""), false)); model.addKeyColumnNameValue(new KeyColumnNameValue(false, new ColumnName(""), new ColumnValue(""), false));
updateUpdateCheckBoxEnable(); updateUpdateCheckBoxEnable();
@ -596,6 +598,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Remove_Field")); this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_RWA_Remove_Field"));
} }
@Override
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
// DBManipulationPane target = this.getDBManipulationPane(); // DBManipulationPane target = this.getDBManipulationPane();
@ -608,7 +611,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_sure_remove_item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Remove"), JOptionPane.OK_CANCEL_OPTION, com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_sure_remove_item") + "?", com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Base_Remove"), JOptionPane.OK_CANCEL_OPTION,
JOptionPane.QUESTION_MESSAGE); JOptionPane.QUESTION_MESSAGE);
if (returnVal == JOptionPane.OK_OPTION) { if (returnVal == JOptionPane.OK_OPTION) {
KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)keyColumnValuesTable.getModel(); KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) keyColumnValuesTable.getModel();
// 把selectedRows从小到大排个序,先删大的再删小的 // 把selectedRows从小到大排个序,先删大的再删小的
java.util.Arrays.sort(selectedRows); java.util.Arrays.sort(selectedRows);
@ -632,12 +635,12 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
* 刷新columnsComboBox * 刷新columnsComboBox
*/ */
private void refreshColumnsComboBox() { private void refreshColumnsComboBox() {
DefaultComboBoxModel model = (DefaultComboBoxModel)this.columnsComboBox.getModel(); DefaultComboBoxModel model = (DefaultComboBoxModel) this.columnsComboBox.getModel();
model.removeAllElements(); model.removeAllElements();
ColumnName[] columnNames = currentColumnNames(); ColumnName[] columnNames = currentColumnNames();
for (int i = 0; i < columnNames.length; i++) { for (ColumnName columnName : columnNames) {
model.addElement(columnNames[i]); model.addElement(columnName);
} }
} }
@ -673,11 +676,12 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
columnsComboBox = new UIComboBox(new DefaultComboBoxModel()); columnsComboBox = new UIComboBox(new DefaultComboBoxModel());
columnsComboBox.setRenderer(new UIComboBoxRenderer() { columnsComboBox.setRenderer(new UIComboBoxRenderer() {
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
if (value instanceof ColumnName) { if (value instanceof ColumnName) {
this.setText(((ColumnName)value).name); this.setText(((ColumnName) value).name);
} }
return this; return this;
@ -685,20 +689,18 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
}); });
column1.setCellEditor(new DefaultCellEditor(columnsComboBox) { column1.setCellEditor(new DefaultCellEditor(columnsComboBox) {
@Override
public boolean stopCellEditing() { public boolean stopCellEditing() {
if (super.stopCellEditing()) { return super.stopCellEditing();
return true;
}
return false;
} }
}); });
((DefaultCellEditor)column1.getCellEditor()).setClickCountToStart(2); ((DefaultCellEditor) column1.getCellEditor()).setClickCountToStart(2);
//设置Column 2的Editor //设置Column 2的Editor
column2.setCellEditor(new ColumnValueEditor()); column2.setCellEditor(new ColumnValueEditor());
} }
@Override
public void populateBean(DBManipulation dbManipulation) { public void populateBean(DBManipulation dbManipulation) {
if (dbManipulation == null) { if (dbManipulation == null) {
dbManipulation = new DBManipulation(); dbManipulation = new DBManipulation();
@ -750,7 +752,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
} }
private void populateKeyColumnValueTable(DMLConfig dmlConfig) { private void populateKeyColumnValueTable(DMLConfig dmlConfig) {
KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)this.keyColumnValuesTable.getModel(); KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) this.keyColumnValuesTable.getModel();
keyColumnNameValueTableModel.removeAllKeyColumnNameValue(); keyColumnNameValueTableModel.removeAllKeyColumnNameValue();
if (dmlConfig != null) { if (dmlConfig != null) {
@ -766,7 +768,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
String columnName = column.getColumnName(); String columnName = column.getColumnName();
if (!acceptPara && column.getColumnValue() instanceof Parameter) { if (!acceptPara && column.getColumnValue() instanceof Parameter) {
// 表单中,将以前的参数转换为公式 // 表单中,将以前的参数转换为公式
column.setColumnValue(BaseFormula.createFormulaBuilder().build(((Parameter)column.getColumnValue()).getName())); column.setColumnValue(BaseFormula.createFormulaBuilder().build(((Parameter) column.getColumnValue()).getName()));
} }
KeyColumnNameValue newColumnNameValue = new KeyColumnNameValue(column.isKey(), new ColumnName(columnName), new ColumnValue(column.getColumnValue()), KeyColumnNameValue newColumnNameValue = new KeyColumnNameValue(column.isKey(), new ColumnName(columnName), new ColumnValue(column.getColumnValue()),
@ -782,6 +784,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
} }
} }
@Override
public DBManipulation updateBean() { public DBManipulation updateBean() {
DataBaseItems para = chooseTable.updateBean(true); DataBaseItems para = chooseTable.updateBean(true);
DBManipulation dbMani = new DBManipulation(); DBManipulation dbMani = new DBManipulation();
@ -801,19 +804,19 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
dmlConfig.setTable(new Table(para.getSchemaName(), para.getTableName())); dmlConfig.setTable(new Table(para.getSchemaName(), para.getTableName()));
KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel)this.keyColumnValuesTable.getModel(); KeyColumnTableModel keyColumnNameValueTableModel = (KeyColumnTableModel) this.keyColumnValuesTable.getModel();
int rowCount = keyColumnNameValueTableModel.keyColumnNameValueList.size(); int rowCount = keyColumnNameValueTableModel.keyColumnNameValueList.size();
for (int i = 0; i < rowCount; i++) { for (int i = 0; i < rowCount; i++) {
KeyColumnNameValue newKeyColumnNameValue = keyColumnNameValueTableModel.keyColumnNameValueList.get(i); KeyColumnNameValue newKeyColumnNameValue = keyColumnNameValueTableModel.keyColumnNameValueList.get(i);
// peter:先添加key column name. // peter:先添加key column name.
dmlConfig.addColumnConfig(new ColumnConfig(newKeyColumnNameValue.cn.name, newKeyColumnNameValue.cv.obj, newKeyColumnNameValue.isKey,false)); dmlConfig.addColumnConfig(new ColumnConfig(newKeyColumnNameValue.cn.name, newKeyColumnNameValue.cv.obj, newKeyColumnNameValue.isKey, false));
} }
dmlConfig.setUpdateSelected(UpdateCheckBox.isSelected()); dmlConfig.setUpdateSelected(UpdateCheckBox.isSelected());
if (jobs != null) { if (jobs != null) {
for (int i = 0; i < jobs.length; i++) { for (NameSubmitJob job : jobs) {
dmlConfig.addSubmitJob(jobs[i]); dmlConfig.addSubmitJob(job);
} }
} }
dmlConfig.setCondition(condition); dmlConfig.setCondition(condition);
@ -840,6 +843,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Values_Editor"); return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Values_Editor");
} }
@Override
public void populateBean(Object object) { public void populateBean(Object object) {
vPane.populate(object); vPane.populate(object);
} }
@ -855,55 +859,67 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
* alex:ColumnValue的编辑器,弹出对话框来编辑...个人觉得不大好 * alex:ColumnValue的编辑器,弹出对话框来编辑...个人觉得不大好
*/ */
protected class ColumnValueEditor extends AbstractCellEditor implements TableCellEditor { protected class ColumnValueEditor extends AbstractCellEditor implements TableCellEditor {
/** The Swing component being edited. */ /**
private UILabel textLabel; * The Swing component being edited.
private ValuePane vPane; */
private BasicDialog vPaneDLG; private final UILabel textLabel;
private final ValuePane vPane;
protected ColumnValueEditor() { protected ColumnValueEditor() {
this(v_Types); this(v_Types);
} }
/**
* 列值编辑器
*
* @param types 编辑器类型
*/
protected ColumnValueEditor(Editor<?>[] types) { protected ColumnValueEditor(Editor<?>[] types) {
textLabel = new UILabel(); textLabel = new UILabel();
textLabel.addMouseListener(new MouseAdapter() { DialogActionAdapter adapter = new DialogActionAdapter() {
public void mousePressed(MouseEvent e) { @Override
vPaneDLG.setAlwaysOnTop(true);
vPaneDLG.setVisible(true);
}
});
vPane = new ValuePane(types);
vPaneDLG = vPane.showSmallWindow(new JFrame(), new DialogActionAdapter() {
public void doOk() { public void doOk() {
fireEditingStopped(); // Make the renderer fireEditingStopped(); // Make the renderer
// reappear. // reappear.
updateUpdateCheckBoxEnable(); updateUpdateCheckBoxEnable();
} }
@Override
public void doCancel() { public void doCancel() {
fireEditingCanceled(); fireEditingCanceled();
} }
};
textLabel.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
Window window = e.getComponent() == null
? DesignerContext.getDesignerFrame()
: SwingUtilities.getWindowAncestor(e.getComponent());
vPane.showSmallWindow(window, adapter)
.setVisible(true);
}
}); });
vPane = new ValuePane(types);
} }
/* /*
* 双击以编辑 * 双击以编辑
*/ */
@Override
public boolean isCellEditable(EventObject anEvent) { public boolean isCellEditable(EventObject anEvent) {
if (anEvent instanceof MouseEvent) { if (anEvent instanceof MouseEvent) {
return ((MouseEvent)anEvent).getClickCount() >= 2; return ((MouseEvent) anEvent).getClickCount() >= 2;
} }
return true; return true;
} }
@Override
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
if (value instanceof ColumnValue) { if (value instanceof ColumnValue) {
vPane.populateBean(((ColumnValue)value).obj); vPane.populateBean(((ColumnValue) value).obj);
if (((ColumnValue)value).obj != null) { if (((ColumnValue) value).obj != null) {
textLabel.setText(((ColumnValue)value).obj.toString()); textLabel.setText(((ColumnValue) value).obj.toString());
} else { } else {
textLabel.setText(""); textLabel.setText("");
} }
@ -912,6 +928,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
return textLabel; return textLabel;
} }
@Override
public Object getCellEditorValue() { public Object getCellEditorValue() {
return new ColumnValue(vPane.updateBean()); return new ColumnValue(vPane.updateBean());
} }
@ -924,12 +941,13 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
this.name = name; this.name = name;
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (!(obj instanceof ColumnName)) { if (!(obj instanceof ColumnName)) {
return false; return false;
} }
return ComparatorUtils.equals(this.name, ((ColumnName)obj).name); return ComparatorUtils.equals(this.name, ((ColumnName) obj).name);
} }
@Override @Override
@ -945,16 +963,17 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
this.obj = obj; this.obj = obj;
} }
public Object getObj(){ public Object getObj() {
return obj; return obj;
} }
@Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (!(obj instanceof ColumnValue)) { if (!(obj instanceof ColumnValue)) {
return false; return false;
} }
return ComparatorUtils.equals(this.obj, ((ColumnValue)obj).obj); return ComparatorUtils.equals(this.obj, ((ColumnValue) obj).obj);
} }
@Override @Override
@ -998,14 +1017,17 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
} }
} }
@Override
public String getColumnName(int col) { public String getColumnName(int col) {
return COLUMN_NAMES[col]; return COLUMN_NAMES[col];
} }
@Override
public int getColumnCount() { public int getColumnCount() {
return COLUMN_NAMES.length; return COLUMN_NAMES.length;
} }
@Override
public int getRowCount() { public int getRowCount() {
return keyColumnNameValueList.size(); return keyColumnNameValueList.size();
} }
@ -1034,12 +1056,13 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
} }
} }
protected static class KeyColumnValueTableModel extends KeyColumnTableModel implements Cloneable{ protected static class KeyColumnValueTableModel extends KeyColumnTableModel implements Cloneable {
public KeyColumnValueTableModel(KeyColumnTableModel model) { public KeyColumnValueTableModel(KeyColumnTableModel model) {
super(model); super(model);
} }
@Override
public Object getValueAt(int row, int col) { public Object getValueAt(int row, int col) {
KeyColumnNameValue knv = keyColumnNameValueList.get(row); KeyColumnNameValue knv = keyColumnNameValueList.get(row);
@ -1054,18 +1077,20 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
return null; return null;
} }
@Override
public void setValueAt(Object value, int row, int col) { public void setValueAt(Object value, int row, int col) {
KeyColumnNameValue knv = keyColumnNameValueList.get(row); KeyColumnNameValue knv = keyColumnNameValueList.get(row);
if (col == 0 && value instanceof Boolean) { if (col == 0 && value instanceof Boolean) {
knv.isKey = ((Boolean)value).booleanValue(); knv.isKey = ((Boolean) value).booleanValue();
} else if (col == 1 && value instanceof ColumnName) { } else if (col == 1 && value instanceof ColumnName) {
knv.cn = (ColumnName)value; knv.cn = (ColumnName) value;
} else if (col == 2 && value instanceof ColumnValue) { } else if (col == 2 && value instanceof ColumnValue) {
knv.cv = (ColumnValue)value; knv.cv = (ColumnValue) value;
} }
} }
@Override
public Class<?> getColumnClass(int c) { public Class<?> getColumnClass(int c) {
switch (c) { switch (c) {
case 0: case 0:
@ -1078,6 +1103,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
return String.class; return String.class;
} }
@Override
public boolean isCellEditable(int row, int col) { public boolean isCellEditable(int row, int col) {
return true; return true;
} }
@ -1094,7 +1120,6 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
} }
public static class KeyColumnNameValue { public static class KeyColumnNameValue {
private boolean isKey = false; private boolean isKey = false;
private ColumnName cn; private ColumnName cn;
@ -1111,6 +1136,7 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
* *
* @return 字符串z * @return 字符串z
*/ */
@Override
public String toString() { public String toString() {
return (isKey ? "* " : "") + cn + ":" + cv; return (isKey ? "* " : "") + cn + ":" + cv;
} }
@ -1124,12 +1150,13 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
/* /*
* ColumnNameTableCellRenderer * ColumnNameTableCellRenderer
*/ */
public class ColumnNameTableCellRenderer extends DefaultTableCellRenderer { public static class ColumnNameTableCellRenderer extends DefaultTableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof ColumnName) { if (value instanceof ColumnName) {
this.setText(((ColumnName)value).name); this.setText(((ColumnName) value).name);
} }
return this; return this;
@ -1139,16 +1166,17 @@ public class DBManipulationPane extends BasicBeanPane<DBManipulation> {
/* /*
* ColumnValueTableCellRenderer * ColumnValueTableCellRenderer
*/ */
private class ColumnValueTableCellRenderer extends DefaultTableCellRenderer { private static class ColumnValueTableCellRenderer extends DefaultTableCellRenderer {
@Override
public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) { public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column); super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
if (value instanceof ColumnValue) { if (value instanceof ColumnValue) {
if (((ColumnValue)value).obj != null) { if (((ColumnValue) value).obj != null) {
if (((ColumnValue)value).obj instanceof Date) { if (((ColumnValue) value).obj instanceof Date) {
this.setText(DateUtils.DATEFORMAT2.format(((ColumnValue)value).obj)); this.setText(DateUtils.DATEFORMAT2.format(((ColumnValue) value).obj));
} else { } else {
this.setText(((ColumnValue)value).obj.toString()); this.setText(((ColumnValue) value).obj.toString());
} }
} else { } else {
this.setText(""); this.setText("");

4
designer-realize/src/main/java/com/fr/design/write/submit/SmartInsertDBManipulationPane.java

@ -456,7 +456,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
newAdd.clear(); newAdd.clear();
for (int i = 0; i < cs; i++) { for (int i = 0; i < cs; i++) {
for (int j = 0; j < rs; j++) { for (int j = 0; j < rs; j++) {
TemplateCellElement cellElement = ePane.getEditingElementCase().getTemplateCellElement(c + i, r + j ); TemplateCellElement cellElement = ePane.getEditingElementCase().getTemplateCellElement(c + i, r + j);
if (cellElement != null && ((i + c) != 0 || (r + j) != 0)) { if (cellElement != null && ((i + c) != 0 || (r + j) != 0)) {
String value = cellElement.toString(); String value = cellElement.toString();
if (!newAdd.contains(value) && !allColumnRow.contains(value)) { if (!newAdd.contains(value) && !allColumnRow.contains(value)) {
@ -512,7 +512,7 @@ public class SmartInsertDBManipulationPane extends DBManipulationPane {
private SmartJTablePaneAction a = new AbstractSmartJTablePaneAction(this, SmartInsertDBManipulationPane.this) { private SmartJTablePaneAction a = new AbstractSmartJTablePaneAction(this, SmartInsertDBManipulationPane.this) {
@Override @Override
public void doOk() { public void doOk() {
((KeyColumnTableModel)keyColumnValuesTable.getModel()).refreshNameValueList((KeyColumnTableModel)model); ((KeyColumnTableModel) keyColumnValuesTable.getModel()).refreshNameValueList((KeyColumnTableModel) model);
} }
@Override @Override

Loading…
Cancel
Save