1 package org.enhydra.shark.swingclient.workflowadmin.instantiation.actions; 2 3 import java.awt.event.*; 4 import java.util.*; 5 6 import javax.swing.*; 7 8 9 10 import org.enhydra.shark.api.client.wfmodel.*; 11 import org.enhydra.shark.swingclient.*; 12 import org.enhydra.shark.swingclient.workflowadmin.*; 13 import org.enhydra.shark.swingclient.workflowadmin.instantiation.*; 14 15 21 public class InstantiateProcess extends ActionBase { 22 23 public InstantiateProcess (ProcessInstantiationManagement pim) { 24 super(pim); 25 } 26 27 public void actionPerformed(ActionEvent e) { 28 ProcessInstantiationManagement pim=(ProcessInstantiationManagement)actionPanel; 29 SharkAdmin workflowAdmin=pim.getWorkflowAdmin(); 30 WfProcessMgr spm=pim.getSelectedProcessMgr(); 31 try { 32 if (spm!=null) { 33 WfProcess proc=spm.create_process(pim.getProcessInstantiator()); 34 Map context=proc.process_context(); 36 Map contextSig=SharkAdmin.getExecAmin().getProcessMgrInputSignature(spm.name()); 37 38 Map formalPars=new LinkedHashMap(); 39 if (context!=null) { 40 for (Iterator i=context.entrySet().iterator(); i.hasNext();) { 41 Map.Entry me=(Map.Entry)i.next(); 42 if (contextSig.containsKey(me.getKey())) { 43 formalPars.put(me.getKey(),me.getValue()); 44 } 45 } 46 } 47 if (formalPars.size()>0) { 48 int updateVar=JOptionPane.showConfirmDialog( 49 workflowAdmin.getFrame(), 50 ResourceManager.getLanguageDependentString( 51 "MessageDoYouWantToUpdateProcessVariables"), 52 ResourceManager.getLanguageDependentString("ProcessInstantiationManagementKey"), 53 JOptionPane.YES_NO_OPTION, 54 JOptionPane.QUESTION_MESSAGE); 55 if (updateVar==JOptionPane.YES_OPTION) { 56 UpdateVariables upvd= 57 new UpdateVariables( 58 workflowAdmin.getFrame(), 59 ResourceManager.getLanguageDependentString("DialogUpdateProcessVariables"), 60 proc.key(), 61 formalPars, 62 null); 63 upvd.showDialog(); 64 if (context!=null) { 65 proc.set_process_context(formalPars); 66 } 67 } 68 } 69 70 proc.start(); 71 pim.getProcessInstantiator().addPerformer(proc); 72 pim.getTreeSelectionListener().valueChanged(null); 73 workflowAdmin.refresh(true); 74 75 } 76 } catch (NotEnabled ne) { 77 JOptionPane.showMessageDialog(workflowAdmin.getFrame(), 78 ResourceManager.getLanguageDependentString( 79 "WarningProcessInstantiationForSelectedDefinitionIsCurrentlyDisabled"), 80 workflowAdmin.getAppTitle(),JOptionPane.ERROR_MESSAGE); 81 } catch (Exception ex){ 82 ex.printStackTrace(); 83 System.out.println("Error while instatiating process:"); 84 } 85 } 86 } 87 | Popular Tags |