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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package com.vci.client.uif.engine.client.tableArea.editable.editor;
 
import java.awt.Component;
import java.util.List;
 
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.JTextField;
 
import com.vci.client.ui.swing.components.table.VCIJTableNode;
import com.vci.client.uif.engine.client.controls.ControlFactory;
import com.vci.client.uif.engine.client.controls.DateControl;
import com.vci.client.uif.engine.client.controls.DateTimeControl;
import com.vci.client.uif.engine.client.controls.TimeControl;
import com.vci.client.uif.engine.common.IDataNode;
 
/**
 * 时间类型列的编辑器对象
 * @author xiongchao
 *
 */
public class DateTimeCellEditor extends CustomControlEditor {
 
    /**
     * 
     */
    private static final long serialVersionUID = 8345901497753591770L;
 
    public DateTimeCellEditor(JTextField textField) {
        super(textField);
    }
    
    private DateTimeControl dt = null;
    @Override
    public Component getTableCellEditorComponent(JTable table, Object value,
             boolean isSelected,
             int row, int column) {        
        if(dt == null){
            Component compt = ControlFactory.createControl(getPrmItem());
            if(compt instanceof DateTimeControl){
                dt = (DateTimeControl)compt;
            } else if(compt instanceof DateControl){
                dt = (DateControl)compt;
            } else if(compt instanceof TimeControl){
                dt = (TimeControl)compt;
            }
            dt.getCalPal().addPropertyChangeListener(this);
        }
        if(value != null){
            dt.setValue(value.toString());
        }
        Component compt = super.getTableCellEditorComponent(table, value, isSelected, row, column);
        compt = dt;
        return compt;
    }
 
    @Override
    public Object getCellEditorValue() {
        Object res = null;
        if(dt != null){
            res = dt.getValue();
        }
        return res;
    }
    
    @Override
    protected boolean checkValueChanged(){
        Object newValueObj = getCellEditorValue();
        if(newValueObj == null){
            return false;
        }
        String newValue = newValueObj.toString();
        boolean changed = !tablePanel.getOldValue().equals(newValue);
        tablePanel.setChanged(changed);
        return changed;
    }
 
}