Source Code Cross Referenced for JetspeedActions.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » 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 » jetspeed 2.1.3 » org.apache.jetspeed 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.jetspeed;
018:
019:        import java.util.ArrayList;
020:        import java.util.Collections;
021:        import java.util.HashMap;
022:        import java.util.List;
023:        import java.util.Map;
024:        import java.util.StringTokenizer;
025:
026:        import javax.portlet.PortletMode;
027:        import javax.portlet.WindowState;
028:
029:        /**
030:         * Jestpeed Action Declarations
031:         *
032:         * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
033:         * @author <a href="mailto:ate@douma.nu">Ate Douma</a>
034:         * @version $Id: JetspeedActions.java 593513 2007-11-09 12:48:34Z woonsan $
035:         */
036:        public class JetspeedActions {
037:            public static final PortletMode ABOUT_MODE = new PortletMode(
038:                    "about");
039:            public static final PortletMode CONFIG_MODE = new PortletMode(
040:                    "config");
041:            public static final PortletMode EDIT_DEFAULTS_MODE = new PortletMode(
042:                    "edit_defaults");
043:            //public static final PortletMode PREVIEW_MODE = new PortletMode("preview");
044:            public static final PortletMode PRINT_MODE = new PortletMode(
045:                    "print");
046:            public static final WindowState SOLO_STATE = new WindowState("solo");
047:
048:            public static final int MASK_MINIMIZE = 0x01;
049:            public static final int MASK_MAXIMIZE = 0x02;
050:            public static final int MASK_NORMAL = 0x04;
051:            public static final int MASK_VIEW = 0x08;
052:            public static final int MASK_EDIT = 0x10;
053:            public static final int MASK_HELP = 0x20;
054:
055:            public static final String VIEW = PortletMode.VIEW.toString();
056:            public static final String EDIT = PortletMode.EDIT.toString();
057:            public static final String HELP = PortletMode.HELP.toString();
058:            public static final String ABOUT = ABOUT_MODE.toString();
059:            public static final String CONFIG = CONFIG_MODE.toString();
060:            public static final String EDIT_DEFAULTS = EDIT_DEFAULTS_MODE
061:                    .toString();
062:            //public static final String PREVIEW = PREVIEW_MODE.toString();
063:            public static final String PRINT = PRINT_MODE.toString();
064:            public static final String NORMAL = WindowState.NORMAL.toString();
065:            public static final String MINIMIZE = WindowState.MINIMIZED
066:                    .toString();
067:            public static final String MAXIMIZE = WindowState.MAXIMIZED
068:                    .toString();
069:            public static final String SOLO = SOLO_STATE.toString();
070:
071:            private static final List standardPortletModes;
072:            private static final List standardWindowStates;
073:
074:            static {
075:                ArrayList list = new ArrayList(3);
076:                list.add(PortletMode.VIEW);
077:                list.add(PortletMode.EDIT);
078:                list.add(PortletMode.HELP);
079:                standardPortletModes = Collections.unmodifiableList(list);
080:                list = new ArrayList(3);
081:                list.add(WindowState.NORMAL);
082:                list.add(WindowState.MINIMIZED);
083:                list.add(WindowState.MAXIMIZED);
084:                standardWindowStates = Collections.unmodifiableList(list);
085:            }
086:
087:            private static JetspeedActions instance = new JetspeedActions(
088:                    new String[] {}, new String[] {});
089:
090:            private final List extendedPortletModes;
091:            private final List extendedWindowStates;
092:            private final Map actionsMap;
093:            private final Object[] actions;
094:
095:            public static List getStandardPortletModes() {
096:                return standardPortletModes;
097:            }
098:
099:            public static List getStandardWindowStates() {
100:                return standardWindowStates;
101:            }
102:
103:            public JetspeedActions(String[] supportedPortletModes,
104:                    String[] supportedWindowStates) {
105:                int index = 0;
106:
107:                ArrayList actionsList = new ArrayList();
108:
109:                actionsMap = new HashMap();
110:
111:                actionsMap.put(WindowState.MINIMIZED.toString(), new Integer(
112:                        index++));
113:                actionsList.add(WindowState.MINIMIZED);
114:                actionsMap.put(WindowState.MAXIMIZED.toString(), new Integer(
115:                        index++));
116:                actionsList.add(WindowState.MAXIMIZED);
117:                actionsMap.put(WindowState.NORMAL.toString(), new Integer(
118:                        index++));
119:                actionsList.add(WindowState.NORMAL);
120:                actionsMap.put(PortletMode.VIEW.toString(),
121:                        new Integer(index++));
122:                actionsList.add(PortletMode.VIEW);
123:                actionsMap.put(PortletMode.EDIT.toString(),
124:                        new Integer(index++));
125:                actionsList.add(PortletMode.EDIT);
126:                actionsMap.put(PortletMode.HELP.toString(),
127:                        new Integer(index++));
128:                actionsList.add(PortletMode.HELP);
129:
130:                ArrayList list = new ArrayList();
131:
132:                for (int i = 0; index < 32 && i < supportedWindowStates.length; i++) {
133:                    WindowState state = new WindowState(
134:                            supportedWindowStates[i]);
135:                    if (!actionsMap.containsKey(state.toString())) {
136:                        actionsMap.put(state.toString(), new Integer(index++));
137:                        actionsList.add(state);
138:                        list.add(state);
139:                    } else if (!standardWindowStates.contains(state)) {
140:                        throw new IllegalArgumentException(
141:                                "WindowState "
142:                                        + state
143:                                        + " already defined as extended PortletMode or WindowState");
144:                    }
145:                }
146:                extendedWindowStates = Collections.unmodifiableList(list);
147:
148:                list = new ArrayList();
149:
150:                for (int i = 0; index < 32 && i < supportedPortletModes.length; i++) {
151:                    PortletMode mode = new PortletMode(supportedPortletModes[i]);
152:                    if (!actionsMap.containsKey(mode.toString())) {
153:                        actionsMap.put(mode.toString(), new Integer(index++));
154:                        actionsList.add(mode);
155:                        list.add(mode);
156:                    } else if (!standardPortletModes.contains(mode)) {
157:                        throw new IllegalArgumentException(
158:                                "PortletMode "
159:                                        + mode
160:                                        + " already defined as extended PortletMode or WindowState");
161:                    }
162:                }
163:                extendedPortletModes = Collections.unmodifiableList(list);
164:
165:                actions = actionsList.toArray();
166:
167:                instance = this ;
168:            }
169:
170:            public static List getExtendedPortletModes() {
171:                return instance.extendedPortletModes;
172:            }
173:
174:            public static List getExtendedWindowStates() {
175:                return instance.extendedWindowStates;
176:            }
177:
178:            public static int getContainerActionMask(String action) {
179:                Integer index = (Integer) instance.actionsMap.get(action);
180:                if (index == null) {
181:                    throw new IllegalArgumentException("Unknown action: "
182:                            + action);
183:                }
184:                return 1 << index.intValue();
185:            }
186:
187:            public static String getContainerAction(int index) {
188:                JetspeedActions ja = JetspeedActions.instance;
189:                return index > -1 && index < ja.actions.length ? ja.actions[index]
190:                        .toString()
191:                        : null;
192:            }
193:
194:            public static String getContainerActions(int mask) {
195:                JetspeedActions ja = JetspeedActions.instance;
196:                StringBuffer buffer = new StringBuffer();
197:                boolean append = false;
198:
199:                for (int i = 0, j = 1 << i; i < ja.actions.length; i++, j = 1 << i) {
200:                    if ((mask & j) == j) {
201:                        if (append)
202:                            buffer.append(", ");
203:                        else
204:                            append = true;
205:                        buffer.append(ja.actions[i].toString());
206:                    }
207:                }
208:                return buffer.toString();
209:            }
210:
211:            public static int getContainerActionsMask(String actions) {
212:                int mask = 0;
213:
214:                if (actions != null) {
215:                    JetspeedActions ja = JetspeedActions.instance;
216:
217:                    StringTokenizer tokenizer = new StringTokenizer(actions,
218:                            ",\t ");
219:
220:                    Integer index;
221:                    while (tokenizer.hasMoreTokens()) {
222:                        String action = tokenizer.nextToken();
223:                        index = (Integer) ja.actionsMap.get(action);
224:                        if (index == null)
225:                            throw new IllegalArgumentException(
226:                                    "Unknown action: " + action);
227:                        mask |= (1 << index.intValue());
228:                    }
229:                }
230:                return mask;
231:            }
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.