KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > compiere > apps > ASyncProcessBase


1 /******************************************************************************
2  * The contents of this file are subject to the Compiere License Version 1.1
3  * ("License"); You may not use this file except in compliance with the License
4  * You may obtain a copy of the License at http://www.compiere.org/license.html
5  * Software distributed under the License is distributed on an "AS IS" basis,
6  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for
7  * the specific language governing rights and limitations under the License.
8  * The Original Code is Compiere ERP & CRM Business Solution
9  * The Initial Developer of the Original Code is Jorg Janke and ComPiere, Inc.
10  * Portions created by Jorg Janke are Copyright (C) 1999-2001 Jorg Janke, parts
11  * created by ComPiere are Copyright (C) ComPiere, Inc.; All Rights Reserved.
12  * Contributor(s): ______________________________________.
13  *****************************************************************************/

14 package org.compiere.apps;
15
16 import org.compiere.process.*;
17 import org.compiere.util.*;
18
19 /**
20  * ASync Process Base Class
21  *
22  * @author Jorg Janke
23  * @version $Id: ASyncProcessBase.java,v 1.4 2003/02/15 06:31:42 jjanke Exp $
24  */

25 public abstract class ASyncProcessBase implements ASyncProcess
26 {
27     /**
28      * Constructor
29      * @param pi process info
30      */

31     public ASyncProcessBase(ProcessInfo pi)
32     {
33         m_pi = pi;
34     } // ASyncProcessBase
35

36     private ProcessInfo m_pi;
37     private boolean m_isLocked = false;
38     private Splash m_splash;
39
40     /**
41      * Start ASync Worker
42      */

43     void start()
44     {
45         if (isUILocked()) // don't start twice
46
return;
47         ASyncWorker worker = new ASyncWorker (this, m_pi);
48         worker.start(); // calls lockUI, executeASync, unlockUI
49
} // start
50

51     /**
52      * Lock User Interface.
53      * Called from the Worker before processing
54      * @param pi process info
55      */

56     public void lockUI (ProcessInfo pi)
57     {
58         m_isLocked = true;
59         m_splash = new Splash (Msg.getMsg(Env.getCtx(), "Processing"));
60         m_splash.toFront();
61     } // lockUI
62

63     /**
64      * Unlock User Interface.
65      * Called from the Worker when processing is done
66      * @param pi process info
67      */

68     public void unlockUI (ProcessInfo pi)
69     {
70         m_isLocked = false;
71         m_splash.dispose();
72         m_splash = null;
73     } // unlockUI
74

75     /**
76      * Is the UI locked (Internal method)
77      * @return true, if UI is locked
78      */

79     public boolean isUILocked()
80     {
81         return m_isLocked;
82     } // isLoacked
83

84     /**
85      * Method to be executed async
86      * Called from the Worker
87      * @param pi process info
88      */

89     public abstract void executeASync (ProcessInfo pi);
90
91 } // ASyncProcessBase
92
Popular Tags