Source Code Cross Referenced for WindowStateProvider.java in  » Swing-Library » wings3 » org » wings » portlet » 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 » Swing Library » wings3 » org.wings.portlet 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.wings.portlet;
002:
003:        import javax.portlet.RenderRequest;
004:        import javax.swing.event.EventListenerList;
005:
006:        import org.apache.commons.logging.Log;
007:        import org.apache.commons.logging.LogFactory;
008:        import org.wings.session.Session;
009:        import org.wings.session.SessionManager;
010:
011:        /**
012:         * This class provides the actual portlet window state as events. The static
013:         * Strings MAXIMIZED_WS, MINIMIZED_WS and NORMAL_WS are provided for comparing
014:         * with the actual window state. Also custom window states can be used. To get
015:         * an instance use getInstance() instead of the cunstrucor which is hidden. For
016:         * getting notified about a window state change use the
017:         * addWindowStateChangeListner Method
018:         * 
019:         * @author <a href="mailto:marc.musch@mercatis.com">Marc Musch</a>
020:         * 
021:         */
022:        public class WindowStateProvider {
023:
024:            private final transient static Log log = LogFactory
025:                    .getLog(WindowStateProvider.class);
026:
027:            /**
028:             * The String maximized
029:             */
030:            public static final String MAXIMIZED_WS = "maximized";
031:
032:            /**
033:             * The String minimized
034:             */
035:            public static final String MINIMIZED_WS = "minimized";
036:
037:            /**
038:             * The String normal
039:             */
040:            public static final String NORMAL_WS = "normal";
041:
042:            /**
043:             * Listeners intereted in an event fired if the window state changes
044:             */
045:            private EventListenerList listeners = new EventListenerList();
046:
047:            /**
048:             * The old window state, used so that only events are fired, if the window
049:             * state really has changed
050:             */
051:            private String oldWindowState = NORMAL_WS;
052:
053:            private WindowStateProvider() {
054:
055:            }
056:
057:            /**
058:             * Use this method to get an instance of this class, the constructir is
059:             * hidden.
060:             * 
061:             * @return Instance of this class
062:             */
063:            public static WindowStateProvider getInstance() {
064:                Session session = SessionManager.getSession();
065:
066:                WindowStateProvider pwsp = (WindowStateProvider) session
067:                        .getProperty(Const.WINGS_SESSION_PROPERTY_WINDOW_STATE_PROVIDER);
068:                if (pwsp != null) {
069:                    return pwsp;
070:                } else {
071:                    WindowStateProvider newPwsp = new WindowStateProvider();
072:                    session.setProperty(
073:                            Const.WINGS_SESSION_PROPERTY_WINDOW_STATE_PROVIDER,
074:                            newPwsp);
075:                    return newPwsp;
076:                }
077:
078:            }
079:
080:            /**
081:             * Adds a new listner for window state changes
082:             * 
083:             * @param listener -
084:             *            the listner for these events
085:             */
086:            public void addWindowStateChangeListener(
087:                    WindowStateListener listener) {
088:                listeners.add(WindowStateListener.class, listener);
089:            }
090:
091:            /**
092:             * Forces the delivering of the window change event, but only if the window
093:             * state really has changed
094:             */
095:            public void updateWindowState() {
096:                Session session = SessionManager.getSession();
097:                RenderRequest request = (RenderRequest) session
098:                        .getProperty(Const.WINGS_SESSION_PROPERTY_RENDER_REQUEST);
099:                if (request != null) {
100:                    String ws = request.getWindowState().toString();
101:                    log.debug("WingS-Portlet-Bridge: providing window state \""
102:                            + ws + "\"");
103:                    if (ws != null && !ws.equals(oldWindowState)) {
104:                        oldWindowState = ws;
105:                        notifyWindowState(new WindowStateEvent(this , ws));
106:                    }
107:                }
108:            }
109:
110:            /**
111:             * Notifies the listeners
112:             * 
113:             * @param e -
114:             *            the event to deliver
115:             */
116:            private synchronized void notifyWindowState(WindowStateEvent e) {
117:                for (WindowStateListener l : listeners
118:                        .getListeners(WindowStateListener.class))
119:                    l.windowStateChanged(e);
120:            }
121:
122:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.