KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > shark > corbaclient > worklist > actions > UpdateActivityVariables


1 package org.enhydra.shark.corbaclient.worklist.actions;
2
3
4 import java.awt.*;
5 import java.awt.event.*;
6
7 import javax.swing.*;
8
9 import org.omg.WfBase.*;
10 import org.omg.WorkflowModel.*;
11 import org.enhydra.shark.corbaclient.*;
12 import org.enhydra.shark.corbaclient.worklist.*;
13
14 /**
15  * Implements the action of updating workitem variables. It get's the workitem
16  * that corredponds to the selecte table row, and shows the dialog for the
17  * update of variables.
18  *
19  * @author Sasa Bojanic
20  * @version 1.0
21  */

22 public class UpdateActivityVariables extends ActionBase {
23    public UpdateActivityVariables (Worklist worklist) {
24       super(worklist);
25    }
26
27    public void actionPerformed(ActionEvent e) {
28       Worklist worklist=(Worklist)actionPanel;
29       WfAssignment ass=worklist.getSelectedAssignment();
30       if (ass!=null) {
31          // check if the workitem is accepted
32
try {
33             boolean accepted=ass.get_accepted_status();
34             if (!accepted) {
35                JOptionPane.showMessageDialog(worklist.getWindow(),
36                                              ResourceManager.getLanguageDependentString(
37                                                 "WarningTheWorkitemMustBeAcceptedBeforeVariableUpdate"),
38                                              SharkClient.getAppTitle(),JOptionPane.WARNING_MESSAGE);
39                return;
40             }
41
42             WfActivity wa;
43             wa=ass.activity();
44
45             // check the context of activity
46
String JavaDoc waKey=wa.key();
47             NameValue[] actContext=null;
48             if (worklist.isWorkitemContextUpdated(waKey)) {
49                actContext=worklist.getWorkitemContext(waKey);
50             } else {
51                actContext=WorkflowUtilities.getActivityContext(wa.process_context(),
52                                                                wa,WorkflowUtilities.VARIABLE_TO_PROCESS_ALL);
53             }
54             NameValue[] readOnlyContext=null;
55             if (actContext!=null && actContext.length>0) {
56                readOnlyContext=WorkflowUtilities.getActivityContext(actContext,wa,
57                                                                     WorkflowUtilities.VARIABLE_TO_PROCESS_VIEW);
58             }
59             Window w=worklist.getWindow();
60             UpdateVariables upvd=new UpdateVariables(w,
61                                                      ResourceManager.getLanguageDependentString("DialogUpdateProcessVariables"),
62                                                      wa.container().key(),
63                                                      actContext,
64                                                      readOnlyContext);
65             upvd.showDialog();
66             if (actContext!=null && !upvd.isCanceled()) {
67                worklist.putWorkitemContext(waKey,actContext);
68                NameValue[] updContext=WorkflowUtilities.getActivityContext(actContext,
69                                                                            wa,WorkflowUtilities.VARIABLE_TO_PROCESS_UPDATE);
70                wa.set_process_context(updContext);
71             }
72          } catch (Exception JavaDoc ex) {}
73       }
74    }
75
76 }
77
78
Popular Tags