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.Toolkit;
|
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionListener;
|
|
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.LogonApplication;
|
import com.vci.client.framework.rightConfig.object.FunctionObject;
|
import com.vci.client.ui.swing.components.VCIJDialog;
|
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;
|
|
/**
|
* 抄送
|
*
|
* @author Administrator
|
*
|
*/
|
public class CCTaskDialog extends VCIJDialog {
|
|
private static final long serialVersionUID = 1461586100225135416L;
|
|
private FlowTaskInfo flowTask;
|
|
private IFlowTaskTpyeEvent action;
|
|
private ProcessTaskInfo frocessTaskInfo;
|
|
// private JButton btnCommit;
|
private JButton btnCancel;
|
// private JButton btnSave;
|
private JTable historyTable;
|
|
private HistoryTableModel historyTableModel;
|
|
private boolean view = false;
|
FunctionObject funcObject = new FunctionObject();
|
public CCTaskDialog(FlowTaskInfo flowTask, ProcessTaskInfo frocessTaskInfo) {
|
super(LogonApplication.frame, true);
|
setTitle(getI18nString("todo"));
|
this.flowTask = flowTask;
|
this.frocessTaskInfo = frocessTaskInfo;
|
initUI();
|
initData();
|
addListener();
|
}
|
|
public CCTaskDialog(FlowTaskInfo flowTask, ProcessTaskInfo frocessTaskInfo, boolean view) {
|
super(LogonApplication.frame, true);
|
this.view = view;
|
setTitle("查看");
|
this.flowTask = flowTask;
|
this.frocessTaskInfo = frocessTaskInfo;
|
initUI();
|
initData();
|
addListener();
|
}
|
|
private void initData() {
|
ProcessCustomClientDelegate processCustomClientDelegate = new ProcessCustomClientDelegate();
|
FlowApproveHistoryInfo[] historyActivity;
|
try {
|
historyActivity = processCustomClientDelegate.getHistoryActivityByProInsId(flowTask.executionId);
|
historyTableModel.setData(historyActivity);
|
} catch (VCIError e) {
|
e.printStackTrace();
|
}
|
|
}
|
|
private void addListener() {
|
if(!view) {
|
// btnCommit.addActionListener(new ActionListener() {
|
// public void actionPerformed(ActionEvent arg0) {
|
// if(action.completeTask()) {
|
// refreshTable();
|
// dispose();
|
// }else{
|
// return;
|
// }
|
// }
|
// });
|
//
|
btnCancel.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent arg0) {
|
dispose();
|
}
|
});
|
//
|
// btnSave.addActionListener(new ActionListener() {
|
// public void actionPerformed(ActionEvent arg0) {
|
// String saveMess = action.save();
|
// if("".equals(saveMess)||saveMess==null){
|
// refreshTable();
|
// dispose();
|
// VCIOptionPane.showMessage(LogonApplication.frame, "保存成功!");
|
// }
|
// }
|
// });
|
}
|
}
|
|
public void refreshTable() {
|
TodoTaskPanel instance = TodoTaskPanel.getInstance(funcObject,"");
|
instance.initData();
|
}
|
|
private void initUI() {
|
setSize(780, 600);
|
centerToScreen();
|
|
JPanel panel = new JPanel();
|
getContentPane().add(panel, BorderLayout.CENTER);
|
panel.setLayout(new BorderLayout(0, 0));
|
|
JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.TOP);
|
panel.add(tabbedPane, BorderLayout.CENTER);
|
|
if(!view) {
|
JPanel taskPanel = new JPanel();
|
String className = getFlowTaskClass(frocessTaskInfo.taskType);
|
action = getInstance(className);
|
if (action == null) {
|
return;
|
}
|
action.init(flowTask, frocessTaskInfo);
|
taskPanel.setLayout(new BorderLayout(0, 0));
|
taskPanel.add(action.getComponent(), BorderLayout.CENTER);
|
JPanel btnPanel = new JPanel();
|
JPanel botPanel = new JPanel();
|
JPanel labPanel = new JPanel();
|
JLabel label = new JLabel("(点击有下划线的属性名称,显示描述)");
|
label.setForeground(Color.RED);
|
labPanel.setLayout(new FlowLayout(FlowLayout.CENTER));
|
labPanel.add(label);
|
botPanel.setLayout(new BorderLayout());
|
// btnCommit = new JButton(getI18nString("commit"));
|
// btnSave = new JButton(getI18nString("save"));
|
btnCancel = new JButton("关闭");
|
// btnPanel.add(btnSave);
|
// btnPanel.add(btnCommit);
|
btnPanel.add(btnCancel);
|
// btnSave.setVisible(action.isShowSaveButton());
|
|
// if(action instanceof AttributeTypeTemplateDialog){
|
// botPanel.add(labPanel,BorderLayout.CENTER);
|
// }
|
botPanel.add(btnPanel,BorderLayout.SOUTH);
|
|
taskPanel.add(botPanel, BorderLayout.SOUTH);
|
tabbedPane.addTab(getFlowTaskName(frocessTaskInfo.taskType), null, taskPanel, null);
|
}
|
|
// RmDataPanel rmDataPanel = new RmDataPanel();
|
// rmDataPanel.init(flowTask);
|
// tabbedPane.addTab(getI18nString("flowData"), null, rmDataPanel, null);
|
|
JPanel historyPanel = new JPanel();
|
tabbedPane.addTab(getI18nString("processHis"), null, historyPanel, null);
|
historyPanel.setLayout(new BorderLayout(0, 0));
|
|
JScrollPane scrollPane = new JScrollPane();
|
historyPanel.add(scrollPane, BorderLayout.CENTER);
|
|
historyTableModel = new HistoryTableModel();
|
historyTable = new JTable(historyTableModel);
|
historyTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
|
scrollPane.setViewportView(historyTable);
|
historyTable.setRowHeight(25);
|
|
ViewExecutionImagePanel viewPanel = new ViewExecutionImagePanel(flowTask.executionId, flowTask.name);
|
tabbedPane.addTab(getI18nString("process"), null, viewPanel, null);
|
|
}
|
|
private IFlowTaskTpyeEvent getInstance(String className) {
|
@SuppressWarnings("rawtypes")
|
Class clazz;
|
try {
|
clazz = Class.forName(className);
|
Object newInstance = clazz.newInstance();
|
return (IFlowTaskTpyeEvent) newInstance;
|
} catch (ClassNotFoundException e) {
|
e.printStackTrace();
|
} catch (InstantiationException e) {
|
e.printStackTrace();
|
} catch (IllegalAccessException e) {
|
e.printStackTrace();
|
}
|
return null;
|
|
}
|
|
/**
|
* 居中屏幕
|
*/
|
private void centerToScreen() {
|
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension componentSize = getSize();
|
if (componentSize.height > 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 String getFlowTaskName(String type) {
|
return getI18nStringByCode("workflow.task.type." + type);
|
}
|
|
private String getFlowTaskClass(String type) {
|
return getI18nStringByCode("workflow.task.type." + type + ".class");
|
}
|
}
|