package com.vci.client.workflow.task; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.TextField; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Map; import javax.swing.BorderFactory; import javax.swing.JButton; import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTabbedPane; import javax.swing.JTable; import com.vci.client.ClientSession; import com.vci.client.LogonApplication; import com.vci.client.common.objects.DeptObject; import com.vci.client.common.objects.RoleObject; import com.vci.client.common.objects.UserObject; import com.vci.client.framework.delegate.RightManagementClientDelegate; import com.vci.client.framework.rightConfig.object.FunctionObject; import com.vci.client.framework.systemConfig.stafforgmanage.RightManagementTreeCellRenderer; 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.ui.swing.components.VCIJDialog; import com.vci.client.ui.tree.VCIBaseTree; import com.vci.client.ui.tree.VCIBaseTreeModel; import com.vci.client.ui.tree.VCIBaseTreeNode; import com.vci.client.workflow.commom.ClientHelper; import com.vci.client.workflow.delegate.ProcessCustomClientDelegate; import com.vci.corba.common.VCIError; import com.vci.corba.workflow.data.FlowApproveHistoryInfo; import com.vci.corba.workflow.data.FlowTaskInfo; import com.vci.corba.workflow.data.ProcessTaskInfo; import java.awt.GridBagLayout; import java.awt.GridBagConstraints; import javax.swing.JComboBox; import java.awt.Insets; import javax.swing.JTextArea; import javax.swing.event.TreeExpansionEvent; import javax.swing.event.TreeExpansionListener; import javax.swing.tree.TreePath; /** * 待办任务 * * @author Administrator * */ public class TodoTaskByPlatformDialog extends VCIJDialog { private static final long serialVersionUID = 1461586100225135416L; private JTable historyTable; private HistoryTableModel historyTableModel; private boolean view = false; FunctionObject funcObject = new FunctionObject(); private String executionId; private JButton commit; private JButton cancel; private JComboBox outComeComb; private String outCome; private String desc; private String taskId; private String taskName; private boolean saveFlag = false; private JTextArea descTextArea; private String status; //下拉树Panel容器 private JScrollPane treePanel = new JScrollPane(); //下一节点人 private TextField nextUserTextField; private String nextUser = ""; private VCIBaseTreeModel treeModel; private JScrollPane treeScrollPane; private VCIBaseTreeNode rootNode = new VCIBaseTreeNode("人员组织", "root"); private VCIBaseTreeNode userNode; private VCIBaseTreeNode roleNode; private VCIBaseTreeNode departmentNode; private VCIBaseTree rightManagementTree; private UserObject userInfo; private VCIBaseTreeNode selectNode; private String userValue ; private String roleValue ; private String departmentValue ; public boolean isSaveFlag() { return saveFlag; } public void setSaveFlag(boolean saveFlag) { this.saveFlag = saveFlag; } public String getNextUser() { return nextUser; } public void setNextUser(String nextUser) { this.nextUser = nextUser; } public String getOutCome() { return outCome; } public void setOutCome(String outCome) { this.outCome = outCome; } public String getDesc() { return desc; } public void setDesc(String desc) { this.desc = desc; } public TodoTaskByPlatformDialog(String executionId,String taskId,String taskName,String status) { super(LogonApplication.frame, true); this.executionId = executionId; this.taskId = taskId; this.taskName = taskName; this.status = status; initUI(); initData(); addListener(); initOutComeComb(); this.setLocationRelativeTo(null); } // public TodoTaskByPlatformDialog(Map datamap, ProcessTaskInfo frocessTaskInfo, boolean view) { // super(LogonApplication.frame, true); // this.view = view; // setTitle("查看"); // this.datamap = datamap; // this.frocessTaskInfo = frocessTaskInfo; // initUI(); // initData(); // addListener(); // } private void initData() { ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate(); FlowApproveHistoryInfo[] historyActivity; String[] allCandidatesForTask = new String[0]; try { historyActivity = processCustomClientDelegate.getHistoryActivityByProInsIdbyPLM(executionId); historyTableModel.setData(historyActivity); //解析子流程节点 String deployId; deployId = processCustomClientDelegate.getDeploymentIdByExecutionId(executionId); allCandidatesForTask = processCustomClientDelegate.getAllCandidatesForTask(deployId, taskName, ""); } catch (VCIError e) { e.printStackTrace(); } catch (VCIException e) { // TODO Auto-generated catch block e.printStackTrace(); } if(allCandidatesForTask.length==1){ if("#{process_applicant}".equals(allCandidatesForTask[0])){ userValue = null; }else{ userValue = allCandidatesForTask[0]; } roleValue = null; departmentValue = null; } if(allCandidatesForTask.length==2){ userValue = allCandidatesForTask[0]; roleValue = allCandidatesForTask[1]; departmentValue = null; } if(allCandidatesForTask.length==3){ userValue = allCandidatesForTask[0]; roleValue = allCandidatesForTask[1]; departmentValue = allCandidatesForTask[2]; } } private void addListener() { commit.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { saveFlag = true; outCome = (String) outComeComb.getSelectedItem(); desc = descTextArea.getText(); // ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate( // LogonApplication.getUserEntityObject()); // String jbpmDeploymentId; // try { // jbpmDeploymentId = new ProcessCustomClientDelegate().getDeploymentIdByExecutionId(executionId); // String[] nextTaskName; // try { // nextTaskName = processCustomClientDelegate.getNextTaskNames( // jbpmDeploymentId, taskName, outCome); // if(nextTaskName!=null){ // // } // System.out.println(""); // } catch (VCIException e) { // e.printStackTrace(); // } // } catch (VCIError e) { // e.printStackTrace(); // } dispose(); } }); cancel.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { dispose(); } }); /** * 树的展开事件 */ rightManagementTree.addTreeExpansionListener(new TreeExpansionListener() { public void treeExpanded(TreeExpansionEvent event) { TreePath treePath = event.getPath(); selectNode = (VCIBaseTreeNode) treePath.getLastPathComponent(); Object object = selectNode.getObj(); // if (!selectNode.isExpand()) { if (selectNode.getChildCount()==0) { selectNode.setExpand(true); if (object instanceof UserObject) { UserObject user = (UserObject) object; if (user.getId().equals("root")) { try { UserObject[] userInfos = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfo(); for (UserObject userObject : userInfos) { if(userValue!=null&&!"".equals(userValue)){ String[] split = userValue.split(","); for(String userSplit : split){ if(userSplit.equals(userObject.getUserName())){ treeModel.insertNodeInto(new VCIBaseTreeNode(userObject.toString(), userObject), selectNode, selectNode.getChildCount()); } } } } } catch (VCIException e) { e.printStackTrace(); return; } } } if (object instanceof RoleObject) { RoleObject role = (RoleObject) object; if (role.getId().equals("root")) { try { RoleObject[] roleInfos = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchRoleInfo(); for (RoleObject roleObject : roleInfos) { if(roleValue!=null&&!"".equals(roleValue)){ String[] split = roleValue.split(","); for(String roleSplit : split){ if(roleSplit.equals(roleObject.getId())){ treeModel.insertNodeInto(new VCIBaseTreeNode(roleObject.getName(), roleObject), selectNode, selectNode.getChildCount()); } } } } } catch (VCIException e) { e.printStackTrace(); return; } }else{ try { UserObject[] fetchUserInfoByRoleId = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByRoleId(role.getId(), role.getType()); for (UserObject userObject : fetchUserInfoByRoleId) { treeModel.insertNodeInto(new VCIBaseTreeNode(userObject.toString(), userObject), selectNode, selectNode.getChildCount()); } } catch (VCIException e) { e.printStackTrace(); } } } if (object instanceof DeptObject){ RightManagementClientDelegate del = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()); try { DeptObject[] DeptInfos = null; DeptObject deptObject = (DeptObject) object; if (deptObject.getId().equals("root")){ DeptInfos= new RightManagementClientDelegate(LogonApplication.getUserEntityObject()) .fetchDepartmentInfo(); }else{ DeptInfos = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()) .fetchDepartmentInfoByParentId(deptObject.getId()); } if (DeptInfos == null){ if (!deptObject.getId().equals("root")){ UserObject[] objs = del.getUserByDeptId(deptObject.getId()); for(int i=0;i screenSize.height) { componentSize.height = screenSize.height; } if (componentSize.width > screenSize.width) { componentSize.width = screenSize.width; } setLocation((screenSize.width - componentSize.width) / 2, (screenSize.height - componentSize.height) / 2); } private String getI18nString(String spCode) { return ClientHelper.getI18nStringForWorkflow(this.getClass().getName() + "." + spCode, this.getLocale()); } private String getI18nStringByCode(String spCode) { return ClientHelper.getI18nStringForWorkflow(spCode, this.getLocale()); } private void initOutComeComb(){ ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate(); try { String[] allOutComes = processCustomClientDelegate .getAllOutComes(taskId); for(String outCome : allOutComes){ outComeComb.addItem(outCome); } } catch (VCIException e) { e.printStackTrace(); } } protected void initUserTree(VCIBaseTreeNode rootNode, String puid) { String userName = LogonApplication.getUserEntityObject().getUserName(); try { userInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByName(userName); } catch (VCIException e) { e.printStackTrace(); return; } UserObject userObject = new UserObject(); userObject.setId("root"); userNode = new VCIBaseTreeNode("用户", userObject); rootNode.add(userNode); } protected void initRoleTree(VCIBaseTreeNode rootNode, String puid) { String userName = LogonApplication.getUserEntityObject().getUserName(); try { userInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByName(userName); } catch (VCIException e) { e.printStackTrace(); return; } RoleObject roleObject = new RoleObject(); roleObject.setId("root"); roleNode = new VCIBaseTreeNode(LocaleDisplay.getI18nString("rmip.stafforg.menu.role", "RMIPFramework", getLocale()), roleObject); rootNode.add(roleNode); } protected void initDepartTree(VCIBaseTreeNode rootNode, String puid) { String userName = LogonApplication.getUserEntityObject().getUserName(); try { userInfo = new RightManagementClientDelegate(LogonApplication.getUserEntityObject()).fetchUserInfoByName(userName); } catch (VCIException e) { e.printStackTrace(); return; } DeptObject rootDepartment = new DeptObject(); rootDepartment.setId("root"); departmentNode = new VCIBaseTreeNode( LocaleDisplay.getI18nString("rmip.stafforg.menu.department", "RMIPFramework", getLocale()), rootDepartment); rootNode.add(departmentNode); } }