1 14 package org.compiere.util; 15 16 import javax.swing.*; 17 18 import org.compiere.process.*; 19 20 26 public class ASyncWorker extends Thread 27 { 28 34 public static ProcessInfo executeSync (ASyncProcess parent, ProcessInfo pi) 35 { 36 ASyncWorker worker = new ASyncWorker (parent, pi); 37 worker.start(); 38 try 39 { 40 worker.join(); 41 } 42 catch (InterruptedException e) 43 { 44 Log.error("ASyncWorker.executeSync", e); 45 } 46 return worker.getResult(); 47 } 49 54 public ASyncWorker (ASyncProcess parent, ProcessInfo pi) 55 { 56 m_parent = parent; 57 m_pi = pi; 58 } 60 private ProcessInfo m_pi; 61 private ASyncProcess m_parent; 62 63 66 public void run() 67 { 68 SwingUtilities.invokeLater(new Runnable () 69 { 70 public void run() 71 { 72 m_parent.lockUI(m_pi); 73 } 74 }); 75 76 m_parent.executeASync(m_pi); 78 80 SwingUtilities.invokeLater(new Runnable () 81 { 82 public void run() 83 { 84 m_parent.unlockUI (m_pi); 85 } 86 }); 87 } 89 93 public ProcessInfo getResult() 94 { 95 return m_pi; 96 } 98 } | Popular Tags |