Source Code Cross Referenced for Navigator.java in  » Report » openi » org » openi » xmla » navigator » 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 » Report » openi » org.openi.xmla.navigator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ====================================================================
003:         * This software is subject to the terms of the Common Public License
004:         * Agreement, available at the following URL:
005:         *   http://www.opensource.org/licenses/cpl.html .
006:         * Copyright (C) 2003-2004 TONBELLER AG.
007:         * All Rights Reserved.
008:         * You must accept the terms of that agreement to use this software.
009:         * ====================================================================
010:         *
011:         * Contributor(s): i18n: Pedro Casals Fradera (2006/06/24)
012:         *
013:         */
014:        package org.openi.xmla.navigator;
015:
016:        import java.util.List;
017:        import java.util.Set;
018:
019:        import javax.servlet.http.HttpSession;
020:
021:        import org.w3c.dom.Document;
022:
023:        import com.tonbeller.jpivot.core.ModelChangeEvent;
024:        import com.tonbeller.jpivot.core.ModelChangeListener;
025:
026:        import org.openi.project.ProjectContext;
027:        import org.openi.xmla.navigator.hierarchy.*;
028:        import com.tonbeller.jpivot.navigator.member.MemberNavigator;
029:        import com.tonbeller.jpivot.olap.model.Hierarchy;
030:        import com.tonbeller.jpivot.olap.model.OlapModel;
031:        import com.tonbeller.jpivot.ui.Available;
032:        import com.tonbeller.wcf.component.Component;
033:        import com.tonbeller.wcf.component.ComponentSupport;
034:        import com.tonbeller.wcf.controller.RequestContext;
035:        import com.tonbeller.wcf.controller.RequestListener;
036:        import com.tonbeller.wcf.selection.SelectionModel;
037:        import com.tonbeller.wcf.tree.NodeSorter;
038:
039:        /**
040:         * Root Component, contains MemberNavigator and HierarchyNavigator.
041:         * Coordinates the activities between MemberNavigator and HierarchyNavigator (GOF Director pattern).
042:         *
043:         * @author av
044:         */
045:
046:        public class Navigator extends ComponentSupport implements 
047:                ModelChangeListener, Available {
048:            OlapModel olapModel;
049:            MemberNavigator memberNav;
050:            HierarchyNavigator hierarchyNav;
051:            HierarchyItem currentItem;
052:            Component current;
053:
054:            public Navigator(String id, Component parent, OlapModel olapModel) {
055:                super (id, parent);
056:                this .olapModel = olapModel;
057:                olapModel.addModelChangeListener(this );
058:
059:                RequestListener acceptHandler = createMemberNavAcceptHandler();
060:                RequestListener cancelHandler = createMemberNavCancelHandler();
061:                memberNav = new MemberNavigator(id + ".membernav", this ,
062:                        olapModel, acceptHandler, cancelHandler);
063:                hierarchyNav = new HierarchyNavigator(id + ".hiernav", this ,
064:                        olapModel);
065:                if (memberNav.isAvailable())
066:                    hierarchyNav
067:                            .setHierarchyItemClickHandler(createHierarchyItemClickHandler());
068:                current = hierarchyNav;
069:            }
070:
071:            /**
072:             * lifecycle
073:             */
074:            public void initialize(RequestContext context) throws Exception {
075:                ProjectContext prjCtx = (ProjectContext) context.getSession()
076:                        .getAttribute("projectContext");
077:                context.setLocale(prjCtx.getUser().getLocale());
078:                super .initialize(context);
079:                memberNav.initialize(context);
080:                hierarchyNav.initialize(context);
081:            }
082:
083:            /**
084:             * lifecycle
085:             */
086:            public void destroy(HttpSession session) throws Exception {
087:                memberNav.destroy(session);
088:                hierarchyNav.destroy(session);
089:                super .destroy(session);
090:            }
091:
092:            public Document render(RequestContext context) throws Exception {
093:                return current.render(context);
094:            }
095:
096:            /**
097:             * sets component to visible
098:             */
099:            public void show(Component component) {
100:                if (component == null)
101:                    this .current = hierarchyNav;
102:                else
103:                    this .current = component;
104:            }
105:
106:            /**
107:             * invoked when the user clicks on a Hierarchy in the HierarchyNavigator
108:             */
109:            private class HierarchyItemClickAdapter implements 
110:                    HierarchyItemClickHandler {
111:                public void itemClicked(RequestContext context,
112:                        HierarchyItem item, SelectionModel selection,
113:                        boolean allowChangeOrder) {
114:
115:                    currentItem = item;
116:                    Hierarchy[] hiers = item.getDimension().getHierarchies();
117:                    memberNav.setHierarchies(hiers, allowChangeOrder);
118:                    memberNav.setSelectionModel(selection);
119:                    memberNav.expandSelected(false);
120:                    Set deleted = memberNav.getDeleteNodeModel().getDeleted();
121:                    deleted.clear();
122:                    deleted.addAll(item.getDeleted());
123:                    show(memberNav);
124:                }
125:            }
126:
127:            private class MemberNavAcceptHandler implements  RequestListener {
128:                public void request(RequestContext context) throws Exception {
129:                    // read user selection (checkboxes)
130:                    boolean valid = memberNav.validate(context);
131:
132:                    // the selection is an unsorted set.
133:                    // Order the selected items into tree order.
134:                    Set set = memberNav.getSelectionModel().getSelection();
135:                    List list = NodeSorter.preOrder(set, memberNav.getModel());
136:                    String errmesg = currentItem.validateSelection(list);
137:                    if (errmesg != null)
138:                        memberNav.setError(errmesg);
139:                    else if (valid) {
140:                        currentItem.setSelection(list);
141:                        currentItem.setDeleted(memberNav.getDeleteNodeModel()
142:                                .getDeleted());
143:                        show(hierarchyNav);
144:                        //reflect the changes on first ok
145:                        hierarchyNav.getAcceptHandler().request(context);
146:                    }
147:                }
148:            }
149:
150:            private class MemberNavCancelHandler implements  RequestListener {
151:                public void request(RequestContext context) throws Exception {
152:                    memberNav.revert(context);
153:                    show(hierarchyNav);
154:                }
155:            }
156:
157:            /**
158:             * factory method that allows derived classes to install their own handlers
159:             */
160:            protected RequestListener createMemberNavAcceptHandler() {
161:                return new MemberNavAcceptHandler();
162:            }
163:
164:            /**
165:             * factory method that allows derived classes to install their own handlers
166:             */
167:            protected HierarchyItemClickHandler createHierarchyItemClickHandler() {
168:                return new HierarchyItemClickAdapter();
169:            }
170:
171:            /**
172:             * factory method that allows derived classes to install their own handlers
173:             */
174:            protected RequestListener createMemberNavCancelHandler() {
175:                return new MemberNavCancelHandler();
176:            }
177:
178:            /**
179:             * Returns the visible.
180:             * @return boolean
181:             */
182:            public boolean isVisible() {
183:                return hierarchyNav.isVisible();
184:            }
185:
186:            /**
187:             * Sets the visible.
188:             * @param visible The visible to set
189:             */
190:            public void setVisible(boolean visible) {
191:                hierarchyNav.setVisible(visible);
192:            }
193:
194:            public void modelChanged(ModelChangeEvent e) {
195:                show(hierarchyNav);
196:            }
197:
198:            public void structureChanged(ModelChangeEvent e) {
199:                if (memberNav.isAvailable())
200:                    hierarchyNav
201:                            .setHierarchyItemClickHandler(createHierarchyItemClickHandler());
202:                else
203:                    hierarchyNav.setHierarchyItemClickHandler(null);
204:                show(hierarchyNav);
205:            }
206:
207:            public HierarchyNavigator getHierarchyNav() {
208:                return hierarchyNav;
209:            }
210:
211:            public MemberNavigator getMemberNav() {
212:                return memberNav;
213:            }
214:
215:            public boolean isAvailable() {
216:                return hierarchyNav.isAvailable();
217:            }
218:
219:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.