KickJava   Java API By Example, From Geeks To Geeks.

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


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 java.awt.*;
17 import java.awt.event.*;
18 import java.util.*;
19 import javax.swing.*;
20 import java.sql.*;
21
22 import org.compiere.apps.*;
23 import org.compiere.model.*;
24 import org.compiere.util.*;
25 import org.compiere.plaf.*;
26
27 /**
28  * Main Application Window.
29  * - Constructs, initializes and positions JFrame
30  * - Gets content, menu, title from APanel
31  *
32  * @author Jorg Janke
33  * @version $Id: AWindow.java,v 1.21 2003/06/11 04:05:00 jjanke Exp $
34  */

35 public class AWindow extends JFrame
36 {
37     /**
38      * Standard Constructor - requires initWindow
39      */

40     public AWindow ()
41     {
42         super();
43         //
44
this.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
45         CompiereColor.setBackground(this);
46         // Set UI Components
47
this.setIconImage(org.compiere.Compiere.getImage16());
48         this.getContentPane().add(m_APanel, BorderLayout.CENTER);
49         this.setGlassPane(m_glassPane);
50     } // AWindow
51

52     /** The GlassPane */
53     private AGlassPane m_glassPane = new AGlassPane();
54     /** Application Window */
55     private APanel m_APanel = new APanel();
56
57     /**
58      * Dynamic Initialization Workbench
59      * @param AD_Workbench_ID workbench
60      * @param isSOTrx sales trx
61      * @return true if loaded OK
62      */

63     protected boolean initWorkbench (int AD_Workbench_ID, boolean isSOTrx)
64     {
65         this.setName("AWindow_WB_" + AD_Workbench_ID);
66         boolean loadedOK = m_APanel.initPanel (AD_Workbench_ID, 0, null, isSOTrx);
67         //
68
commonInit();
69         return loadedOK;
70     } // initWorkbench
71

72     /**
73      * Dynamic Initialization Single Window
74      * @param AD_Window_ID window
75      * @param query query
76      * @param isSOTrx sales trx
77      * @return true if loaded OK
78      */

79     public boolean initWindow (int AD_Window_ID, MQuery query, boolean isSOTrx)
80     {
81         this.setName("AWindow_" + AD_Window_ID);
82         //
83
boolean loadedOK = m_APanel.initPanel (0, AD_Window_ID, query, isSOTrx);
84         commonInit();
85         return loadedOK;
86     } // initWindow
87

88     /**
89      * Common Init.
90      * After APanel loaed
91      */

92     private void commonInit()
93     {
94         this.setJMenuBar(m_APanel.getMenuBar());
95         this.setTitle(m_APanel.getTitle());
96     } // commonInit
97

98     /*************************************************************************/
99
100     /**
101      * Set Window Busy
102      * @param busy busy
103      */

104     public void setBusy (boolean busy)
105     {
106         if (busy == m_glassPane.isVisible())
107             return;
108         Log.trace(Log.l1_User, "AWindow.setBusy - " + busy);
109         m_glassPane.setMessage(null);
110         m_glassPane.setVisible(busy);
111         m_glassPane.requestFocus();
112     } // setBusy
113

114     /**
115      * Set Busy Message
116      * @param AD_Message message
117      */

118     public void setBusyMessage (String JavaDoc AD_Message)
119     {
120         m_glassPane.setMessage(AD_Message);
121     } // setBusyMessage
122

123     /**
124      * Set and start Busy Counter
125      * @param time in seconds
126      */

127     public void setBusyTimer (int time)
128     {
129         m_glassPane.setBusyTimer (time);
130     } // setBusyTimer
131

132     /**
133      * Window Events
134      * @param e event
135      */

136     protected void processWindowEvent(WindowEvent e)
137     {
138         super.processWindowEvent(e);
139 // System.out.println(">> Apps WE_" + e.getID() // + " Frames=" + getFrames().length
140
// + " " + e);
141
} // processWindowEvent
142

143     /**
144      * Dispose
145      */

146     public void dispose()
147     {
148         Log.trace(Log.l1_User, "AWindow.dispose");
149         if (m_APanel != null)
150             m_APanel.dispose();
151         m_APanel = null;
152         this.removeAll();
153         super.dispose();
154     // System.gc();
155
} // dispose
156

157     /**
158      * String Representation
159      * @return Name
160      */

161     public String JavaDoc toString()
162     {
163         return getName();
164     } // toString
165

166 } // AWindow
167
Popular Tags