package com.vci.client.workflow.task;
|
|
import java.awt.BorderLayout;
|
import java.awt.FlowLayout;
|
|
import javax.swing.ButtonGroup;
|
import javax.swing.JButton;
|
import javax.swing.JDialog;
|
import javax.swing.JOptionPane;
|
import javax.swing.JPanel;
|
import javax.swing.border.EmptyBorder;
|
import java.awt.GridBagLayout;
|
import javax.swing.JLabel;
|
import java.awt.GridBagConstraints;
|
import javax.swing.JTextField;
|
import java.awt.Insets;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.common.objects.UserObject;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
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;
|
|
import javax.swing.JRadioButton;
|
import java.awt.event.ActionListener;
|
import java.awt.event.ActionEvent;
|
|
public class TasksAssignedByPlatformDialog extends JDialog {
|
|
private final JPanel contentPanel = new JPanel();
|
private JTextField JTextName;
|
private JRadioButton jRadioButTrue;
|
private JRadioButton jRadioButFalse;
|
private JButton choice;
|
private JButton okButton;
|
private JButton cancelButton;
|
private VCIJCalendarPanel txtStartTime;
|
private VCIJCalendarPanel txtEndTime;
|
private JRadioButton hisTodoTaskYes = new JRadioButton("是");
|
private JRadioButton hisTodoTaskNo = new JRadioButton("否");
|
|
private UserObject[] userObject;
|
private boolean isTrue;//是否生效
|
private boolean saveFlag = false;
|
private JButton closeBtn;
|
public boolean isSaveFlag() {
|
return saveFlag;
|
}
|
|
public void setSaveFlag(boolean saveFlag) {
|
this.saveFlag = saveFlag;
|
}
|
|
public boolean getIsTrue() {
|
return isTrue;
|
}
|
|
public void setIsTrue(boolean isTrue) {
|
this.isTrue = isTrue;
|
}
|
|
/**
|
* Launch the application.
|
*/
|
public static void main(String[] args) {
|
// try {
|
// TasksAssignedByPlatformDialog dialog = new TasksAssignedByPlatformDialog();
|
// dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
|
// dialog.setVisible(true);
|
// } catch (Exception e) {
|
// e.printStackTrace();
|
// }
|
}
|
|
/**
|
* Create the dialog.
|
*/
|
public TasksAssignedByPlatformDialog() {
|
super(LogonApplication.frame,true);
|
init();
|
this.setLocationRelativeTo(null);
|
}
|
public TasksAssignedByPlatformDialog(String arg) {
|
|
}
|
public void initData(){
|
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();
|
}
|
}
|
public JPanel init() {
|
setBounds(100, 100, 450, 300);
|
JPanel mainPanel = new JPanel();
|
getContentPane().setLayout(new BorderLayout());
|
mainPanel.setLayout(new BorderLayout());
|
contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
|
mainPanel.add(contentPanel, BorderLayout.CENTER);
|
GridBagLayout gbl_contentPanel = new GridBagLayout();
|
gbl_contentPanel.columnWidths = new int[]{0, 0, 0, 0, 0, 0};
|
gbl_contentPanel.rowHeights = new int[]{0, 0, 0, 0, 0, 0};
|
gbl_contentPanel.columnWeights = new double[]{0.0, 0.0, 0.0, 1.0, 0.0, Double.MIN_VALUE};
|
gbl_contentPanel.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
contentPanel.setLayout(gbl_contentPanel);
|
{
|
JLabel label = new JLabel("委托给 :");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 5, 5);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 1;
|
contentPanel.add(label, gbc_label);
|
}
|
{
|
JTextName = new JTextField();
|
GridBagConstraints gbc_JTextName = new GridBagConstraints();
|
gbc_JTextName.insets = new Insets(0, 0, 5, 5);
|
gbc_JTextName.fill = GridBagConstraints.HORIZONTAL;
|
gbc_JTextName.gridx = 3;
|
gbc_JTextName.gridy = 1;
|
JTextName.setEditable(false);
|
contentPanel.add(JTextName, gbc_JTextName);
|
}
|
{
|
choice = new JButton("选择");
|
choice.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
choice_ActionPerformed();
|
}
|
});
|
GridBagConstraints gbc_choice = new GridBagConstraints();
|
gbc_choice.insets = new Insets(0, 0, 5, 0);
|
gbc_choice.gridx = 4;
|
gbc_choice.gridy = 1;
|
contentPanel.add(choice, gbc_choice);
|
}
|
{
|
JLabel label = new JLabel("有效时间:从");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 5, 5);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 2;
|
contentPanel.add(label, gbc_label);
|
}
|
{
|
txtStartTime = new VCIJCalendarPanel("yyyy-MM-dd", false, false, false);
|
GridBagLayout gbl_txtStartTime = (GridBagLayout) txtStartTime.getLayout();
|
gbl_txtStartTime.rowWeights = new double[]{0.0};
|
gbl_txtStartTime.rowHeights = new int[]{0};
|
gbl_txtStartTime.columnWeights = new double[]{0.0, 0.0, 0.0};
|
gbl_txtStartTime.columnWidths = new int[]{0, 0, 0};
|
GridBagConstraints gbc_txtStartTime = new GridBagConstraints();
|
gbc_txtStartTime.insets = new Insets(0, 0, 5, 5);
|
gbc_txtStartTime.fill = GridBagConstraints.BOTH;
|
gbc_txtStartTime.gridx = 3;
|
gbc_txtStartTime.gridy = 2;
|
contentPanel.add(txtStartTime, gbc_txtStartTime);
|
}
|
{
|
JLabel label = new JLabel("到");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.anchor = GridBagConstraints.EAST;
|
gbc_label.insets = new Insets(0, 0, 5, 5);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 3;
|
contentPanel.add(label, gbc_label);
|
}
|
{
|
txtEndTime = new VCIJCalendarPanel("yyyy-MM-dd", false, false, false);
|
GridBagLayout gbl_txtEndTime = (GridBagLayout) txtEndTime.getLayout();
|
gbl_txtEndTime.rowWeights = new double[]{0.0};
|
gbl_txtEndTime.rowHeights = new int[]{0};
|
gbl_txtEndTime.columnWeights = new double[]{0.0, 0.0, 0.0};
|
gbl_txtEndTime.columnWidths = new int[]{0, 0, 0};
|
GridBagConstraints gbc_txtEndTime = new GridBagConstraints();
|
gbc_txtEndTime.insets = new Insets(0, 0, 5, 5);
|
gbc_txtEndTime.fill = GridBagConstraints.BOTH;
|
gbc_txtEndTime.gridx = 3;
|
gbc_txtEndTime.gridy = 3;
|
contentPanel.add(txtEndTime, gbc_txtEndTime);
|
}
|
{
|
JLabel label = new JLabel("是否生效:");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(0, 0, 0, 5);
|
gbc_label.gridx = 1;
|
gbc_label.gridy = 4;
|
contentPanel.add(label, gbc_label);
|
}
|
{
|
JPanel panel = new JPanel();
|
GridBagConstraints gbc_panel = new GridBagConstraints();
|
gbc_panel.insets = new Insets(0, 0, 0, 5);
|
gbc_panel.fill = GridBagConstraints.BOTH;
|
gbc_panel.gridx = 3;
|
gbc_panel.gridy = 4;
|
contentPanel.add(panel, gbc_panel);
|
{
|
jRadioButTrue = new JRadioButton();
|
jRadioButTrue.setText("是");
|
panel.add(jRadioButTrue);
|
}
|
{
|
jRadioButFalse = new JRadioButton();
|
jRadioButFalse.setText("否");
|
jRadioButFalse.setSelected(true);
|
panel.add(jRadioButFalse);
|
}
|
{
|
ButtonGroup bg = new ButtonGroup();
|
bg.add(jRadioButTrue);
|
bg.add(jRadioButFalse);
|
ButtonGroup hisTodoTaskBg = new ButtonGroup();
|
hisTodoTaskBg.add(hisTodoTaskYes);
|
hisTodoTaskBg.add(hisTodoTaskNo);
|
}
|
}
|
{
|
JPanel buttonPane = new JPanel();
|
buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT));
|
mainPanel.add(buttonPane, BorderLayout.SOUTH);
|
{
|
okButton = new JButton("保存");
|
okButton.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
add_ActionPerformed();
|
//如果是生效,并且委托待办任务
|
if(jRadioButTrue.isSelected()){
|
// if(hisTodoTaskYes.isSelected()){
|
// new .assignTask(userName);
|
ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject());
|
processCustomClientDelegate.assignTaskByPlatform(LogonApplication.getUserEntityObject().getUserName(), JTextName.getText());
|
// }
|
|
}
|
dispose();
|
}
|
});
|
buttonPane.add(okButton);
|
getRootPane().setDefaultButton(okButton);
|
}
|
{
|
cancelButton = new JButton("清除");
|
cancelButton.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
clear_ActionPerformed();
|
}
|
});
|
buttonPane.add(cancelButton);
|
}
|
{
|
closeBtn = new JButton("关闭");
|
closeBtn.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
dispose();
|
}
|
});
|
// buttonPane.add(closeBtn);
|
}
|
}
|
getContentPane().add(mainPanel,BorderLayout.CENTER);
|
initData();
|
return mainPanel;
|
}
|
private void choice_ActionPerformed() {
|
TaskAssignedForPlatformDialog dialog = new TaskAssignedForPlatformDialog(LogonApplication.frame,"AutoSetTaskAssign");
|
userObject = dialog.getProcessDefinitionObject();
|
if(!dialog.isOk()){
|
return;
|
}else 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);
|
}
|
} catch(VCIError e){
|
e.printStackTrace();
|
}
|
}
|
|
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;
|
}
|
}
|