Source Code Cross Referenced for Navigation.java in  » Web-Framework » JAT » com » jat » presentation » controller » navigation » 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 » Web Framework » JAT » com.jat.presentation.controller.navigation 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.jat.presentation.controller.navigation;
002:
003:        import java.util.Enumeration;
004:        import java.util.Vector;
005:        import javax.servlet.http.HttpServletRequest;
006:        import javax.servlet.http.HttpSession;
007:
008:        import com.jat.core.config.Config;
009:        import com.jat.core.log.LogManager;
010:        import com.jat.presentation.controller.Action;
011:
012:        /**
013:         * <p>Title: JAT</p>
014:         * <p>Description: </p>
015:         * <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
016:         * <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p>
017:         * @author stf
018:         * @version 1.0
019:         * @since 1.2
020:         */
021:
022:        public class Navigation {
023:
024:            public static String NAVIGATION = "JAT_NAVIGATION";
025:            public static String BACK = "JAT_BACK";
026:            public static String FORWARD = "JAT_FORWARD";
027:
028:            public static Navigation getDefault(HttpSession session) {
029:                Navigation nav = (Navigation) session.getAttribute(NAVIGATION);
030:                if (nav == null) {
031:                    nav = new Navigation();
032:                    session.setAttribute(NAVIGATION, nav);
033:                }
034:                return nav;
035:            }
036:
037:            public void addAction(HttpServletRequest request, Action action) {
038:                try {
039:                    boolean enabled = Config.getCurrent().getValue(
040:                            "navigation", "enabled").equalsIgnoreCase("true");
041:                    if (!enabled)
042:                        return;
043:                } catch (Exception ex) {
044:                    LogManager.sendDebug(this .getClass().getName()
045:                            + "::addAction: exception: " + ex);
046:                }
047:                if (this .isBackAction(request)) {
048:                    this .addForwardList(current);
049:                    this .current = this .removeBackList();
050:                } else if (this .isForwardAction(request)) {
051:                    this .addBackList(current);
052:                    this .current = this .removeForwardList();
053:                } else {
054:                    this .addBackList(current);
055:                    if (action.isNavigable())
056:                        this .current = new NavigationAction(request);
057:                    this .forwardList = new Vector();
058:                }
059:            }
060:
061:            public boolean hasBack() {
062:                return this .backList.size() > 0;
063:            }
064:
065:            public NavigationAction getBack() {
066:                NavigationAction back = null;
067:                if (this .hasBack())
068:                    back = (NavigationAction) this .backList.lastElement();
069:                return back;
070:            }
071:
072:            public boolean hasForward() {
073:                return this .forwardList.size() > 0;
074:            }
075:
076:            public NavigationAction getForward() {
077:                NavigationAction forward = null;
078:                if (hasForward())
079:                    forward = (NavigationAction) this .forwardList.lastElement();
080:                return forward;
081:            }
082:
083:            public String toString() {
084:                String ret = this .getClass().getName() + ":{";
085:                ret += "CURRENT=["
086:                        + (current != null ? this .current.getURI() : "null")
087:                        + "]";
088:                ret += "}, BACK_LIST(" + this .backList.size() + ")={";
089:                for (Enumeration e = this .backList.elements(); e
090:                        .hasMoreElements();) {
091:                    ret += "[" + ((NavigationAction) e.nextElement()).getURI()
092:                            + "]";
093:                }
094:                ret += " }, FORWARD_LIST(" + this .forwardList.size() + ")={";
095:                for (Enumeration e = this .forwardList.elements(); e
096:                        .hasMoreElements();) {
097:                    ret += "[" + ((NavigationAction) e.nextElement()).getURI()
098:                            + "]";
099:                }
100:                ret += " }";
101:                return ret;
102:            }
103:
104:            protected boolean isBackAction(HttpServletRequest request) {
105:                return request.getParameter(BACK) != null;
106:            }
107:
108:            protected boolean isForwardAction(HttpServletRequest request) {
109:                return request.getParameter(FORWARD) != null;
110:            }
111:
112:            protected void addBackList(NavigationAction action) {
113:                if (action == null)
114:                    return;
115:                if (this .getBack() != null && this .getBack().equals(action))
116:                    this .removeBackList();
117:                if (this .backList.size() > 10)
118:                    this .backList.remove(0);
119:                this .backList.addElement(action);
120:            }
121:
122:            protected void addForwardList(NavigationAction action) {
123:                if (action == null)
124:                    return;
125:                if (this .getForward() != null
126:                        && this .getForward().equals(action))
127:                    this .removeForwardList();
128:                this .forwardList.addElement(action);
129:            }
130:
131:            protected NavigationAction removeBackList() {
132:                if (backList.size() > 0)
133:                    return (NavigationAction) this .backList
134:                            .remove(this .backList.size() - 1);
135:                return null;
136:            }
137:
138:            protected NavigationAction removeForwardList() {
139:                if (forwardList.size() > 0)
140:                    return (NavigationAction) this .forwardList
141:                            .remove(this .forwardList.size() - 1);
142:                return null;
143:            }
144:
145:            private Navigation() {
146:            }
147:
148:            private Vector backList = new Vector();
149:            private Vector forwardList = new Vector();
150:            private NavigationAction current = null;
151:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.