Source Code Cross Referenced for StateHandler.java in  » Content-Management-System » harmonise » org » openharmonise » him » context » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Content Management System » harmonise » org.openharmonise.him.context 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the 
003:         * Mozilla Public License Version 1.1 (the "License"); 
004:         * you may not use this file except in compliance with the License. 
005:         * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. 
009:         * See the License for the specific language governing rights and 
010:         * limitations under the License.
011:         *
012:         * The Initial Developer of the Original Code is Simulacra Media Ltd.
013:         * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014:         *
015:         * All Rights Reserved.
016:         *
017:         * Contributor(s):
018:         */
019:
020:        package org.openharmonise.him.context;
021:
022:        import java.awt.*;
023:        import java.util.*;
024:
025:        import javax.swing.*;
026:
027:        import org.openharmonise.vfs.context.ContextEvent;
028:        import org.openharmonise.vfs.context.ContextHandler;
029:        import org.openharmonise.vfs.context.ContextType;
030:
031:        /**
032:         * The state handler maintains the "busy" state of the application.
033:         * Following the singleton pattern, any object can add a "wait" to the
034:         * state handler, which will then inform the UI elements that indicate
035:         * this to the user. The state handler will deal with overlapping "waits"
036:         * only removing the UI indications when all "waits" have been cleared.
037:         * 
038:         * @author Matthew Large
039:         * @version $Revision: 1.1 $
040:         *
041:         */
042:        public class StateHandler {
043:
044:            /**
045:             * Handler instance, following singleton pattern.
046:             */
047:            private static StateHandler m_instance = null;
048:
049:            /**
050:             * Main frame to set cursor on.
051:             */
052:            private JFrame m_frame = null;
053:
054:            /**
055:             * List of "wait" names.
056:             */
057:            private ArrayList m_aWaits = new ArrayList();
058:
059:            /**
060:             * Message to be displyed in status bar.
061:             */
062:            private String m_sBarText = null;
063:
064:            /**
065:             * 
066:             */
067:            private StateHandler() {
068:                super ();
069:            }
070:
071:            /**
072:             * Returns the message to be displayed in the status bar.
073:             * 
074:             * @return Status bar message
075:             */
076:            public String getBarText() {
077:                return this .m_sBarText;
078:            }
079:
080:            /**
081:             * Returns the handler instance, follows the singleton pattern.
082:             * 
083:             * @return Handler instance
084:             */
085:            public static StateHandler getInstance() {
086:                if (m_instance == null) {
087:                    m_instance = new StateHandler();
088:                }
089:                return m_instance;
090:            }
091:
092:            /**
093:             * Sets the main application window on which the cursor is to be
094:             * set.
095:             * 
096:             * @param frame Main application frame
097:             */
098:            public void setApplicationWindow(JFrame frame) {
099:                this .m_frame = frame;
100:            }
101:
102:            /**
103:             * Adds a "wait" to the state handler.
104:             * 
105:             * @param sWaitName Wait name
106:             */
107:            public void addWait(String sWaitName) {
108:                this .addWait(sWaitName, null);
109:            }
110:
111:            /**
112:             * Adds a "wait" to the state handler.
113:             * 
114:             * @param sWaitName Wait name
115:             * @param sBarText Status bar message
116:             */
117:            public void addWait(String sWaitName, String sBarText) {
118:                if (this .m_aWaits.size() == 0) {
119:                    if (sBarText != null) {
120:                        this .m_sBarText = sBarText;
121:                    }
122:                    ContextEvent ce = new ContextEvent(
123:                            ContextType.CONTEXT_WAIT, "ON");
124:                    ContextHandler.getInstance().fireContextEvent(ce);
125:                    this .m_frame.setCursor(Cursor.WAIT_CURSOR);
126:                }
127:                this .m_aWaits.add(sWaitName);
128:            }
129:
130:            /**
131:             * Adds a "wait" to the state handler.
132:             * 
133:             * @param comp Component to set the cursor on, for dialogs
134:             * @param sWaitName Wait name
135:             */
136:            public void addWait(Component comp, String sWaitName) {
137:                this .addWait(comp, sWaitName, null);
138:            }
139:
140:            /**
141:             * Adds a "wait" to the state handler.
142:             * 
143:             * @param comp Component to set the cursor on, for dialogs
144:             * @param sWaitName Wait name
145:             * @param sBarText Status bar message
146:             */
147:            public void addWait(Component comp, String sWaitName,
148:                    String sBarText) {
149:                comp.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
150:                this .addWait(sWaitName, sBarText);
151:            }
152:
153:            /**
154:             * Removes a "wait" from the state handler.
155:             * 
156:             * @param comp Component to set the cursor on, for dialogs
157:             * @param sWaitName Wait name
158:             */
159:            public void removeWait(Component comp, String sWaitName) {
160:                comp.setCursor(Cursor
161:                        .getPredefinedCursor(Cursor.DEFAULT_CURSOR));
162:                this .removeWait(sWaitName);
163:            }
164:
165:            /**
166:             * Removes a "wait" from the state handler.
167:             * 
168:             * @param sWaitName Wait name
169:             */
170:            public void removeWait(String sWaitName) {
171:                this .m_aWaits.remove(sWaitName);
172:                this .m_sBarText = null;
173:                if (this .m_aWaits.size() == 0) {
174:                    ContextEvent ce = new ContextEvent(
175:                            ContextType.CONTEXT_WAIT, "OFF");
176:                    ContextHandler.getInstance().fireContextEvent(ce);
177:                    this.m_frame.setCursor(Cursor.DEFAULT_CURSOR);
178:                }
179:            }
180:
181:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.