Source Code Cross Referenced for ProviderRules.java in  » Portal » Open-Portal » com » sun » portal » providers » window » util » 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 » Portal » Open Portal » com.sun.portal.providers.window.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002 Sun Microsystems, Inc. All
003:         * rights reserved. Use of this product is subject
004:         * to license terms. Federal Acquisitions:
005:         * Commercial Software -- Government Users
006:         * Subject to Standard License Terms and
007:         * Conditions.
008:         *
009:         * Sun, Sun Microsystems, the Sun logo, and Sun ONE
010:         * are trademarks or registered trademarks of Sun Microsystems,
011:         * Inc. in the United States and other countries.
012:         */
013:        package com.sun.portal.providers.window.util;
014:
015:        import java.util.List;
016:        import java.util.ArrayList;
017:        import java.util.Map;
018:        import java.util.HashMap;
019:
020:        import com.sun.portal.container.WindowState;
021:        import com.sun.portal.container.ChannelMode;
022:
023:        import com.sun.portal.desktop.util.Integers;
024:        import com.sun.portal.providers.containers.ProviderWindowStates;
025:
026:        public class ProviderRules {
027:
028:            private static final Map _windowStateMap = getWindowStateMap();
029:            private static final Map _windowStateReverseMap = getWindowStateReverseMap();
030:
031:            private static List channelModeVHE = new ArrayList();
032:            private static List channelModeVH = new ArrayList();
033:            private static List windowStateMN = new ArrayList();
034:            private static List windowStateALL = new ArrayList();
035:
036:            static {
037:                channelModeVHE.add(ChannelMode.VIEW);
038:                channelModeVHE.add(ChannelMode.EDIT);
039:                channelModeVHE.add(ChannelMode.HELP);
040:
041:                channelModeVH.add(ChannelMode.VIEW);
042:                channelModeVH.add(ChannelMode.HELP);
043:
044:                // A list containing the MAX window state, to be used as
045:                // allowable window state when in HELP or EDIT mode.
046:                windowStateMN.add(WindowState.MAXIMIZED);
047:                windowStateMN.add(WindowState.NORMAL);
048:
049:                windowStateALL.add(WindowState.NORMAL);
050:                windowStateALL.add(WindowState.MAXIMIZED);
051:                windowStateALL.add(WindowState.MINIMIZED);
052:
053:            }
054:
055:            private static Map getWindowStateMap() {
056:                Map _windowStateMap = new HashMap();
057:
058:                _windowStateMap.put(
059:                        Integers.get(ProviderWindowStates.MINIMIZE),
060:                        WindowState.MINIMIZED);
061:                _windowStateMap.put(
062:                        Integers.get(ProviderWindowStates.MAXIMIZE),
063:                        WindowState.MAXIMIZED);
064:                _windowStateMap.put(Integers.get(ProviderWindowStates.NORMAL),
065:                        WindowState.NORMAL);
066:                return _windowStateMap;
067:
068:            }
069:
070:            private static Map getWindowStateReverseMap() {
071:
072:                Map _windowStateReverseMap = new HashMap();
073:                _windowStateReverseMap.put(WindowState.MINIMIZED, Integers
074:                        .get(ProviderWindowStates.MINIMIZE));
075:                _windowStateReverseMap.put(WindowState.MAXIMIZED, Integers
076:                        .get(ProviderWindowStates.MAXIMIZE));
077:                _windowStateReverseMap.put(WindowState.NORMAL, Integers
078:                        .get(ProviderWindowStates.NORMAL));
079:
080:                return _windowStateReverseMap;
081:            }
082:
083:            public static List getAllowableChannelModes(ChannelMode mode,
084:                    boolean authless) {
085:
086:                if (mode == null) {
087:                    throw new IllegalArgumentException(
088:                            "mode passed is null in getAllowableChannelModes.");
089:                }
090:                if (authless) {
091:                    if (mode.equals(ChannelMode.EDIT)) {
092:                        //
093:                        // should never be here, as authless is not allowed
094:                        // to be in edit mode.
095:                        // TODO: change to assertion.
096:                        //throw new RuntimeException(
097:                        //"Authless should not be in edit mode ever.");
098:                        throw new AssertionError(
099:                                "Authless should not be in edit mode ever.");
100:                    }
101:                    //
102:                    // Authless user can't change to EDIT mode.
103:                    //
104:                    return channelModeVH;
105:                } else {
106:                    // A list containing the VIEW mode and EDIT mode and HELP mode
107:                    // to be used as allowable modes.
108:                    return channelModeVHE;
109:                }
110:            }
111:
112:            //rama
113:            public static List getDefaultAllowableWindowStates(ChannelMode mode) {
114:
115:                if (mode == null) {
116:                    throw new RuntimeException(
117:                            "mode passed is null in getAllowableWindowStates.");
118:                }
119:                if (mode.equals(ChannelMode.VIEW)) {
120:                    return windowStateALL;
121:                } else if (mode.equals(ChannelMode.EDIT)) {
122:                    return windowStateMN;
123:                } else if (mode.equals(ChannelMode.HELP)) {
124:                    return windowStateMN;
125:                }
126:
127:                return null;
128:
129:            }
130:
131:            /**
132:             * Validate window state for the channelMode passed in. For Edit and
133:             * Help mode, window state minimized is not allowed.
134:             */
135:            public static boolean validateWindowStateChange(
136:                    ChannelMode channelMode, WindowState windowState) {
137:                boolean validState = true;
138:
139:                if (channelMode == null || windowState == null) {
140:                    return true;
141:                }
142:
143:                if ((channelMode.equals(ChannelMode.EDIT) || channelMode
144:                        .equals(ChannelMode.HELP))) {
145:                    if (windowState.equals(WindowState.MINIMIZED)) {
146:                        validState = false;
147:                    }
148:                }
149:                return validState;
150:            }
151:
152:            /**
153:             * Convert the window state representation used by the provider layer to
154:             * the representation understood by the container layer
155:             */
156:            public static List mapToStandards(int[] portalWindowStates) {
157:                List newList = new ArrayList();
158:                for (int i = 0; portalWindowStates != null
159:                        && i < portalWindowStates.length; i++) {
160:                    WindowState winState = (WindowState) _windowStateMap
161:                            .get(Integers.get(portalWindowStates[i]));
162:                    if (winState != null) {
163:                        newList.add(winState);
164:                    }
165:                }
166:                return newList;
167:
168:            }
169:
170:            /**
171:             * Convert the window state representation used by the provider layer to
172:             * the representation understood by the container layer
173:             */
174:            public static WindowState mapToStandards(int portalWindowState) {
175:                WindowState winState = (WindowState) _windowStateMap
176:                        .get(Integers.get(portalWindowState));
177:                return winState;
178:            }
179:
180:            /**
181:             * Convert the window state representation used by the container layer to
182:             * the representation understood by the provider layer
183:             */
184:            public static int mapToProvider(WindowState windowState) {
185:                int winState = ((Integer) _windowStateReverseMap
186:                        .get(windowState)).intValue();
187:                return winState;
188:            }
189:
190:            // rama
191:            public static WindowState getDefaultWindowState(
192:                    ChannelMode channelMode) {
193:                if (ChannelMode.VIEW.equals(channelMode)) {
194:                    return WindowState.NORMAL;
195:                } else if (ChannelMode.HELP.equals(channelMode)) {
196:                    return WindowState.MAXIMIZED;
197:                }
198:                if (ChannelMode.EDIT.equals(channelMode)) {
199:                    return WindowState.MAXIMIZED;
200:                }
201:                return WindowState.NORMAL;
202:            }
203:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.