package com.vci.client.workflow.template; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Dimension; import java.awt.Insets; 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.awt.image.BufferedImage; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Enumeration; import java.util.HashMap; import java.util.Hashtable; import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import java.util.zip.ZipInputStream; import javax.imageio.ImageIO; import javax.swing.ImageIcon; import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JSplitPane; import javax.swing.JTextField; import javax.swing.SwingUtilities; import javax.swing.border.TitledBorder; import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; import org.w3c.dom.Node; import com.mxgraph.io.mxCodec; import com.mxgraph.model.mxIGraphModel; import com.mxgraph.swing.mxGraphComponent; import com.mxgraph.util.mxUtils; import com.mxgraph.view.mxGraph; import com.vci.client.LogonApplication; import com.vci.client.common.VCIBasePanel; import com.vci.client.framework.rightConfig.object.FunctionObject; import com.vci.client.framework.util.RightControlUtil; import com.vci.client.ui.exception.VCIException; import com.vci.client.ui.swing.KJButton; 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.VCIJComboBox; import com.vci.client.ui.swing.components.VCIJLabel; import com.vci.client.ui.swing.components.VCIJPanel; import com.vci.client.ui.swing.components.VCIJScrollPane; import com.vci.client.ui.swing.components.table.AbstractVCIJTableDataProvider; import com.vci.client.ui.swing.components.table.VCIJTableNode; import com.vci.client.ui.swing.components.table.VCIJTablePanel; import com.vci.client.workflow.commom.ClientHelper; import com.vci.client.workflow.delegate.ProcessCustomClientDelegate; import com.vci.client.workflow.editor.EditorCreateXmlToJbpm; import com.vci.client.workflow.editor.FlowCellRenderer; import com.vci.client.workflow.editor.FlowDesigner; import com.vci.client.workflow.editor.TaskDescCObject; import com.vci.client.workflow.editor.ZipUtil; import com.vci.client.workflow.template.object.ProcessCategoryObject; import com.vci.client.workflow.template.object.ProcessDefinitionObject; import com.vci.corba.common.VCIError; import com.vci.corba.workflow.data.CustomInfo; import com.vci.corba.workflow.data.ProcessTaskInfo; import com.vci.corba.workflow.data.PropertyInfo; public class ProcessCustomDataPanel extends VCIBasePanel{ private static final long serialVersionUID = 1L; private VCIJButton addButton = VCISwingUtil.createVCIJButton("","增加" ,"增加" , "add.png",null); private VCIJButton editButton = VCISwingUtil.createVCIJButton("","修改","修改", "edit.png",null); private VCIJButton deleteButton = VCISwingUtil.createVCIJButton("","删除" ,"删除", "delete.gif" ,null); private VCIJButton btnStart = VCISwingUtil.createVCIJButton("start", "启用", "启用", "ruby_get.png", null); private VCIJButton btnStop = VCISwingUtil.createVCIJButton("stop", "停用", "停用", "ruby_delete.png", null); private VCIJButton btnExp = VCISwingUtil.createVCIJButton("","导出" ,"导出", "export.gif" ,null);//new VCIJButton("导出"); private VCIJButton btnImport = VCISwingUtil.createVCIJButton("","导入" ,"导入", "import.gif" ,null);//new VCIJButton("导入"); private VCIJButton btncute = VCISwingUtil.createVCIJButton("","剪切" ,"剪切", "cut.gif" ,null);//new VCIJButton("剪切"); private VCIJButton btnpast = VCISwingUtil.createVCIJButton("","粘贴" ,"粘贴 ", "paste.gif" ,null);//new VCIJButton("粘贴"); //private String userName = LogonApplication.getUserEntityObject().getUserName(); private VCIJComboBox typeComb = new VCIJComboBox(); private String processCategoryId = ""; private String temname = ""; private String status = ""; private JTextField textField = null; private KJButton searchButton = new KJButton("查询","search.png"); //FunctionObject funcObj = new FunctionObject(); final JDialog dialog = new JDialog(LogonApplication.frame); public String getTextField() { return textField.getText().trim(); } private LinkedList selfCustomButtons = new LinkedList(); { selfCustomButtons.add(addButton); selfCustomButtons.add(editButton); selfCustomButtons.add(deleteButton); selfCustomButtons.add(btnStart); selfCustomButtons.add(btnStop); selfCustomButtons.add(btncute); selfCustomButtons.add(btnpast); selfCustomButtons.add(btnExp); selfCustomButtons.add(btnImport); } public ProcessCustomDataPanel(FunctionObject funcObj){ super(funcObj); init(); checkPermission(); } private void init() { LogonApplication.getUserEntityObject().setModules(this.getClass().getName()); initComponents(); initAction();//初始化按钮点击事件 if(tablePanel != null){ if(tablePanel.getTableModel().getList().size() > 0){ loadFlowImage(0); } } } private void initComponents() { setLayout(new BorderLayout()); add(initTablePanel(), BorderLayout.CENTER); /**加载流程模板分类时,去除空选项**/ // if(typeComb.getModel().getSize() > 0) { // typeComb.setSelectedIndex(0); // comboxActionPerformed(); // } } /** * 加载流程分类 * @return */ private JComboBox getCombox() { ProcessCategoryObject[] processCategories = null; ProcessCustomClientDelegate delSrv = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()); try { processCategories = delSrv.getProcessCategories("root"); } catch (VCIException e) { e.printStackTrace(); } if(processCategories!=null){ typeComb.addItem(new ProcessCategoryObject()); for(int i=0;i{ public ProcessDefinitionObject[] getDatas(int arg0, int arg1) { ProcessDefinitionObject[] processDefinitionsCount = null; ProcessDefinitionObject[] processDefinitions = null; try { if(processCategoryId!=null&&!"".equals(processCategoryId)){ processDefinitions = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()).getProcessDefinitions(processCategoryId); //processDefinitions = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()).getProcessDefinitionsByPage(processCategoryId,temname,arg1,arg0); if(temname!=null&&!"".equals(temname)){ processDefinitionsCount = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()).getProcessDefinitionByProcessDefinitionName(temname,processCategoryId); }else{ processDefinitionsCount = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()).getProcessDefinitions(processCategoryId); } this.total = processDefinitionsCount.length; }else{ processDefinitions = new ProcessDefinitionObject[0]; this.total = 0; } } catch (VCIException e) { e.printStackTrace(); } catch (Throwable e) { e.printStackTrace(); } Arrays.sort(processDefinitions, new Comparator(){ public int compare(ProcessDefinitionObject o1, ProcessDefinitionObject o2) { String n1 = o1.getName(); Long v1 = o1.getVersion(); String n2 = o2.getName(); Long v2 = o2.getVersion(); if(n1.equals(n2)){ return v1.compareTo(v2); } else { return n1.compareTo(n2); } }}); return processDefinitions; } public VCIJTableNode getNewRowNode(ProcessDefinitionObject dataObj) { VCIJTableNode node = new VCIJTableNode(dataObj); node.setPropertyValue(getSpecialColumns()[0], dataObj.getName()); node.setPropertyValue(getSpecialColumns()[1], dataObj.getVersion()); if("1".equals(dataObj.getStatus())) { status = "启用"; }else{ status = "停用"; } node.setPropertyValue(getSpecialColumns()[2], status); return node; } public String[] getSpecialColumns() { return "流程模板名称, 版本,状态".split(","); } public int getTotal() { return this.total; } } MyDataProvider dataProvider = new MyDataProvider(); VCIJTablePanel tablePanel = new VCIJTablePanel(dataProvider); private VCIJPanel tablePanel(){ int startIndex = dataProvider.getDataColumnStartIndex(); LinkedHashMap widthMaps = new LinkedHashMap(); widthMaps.put(startIndex++, 250); widthMaps.put(startIndex++, 50); widthMaps.put(startIndex++, 50); tablePanel.setColumnWidthMaps(widthMaps); //tablePanel.setCustomButtonFlowAlign(FlowLayout.CENTER); //tablePanel.setPageButtonFlowAlign(FlowLayout.CENTER); //tablePanel.setCustomButtonAutoScroll(false); tablePanel.setCustomButtons(selfCustomButtons); tablePanel.setShowPaging(false); tablePanel.setShowExport(false); tablePanel.buildTablePanel(); tablePanel.refreshTableData(); tablePanel.getTable().addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { int index = tablePanel.getTable().getSelectedRow(); loadFlowImage(index); } }); return tablePanel; } private void loadFlowImage(int index){ loadFlowCharPanel(tablePanel.getTableModel().getList().get(index).getObject()); } private JPanel initTablePanel(){ JPanel pal = new JPanel(); pal.setLayout(new BorderLayout()); pal.setBorder(new TitledBorder("流程模板管理")); JLabel labelName = new JLabel("流程分类"); JLabel queryName = new JLabel("流程模板名称"); textField = new JTextField(); labelName.setBounds(30, 5, 80, 25); typeComb.setBounds(120, 5, 180, 25); queryName.setBounds(310, 5, 80, 25); textField.setBounds(400, 5, 180, 25); searchButton.setBounds(590, 5, 80, 25); JPanel searchPal = new JPanel(); searchPal.setLayout(null); searchPal.setPreferredSize(new Dimension(900,35)); searchPal.add(labelName); searchPal.add(getCombox()); searchPal.add(queryName); searchPal.add(textField); searchPal.add(searchButton); pal.add(searchPal, BorderLayout.NORTH); splitPane.setDividerSize(7); splitPane.setContinuousLayout(true); splitPane.setOneTouchExpandable(true); splitPane.setDividerLocation(580); splitPane.setLeftComponent(tablePanel()); splitPane.setRightComponent(jspFlowImage); pal.add(splitPane, BorderLayout.CENTER); pal.setVisible(true); return pal; } private JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new VCIJPanel(), new VCIJPanel()); private VCIJLabel lblFlowImage = new VCIJLabel(); private VCIJScrollPane jspFlowImage = new VCIJScrollPane(lblFlowImage); private void loadFlowCharPanel(ProcessDefinitionObject procDecObj){ ProcessCustomClientDelegate del = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()); String deploymentId = procDecObj.getJbpmDeploymentId(); try { byte[] chartData = del.getProcessChart(deploymentId); InputStream is = new ByteArrayInputStream(chartData, 0, chartData.length); BufferedImage bu = ImageIO.read(is); ImageIcon icon = new ImageIcon(bu); lblFlowImage.setIcon(icon); Color color = new Color(255, 251, 255); jspFlowImage.getViewport().setBackground(color); } catch (VCIException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } /** * 保存剪切的模板 */ private List pastList =new ArrayList(); /** * 事件 */ private void initAction(){ addButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { // VCISwingUtil.setLookAndFeel(VCISwingUtil.LOOK_AND_FEEL_AlloyLookAndFeel); try { addButton_conform(); } catch (VCIError e1) { // TODO Auto-generated catch block e1.printStackTrace(); JOptionPane.showMessageDialog(null, e1.getMessage(), "addButton_conform", JOptionPane.ERROR_MESSAGE); } // VCISwingUtil.setLookAndFeel(VCISwingUtil.LOOK_AND_FEEL_PlasticLookAndFeel); } }); editButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { // VCISwingUtil.setLookAndFeel(VCISwingUtil.LOOK_AND_FEEL_AlloyLookAndFeel); try { editButton_conform(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); JOptionPane.showMessageDialog(null, e1.getMessage(), "editButton_conform", JOptionPane.ERROR_MESSAGE); } // VCISwingUtil.setLookAndFeel(VCISwingUtil.LOOK_AND_FEEL_PlasticLookAndFeel); } }); deleteButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { deleteButton_conform(); } }); typeComb.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent arg0) { comboxActionPerformed(); } }); searchButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { searchButton_actionPerformed(); } }); btncute.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { cuteTem(); } }); btnpast.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { pastTemp(); } }); btnStart.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { btnStart_conform(); } }); btnStop.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { btnStop_conform(); } }); btnExp.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { try { exportTemplate(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); JOptionPane.showMessageDialog(null, e1.getMessage(), "exportTemplate", JOptionPane.ERROR_MESSAGE); } } }); btnImport.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(ActionEvent e) { try { importTemplate(); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); JOptionPane.showMessageDialog(null, e1.getMessage(), "importTemplate", JOptionPane.ERROR_MESSAGE); } } }); // tablePanel.getTable().addMouseListener(new MouseListener() { // // @Override // public void mouseReleased(MouseEvent arg0) { // // TODO Auto-generated method stub // // } // // @Override // public void mousePressed(MouseEvent arg0) { // // TODO Auto-generated method stub // // } // // @Override // public void mouseExited(MouseEvent arg0) { // // TODO Auto-generated method stub // // } // // @Override // public void mouseEntered(MouseEvent arg0) { // // TODO Auto-generated method stub // // } // // @Override // public void mouseClicked(MouseEvent arg0) { // int rowIndex = tablePanel.getTable().getSelectedRow(); // tablePanel.getTableModel().get // ProcessDefinitionObject processDefinitionObject = (ProcessDefinitionObject)tablePanel.getTable()getValueAt(rowIndex, 2); // textField.setText(processDefinitionObject.getCategroyId()); // typeComb.setSelectedItem(processDefinitionObject); // } // }); // .addTableModelListener(new TableModelListener() { // // @Override // public void tableChanged(TableModelEvent arg0) { // int len = tablePanel.getSelectedRowIndexs().length; // textField.setText(String.valueOf(len)); // } // }); // getaddListSelectionListener(new ListSelectionListener(){ // // public void valueChanged(ListSelectionEvent e) // { // int rows=table.getSelectedRow(); // jid.setText(table.getValueAt(rows, 0).toString()); // jname.setText(table.getValueAt(rows, 1).toString()); // jsex.setText(table.getValueAt(rows, 2).toString()); // jdate.setText(table.getValueAt(rows, 3).toString()); // jam.setText(table.getValueAt(rows, 4).toString()); // jbj.setText(table.getValueAt(rows, 5).toString()); // } // }); } /** * 模板剪切 */ private void cuteTem() { ProcessCategoryObject cateObj = (ProcessCategoryObject)typeComb.getSelectedItem(); pastList =new ArrayList(); if(cateObj==null||"".equals(cateObj.getId())){ VCIOptionPane.showMessage(this, "请先选择流程分类!"); return; } int len = tablePanel.getSelectedRowIndexs().length; if(len == 0){ VCIOptionPane.showMessage(this, "请选择数据再进行修改操作!"); return; } List selectedObjs = tablePanel.getSelectedRowObjects(); for(ProcessDefinitionObject o : selectedObjs){ pastList.add(o.getJbpmDeploymentId()); } VCIOptionPane.showMessage(this, "保存数据到剪切板中!"); } /** * 模板粘贴 */ private void pastTemp() { ProcessCategoryObject cateObj = (ProcessCategoryObject)typeComb.getSelectedItem(); String categoryId = cateObj.getId(); ProcessCustomClientDelegate delegate = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()); try { for(int i=0;i entries = zf.entries(); //流程图graphXml byte[] graphXml = null; //流程模板xml byte[] processXml = null; //objectXml byte[] objectXml = null; //遍历zip文件 for (Enumeration e = entries ; e.hasMoreElements() ;) { ZipEntry nextElement = (ZipEntry) e.nextElement(); String name = nextElement.getName(); System.out.println(name); ZipEntry entry = zf.getEntry(name); InputStream inputStream = zf.getInputStream(entry); if(name.contains(".graph")){ graphXml = InputStreamToByte(inputStream); } else if(name.contains(".jpdl.xml")){ processXml = InputStreamToByte(inputStream); } else if(name.contains(".xml")){ objectXml = InputStreamToByte(inputStream); } } // JDialog dialog = new JDialog(LogonApplication.frame); dialog.setTitle("流程自定义"); dialog.setModal(true); FlowDesigner designer = new FlowDesigner(); designer.setFlowCategory((ProcessCategoryObject) selectedObj); ProcessDefinitionObject pd = new ProcessDefinitionObject(); String substring = fileName.substring(0,fileName.lastIndexOf(".")); pd.setName(substring); pd.setKey(substring); pd.setVersion(1); designer.setProcessDefinition(graphXml, processXml,pd,objectXml); designer.updatePanel(null); designer.isEdit(false); dialog.setContentPane(designer); Insets screenInsets = Toolkit.getDefaultToolkit() .getScreenInsets( LogonApplication.frame .getGraphicsConfiguration()); Dimension screenSize = Toolkit.getDefaultToolkit() .getScreenSize(); dialog.setLocation(0, 0); // dialog.setResizable(false); dialog.setSize((int) screenSize.getWidth(), (int) (screenSize.getHeight() - screenInsets.bottom)); dialog.setVisible(true); } catch (Exception e) { e.printStackTrace(); throw e; } } else { VCIOptionPane.showMessage(LogonApplication.frame, ClientHelper.getI18nStringForWorkflow(this.getClass().getName() + "." + "pleaseChooseProcessCategoryNode", getLocale())); } } /** * 将输入流转换为字节数组 * @param is * @return * @throws IOException */ private static byte[] InputStreamToByte(InputStream is) throws IOException { ByteArrayOutputStream bytestream = new ByteArrayOutputStream(); int ch; while ((ch = is.read()) != -1) { bytestream.write(ch); } byte imgdata[] = bytestream.toByteArray(); bytestream.close(); return imgdata; } /** * 模板导出 * @throws Exception */ public void exportTemplate() throws Exception{ ProcessCategoryObject cateObj = (ProcessCategoryObject)typeComb.getSelectedItem(); if(cateObj==null||"".equals(cateObj.getId())){ VCIOptionPane.showMessage(this, "请先选择流程分类!"); return; } int len = tablePanel.getSelectedRowIndexs().length; if(len == 0){ VCIOptionPane.showMessage(this, "请选择数据再进行操作!"); return; } if (len > 1){ VCIOptionPane.showMessage(this,"一次只能对一个对象进行修改,请重新选择!"); return; } ProcessDefinitionObject selectedObj = tablePanel.getSelectedRowObjects().get(0); boolean flag = false; if (selectedObj instanceof ProcessDefinitionObject) { FileChooseDiaog dialog = new FileChooseDiaog("export"); String filepath = dialog.getFilepath(); String zipName = dialog.getFileName(); if(filepath==null||"".equals(filepath)){ return; } ProcessDefinitionObject flowCategory = ( ProcessDefinitionObject) selectedObj; String templateName = flowCategory.getName(); //设置Designer对象 FlowDesigner designer = new FlowDesigner(); // VCIBaseTreeNode selectedTreeNode = toolBar.getMainPanel().getCurrentSelectedTreeNode(); // Object parentObj = ((VCIBaseTreeNode)selectedTreeNode.getParent()).getObj(); designer.setFlowCategory(cateObj); designer.setProcessDefinition((ProcessDefinitionObject) selectedObj); //获取graph对象 mxGraphComponent graphComponent = designer.getGraphComponent(); mxGraph graph = designer.getGraphComponent().getGraph(); BufferedImage image = FlowCellRenderer.createBufferedImage(graph, null, 1, Color.decode("#FFFBFF"), graphComponent.isAntiAlias(), graphComponent.getCanvas()); ByteArrayOutputStream baos = new ByteArrayOutputStream(); try { //获取流程图片 ImageIO.write(image, "png", baos); byte[] jbpmImage = baos.toByteArray(); //获取流程模板xml文件 EditorCreateXmlToJbpm getXml = new EditorCreateXmlToJbpm(designer); String jbpmXml = getXml.getsXml(); //获取流程图xml文件 mxCodec codec = new mxCodec(); mxIGraphModel model = designer.getGraphComponent().getGraph().getModel(); Node encode = codec.encode(model); String graphXml = mxUtils.getXml(encode); //创建对象xml Document document = DocumentHelper.createDocument(); Element rootElement = document.addElement("root"); //流程部署ID String jbpmDeploymentId = ((ProcessDefinitionObject) selectedObj).getJbpmDeploymentId(); //获取所有任务名称 String[] allTaskNames = new ProcessCustomClientDelegate().getAllTaskNames(jbpmDeploymentId); for(String taskName :allTaskNames){ //流程任务信息 ProcessTaskInfo processTaskInfo = new ProcessCustomClientDelegate().findById(jbpmDeploymentId, taskName); CustomInfo[] customUserInfos = processTaskInfo.customUserInfos; PropertyInfo[] taskTypeProperties = processTaskInfo.taskTypeProperties; //任务描述策略信息 TaskDescCObject[] taskDescCObject = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()).getTaskDescList(jbpmDeploymentId, taskName); //任务节点 // taskName = taskName.replaceAll(" ", ""); // Element taskNameElement = rootElement.addElement(taskName); //ProcessTaskInfo节点 Element processTaskInfoEle = rootElement.addElement("ProcessTaskInfo"); processTaskInfoEle.addAttribute("id", processTaskInfo.id); processTaskInfoEle.addAttribute("deploymentId", processTaskInfo.deploymentId); processTaskInfoEle.addAttribute("taskName", processTaskInfo.taskName); processTaskInfoEle.addAttribute("taskType", processTaskInfo.taskType); processTaskInfoEle.addAttribute("taskDesc", processTaskInfo.taskDesc); processTaskInfoEle.addAttribute("pltreatment", String.valueOf(processTaskInfo.pltreatment)); processTaskInfoEle.addAttribute("popUserDialog", processTaskInfo.popUserDialog); //CustomInfo节点 // if(customUserInfos.length==0){ // Element customInfoEle = processTaskInfoEle.addElement("CustomInfo"); // customInfoEle.addAttribute("className", ""); // customInfoEle.addAttribute("value", ""); // } for(int i =0;i map = new Hashtable(); InputStream is = new ByteArrayInputStream(jbpmImage); map.put(templateName + ".png", is); InputStream jpdlIs = new ByteArrayInputStream( jbpmXml.getBytes("utf-8")); map.put(templateName + ".jpdl.xml", jpdlIs); InputStream graphIs = new ByteArrayInputStream( graphXml.getBytes("utf-8")); map.put(templateName + ".graph", graphIs); InputStream taskObjectIs = new ByteArrayInputStream( taskObjectXML.getBytes("utf-8")); map.put(templateName + ".xml", taskObjectIs); ZipUtil.saveZip(path+"\\"+name + ".zip", map); File file = new File(path+"\\"+name + ".zip"); FileInputStream fis = new FileInputStream(file); ZipInputStream zin = new ZipInputStream(fis); } catch (Throwable e) { e.printStackTrace(); } return true; } /** * 搜索事件 */ private void searchButton_actionPerformed(){ processCategoryId = ((ProcessCategoryObject)typeComb.getSelectedItem()).getId();//获取流程分类 add by liujw temname = this.getTextField(); tablePanel.refreshTableData(); } private void comboxActionPerformed() { processCategoryId = ((ProcessCategoryObject)typeComb.getSelectedItem()).getId(); if(processCategoryId!=null&&!"".equals(processCategoryId)){ this.setProcessCategoryId(processCategoryId); this.tablePanel.setPageIndex(1); tablePanel.refreshTableData(); if(tablePanel != null){ if(tablePanel.getTableModel().getList().size() > 0){ loadFlowImage(0); } } }else{ tablePanel.refreshTableData(); } } /** * 添加事件 * @throws VCIError */ private void addButton_conform() throws VCIError{ ProcessCategoryObject obj = (ProcessCategoryObject)typeComb.getSelectedItem(); if(obj==null||"".equals(obj.getId())){ VCIOptionPane.showMessage(this, "请先选择流程分类!"); return; } dialog.setTitle(getI18nString("processCustom")); dialog.setModal(true); FlowDesigner designer = new FlowDesigner(); designer.setFlowCategory(obj); designer.isEdit(false); dialog.setContentPane(designer); Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(LogonApplication.frame.getGraphicsConfiguration()); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); dialog.setLocation(0, 0); dialog.setResizable(false); dialog.setSize((int)screenSize.getWidth(), (int)(screenSize.getHeight() - screenInsets.bottom)); SwingUtilities.invokeLater(new Runnable() { public void run() { dialog.setVisible(true); } }); tablePanel.refreshTableData(); } /** * 修改事件 * @throws Exception */ private void editButton_conform() throws Exception{ ProcessCategoryObject cateObj = (ProcessCategoryObject)typeComb.getSelectedItem(); if(cateObj==null||"".equals(cateObj.getId())){ VCIOptionPane.showMessage(this, "请先选择流程分类!"); return; } int len = tablePanel.getSelectedRowIndexs().length; if(len == 0){ VCIOptionPane.showMessage(this, "请选择数据再进行修改操作!"); return; } if (len > 1){ VCIOptionPane.showMessage(this, "一次只能对一个对象进行修改,请重新选择!"); return; } ProcessDefinitionObject obj = tablePanel.getSelectedRowObjects().get(0); dialog.setTitle(getI18nString("processCustom")); dialog.setModal(true); FlowDesigner designer = new FlowDesigner(); ProcessCategoryObject parentObj = (ProcessCategoryObject)typeComb.getSelectedItem(); designer.setFlowCategory(parentObj); designer.setProcessDefinition(obj); designer.updatePanel(null); designer.isEdit(true);//编辑状态 dialog.setContentPane(designer); Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets(LogonApplication.frame.getGraphicsConfiguration()); Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); dialog.setLocation(0, 0); dialog.setResizable(false); dialog.setSize((int)screenSize.getWidth(), (int)(screenSize.getHeight() - screenInsets.bottom)); SwingUtilities.invokeLater(new Runnable() { public void run() { dialog.setVisible(true); } }); tablePanel.refreshTableData(); } /** * 删除事件 */ private void deleteButton_conform(){ int len = tablePanel.getSelectedRowIndexs().length; if(len == 0){ VCIOptionPane.showMessage(this, "请选择要删除的对象!"); return; } if (VCIOptionPane.showQuestion(LogonApplication.frame, "确定要删除模板吗?") != 0) { return; } String[] puids = new String[len]; Map map = new HashMap(); for (int i = 0; i < len; i++) { ProcessDefinitionObject processDefinitionObject = tablePanel.getSelectedRowObjects().get(i); puids[i] = processDefinitionObject.getId(); map.put(processDefinitionObject.getId(), processDefinitionObject.getName()); try { deleteProcessDefinition(processDefinitionObject.getJbpmDeploymentId(), processDefinitionObject.getId()); } catch (VCIException exp) { VCIOptionPane.showError(LogonApplication.frame, "RMIPWorkflow", exp); return; } catch (Exception ex) { ex.printStackTrace(); } } tablePanel.refreshTableData(); } private void deleteProcessDefinition(String deployId, String pdId) throws VCIException { ProcessCustomClientDelegate delegate = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()); delegate.deleteProcessDefinition(deployId, pdId); } //启用流程 private void btnStart_conform(){ ProcessCategoryObject cateObj = (ProcessCategoryObject)typeComb.getSelectedItem(); if(cateObj==null||"".equals(cateObj.getId())){ VCIOptionPane.showMessage(this, "请先选择流程分类!"); return; } int len = tablePanel.getSelectedRowIndexs().length; if(len == 0){ VCIOptionPane.showMessage(this, "请选择数据再进行修改操作!"); return; } if (len > 1){ VCIOptionPane.showMessage(this,"一次只能对一个对象进行修改,请重新选择!"); return; } ProcessCustomClientDelegate processCusDel = new ProcessCustomClientDelegate(LogonApplication.userEntityObject); ProcessDefinitionObject obj = tablePanel.getSelectedRowObjects().get(0); try { boolean res = processCusDel.setProcessHide(obj.getJbpmDeploymentId(), (short)1); if(res){ JOptionPane.showMessageDialog(LogonApplication.frame, "启用成功!"); tablePanel.refreshTableData(); } } catch (VCIError e) { e.printStackTrace(); } } //停用流程 private void btnStop_conform() { ProcessCategoryObject cateObj = (ProcessCategoryObject)typeComb.getSelectedItem(); if(cateObj==null||"".equals(cateObj.getId())){ VCIOptionPane.showMessage(this, "请先选择流程分类!"); return; } int len = tablePanel.getSelectedRowIndexs().length; if(len == 0){ VCIOptionPane.showMessage(this, "请选择数据再进行修改操作!"); return; } if (len > 1){ VCIOptionPane.showMessage(this,"一次只能对一个对象进行修改,请重新选择!"); return; } ProcessCustomClientDelegate processCusDel = new ProcessCustomClientDelegate(LogonApplication.userEntityObject); ProcessDefinitionObject obj = tablePanel.getSelectedRowObjects().get(0); try { //status为0标识停用流程 boolean res = processCusDel.setProcessHide(obj.getJbpmDeploymentId(), (short)0); if(res) { JOptionPane.showMessageDialog(LogonApplication.frame, "停用成功!"); tablePanel.refreshTableData(); } } catch (VCIError e) { e.printStackTrace(); } } public String getProcessCategoryId() { return processCategoryId; } public void setProcessCategoryId(String processCategoryId) { this.processCategoryId = processCategoryId; } private String getI18nString(String spCode){ return ClientHelper.getI18nStringForWorkflow(this.getClass().getName() + "." + spCode, Locale.getDefault()); } }