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
134
package com.vci.client.portal.Formdesign.util;
 
import java.awt.Dimension;
 
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.JTextField;
 
import com.vci.client.portal.Formdesign.object.CompnentGroup;
import com.vci.client.portal.Formdesign.widget.FileChooserJPanel;
import com.vci.client.portal.Formdesign.widget.TextButtonJPanel;
import com.vci.client.ui.swing.components.VCIJCalendarPanel;
import com.vci.client.ui.swing.components.VCIJComboBox;
import com.vci.common.portal.enums.ControlType;
 
public class CompnentUtil {
 
    public static void CreateCompent(CompnentGroup group, ControlType ctrlType) {
        
        JLabel labelCom = group.getjLabel();
        
        if (labelCom == null) {
            labelCom = new JLabel(group.getField());
            labelCom.setName(group.getField());
        }
        
        //CanzhaoJPanel cz = new CanzhaoJPanel();
        if (ctrlType == null)
            ctrlType = ControlType.Text;
        
        switch (ctrlType)
        {
        case Text:
        case Password:
        case Number:
        case Hidden:
            {
                JTextField textField = new JTextField();
                textField.setEditable(false);
                textField.setPreferredSize(new Dimension(90, 25));
                group.setjCompnent(textField);
                group.setjLabel(labelCom);
            }
            break;
        case TextBtn:
        case Customform:
        case Custom:
        case UserChoose:
            {
                TextButtonJPanel textBtn = new TextButtonJPanel();
                textBtn.setPreferredSize(new Dimension(90, 25));
                group.setjCompnent(textBtn);
                group.setjLabel(labelCom);
            }
            break;
        case RichText:
        case TextArea:
        case WebEditor:
            {
                JTextArea textArea = new JTextArea();
                textArea.setEnabled(false);
                textArea.setEditable(false);
                
                group.setjCompnent(textArea);
                group.setjLabel(labelCom);
 
            }
            break;
        case Checkbox:
            {
                JCheckBox checkBox = new JCheckBox();
                checkBox.setEnabled(false);
                //checkBox.setText(group.getField());
                group.setjCompnent(checkBox);
                group.setjLabel(labelCom);
            }
            break;
        case Select:
            {
                VCIJComboBox comboBox = new VCIJComboBox();
                comboBox.setPreferredSize(new Dimension(90, 25));
                comboBox.setEditable(false);
                comboBox.setEnabled(false);
                group.setjCompnent(comboBox);
                group.setjLabel(labelCom);
        
            }
            break;
        case Radio:
            {
                JRadioButton radioButton = new JRadioButton();
                //radioButton.setText(group.getField());
                radioButton.setEnabled(false);
                group.setjCompnent(radioButton);
                group.setjLabel(labelCom);
                
            }
            break;
        case Date:
        case Time:
        case Datetime:
            {
                VCIJCalendarPanel calendarPanel = new VCIJCalendarPanel();
                calendarPanel.setPreferredSize(new Dimension(90, 25));
                calendarPanel.setEnabled(false);
                group.setjCompnent(calendarPanel);
                group.setjLabel(labelCom);
    
            }
            break;
        case File:
        case MultiFile:
            {
                FileChooserJPanel fileChooser = new FileChooserJPanel();
                fileChooser.setPreferredSize(new Dimension(90, 25));
                fileChooser.setEnabled(false);
                group.setjCompnent(fileChooser);
                group.setjLabel(labelCom);
                
            }
            break;
        default:
            JTextField textField = new JTextField();
            textField.setEditable(false);
            textField.setPreferredSize(new Dimension(90, 25));
            group.setjCompnent(textField);
            group.setjLabel(labelCom);
            
            break;
        }
    }
}