package com.vci.client.workflow.task; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.FlowLayout; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.text.MessageFormat; import javax.swing.Box; import javax.swing.JButton; import javax.swing.JComboBox; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.ListSelectionModel; import javax.swing.SwingUtilities; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.TableColumnModel; import com.vci.client.LogonApplication; import com.vci.client.framework.rightConfig.object.FunctionObject; import com.vci.client.ui.date.PopupCalendarMethod; import com.vci.client.ui.exception.VCIException; import com.vci.client.ui.image.BundleImage; import com.vci.client.ui.locale.LocaleDisplay; 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.ui.swing.components.VCIJComboBox; 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.FlowTaskInfo; import com.vci.corba.workflow.data.ProcessTaskInfo; public class DoneProcessPanel extends JPanel { /** * 已完成流程 */ private static final long serialVersionUID = -8012025583336084880L; //查询日期:由 private String DATE_START = LocaleDisplay.getI18nString("rmip.framework.log.startDate", "RMIPFramework", getLocale()); //到 private String TO = LocaleDisplay.getI18nString("rmip.framework.log.to", "RMIPFramework", getLocale()); //查询 private String QUERY = LocaleDisplay.getI18nString("rmip.framework.log.query", "RMIPFramework", getLocale()); private JLabel dateLabelStart = new JLabel(DATE_START); private JLabel dateLabelTo = new JLabel(TO); private VCIJComboBox startDateBox = new VCIJComboBox(); private VCIJComboBox endDateBox = new VCIJComboBox(); private JButton startDateButton = new PopupCalendarMethod().createDateDialogButton("date.gif",startDateBox); private JButton endDateButton = new PopupCalendarMethod().createDateDialogButton("date.gif",endDateBox); private JButton queryBtn = new JButton("查询"); private JButton clearBtn = new JButton("清空"); private JLabel missionJLabel = new JLabel("任务名称:"); private JTextField missionField = new JTextField(); private JLabel applicaJLabel = new JLabel("创建人:"); private JTextField applicaField = new JTextField(); private JLabel applicaDepartJLabel = new JLabel("创建部门:"); private JTextField applicaDeparField = new JTextField(); private JTable doneProcessTable; private DoneProcessTableModel doneProcessModel; private VCIJButton btnRefresh = VCISwingUtil.createVCIJButton("", "刷新", "刷新", "arrow_refresh.png"); private JButton btnView; private static DoneProcessPanel doneProcessPanel; String finishFlag = ""; String querySQL = ""; private VCIJCalendarPanel txtStartTime = new VCIJCalendarPanel(); private VCIJCalendarPanel txtEndTime = new VCIJCalendarPanel(); // added by ligang 分页功能的实现 private JButton firstPageButton = null; private JButton prePageButton = null; private JButton nextPageButton = null; private JButton lastPageButton = null; private JTextField textField = null; private JButton zhidingPageButton = null; int pagesize = getPageSize();// 每页记录数 int pageCount = 0;// 总页数 int rowCount = 0;// 总记录数 int curPage = 1; int TABLE_PAGE = 1;// 当前页数 private JLabel laber_pageinfo = new JLabel(getI18nString("pageInfo"));// 当前页/总页数 /** * 任务箱参数 */ static String taskType =""; FunctionObject funcObject = new FunctionObject(); private DoneProcessPanel(String taskType) { this.taskType = taskType; initUI(); initializeData(); checkPermission(); } /** 权限检查的模块标识 **/ private String checkPermissionModuleId = "com.vci.rmip.workflow.client.task.DoneProcessPanel"; @SuppressWarnings("unchecked") private void checkPermission() { // RightControlUtil.checkButtonStatutByModule(checkPermissionModuleId, // RightControlUtil.UPDATE, btnView); // checkRight(RightControlUtil.UPDATE, btnView); } private void initUI() { setLayout(new BorderLayout()); JPanel topPanel = new JPanel(new BorderLayout()); JPanel palNorthBtn = new JPanel(new FlowLayout(FlowLayout.CENTER, 5, 5)); btnView = new JButton("查看"); btnView.setIcon(VCISwingUtil.createImageIcon("search.png")); palNorthBtn.add(btnView); palNorthBtn.add(btnRefresh); btnRefresh.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { initializeData(); } }); } }); btnView.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { viewFlowInfo(); } }); JPanel searchPanel = new JPanel(new FlowLayout(FlowLayout.LEFT,5,5)); searchPanel.add(missionJLabel); missionField.setPreferredSize(new Dimension(100,25)); searchPanel.add(missionField); searchPanel.add(applicaJLabel); applicaField.setPreferredSize(new Dimension(100,25)); searchPanel.add(applicaField); searchPanel.add(applicaDepartJLabel); applicaDeparField.setPreferredSize(new Dimension(100,25)); searchPanel.add(applicaDeparField); JPanel dataPanel = new JPanel(new FlowLayout(FlowLayout.LEFT,5,5)); dataPanel.add(dateLabelStart); dataPanel.add(txtStartTime); dataPanel.add(dateLabelTo); dataPanel.add(txtEndTime); queryBtn.setIcon(VCISwingUtil.createImageIcon("search.png")); clearBtn.setIcon(VCISwingUtil.createImageIcon("clear.gif")); dataPanel.add(queryBtn); dataPanel.add(clearBtn); queryBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { queryBtn_ActionPerformed(); } }); } }); clearBtn.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { clearBtn_ActionPerformed(); } }); } }); topPanel.add(searchPanel,BorderLayout.NORTH); topPanel.add(dataPanel,BorderLayout.CENTER); add(topPanel, BorderLayout.NORTH); doneProcessModel = new DoneProcessTableModel(); doneProcessTable = new JTable(); doneProcessTable.setAutoResizeMode(JTable.AUTO_RESIZE_NEXT_COLUMN); doneProcessTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); doneProcessTable.setModel(doneProcessModel); doneProcessTable.setRowHeight(25); doneProcessTable.setShowGrid(true); doneProcessTable.getTableHeader().setFont(VCISwingUtil.FONT_DEFAULT); doneProcessTable.addMouseListener(new MouseAdapter() { public void mouseClicked(MouseEvent e) { if (e.getClickCount() == 2) { viewFlowInfo(); } } }); DefaultTableCellRenderer firstColumnRender = new DefaultTableCellRenderer(); firstColumnRender.setHorizontalAlignment(JLabel.CENTER); TableColumnModel doneModel = doneProcessTable.getColumnModel(); doneModel.getColumn(0).setCellRenderer(firstColumnRender); doneModel.getColumn(0).setPreferredWidth(48); doneModel.getColumn(0).setMaxWidth(48); doneModel.getColumn(2).setPreferredWidth(150); doneModel.getColumn(3).setPreferredWidth(150); JScrollPane jspTable = new JScrollPane(); jspTable.getViewport().add(doneProcessTable); add(jspTable, BorderLayout.CENTER); JPanel palPageBtns = new JPanel(); JPanel southPanel = new JPanel(new BorderLayout()); southPanel.add(palNorthBtn,BorderLayout.NORTH); southPanel.add(palPageBtns,BorderLayout.CENTER); add(southPanel, BorderLayout.SOUTH); initPageerButtons(palPageBtns); } public void initializeData() { curPage = 1; rowCount = getRowCount(); pageCount = getPageCount(); initData(); updateBtnStatus(); laber_pageinfo.setText(MessageFormat.format(getI18nString("pageInfo"), rowCount, pageCount, curPage)); } private void initPageerButtons(JPanel pal) { firstPageButton = new JButton(""); pal.add(firstPageButton); firstPageButton.setIcon(new BundleImage() .createImageIcon("resultset_first.png")); prePageButton = new JButton(""); pal.add(prePageButton); prePageButton.setIcon(new BundleImage() .createImageIcon("resultset_previous.png")); textField = new JTextField(3); pal.add(textField); zhidingPageButton = new JButton(); pal.add(zhidingPageButton); zhidingPageButton.setIcon(new BundleImage() .createImageIcon("arrow_rotate_clockwise.png")); nextPageButton = new JButton(""); pal.add(nextPageButton); nextPageButton.setIcon(new BundleImage() .createImageIcon("resultset_next.png")); lastPageButton = new JButton(""); pal.add(lastPageButton); lastPageButton.setIcon(new BundleImage() .createImageIcon("resultset_last.png")); firstPageButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { curPage = 1; initData(); updateBtnStatus(); } }); prePageButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (curPage > 1) { curPage--; } initData(); updateBtnStatus(); } }); nextPageButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (curPage < getPageCount()) { curPage++; } initData(); updateBtnStatus(); } }); lastPageButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { curPage = getPageCount(); initData(); updateBtnStatus(); } }); zhidingPageButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int i = getTextField(); if(i != 0 ){ curPage = i; initData(); updateBtnStatus(); } } }); pal.add(Box.createHorizontalStrut(30)); pal.add(laber_pageinfo); } private void viewFlowInfo() { int selectedRow = doneProcessTable.getSelectedRow(); if (selectedRow == -1) { JOptionPane.showMessageDialog(DoneProcessPanel.this, "请选择需要查看的已完成流程!", "提示信息", JOptionPane.INFORMATION_MESSAGE); return; } FlowTaskInfo flowHistoryTaskInfo = doneProcessModel.getValue(selectedRow); if (flowHistoryTaskInfo == null) { return; } // 查出阶段名称 ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate(LogonApplication.getUserEntityObject()); String jbpmDeploymentId; try { jbpmDeploymentId = processCustomClientDelegate .getDeploymentIdByExecutionId(flowHistoryTaskInfo.executionId); if ("".equals(jbpmDeploymentId)) { // JOptionPane.showMessageDialog(doneTaskPanel, // "该流程不存在或已经执行完成!","提示信息", JOptionPane.INFORMATION_MESSAGE); jbpmDeploymentId = processCustomClientDelegate .getDepolymentID(flowHistoryTaskInfo.executionId); ProcessTaskInfo frocessTaskInfo = processCustomClientDelegate .findTaskPropertyByProcessId(jbpmDeploymentId); finishFlag = "完成"; DoneProcessDialog doneProcessDialog = new DoneProcessDialog( flowHistoryTaskInfo, frocessTaskInfo, finishFlag); doneProcessDialog.setVisible(true); // initData(); // return; } else { ProcessTaskInfo frocessTaskInfo = processCustomClientDelegate .findTaskPropertyByProcessId(jbpmDeploymentId); DoneProcessDialog doneProcessDialog = new DoneProcessDialog( flowHistoryTaskInfo, frocessTaskInfo, finishFlag); doneProcessDialog.setVisible(true); } } catch (VCIError e) { e.printStackTrace(); } } public void initData() { try { FlowTaskInfo[] dataObjs = new ProcessCustomClientDelegate( LogonApplication.getUserEntityObject()) .getDoneProcessByUserId(LogonApplication.getUserObject() .getUserName(), curPage, pagesize,taskType,querySQL); doneProcessModel.setData(dataObjs); doneProcessTable.removeAll(); doneProcessTable.setModel(doneProcessModel); } catch (VCIError e) { e.printStackTrace(); } updateUI(); } public static DoneProcessPanel getInstance(FunctionObject funcObject,String taskType) { // if (doneTaskPanel == null) { doneProcessPanel = new DoneProcessPanel(taskType); // } return doneProcessPanel; } private int getPageSize() { if (this.pagesize == 0) { String pageSize = "150"; // try { // pageSize = new // UserRightClientDelegate().getConfigValue("log.query.pagesize"); // } catch (VCIError e) { // e.printStackTrace(); // } int pageSizeGet = Integer.parseInt(pageSize); this.pagesize = pageSizeGet; } return pagesize; } private int getRowCount() { try { return new ProcessCustomClientDelegate( LogonApplication.getUserEntityObject()) .queryDoneProcessCount(LogonApplication.getUserObject() .getUserName(),taskType); } catch (VCIException e) { e.printStackTrace(); return 1; } } private int getPageCount() { int dataRowCount = getRowCount(); int pageSize = getPageSize(); int pageCount = dataRowCount / pageSize; if (dataRowCount % pageSize > 0) { pageCount++; } return pageCount; } private void updateBtnStatus() { int rowCount = this.getRowCount(); int pageSize = getPageSize(); int pageCount = rowCount / pageSize; if (rowCount % pageSize > 0) { pageCount++; } if (pageCount <= 1) { firstPageButton.setEnabled(false); prePageButton.setEnabled(false); lastPageButton.setEnabled(false); nextPageButton.setEnabled(false); } else { if (curPage == 1) { firstPageButton.setEnabled(false); prePageButton.setEnabled(false); lastPageButton.setEnabled(true); nextPageButton.setEnabled(true); } else if (curPage >= pageCount) { firstPageButton.setEnabled(true); prePageButton.setEnabled(true); lastPageButton.setEnabled(false); nextPageButton.setEnabled(false); } else { firstPageButton.setEnabled(true); prePageButton.setEnabled(true); lastPageButton.setEnabled(true); nextPageButton.setEnabled(true); } } laber_pageinfo.setText(MessageFormat.format(getI18nString("pageInfo"), rowCount, pageCount, curPage)); } private void queryBtn_ActionPerformed(){ getDateTimeFilterString(); initData(); updateBtnStatus(); } private void clearBtn_ActionPerformed(){ txtStartTime.setDateString(); txtEndTime.setDateString(); querySQL = ""; missionField.setText(""); applicaField.setText(""); applicaDeparField.setText(""); } /** * 返回日期范围的过滤条件字符串 *
Description:
* * @author xchao * @time 2012-11-9 * @return */ public String getDateTimeFilterString(){ String filterString = ""; String startTime = txtStartTime.getDateString();//开始时间 String endTime = txtEndTime.getDateString();//结束时间 String mission = missionField.getText();//任务名称 String application = applicaField.getText();//创建人 String applicaDepar = applicaDeparField.getText();//创建人部门 if(startTime == null || "".equals(startTime.trim())){ startTime = "1900-01-01 00:00:00"; } else { startTime = startTime.substring(0, 10) + " 00:00:00"; } if(endTime == null || "".equals(endTime.trim())){ endTime = "9900-12-30 23:59:59"; } else { endTime = endTime.substring(0, 10) + " 23:59:59"; } filterString = " AND " + "(" + "CREATE_ >= TO_DATE('" + startTime + "','yyyy-MM-dd HH24:mi:ss')" + " AND " + "CREATE_ <= TO_DATE('" + endTime + "','yyyy-MM-dd HH24:mi:ss')"; filterString += ")" + ""; if(!"".equals(mission)){ filterString += " AND PLDESC = '" + mission +"'"; } if (!"".equals(application)){ filterString += " AND createUser like '%" + application +"%'"; } if (!"".equals(applicaDepar)){ filterString += "#"+applicaDepar; } querySQL = filterString; return querySQL; } private String getI18nString(String spCode) { return ClientHelper.getI18nStringForWorkflow(this.getClass().getName() + "." + spCode, this.getLocale()); } private int getTextField(){ int i = 0;//输入的页数 int count = getPageCount();//总页数 if(textField.getText() == ""){ VCIOptionPane.showMessage(this, "请输入要跳转的页数"); return i; }else { String field = textField.getText(); if(!field.matches("^[0-9_]+$")) { VCIOptionPane.showMessage(this, "请输入数字"); return i; }else if(Integer.parseInt(field)>count){ VCIOptionPane.showMessage(this, "输入的页数大于总页数"); return i; }else { i = Integer.parseInt(field); return i; } } } }