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 getSelectedUsers() { // List list = new ArrayList(); // 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