1
zhanghua
2024-09-26 c775c6953d9759e70f08acbfa8f6d7490aaae3d1
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
package com.netsdk.demo.customize.courseRecord.frame;
 
import com.netsdk.demo.customize.courseRecord.pojo.CourseInfo;
import com.netsdk.demo.util.DateChooserJButton;
import com.netsdk.lib.structure.NET_TIME;
 
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
 
public class CourseDetailDialog extends JDialog {
 
    private final JPanel contentPanel = new JPanel();
 
    public JTextField szNameField;         // 课程名称
    public JTextField szTeacherField;      // 教师名称
    public JTextArea szInfoTextArea;       // 课程介绍
    public JComboBox cbxRecord;            // 录制播放模式
    public JComboBox cbxCompose;           // 合成通道模式
    public JPanel dateStartPanel;
    public JPanel dateEndPanel;
    public DateChooserJButton dateChooserStartJButton;
    public DateChooserJButton dateChooserEndJButton;
    public JRadioButton resourceRadioButton;
 
    private JButton okButton;
    private JButton cancelButton;
 
    public CourseInfo courseInfo;  // 保存课程信息
 
    private CourseRecordMainFrame mainFrame;   // 父窗口
 
    /**
     * Create the dialog.
     */
    public CourseDetailDialog(CourseRecordMainFrame frame) {
        this.mainFrame = frame;
        setTitle("课程详情");
        setBounds(100, 100, 569, 442);
        getContentPane().setLayout(new BorderLayout());
        contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
        getContentPane().add(contentPanel, BorderLayout.CENTER);
        contentPanel.setLayout(null);
        {
            JLabel lblSzName = new JLabel("课程名称: ");
            lblSzName.setBounds(31, 23, 81, 15);
            contentPanel.add(lblSzName);
        }
        {
            JLabel lblSzTeacher = new JLabel("教师姓名:");
            lblSzTeacher.setBounds(31, 58, 81, 15);
            contentPanel.add(lblSzTeacher);
        }
        {
            JLabel lblSzInfo = new JLabel("简    介:");
            lblSzInfo.setBounds(31, 95, 81, 15);
            contentPanel.add(lblSzInfo);
        }
        {
            szNameField = new JTextField();
            szNameField.setBounds(116, 20, 180, 21);
            contentPanel.add(szNameField);
            szNameField.setColumns(10);
        }
        {
            szTeacherField = new JTextField();
            szTeacherField.setColumns(10);
            szTeacherField.setBounds(116, 55, 180, 21);
            contentPanel.add(szTeacherField);
        }
 
        szInfoTextArea = new JTextArea();
        szInfoTextArea.setBounds(116, 91, 412, 108);
        contentPanel.add(szInfoTextArea);
 
        JLabel lblStartTime = new JLabel("开始时间:");
        lblStartTime.setBounds(31, 223, 81, 15);
        contentPanel.add(lblStartTime);
 
        JLabel lblEndTime = new JLabel("结束时间:");
        lblEndTime.setBounds(31, 260, 81, 15);
        contentPanel.add(lblEndTime);
 
        JLabel lblEmCompose = new JLabel("视频控制:");
        lblEmCompose.setBounds(31, 297, 81, 15);
        contentPanel.add(lblEmCompose);
 
        cbxCompose = new JComboBox();
        cbxCompose.setModel(new DefaultComboBoxModel(new String[]{"直播", "录制", "录播"}));
        cbxCompose.setBounds(115, 294, 181, 21);
        contentPanel.add(cbxCompose);
 
        JLabel lblEmRecord = new JLabel("录制模式:");
        lblEmRecord.setBounds(31, 337, 81, 15);
        contentPanel.add(lblEmRecord);
 
        cbxRecord = new JComboBox();
        cbxRecord.setModel(new DefaultComboBoxModel(new String[]{"电影模式", "多画面模式"}));
        cbxRecord.setSelectedIndex(0);
        cbxRecord.setBounds(116, 334, 180, 21);
        contentPanel.add(cbxRecord);
 
        dateStartPanel = new JPanel();
        dateStartPanel.setBounds(116, 223, 180, 21);
        contentPanel.add(dateStartPanel);
        dateStartPanel.setLayout(new BorderLayout(0, 0));
 
        dateChooserStartJButton = new DateChooserJButton();
        dateStartPanel.add(dateChooserStartJButton, BorderLayout.CENTER);
 
        dateEndPanel = new JPanel();
        dateEndPanel.setBounds(116, 254, 180, 21);
        contentPanel.add(dateEndPanel);
        dateEndPanel.setLayout(new BorderLayout(0, 0));
 
        dateChooserEndJButton = new DateChooserJButton();
        dateEndPanel.add(dateChooserEndJButton, BorderLayout.CENTER);
 
        resourceRadioButton = new JRadioButton("操作资源通道");
        resourceRadioButton.setBounds(327, 291, 157, 27);
        contentPanel.add(resourceRadioButton);
        {
            JPanel buttonPane = new JPanel();
            buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
            getContentPane().add(buttonPane, BorderLayout.SOUTH);
            {
                okButton = new JButton("确认");
                okButton.setActionCommand("OK");
                buttonPane.add(okButton);
                getRootPane().setDefaultButton(okButton);
                okButton.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        getCourseInfo();
                        Dialog owner = (Dialog) SwingUtilities.getWindowAncestor(okButton);
                        owner.setVisible(false);
                    }
                });
            }
            {
                cancelButton = new JButton("取消");
                cancelButton.setActionCommand("Cancel");
                buttonPane.add(cancelButton);
                cancelButton.addActionListener(new ActionListener() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                        courseInfo = null;
                        Dialog owner = (Dialog) SwingUtilities.getWindowAncestor(cancelButton);
                        owner.setVisible(false);
                    }
                });
            }
        }
        this.setModalityType(ModalityType.APPLICATION_MODAL);
    }
 
    // 载入窗体时写入旧的数据
    public void fillCourseInfo(CourseInfo info) {
        courseInfo = info;
        szNameField.setText(courseInfo.courseName);         // 课程名称
        szTeacherField.setText(courseInfo.teacherName);     // 教师名称
        szInfoTextArea.setText(courseInfo.introduction);    // 课程介绍
 
        dateStartPanel.remove(dateChooserStartJButton);
        dateChooserStartJButton = new DateChooserJButton(info.stuStartTime.toStringTimeEx());
        dateStartPanel.add(dateChooserStartJButton, BorderLayout.CENTER);
 
        dateEndPanel.remove(dateChooserEndJButton);
        dateChooserEndJButton = new DateChooserJButton(info.stuEndTime.toStringTimeEx());
        dateEndPanel.add(dateChooserEndJButton, BorderLayout.CENTER);
 
        cbxRecord.setSelectedItem(courseInfo.strCompositeChannelMode);      // 播放模式
        cbxCompose.setSelectedItem(courseInfo.strVideoCtrlType);            // 合成模式
        resourceRadioButton.setSelected(courseInfo.containsResource);       // 是否是资源模式
    }
 
    // 读取当前页面上填写的数据
    private void getCourseInfo() {
        if (courseInfo == null) courseInfo = new CourseInfo();
 
        String[] startDateTimes = dateChooserStartJButton.getOriginalText().split("\\s+");
        String[] startDate = startDateTimes[0].split("-");
        String[] startTime = startDateTimes[1].split(":");
        courseInfo.stuStartTime = new NET_TIME(
                Integer.parseInt(startDate[0]),
                Integer.parseInt(startDate[1]),
                Integer.parseInt(startDate[2]),
                Integer.parseInt(startTime[0]),
                Integer.parseInt(startTime[1]),
                Integer.parseInt(startTime[2])
        );
 
        String[] endDateTimes = dateChooserEndJButton.getOriginalText().split("\\s+");
        String[] endDate = endDateTimes[0].split("-");
        String[] endTime = endDateTimes[1].split(":");
        courseInfo.stuEndTime = new NET_TIME(
                Integer.parseInt(endDate[0]),
                Integer.parseInt(endDate[1]),
                Integer.parseInt(endDate[2]),
                Integer.parseInt(endTime[0]),
                Integer.parseInt(endTime[1]),
                Integer.parseInt(endTime[2])
        );
        courseInfo.SetStrCourseDateTime();
        courseInfo.courseName = szNameField.getText().trim();
        courseInfo.teacherName = szTeacherField.getText().trim();
        courseInfo.introduction = szInfoTextArea.getText().trim();
 
        // 这里对应的是页面上两个下拉框的枚举,并不是接口的参数,所以需要转换下
        courseInfo.strCompositeChannelMode = (String) cbxRecord.getSelectedItem();
        courseInfo.strVideoCtrlType = (String) cbxCompose.getSelectedItem();
        // 这里暂时不区分具体挑选哪一个资源通道,所有的资源通道统一处理
        courseInfo.containsResource = resourceRadioButton.isSelected();
        courseInfo.ParseStrCompositeMode();
        courseInfo.ParseStrVideoCtrl();
    }
}