ludc
2024-09-14 36c2449aec5b51e5ed4e5c6841154b746060e09a
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
/**
 * @author xchao
 * @time 2012-4-26
 * @desc 
 * @version 
 * @since 
 */
package com.vci.client.ui.swing.components.table.test;
 
 
import java.util.Random;
 
import com.vci.client.ui.swing.components.table.AbstractVCIJTableDataProvider;
import com.vci.client.ui.swing.components.table.VCIJTableNode;
import com.vci.common.utility.ObjectUtility;
 
public class TestDataProvider extends AbstractVCIJTableDataProvider<TestPO> {
    private String[] specialColumns = null;
    public String[] getSpecialColumns(){
        String columnString = "编码,名称,描述,其它";
        for(int i = 0; i < 100; i++){
            columnString += ", 属性 " + String.valueOf(i + 1); 
        }
        specialColumns = columnString.split(",");
        return specialColumns;
    }
    @Override
    public Class<?>[] getClasses() {
        this.classes = super.getClasses();
        int offset = 6;
        // boolean
        this.classes[offset++] = Boolean.class;
        this.classes[offset++] = Boolean.class;
        this.classes[offset++] = Boolean.class;
        return this.classes;
    }
    public String[] getColumns() {
        return super.getColumns();
    }
 
    public int getTotal() {
        return this.total;
    }
 
    private Random randmon = new Random();
    public VCIJTableNode<TestPO> getNewRowNode(TestPO dataObj) {
        int column = 0;
        VCIJTableNode<TestPO> node = new VCIJTableNode<TestPO>(dataObj);
        String[] specialColumns = getSpecialColumns();
        node.setPropertyValue(specialColumns[column++], dataObj.getId());
        node.setPropertyValue(specialColumns[column++], dataObj.getName());
        node.setPropertyValue(specialColumns[column++], dataObj.getDesc());
        node.setPropertyValue(specialColumns[column++], dataObj.getOther());
        
        node.setPropertyValue(specialColumns[column++], Boolean.valueOf(randmon.nextBoolean()));
        node.setPropertyValue(specialColumns[column++], Boolean.valueOf(randmon.nextBoolean()));
        node.setPropertyValue(specialColumns[column++], Boolean.valueOf(randmon.nextBoolean()));
        
        for(int i = column; i < specialColumns.length; i++){
            node.setPropertyValue(specialColumns[column++], ObjectUtility.getNewObjectID36());
        }
        return node;
    }
 
    public TestPO[] getDatas(int pageIndex, int pageSize) {
        // 从数据库中查询,存储记录总数
        this.total = 10000;
        // 数据转换
        
        TestPO[] res = new TestPO[pageSize];
        for (int i = 0; i < res.length; i++) {
            TestPO po = new TestPO();
            int index = (pageIndex - 1) * pageSize + i + 1;
            String fixedValue = String.valueOf(index);
            po.setId(index);
            po.setName(ObjectUtility.getNewObjectID36());
            po.setName(fixedValue);
            po.setDesc(ObjectUtility.getNewObjectID36());
            po.setOther(ObjectUtility.getNewObjectID36());
            res[i] = po;
        }
        try {
            Thread.sleep(0);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return res;
    }
}