wangting
2024-09-27 a3e87f78ee262ca9bb7d9b0c997639d5f3295890
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package com.vci.client.uif.engine.client.tableArea.editable.editor;
 
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JTextField;
import javax.swing.event.ChangeEvent;
 
import com.vci.client.uif.engine.client.controls.VCIJComboBoxModelValueObject;
 
/**
 * 文本框、下列列表类型列的编辑器对象
 * @author xiongchao
 *
 */
public class TextFieldAndComboBoxEditor extends BaseCellEditor {
    /**
     * 
     */
    private static final long serialVersionUID = 340849736463848404L;
 
    
    public TextFieldAndComboBoxEditor(JCheckBox checkBox) {
        super(checkBox);
    }
 
    public TextFieldAndComboBoxEditor(JComboBox comboBox) {
        super(comboBox);
    }
 
    public TextFieldAndComboBoxEditor(JTextField textField) {
        super(textField);
    }
    
    @Override
    public void editingStopped(ChangeEvent e) {
        if(!checkValueChanged()) return;
        //setCellValue();
        resetSelectedCheckbox();
    }
 
    /**
     * 当前编辑的值是否发生了变更
     * @return
     */
    @Override
    protected boolean checkValueChanged(){
        Object newValueObj = getCellEditorValue();
        if(newValueObj == null){
            return false;
        }
        String newValue = newValueObj.toString();
        if(newValueObj instanceof VCIJComboBoxModelValueObject){
            newValue = ((VCIJComboBoxModelValueObject)newValueObj).getName();
        }
        boolean changed = !tablePanel.getOldValue().equals(newValue);
        tablePanel.setChanged(changed);
        return changed;
    }
    
}