📄 attempnewpanel.java
字号:
/**
* <p>Title: 卓博营运支撑系统</p>
*
* <p>Description: 为本企业内部运作提供支撑,为企业資源的E化管理提供解決方案</p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: 卓博信息科技有限公司</p>
*
* @author Henry
* @version 1.0
*/
package com.jobcn.ui;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Calendar;
import javax.swing.*;
import com.jobcn.control.Common;
import com.jobcn.control.Constant;
public class AttempNewPanel extends JDialog {
/**
* Create the panel
*/
public AttempNewPanel(final AttempPanel parent) {
super(parent.getTaskDialog(), "新建调度", true);
this.parent = parent;
createContent();
addListener();
}
public void updateUIAndData(String[] values) {
Calendar now = Calendar.getInstance();
String today = Common.getDateString(now.getTime(), "yyyy-MM-dd HH:mm");
int theHour = now.get(Calendar.HOUR_OF_DAY);
int theMinute = now.get(Calendar.MINUTE);
if (values == null) { // 新建调度时更新值
idStr = String.valueOf(parent.getTable().getRowCount()+1);
attempName.setText("");
execCode = 3;
repeatAttemp.setSelected(true);
intervalType = "每天";
createDate = today;
updateDate = "";
execDate.setText(today.substring(0, 10));
execHour.setValue(theHour);
execMinute.setValue(theMinute);
intervalCode = 1;
anyDayRadio.setSelected(true);
anyDayJI.setValue(1);
anyDayJI.setEnabled(true);
anyWeekJI.setValue(1);
anyMonthSelectCode = 1;
anyMonthSelectDay.setSelected(true);
anyDayOfMonthJI.setValue(1);
anyDayOfMonthJI.setEnabled(false);
anyWeekOfMonthJI.setSelectedIndex(0);
anyDayOfWeekJI.setSelectedIndex(0);
hourOrMinuteJI.setValue(1);
hourOrMinute.setSelectedIndex(0);
endTypeCode = 1;
endTime.setSelected(true);
endHour.setValue(theHour);
endMinute.setValue(theMinute);
periodHour.setValue(0);
periodMinute.setValue(0);
startDate.setText(today.substring(0, 10));
startHour.setValue(theHour);
startMinute.setValue(theMinute);
endDateCode = 2;
noEnd.setSelected(true);
endDate.setText(today.substring(0, 10));
setSelectWeeks("");
setSelectMonths("");
anyWeekLabel.setText("");
anyMonthLabel.setText("");
enable.setSelected(false);
selectWeek.setEnabled(false);
selectMonth.setEnabled(false);
}
else { // 编辑调度时更新值
idStr = values[0];
attempName.setText(values[1]);
execCode = Integer.parseInt(values[2]);
selectAttemp(execCode);
intervalType = values[3];
createDate = values[4];
updateDate = values[5];
execDate.setText(values[6]);
execHour.setValue(Integer.parseInt(values[7]));
execMinute.setValue(Integer.parseInt(values[8]));
intervalCode = Integer.parseInt(values[9]);
anyDayJI.setValue(Integer.parseInt(values[10]));
anyWeekJI.setValue(Integer.parseInt(values[11]));
anyMonthSelectCode = Integer.parseInt(values[12]);
anyDayOfMonthJI.setValue(Integer.parseInt(values[13]));
anyWeekOfMonthJI.setSelectedIndex(Integer.parseInt(values[14]));
anyDayOfWeekJI.setSelectedIndex(Integer.parseInt(values[15]));
hourOrMinuteJI.setValue(Integer.parseInt(values[16]));
hourOrMinute.setSelectedIndex(Integer.parseInt(values[17]));
endTypeCode = Integer.parseInt(values[18]);
endHour.setValue(Integer.parseInt(values[19]));
endMinute.setValue(Integer.parseInt(values[20]));
periodHour.setValue(Integer.parseInt(values[21]));
periodMinute.setValue(Integer.parseInt(values[22]));
startDate.setText(values[23]);
startHour.setValue(Integer.parseInt(values[24]));
startMinute.setValue(Integer.parseInt(values[25]));
endDateCode = Integer.parseInt(values[26]);
endDate.setText(values[27]);
setSelectWeeks(values[28]);
setSelectMonths(values[29]);
enable.setSelected(Boolean.parseBoolean(values[30]));
String[] dayNums = values[28].split(",");
String[] monthNums = values[29].split(",");
String weekText="<html><font color=red>", monthText="<html><font color=red>";
int count=0;
for(int i=0;i<dayNums.length;i++) {
if (dayNums[i]==null || dayNums[i].equals("")) {
continue;
}
if (count++ > 0) {
weekText += "," ;
}
weekText += Constant.dayOfWeek[Integer.parseInt(dayNums[i])-1];
}
count=0;
for(int i=0;i<monthNums.length;i++) {
if (monthNums[i]==null || monthNums[i].equals("")) {
continue;
}
if (count++ > 0) {
monthText += ",";
}
monthText += Constant.months[Integer.parseInt(monthNums[i])-1];
}
anyWeekLabel.setText(weekText);
anyMonthLabel.setText(monthText);
}
}
private void createContent() {
setLayout(new BorderLayout());
ButtonGroup execTypeGp = new ButtonGroup();
ButtonGroup frequency = new ButtonGroup();
ButtonGroup endType = new ButtonGroup();
setSize(new Dimension(600, 553));
setLocationRelativeTo(null);
JPanel content = new JPanel();
getContentPane().add(content);
content.setLayout(null);
final JLabel label = new JLabel();
label.setFont(new Font("", Font.PLAIN, 12));
label.setHorizontalAlignment(SwingConstants.TRAILING);
label.setText("名称");
label.setBounds(28, 2, 58, 23);
content.add(label);
attempName = new JTextField();
attempName.setFont(new Font("", Font.PLAIN, 12));
attempName.setBounds(100, 2, 290, 20);
content.add(attempName);
enable = new JCheckBox();
enable.setFont(new Font("", Font.PLAIN, 12));
enable.setText("启用");
enable.setBounds(405, 1, 66, 22);
content.add(enable);
autoAttemp = new JRadioButton();
autoAttemp.setFont(new Font("", Font.PLAIN, 12));
autoAttemp.setText("自动");
autoAttemp.setBounds(15, 50, 50, 20);
content.add(autoAttemp);
oneAttemp = new JRadioButton();
oneAttemp.setFont(new Font("", Font.PLAIN, 12));
oneAttemp.setText("一次");
oneAttemp.setBounds(15, 70, 50, 20);
content.add(oneAttemp);
repeatAttemp = new JRadioButton();
repeatAttemp.setFont(new Font("", Font.PLAIN, 12));
repeatAttemp.setSelected(true);
repeatAttemp.setText("重复");
repeatAttemp.setBounds(15, 90, 50, 20);
content.add(repeatAttemp);
execTypeGp.add(oneAttemp);
execTypeGp.add(repeatAttemp);
execTypeGp.add(autoAttemp);
final JLabel label_1 = new JLabel();
label_1.setFont(new Font("", Font.PLAIN, 12));
label_1.setHorizontalAlignment(SwingConstants.TRAILING);
label_1.setText("运行日期");
label_1.setBounds(65, 70, 80, 20);
content.add(label_1);
panel.setLayout(null);
panel.setBounds(-10, 119, 596, 374);
content.add(panel);
anyDayRadio = new JRadioButton();
anyDayRadio.setSelected(true);
anyDayRadio.setFont(new Font("", Font.PLAIN, 12));
anyDayRadio.setBounds(15, 25, 65, 20);
panel.add(anyDayRadio);
anyDayRadio.setText("每天:");
frequency.add(anyDayRadio);
anyWeekRadio = new JRadioButton();
anyWeekRadio.setFont(new Font("", Font.PLAIN, 12));
anyWeekRadio.setBounds(15, 45, 65, 20);
panel.add(anyWeekRadio);
anyWeekRadio.setText("每周:");
frequency.add(anyWeekRadio);
anyMonthRadio = new JRadioButton();
anyMonthRadio.setFont(new Font("", Font.PLAIN, 12));
anyMonthRadio.setBounds(15, 129, 65, 20);
panel.add(anyMonthRadio);
anyMonthRadio.setText("每月:");
frequency.add(anyMonthRadio);
final JLabel label_1_2 = new JLabel();
label_1_2.setFont(new Font("", Font.PLAIN, 12));
label_1_2.setBounds(10, 300, 65, 20);
panel.add(label_1_2);
label_1_2.setHorizontalAlignment(SwingConstants.TRAILING);
label_1_2.setText("开始日期");
haveEnd = new JRadioButton();
haveEnd.setFont(new Font("", Font.PLAIN, 12));
haveEnd.setBounds(200, 300, 85, 20);
panel.add(haveEnd);
haveEnd.setText("结束日期");
endType.add(haveEnd);
noEnd = new JRadioButton();
noEnd.setFont(new Font("", Font.PLAIN, 12));
noEnd.setBounds(200, 320, 100, 20);
panel.add(noEnd);
noEnd.setSelected(true);
noEnd.setText("无结束日期");
endType.add(noEnd);
final JLabel label_2_1 = new JLabel();
label_2_1.setFont(new Font("", Font.PLAIN, 12));
label_2_1.setHorizontalAlignment(SwingConstants.CENTER);
label_2_1.setText("发生频率");
label_2_1.setBounds(0, 2, 65, 25);
panel.add(label_2_1);
final JLabel label_2_2 = new JLabel();
label_2_2.setFont(new Font("", Font.PLAIN, 12));
label_2_2.setHorizontalAlignment(SwingConstants.CENTER);
label_2_2.setText("持续时间");
label_2_2.setBounds(0, 275, 65, 25);
panel.add(label_2_2);
final JSeparator separator_3_1 = new JSeparator();
separator_3_1.setFont(new Font("", Font.PLAIN, 12));
separator_3_1.setBounds(65, 14, 500, 2);
panel.add(separator_3_1);
final JSeparator separator_3_2 = new JSeparator();
separator_3_2.setFont(new Font("", Font.PLAIN, 12));
separator_3_2.setBounds(65, 285, 500, 2);
panel.add(separator_3_2);
final JLabel anyDayMEI = new JLabel();
anyDayMEI.setFont(new Font("", Font.PLAIN, 12));
anyDayMEI.setHorizontalAlignment(SwingConstants.TRAILING);
anyDayMEI.setText("每");
anyDayMEI.setBounds(80, 25, 20, 20);
panel.add(anyDayMEI);
final JLabel anyDayTIAN = new JLabel();
anyDayTIAN.setFont(new Font("", Font.PLAIN, 12));
anyDayTIAN.setText("天");
anyDayTIAN.setBounds(140, 25, 20, 20);
panel.add(anyDayTIAN);
anyDayJI = new JSpinner(new SpinnerNumberModel(1, 1, 366, 1));
anyDayJI.setValue(1);
anyDayJI.setFont(new Font("", Font.PLAIN, 12));
anyDayJI.setBounds(100, 25, 40, 20);
panel.add(anyDayJI);
final JLabel anyWeekMEI = new JLabel();
anyWeekMEI.setFont(new Font("", Font.PLAIN, 12));
anyWeekMEI.setHorizontalAlignment(SwingConstants.TRAILING);
anyWeekMEI.setText("每");
anyWeekMEI.setBounds(80, 45, 20, 20);
panel.add(anyWeekMEI);
anyWeekJI = new JSpinner(new SpinnerNumberModel(1, 1, 52, 1));
anyWeekJI.setValue(1);
anyWeekJI.setEnabled(false);
anyWeekJI.setFont(new Font("", Font.PLAIN, 12));
anyWeekJI.setBounds(100, 45, 40, 20);
panel.add(anyWeekJI);
final JLabel anyWeekZHOU = new JLabel();
anyWeekZHOU.setFont(new Font("", Font.PLAIN, 12));
anyWeekZHOU.setText("周,");
anyWeekZHOU.setBounds(140, 45, 30, 20);
panel.add(anyWeekZHOU);
label_1_3_1_1_1 = new JLabel();
label_1_3_1_1_1.setVisible(false);
label_1_3_1_1_1.setFont(new Font("", Font.PLAIN, 12));
label_1_3_1_1_1.setText("您已经选择分别在以下日期运行:");
label_1_3_1_1_1.setBounds(150, 70, 200, 20);
panel.add(label_1_3_1_1_1);
selectWeek = new JButton();
selectWeek.setEnabled(false);
selectWeek.setFont(new Font("", Font.PLAIN, 12));
selectWeek.setText("选择星期");
selectWeek.setBounds(60, 70, 85, 20);
panel.add(selectWeek);
selectMonth = new JButton();
selectMonth.setEnabled(false);
selectMonth.setFont(new Font("", Font.PLAIN, 12));
selectMonth.setText("选择月份");
selectMonth.setBounds(60, 180, 85, 20);
panel.add(selectMonth);
label_1_3_1_1_1_1 = new JLabel();
label_1_3_1_1_1_1.setVisible(false);
label_1_3_1_1_1_1.setFont(new Font("", Font.PLAIN, 12));
label_1_3_1_1_1_1.setText("您已经选择分别在以下日期运行:");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -