ludc
2025-01-16 986aa62ed00bee39363bab41b4eeb8259d446efd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
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");
    }
}