Source Code Cross Referenced for Controls.java in  » J2EE » Enhydra-Demos » projectmanagement » presentation » worksheets » 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 » J2EE » Enhydra Demos » projectmanagement.presentation.worksheets 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *  projectManagement
003:         *
004:         *  Enhydra super-servlet presentation object
005:         *
006:         */
007:
008:        package projectmanagement.presentation.worksheets;
009:
010:        import projectmanagement.spec.employee.*;
011:        import projectmanagement.spec.project.*;
012:        import projectmanagement.presentation.*;
013:
014:        import org.w3c.dom.*;
015:        import org.w3c.dom.html.*;
016:
017:        // Enhydra SuperServlet imports
018:        import com.lutris.appserver.server.httpPresentation.HttpPresentation;
019:        import com.lutris.appserver.server.httpPresentation.HttpPresentationComms;
020:        import com.lutris.appserver.server.httpPresentation.HttpPresentationException;
021:        import org.enhydra.xml.xmlc.XMLObject;
022:
023:        // Standard imports
024:        import java.io.IOException;
025:        import java.util.Calendar;
026:
027:        /**
028:         * Generates the blank HTML page.
029:         */
030:        public class Controls extends BasePO {
031:
032:            /**
033:             * Constants
034:             */
035:            private static String EMPLOYEE = "employee";
036:            private static String PROJECT = "project";
037:            private static String YEAR = "year";
038:            private static String MONTH = "month";
039:
040:            private static String IS_PERSONAL = "isPersonal";
041:
042:            /**
043:             * Superclass method override. Returns 1 or 2, depending on action.
044:             */
045:            protected int getRequiredAuthLevel() {
046:                String isPersonal = "";
047:                try {
048:                    isPersonal = this .getComms().request
049:                            .getParameter(IS_PERSONAL);
050:                } catch (Exception ex) {
051:                }
052:
053:                if (isPersonal != null && isPersonal.equalsIgnoreCase("true")) {
054:                    return 1;
055:                } else {
056:                    return 2;
057:                }
058:            }
059:
060:            /**
061:             *  Default event. Just show the page.
062:             */
063:            public XMLObject handleDefault() throws HttpPresentationException {
064:
065:                ControlsHTML page = new ControlsHTML();
066:
067:                String employee = this .getComms().request
068:                        .getParameter(EMPLOYEE);
069:                HTMLSelectElement sel = page.getElementCboEmployee();
070:                fillEmployeeSelection(page, sel, employee);
071:
072:                String project = this .getComms().request.getParameter(PROJECT);
073:                sel = page.getElementCboProject();
074:                fillProjectSelection(page, sel, project);
075:
076:                String year = this .getComms().request.getParameter(YEAR);
077:                String month = this .getComms().request.getParameter(MONTH);
078:
079:                if (year == null) {
080:                    year = String.valueOf(Calendar.getInstance().get(
081:                            Calendar.YEAR));
082:                }
083:                HTMLInputElement txtYear = page.getElementTxtYear();
084:                txtYear.setValue(year);
085:
086:                if (month == null) {
087:                    month = String.valueOf(Calendar.getInstance().get(
088:                            Calendar.MONTH) + 1);
089:                }
090:                fillMonths(page, month);
091:
092:                String isPersonal = this .getComms().request
093:                        .getParameter(IS_PERSONAL);
094:                if (isPersonal != null && isPersonal.equalsIgnoreCase("true")) {
095:                    page.getElementIsPersonal().setValue("true");
096:                }
097:
098:                return page;
099:            }
100:
101:            private void fillEmployeeSelection(ControlsHTML page,
102:                    HTMLSelectElement cboEmployees, String selectedEmployeeID)
103:                    throws ProjectManagementPresentationException {
104:                HTMLOptionElement optEmployee = page.getElementOptEmployee();
105:
106:                String isPersonal = "";
107:                try {
108:                    isPersonal = this .getComms().request
109:                            .getParameter(IS_PERSONAL);
110:                } catch (Exception ex) {
111:                }
112:                if (isPersonal != null && isPersonal.equalsIgnoreCase("true")) {
113:                    try {
114:                        selectedEmployeeID = getUser().getHandle();
115:                    } catch (Exception ex) {
116:                    }
117:                }
118:
119:                try {
120:                    EmployeeManager employeeManager = EmployeeManagerFactory
121:                            .getEmployeeManager("projectmanagement.business.employee.EmployeeManagerImpl");
122:                    Employee[] employees = employeeManager.getAllEmployees();
123:
124:                    // Remove the dummy storyboard text from the prototype HTML
125:                    optEmployee.removeChild(optEmployee.getFirstChild());
126:
127:                    // set the text to select all employees - default option
128:                    HTMLOptionElement clonedOption = null;
129:                    Node optionTextNode = null;
130:                    if (isPersonal == null
131:                            || !isPersonal.equalsIgnoreCase("true")) {
132:                        clonedOption = (HTMLOptionElement) optEmployee
133:                                .cloneNode(true);
134:                        clonedOption.setValue("");
135:                        String all = "All";
136:                        optionTextNode = clonedOption.getOwnerDocument()
137:                                .createTextNode(all);
138:                        clonedOption.appendChild(optionTextNode);
139:                        clonedOption.setAttribute("selected", "selected");
140:                        // Do only a shallow copy of the option as we don't want the text child
141:                        // of the node option
142:                        cboEmployees.appendChild(clonedOption);
143:                    }
144:
145:                    // set all employees
146:
147:                    if (employees != null) {
148:                        for (int i = 0; i < employees.length; i++) {
149:                            Employee e = employees[i];
150:                            // if this is personal, fill the combo only with that employ
151:                            if (isPersonal != null
152:                                    && isPersonal.equalsIgnoreCase("true")
153:                                    && !e.getHandle()
154:                                            .equals(selectedEmployeeID)) {
155:                                continue;
156:                            }
157:
158:                            // Now populate the combo with employees
159:                            // This algorithm is obscure because options
160:                            // are not normal HTML elements
161:                            // First populate the option value (the employee database ID).
162:                            //  Then append a text child as the option
163:                            // text, which is what is displayed as the text
164:                            // in each row of the select box
165:                            clonedOption = (HTMLOptionElement) optEmployee
166:                                    .cloneNode(true);
167:                            clonedOption.setValue(e.getHandle());
168:                            optionTextNode = clonedOption.getOwnerDocument()
169:                                    .createTextNode(
170:                                            e.getFirstName() + " "
171:                                                    + e.getLastName());
172:                            clonedOption.appendChild(optionTextNode);
173:                            if (selectedEmployeeID != null
174:                                    && e.getHandle().equals(selectedEmployeeID)) {
175:                                clonedOption.setAttribute("selected",
176:                                        "selected");
177:                            }
178:                            // Do only a shallow copy of the option as we don't want the text child
179:                            // of the node option
180:                            cboEmployees.appendChild(clonedOption);
181:                        }
182:                    }
183:                    cboEmployees.removeChild(optEmployee);
184:                } catch (NullPointerException ex) {
185:                } catch (Exception ex) {
186:                    this .writeDebugMsg("Error populating list of employees: "
187:                            + ex);
188:                    throw new ProjectManagementPresentationException(
189:                            "Error populating employee list: ", ex);
190:                }
191:
192:            }
193:
194:            private void fillProjectSelection(ControlsHTML page,
195:                    HTMLSelectElement cboProjects, String selectedProjectID)
196:                    throws ProjectManagementPresentationException {
197:                HTMLOptionElement optProject = page.getElementOptProject();
198:                // Remove the dummy storyboard text from the prototype HTML
199:                optProject.removeChild(optProject.getFirstChild());
200:
201:                String isPersonal = "";
202:                try {
203:                    isPersonal = this .getComms().request
204:                            .getParameter(IS_PERSONAL);
205:                } catch (Exception ex) {
206:                }
207:
208:                try {
209:
210:                    // set the text to select all projects - default option
211:                    HTMLOptionElement clonedOption = (HTMLOptionElement) optProject
212:                            .cloneNode(true);
213:                    clonedOption.setValue("");
214:                    String all = "All";
215:                    Node optionTextNode = clonedOption.getOwnerDocument()
216:                            .createTextNode(all);
217:                    clonedOption.appendChild(optionTextNode);
218:                    clonedOption.setAttribute("selected", "selected");
219:                    // Do only a shallow copy of the option as we don't want the text child
220:                    // of the node option
221:                    cboProjects.appendChild(clonedOption);
222:
223:                    // set all projects
224:                    Project[] projects = null;
225:                    ProjectManager projectManager = ProjectManagerFactory
226:                            .getProjectManager("projectmanagement.business.project.ProjectManagerImpl");
227:
228:                    if (isPersonal != null
229:                            && isPersonal.equalsIgnoreCase("true")) {
230:                        // IMPLEMENT ME!!!
231:                        projects = projectManager.getAllProjects();
232:
233:                    } else {
234:                        projects = projectManager.getAllProjects();
235:                    }
236:                    if (projects != null) {
237:                        for (int i = 0; i < projects.length; i++) {
238:                            Project p = projects[i];
239:                            // Now populate the combo with projects
240:                            // This algorithm is obscure because options
241:                            // are not normal HTML elements
242:                            // First populate the option value (the project database ID).
243:                            //  Then append a text child as the option
244:                            // text, which is what is displayed as the text
245:                            // in each row of the select box
246:                            clonedOption = (HTMLOptionElement) optProject
247:                                    .cloneNode(true);
248:                            clonedOption.setValue(p.getHandle());
249:                            optionTextNode = clonedOption.getOwnerDocument()
250:                                    .createTextNode(p.getName());
251:                            clonedOption.appendChild(optionTextNode);
252:                            if (selectedProjectID != null
253:                                    && p.getHandle().equals(selectedProjectID)) {
254:                                clonedOption.setAttribute("selected",
255:                                        "selected");
256:                            }
257:                            // Do only a shallow copy of the option as we don't want the text child
258:                            // of the node option
259:                            cboProjects.appendChild(clonedOption);
260:                        }
261:                    }
262:                    cboProjects.removeChild(optProject);
263:
264:                } catch (NullPointerException ex) {
265:                } catch (Exception ex) {
266:                    ex.printStackTrace();
267:                    this .writeDebugMsg("Error populating list of projects: "
268:                            + ex);
269:                    throw new ProjectManagementPresentationException(
270:                            "Error populating project list: ", ex);
271:                }
272:
273:            }
274:
275:            private void fillMonths(ControlsHTML page, String selectedMonthID)
276:                    throws ProjectManagementPresentationException {
277:                HTMLSelectElement cboMonth = page.getElementCboMonth();
278:                HTMLOptionElement optMonth = page.getElementOptMonth();
279:                // Remove the dummy storyboard text from the prototype HTML
280:                optMonth.removeChild(optMonth.getFirstChild());
281:
282:                try {
283:                    // set all months
284:                    HTMLOptionElement clonedOption = (HTMLOptionElement) optMonth
285:                            .cloneNode(true);
286:                    String all = "All";
287:                    clonedOption.setValue("");
288:                    Node optionTextNode = clonedOption.getOwnerDocument()
289:                            .createTextNode(all);
290:                    clonedOption.appendChild(optionTextNode);
291:                    cboMonth.appendChild(clonedOption);
292:
293:                    for (int i = 1; i <= 12; i++) {
294:                        // Now populate the combo with months
295:                        // This algorithm is obscure because options
296:                        // are not normal HTML elements
297:                        // First populate the option value (the month database ID).
298:                        //  Then append a text child as the option
299:                        // text, which is what is displayed as the text
300:                        // in each row of the select box
301:                        clonedOption = (HTMLOptionElement) optMonth
302:                                .cloneNode(true);
303:                        String curMonth = String.valueOf(i);
304:                        clonedOption.setValue(curMonth);
305:                        optionTextNode = clonedOption.getOwnerDocument()
306:                                .createTextNode(curMonth);
307:                        clonedOption.appendChild(optionTextNode);
308:                        if (selectedMonthID != null
309:                                && curMonth.equals(selectedMonthID)) {
310:                            clonedOption.setAttribute("selected", "selected");
311:                        }
312:                        // Do only a shallow copy of the option as we don't want the text child
313:                        // of the node option
314:                        cboMonth.appendChild(clonedOption);
315:                    }
316:                    cboMonth.removeChild(optMonth);
317:                } catch (NullPointerException ex) {
318:                } catch (Exception ex) {
319:                    this 
320:                            .writeDebugMsg("Error populating list of months: "
321:                                    + ex);
322:                    throw new ProjectManagementPresentationException(
323:                            "Error populating month list: ", ex);
324:                }
325:
326:            }
327:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.