package com.vci.client.workflow.task;
|
|
import java.awt.BorderLayout;
|
import java.awt.Color;
|
import java.awt.Component;
|
import java.awt.GridBagConstraints;
|
import java.awt.GridBagLayout;
|
import java.awt.Insets;
|
import java.util.Locale;
|
import java.util.Map;
|
|
import javax.swing.ButtonGroup;
|
import javax.swing.JLabel;
|
import javax.swing.JOptionPane;
|
import javax.swing.JPanel;
|
import javax.swing.JRadioButton;
|
import javax.swing.JScrollPane;
|
import javax.swing.JTextArea;
|
|
import com.vci.client.LogonApplication;
|
import com.vci.client.ui.exception.VCIException;
|
import com.vci.client.ui.locale.LocaleDisplay;
|
import com.vci.client.ui.swing.VCIOptionPane;
|
import com.vci.client.workflow.delegate.ProcessCustomClientDelegate;
|
import com.vci.corba.common.VCIError;
|
import com.vci.corba.workflow.data.FlowTaskInfo;
|
import com.vci.corba.workflow.data.ProcessTaskInfo;
|
|
import javax.swing.JComboBox;
|
|
public class TodoCheckByPlatformPanel extends JPanel implements IFlowTaskTpyeEventByPlatform {
|
|
ProcessTaskInfo frocessTaskInfo;
|
FlowUserDialog flowUserDialog ;
|
public TodoCheckByPlatformPanel() {
|
setLayout(new BorderLayout(0, 0));
|
|
panel = new JPanel();
|
add(panel, BorderLayout.NORTH);
|
GridBagLayout gbl_panel = new GridBagLayout();
|
gbl_panel.columnWeights = new double[]{0.0, 1.0, 0.0};
|
panel.setLayout(gbl_panel);
|
|
JLabel label = new JLabel("审批:");
|
GridBagConstraints gbc_label = new GridBagConstraints();
|
gbc_label.insets = new Insets(10, 10, 5, 5);
|
gbc_label.gridx = 0;
|
gbc_label.gridy = 1;
|
panel.add(label, gbc_label);
|
|
|
outComeComb = new JComboBox();
|
GridBagConstraints gbc_outComeComb = new GridBagConstraints();
|
gbc_outComeComb.insets = new Insets(0, 0, 5, 5);
|
gbc_outComeComb.fill = GridBagConstraints.HORIZONTAL;
|
gbc_outComeComb.gridx = 1;
|
gbc_outComeComb.gridy = 1;
|
panel.add(outComeComb, gbc_outComeComb);
|
|
JLabel lblNewLabel = new JLabel("审批意见:");
|
GridBagConstraints gbc_lblNewLabel = new GridBagConstraints();
|
gbc_lblNewLabel.insets = new Insets(0, 10, 0, 5);
|
gbc_lblNewLabel.gridx = 0;
|
gbc_lblNewLabel.gridy = 2;
|
panel.add(lblNewLabel, gbc_lblNewLabel);
|
|
JScrollPane scrollPane = new JScrollPane();
|
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
gbc_scrollPane.gridwidth = 2;
|
gbc_scrollPane.weightx = 1.0;
|
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
gbc_scrollPane.gridx = 1;
|
gbc_scrollPane.gridy = 2;
|
panel.add(scrollPane, gbc_scrollPane);
|
|
textArea = new JTextArea();
|
textArea.setLineWrap(true);
|
textArea.setRows(6);
|
textArea.setBackground(Color.WHITE);
|
scrollPane.setViewportView(textArea);
|
|
}
|
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
private JPanel panel;
|
private ButtonGroup bg;
|
private JTextArea textArea;
|
|
private String out = "";
|
private boolean flag = true;
|
|
private String[] userNames = {};
|
private boolean complateTaskFlag = false;
|
String backTaskName = "";
|
private JComboBox outComeComb;
|
private Map<String, String> datamap;
|
public boolean completeTask() {
|
String outcome = "";
|
outcome = (String) outComeComb.getSelectedItem();
|
|
if ("".equals(textArea.getText().trim().length() >= 255)) {
|
JOptionPane.showMessageDialog(LogonApplication.frame, "审批意见不能超过255个汉字!", "提示信息", JOptionPane.INFORMATION_MESSAGE);
|
return false;
|
}
|
out = outcome;
|
|
String taskId = datamap.get("TaskOID".toLowerCase());
|
String taskName = datamap.get("name".toLowerCase());
|
String executionId = datamap.get("executionid".toLowerCase());
|
try {
|
String jbpmDeploymentId = new ProcessCustomClientDelegate().getDeploymentIdByExecutionId(executionId );
|
if("同意".equals(outcome)){
|
// 检查下一个任务是否是结束,如果不是结果,则需要弹出选择处理人的窗口,
|
boolean processTaskByTaskName = new ProcessCustomClientDelegate(
|
LogonApplication.getUserEntityObject())
|
.getProcessTaskByTaskName(taskId, taskName, outcome);
|
if (!processTaskByTaskName) {
|
|
String[] userNames;
|
if(chooseFlowUser(jbpmDeploymentId, taskName, outcome)) {
|
return false;
|
}else {
|
userNames = flowUserDialog.userName;
|
}
|
this.userNames = userNames;
|
if (userNames.length == 0) {
|
return false;
|
}
|
complateTaskFlag = false;
|
}else{
|
complateTaskFlag = true;
|
}
|
}
|
} catch (VCIException e1) {
|
e1.printStackTrace();
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
|
Thread t = new Thread(){
|
public void run() {
|
ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject());
|
try {
|
String taskId = datamap.get("TaskOID".toLowerCase());
|
if(userNames!=null&&userNames.length!=0) {
|
|
processCustomClientDelegate.completeTask(taskId, out,backTaskName, textArea.getText(),userNames);
|
}else {
|
processCustomClientDelegate.completeTask(taskId, out,backTaskName, textArea.getText(),new String[]{});
|
}
|
} catch (VCIError e) {
|
VCIOptionPane.showError(LogonApplication.frame, LocaleDisplay.getI18nString(new VCIException(String.valueOf(e.code),e.messages), "RMIPBom", Locale.getDefault()));
|
flag = false;
|
}
|
}
|
};
|
ProgressSample r = new ProgressSample(t);
|
r.setVisible(true);
|
return flag;
|
}
|
private boolean chooseFlowUser(String jbpmDeploymentId, String taskName, String outcome){
|
flowUserDialog = new FlowUserDialog(LogonApplication.frame , jbpmDeploymentId, taskName, outcome);
|
if(!flowUserDialog.isSelectFlag()){
|
flowUserDialog.setVisible (true);
|
}
|
boolean flag = flowUserDialog.flag;
|
return flag;
|
}
|
public Component getComponent() {
|
return this;
|
}
|
|
public void init(Map<String,String> datamap, ProcessTaskInfo frocessTaskInfo) {
|
this.datamap = datamap;
|
this.frocessTaskInfo = frocessTaskInfo;
|
// RmDataPanel rmDataPanel = new RmDataPanel();
|
// rmDataPanel.init(flowTask);
|
// rmDataPanel.setPreferredSize(new Dimension(700,90));
|
|
GridBagConstraints gbc_rmDataPanel = new GridBagConstraints();
|
// gbc_rmDataPanel.anchor = GridBagConstraints.EAST;
|
gbc_rmDataPanel.gridwidth = 3;
|
gbc_rmDataPanel.weightx = 1.0;
|
gbc_rmDataPanel.fill = GridBagConstraints.BOTH;
|
gbc_rmDataPanel.insets = new Insets(10, 10, 5, 5);
|
gbc_rmDataPanel.gridx = 0;
|
gbc_rmDataPanel.gridy = 0;
|
// panel.add(rmDataPanel, gbc_rmDataPanel);
|
|
// add(rmDataPanel, BorderLayout.NORTH);
|
initOutComeComb();
|
}
|
|
public String save() {
|
return "";
|
}
|
|
public boolean isShowSaveButton() {
|
return false;
|
}
|
|
private void initOutComeComb(){
|
ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate();
|
try {
|
String taskId = datamap.get("TaskOID".toLowerCase());
|
String[] allOutComes = processCustomClientDelegate .getAllOutComes(taskId);
|
for(String outCome : allOutComes){
|
outComeComb.addItem(outCome);
|
}
|
} catch (VCIException e) {
|
e.printStackTrace();
|
}
|
}
|
}
|