package com.vci.client.workflow.task;
|
|
import java.awt.BorderLayout;
|
import java.awt.FlowLayout;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
|
import javax.swing.ButtonGroup;
|
import javax.swing.JButton;
|
import javax.swing.JLabel;
|
import javax.swing.JOptionPane;
|
import javax.swing.JPanel;
|
import javax.swing.JRadioButton;
|
import javax.swing.JTextField;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.common.objects.UserObject;
|
import com.vci.client.framework.rightConfig.object.FunctionObject;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.ui.swing.VCISwingUtil;
|
import com.vci.client.ui.swing.components.VCIJButton;
|
import com.vci.client.ui.swing.components.VCIJCalendarPanel;
|
import com.vci.client.workflow.delegate.ProcessCustomClientDelegate;
|
import com.vci.client.workflow.template.object.TasksAssignedObject;
|
import com.vci.common.utility.ObjectUtility;
|
import com.vci.corba.common.VCIError;
|
|
public class TasksAssignedPanel extends JPanel {
|
/**
|
* 指定代理任务人模块
|
*/
|
|
private static final long serialVersionUID = 844086978269740691L;
|
private VCIJButton btnClear = VCISwingUtil.createVCIJButton("", "清除", "清除", "clear.gif");
|
private JButton addButton;
|
private JLabel fromLabel = new JLabel("从 :");
|
private JLabel JLbelName = new JLabel("委托给 :");
|
private JLabel RadioJLbelName = new JLabel("是否生效:");
|
private JTextField fromUser = new JTextField();
|
private JTextField JTextName = new JTextField();
|
private JButton fromChoice = new JButton("选择");
|
private JButton choice = new JButton("选择");
|
private JLabel JLbelstartTime = new JLabel("有效时间:从");
|
private JLabel JLbelendTime = new JLabel("到");
|
private VCIJCalendarPanel txtStartTime = new VCIJCalendarPanel("yyyy-MM-dd",false,false,false);
|
private VCIJCalendarPanel txtEndTime = new VCIJCalendarPanel("yyyy-MM-dd",false,false,false);
|
private JRadioButton jRadioButTrue = new JRadioButton();
|
private JRadioButton jRadioButFalse = new JRadioButton();
|
private JLabel hisTodoTaskDepute = new JLabel("待办任务委托:");
|
private JRadioButton hisTodoTaskYes = new JRadioButton("是");
|
private JRadioButton hisTodoTaskNo = new JRadioButton("否");
|
private ButtonGroup bg = new ButtonGroup();
|
private ButtonGroup hisTodoTaskBg = new ButtonGroup();
|
|
private UserObject[] userObject;
|
private boolean isTrue;//是否生效
|
|
public boolean getIsTrue() {
|
return isTrue;
|
}
|
|
public void setIsTrue(boolean isTrue) {
|
this.isTrue = isTrue;
|
}
|
|
private static TasksAssignedPanel tasksAssignedPanel;
|
static String querySQL = "";
|
static String taskType ="";
|
static FunctionObject object = new FunctionObject();
|
public static TasksAssignedPanel getInstance(String taskType) {
|
// if (trackTaskPanel == null) {
|
tasksAssignedPanel = new TasksAssignedPanel(object,taskType);
|
// }
|
return tasksAssignedPanel;
|
}
|
|
private TasksAssignedPanel(FunctionObject object,String taskType) {
|
// super(object);
|
this.object = object;
|
this.taskType = taskType;
|
initUI();
|
}
|
private void initUI() {
|
setLayout(new BorderLayout());
|
JPanel palNorthBtn = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5));
|
addButton = new JButton("保存");
|
addButton.setIcon(VCISwingUtil.createImageIcon("add.png"));
|
palNorthBtn.add(addButton);
|
palNorthBtn.add(btnClear);
|
JPanel CenterPanel = new JPanel();
|
CenterPanel.setLayout(null);
|
bg.add(jRadioButTrue);
|
bg.add(jRadioButFalse);
|
hisTodoTaskBg.add(hisTodoTaskYes);
|
hisTodoTaskBg.add(hisTodoTaskNo);
|
|
// fromLabel.setBounds(130, 50, 120, 30);
|
// fromUser.setBounds(210, 50, 120, 30);
|
// fromUser.setEditable(false);
|
// fromChoice.setBounds(330, 50, 70, 30);
|
|
JLbelName.setBounds(130, 50, 170, 30);
|
JTextName.setBounds(210, 50, 170, 30);
|
JTextName.setEditable(false);
|
choice.setBounds(380, 50, 70, 30);
|
|
// JLbelName.setBounds(420, 50, 120, 30);
|
// JTextName.setBounds(530, 50, 120, 30);
|
// JTextName.setEditable(false);
|
// choice.setBounds(650, 50, 70, 30);
|
|
JLbelstartTime.setBounds(130,100,150,30);
|
txtStartTime.setBounds(210,100,180,30);
|
JLbelendTime.setBounds(190,150,20,30);
|
txtEndTime.setBounds(210,150,180,30);
|
|
hisTodoTaskDepute.setBounds(130, 200, 180, 30);
|
hisTodoTaskYes.setBounds(210, 200, 45, 25);
|
hisTodoTaskNo.setBounds(270, 200, 45, 25);
|
hisTodoTaskYes.setSelected(true);
|
|
RadioJLbelName.setBounds(130, 200, 150, 30);
|
jRadioButTrue.setBounds(210, 200, 45, 25);
|
jRadioButFalse.setBounds(270, 200, 45, 25);
|
// CenterPanel.add(fromLabel);
|
// CenterPanel.add(fromUser);
|
// CenterPanel.add(fromChoice);
|
|
CenterPanel.add(JLbelName);
|
CenterPanel.add(JTextName);
|
CenterPanel.add(choice);
|
|
CenterPanel.add(JLbelstartTime);
|
CenterPanel.add(txtStartTime);
|
CenterPanel.add(JLbelendTime);
|
CenterPanel.add(txtEndTime);
|
CenterPanel.add(RadioJLbelName);
|
CenterPanel.add(jRadioButTrue);
|
|
// CenterPanel.add(hisTodoTaskDepute);
|
// CenterPanel.add(hisTodoTaskYes);
|
// CenterPanel.add(hisTodoTaskNo);
|
|
jRadioButTrue.setText("是");
|
jRadioButFalse.setText("否");
|
jRadioButFalse.setSelected(true);
|
CenterPanel.add(jRadioButFalse);
|
add(CenterPanel, BorderLayout.CENTER);
|
|
JPanel southPanel = new JPanel(new BorderLayout());
|
southPanel.add(palNorthBtn,BorderLayout.NORTH);
|
add(southPanel, BorderLayout.SOUTH);
|
addListener();
|
init();
|
}
|
|
private void addListener() {
|
addButton.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent event) {
|
add_ActionPerformed();
|
//如果是生效,并且委托待办任务
|
if(jRadioButTrue.isSelected()){
|
if(hisTodoTaskYes.isSelected()){
|
// new .assignTask(userName);
|
ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject());
|
processCustomClientDelegate.assignTask(LogonApplication.getUserEntityObject().getUserName(), JTextName.getText());
|
}
|
|
}
|
}
|
});
|
// fromChoice.addActionListener(new ActionListener() {
|
// @Override
|
// public void actionPerformed(ActionEvent e) {
|
// fromChoice_ActionPerformed();
|
// }
|
// });
|
choice.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
choice_ActionPerformed();
|
}
|
});
|
btnClear.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
clear_ActionPerformed();
|
}
|
});
|
}
|
|
public void init(){
|
TasksAssignedObject obj;
|
ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject());
|
try {
|
obj = processCustomClientDelegate.getTasksAssignedByUserName("");
|
if(obj.getId() != ""&& obj.getId() != null){
|
String user = obj.getTasksName();
|
user.split(",");
|
// userObject = new UserObject();
|
// userObject.setUserName(obj.getUserName());
|
// userObject.setTrueName(obj.getTasksTrueName());
|
// userObject.setId(obj.getTasksId());
|
// fromUser.setText(obj.getFromUser());
|
// JTextName.setText(userObject.getTrueName());
|
JTextName.setText(obj.getTasksName());
|
txtStartTime.setDate(obj.getStartTime());
|
txtEndTime.setDate(obj.getEndTime());
|
if(obj.getIsTrue()){
|
jRadioButTrue.setSelected(true);
|
}else{
|
jRadioButFalse.setSelected(true);
|
}
|
if(obj.getTasksName().contains(",")){
|
String[] userName = obj.getTasksName().split(",");
|
userObject = new UserObject[userName.length];
|
for(int i = 0;i<userName.length;i++){
|
userObject[i] = new UserObject();
|
userObject[i].setUserName(userName[i]);
|
}
|
}else{
|
userObject = new UserObject[1];
|
userObject[0] = new UserObject();
|
userObject[0].setUserName(obj.getTasksName());
|
}
|
}
|
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
// private void fromChoice_ActionPerformed() {
|
// TaskAssignedDialog dialog = new TaskAssignedDialog(LogonApplication.frame);
|
// userObject = dialog.getProcessDefinitionObject();
|
// if(userObject == null) {
|
// fromUser.setText("");
|
// }else
|
// fromUser.setText(getTasksName(userObject));
|
//
|
// }
|
private void choice_ActionPerformed() {
|
TaskAssignedDialog dialog = new TaskAssignedDialog(LogonApplication.frame);
|
userObject = dialog.getProcessDefinitionObject();
|
if(userObject == null) {
|
JTextName.setText("");
|
}else
|
JTextName.setText(getTasksName(userObject));
|
|
}
|
private void add_ActionPerformed() {
|
if(!jRadioButTrue.isSelected()&&!jRadioButFalse.isSelected()) {
|
JOptionPane.showMessageDialog(LogonApplication.frame, "请选择是否生效");
|
return;
|
}
|
// if("".equals(fromUser.getText())){
|
// JOptionPane.showMessageDialog(LogonApplication.frame, "请选择被委托任务人");
|
// return;
|
// }
|
if("".equals(JTextName.getText())){
|
JOptionPane.showMessageDialog(LogonApplication.frame, "请选择代办人");
|
return;
|
}
|
if(txtStartTime.getDateString() == null ||txtEndTime.getDateString() ==null
|
|| "".equals(txtStartTime.getDateString()) || "".equals(txtEndTime.getDateString())){
|
JOptionPane.showMessageDialog(LogonApplication.frame, "请选择开始日期或结束日期!");
|
return;
|
}
|
// String name = JTextName.getText();
|
if(jRadioButTrue.isSelected()){
|
setIsTrue(true);//生效
|
}else setIsTrue(false);//不生效
|
TasksAssignedObject tasksObject = new TasksAssignedObject();
|
if(userObject != null){
|
String ploid = ObjectUtility.getNewObjectID36();
|
tasksObject.setId(ploid);
|
tasksObject.setIsTrue(isTrue);
|
tasksObject.setUserName(LogonApplication.getUserEntityObject().getUserName());
|
// tasksObject.setTasksId(userObject[0].getId());
|
tasksObject.setTasksName(getTasksName(userObject));
|
// tasksObject.setTasksTrueName(name);
|
tasksObject.setStartTime(txtStartTime.getDate());
|
tasksObject.setEndTime(txtEndTime.getDate());
|
tasksObject.setFromUser(LogonApplication.getUserEntityObject().getUserName());
|
}
|
ProcessCustomClientDelegate processDel = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject());
|
try {
|
boolean res = processDel.saveOrUpdateTasksAssigned(tasksObject);
|
if(res) {
|
JOptionPane.showMessageDialog(this, "保存成功");
|
}
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
}
|
private void clear_ActionPerformed(){
|
if(VCIOptionPane.showQuestion(this, "你确定要删除设置的代办人吗?") != 0) return;
|
ProcessCustomClientDelegate processDel = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject());
|
try{
|
String[] s = new String[1];
|
s[0] = LogonApplication.getUserEntityObject().getUserName();
|
boolean res = processDel.deleteTasksAssignedByUserName(s);
|
if(res) {
|
JOptionPane.showMessageDialog(this, "清除成功");
|
JTextName.setText("");
|
txtStartTime.setDateString();
|
txtEndTime.setDateString();
|
jRadioButTrue.setSelected(false);
|
jRadioButFalse.setSelected(true);
|
hisTodoTaskYes.setSelected(true);
|
}
|
} catch(VCIError e){
|
e.printStackTrace();
|
}
|
}
|
// public List<UserObject> getSelectedUsers() {
|
// List<UserObject> list = new ArrayList<UserObject>();
|
// UserObject[] object = new UserObject[]{};
|
// RightManagementClientDelegate del = new RightManagementClientDelegate();
|
// try {
|
// object = del.fetchUserInfo();
|
// } catch (VCIException e) {
|
// e.printStackTrace();
|
// }
|
// for(UserObject obj : object){
|
// list.add(obj);
|
// }
|
// return list;
|
// }
|
private String getTasksName(UserObject[] object){
|
String userName = "";
|
for(int i = 0 ;i<object.length;i++){
|
if(i+1 == object.length){
|
userName += object[i].getUserName();
|
break;
|
}
|
userName += object[i].getUserName()+",";
|
}
|
return userName;
|
}
|
}
|