yuxc
2025-01-15 c09f81131e8b7c83937206d7cf76f34d2020be75
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package com.vci.client.workflow.editor.ui;
 
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
 
import javax.swing.table.AbstractTableModel;
 
import com.vci.client.workflow.commom.ClientHelper;
import com.vci.corba.workflow.data.PropertyInfo;
 
public class CustomClassTableModel extends AbstractTableModel {
    
    private static final long serialVersionUID = -655431475234368469L;
    
    private String[] columns = {"事件名称"};
    private List<PropertyInfo> data;
    
    public CustomClassTableModel() {
        data = new ArrayList<PropertyInfo>();
    }
    
    public void setData(List<PropertyInfo> data) {
        this.data = data;
        fireTableDataChanged();
    }
    
    public void addRow() {
        if(data.size()==0){
            data = new ArrayList<PropertyInfo>();
        }
        data.add(new PropertyInfo());
        fireTableDataChanged();
    }
    
    public void addRow(PropertyInfo info) {
        data.add(info);
        fireTableDataChanged();
    }
    
    public void deleteRow(int[] selectedRows) {
        for (int i = selectedRows.length - 1; i >= 0 ; i--) {
            data.remove(selectedRows[i]);
        }
        fireTableDataChanged();
    }
 
    public int getRowCount() {
        if(data == null) {
            return 0;
        }
        return data.size();
    }
 
    public int getColumnCount() {
        return columns.length;
    }
 
    public Object getValueAt(int rowIndex, int columnIndex) {
        if(data == null) {
            return null;
        }
        PropertyInfo propertyInfo = data.get(rowIndex);
        if(propertyInfo==null){
            return null;
        }
            if(columnIndex == 0) {
                return propertyInfo.property;
            }else{
                return propertyInfo.value;
            }
//        }
//        return null;
    }
    
    @Override
    public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
        PropertyInfo propertyInfo = data.get(rowIndex);
        switch (columnIndex) {
            case 0:
                propertyInfo.property = ((PropertyObject)aValue).getValue();
                break;
            default:
                propertyInfo.value = ((PropertyObject)aValue).getValue();
                break;
        }
    }
    
    @Override
    public Class<?> getColumnClass(int columnIndex) {
        return String.class;
    }
    
    @Override
    public String getColumnName(int column) {
        return columns[column];
    }
    
    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return true;
    }
    
    public List<PropertyInfo> getData() {
        return data;
    }
    
    private String getI18nString(String code){
        return ClientHelper.getI18nStringForWorkflow(this.getClass().getName() + "." + code, Locale.getDefault());
    }
 
}