ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
package com.vci.client.auth2.view;
 
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.util.ArrayList;
import java.util.List;
 
import javax.swing.JCheckBox;
import javax.swing.JPanel;
 
import com.vci.client.auth2.vo.OpItem;
 
public class RelationAndLifeCycleOpPanel extends JPanel {
    /**
     * 
     */
    private static final long serialVersionUID = 5604599597365546210L;
    private int column = 4;
 
    public RelationAndLifeCycleOpPanel() {
        super();
    }
 
    private String[] operations;
 
    public String[] getOperations() {
        return operations;
    }
    //add by caill start 2015.1.6
    private String[] operationsChina;
 
    public String[] operationsChina() {
        return operationsChina;
    }
    public void setOperations(String[] operations, String[] operationsChina) {    //2016.1.6添加参数
        this.operations = operations;
        this.operationsChina = operationsChina;  //获取传递过来的存放有中文值的list
        updateOperation();
    }
    //add by caill end
 
    public OpItem[] getOpObject() {
        List<OpItem> ops = new ArrayList<OpItem>();
        JCheckBox[] checkBoxs = getOpCheckBoxs();
        for (JCheckBox cb : checkBoxs) {
            OpItem op = new OpItem();
            //op.setName(cb.getText());
            //op.setName("测试");
            //add by caill start 2015.1.6 将英文值从ActionCommand中取出存放到数据库中
            if(cb.getActionCommand().toString() != null && cb.getActionCommand().toString().trim() != ""){
                op.setName(cb.getActionCommand());
            }else{
                op.setName(cb.getText());    //跃迁的英文值还是从text中取出
            }
            //add by caill end
            op.setValue(cb.isSelected());
            if (!ops.contains(op)) {
                ops.add(op);
            }
        }
        return ops.toArray(new OpItem[ops.size()]);
    }
 
    // 链接和状态面板授权控件
    public JCheckBox[] getOpCheckBoxs() {
        Component[] comps = (Component[]) this.getComponents();
        JCheckBox[] checkBoxs = new JCheckBox[comps.length];
        int i = 0;
        for (Component comp : comps) {
            checkBoxs[i] = (JCheckBox) comp;
            ++i;
        }
        return checkBoxs;
    }
    //add by caill start 2015.1.6 将关系和跃迁区域的值以中文的形式显示出来
    public void updateOperation() {
        int x = 0;
        int y = 0;
        for (int i = 0; i < operations.length; i++) {
            JCheckBox cb = new JCheckBox();    
            if(i >= operationsChina.length ){
                cb.setText(operations[i]);        //跃迁的直接显示原来的英文即可
            }else{
                cb.setText(operationsChina[i]);
                cb.setActionCommand(operations[i]);
                //System.out.println(cb.getActionCommand());
            }
            GridBagConstraints g_mpnl = new GridBagConstraints();
            g_mpnl.insets = new Insets(10, 10, 10, 10);
            g_mpnl.anchor = GridBagConstraints.WEST;
            g_mpnl.gridx = x++;
            g_mpnl.gridy = y;
            if ((i + 1) % column == 0 ) {
                ++y;
                x = 0;
            }
            this.add(cb, g_mpnl);
        }
         this.updateUI();
    }
    //add by caill end
    /*public void updateOperation() {
        int x = 0;
        int y = 0;
        for (int i = 0; i < operations.length; i++) {
            JCheckBox cb = new JCheckBox(operations[i]);
            JCheckBox cb = new JCheckBox();
            cb.setText("test"+i);
            GridBagConstraints g_mpnl = new GridBagConstraints();
            g_mpnl.insets = new Insets(10, 10, 10, 10);
            g_mpnl.anchor = GridBagConstraints.WEST;
            g_mpnl.gridx = x++;
            g_mpnl.gridy = y;
 
 
            if ((i + 1) % column == 0 ) {
                ++y;
                x = 0;
            }
            this.add(cb, g_mpnl);
        }
         this.updateUI();
    }*/
 
    public int getColumn() {
        return column;
    }
 
    public void setColumn(int column) {
        this.column = column;
    }
}