Source Code Cross Referenced for TablePanels.java in  » IDE-Netbeans » visualweb.api.designer » com » sun » rave » web » ui » component » 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 » IDE Netbeans » visualweb.api.designer » com.sun.rave.web.ui.component 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package com.sun.rave.web.ui.component;
042:
043:        import com.sun.data.provider.SortCriteria;
044:        import com.sun.rave.web.ui.event.TableSortActionListener;
045:        import com.sun.rave.web.ui.model.Option;
046:        import com.sun.rave.web.ui.theme.Theme;
047:        import com.sun.rave.web.ui.util.LogUtil;
048:        import com.sun.rave.web.ui.util.ThemeUtilities;
049:
050:        import java.io.IOException;
051:
052:        import java.util.ArrayList;
053:        import java.util.Iterator;
054:        import java.util.List;
055:
056:        import javax.faces.context.FacesContext;
057:        import javax.faces.component.NamingContainer;
058:        import javax.faces.component.UIComponent;
059:
060:        /**
061:         * Component that represents an embedded panel.
062:         * <p>
063:         * Note: Column headers and footers are rendered by TableRowGroupRenderer. Table
064:         * column footers are rendered by TableRenderer.
065:         * </p><p>
066:         * Note: To see the messages logged by this class, set the following global
067:         * defaults in your JDK's "jre/lib/logging.properties" file.
068:         * </p><p><pre>
069:         * java.util.logging.ConsoleHandler.level = FINE
070:         * com.sun.rave.web.ui.component.TablePanels.level = FINE
071:         * </pre></p>
072:         */
073:        public class TablePanels extends TablePanelsBase implements 
074:                NamingContainer {
075:            /** The facet name for the filter panel. */
076:            public static final String FILTER_PANEL_ID = "_filterPanel"; //NOI18N
077:
078:            /** The facet name for the preferences panel. */
079:            public static final String PREFERENCES_PANEL_ID = "_preferencesPanel"; //NOI18N
080:
081:            /** The component id for the primary sort column menu. */
082:            public static final String PRIMARY_SORT_COLUMN_MENU_ID = "_primarySortColumnMenu"; //NOI18N
083:
084:            /** The facet name for the primary sort column menu. */
085:            public static final String PRIMARY_SORT_COLUMN_MENU_FACET = "primarySortColumnMenu"; //NOI18N
086:
087:            /** The component id for the primary sort column menu label. */
088:            public static final String PRIMARY_SORT_COLUMN_MENU_LABEL_ID = "_primarySortColumnMenuLabel"; //NOI18N
089:
090:            /** The facet name for the primary sort column menu label. */
091:            public static final String PRIMARY_SORT_COLUMN_MENU_LABEL_FACET = "primarySortColumnMenuLabel"; //NOI18N
092:
093:            /** The component id for the primary sort order menu. */
094:            public static final String PRIMARY_SORT_ORDER_MENU_ID = "_primarySortOrderMenu"; //NOI18N
095:
096:            /** The facet name for the primary sort order menu. */
097:            public static final String PRIMARY_SORT_ORDER_MENU_FACET = "primarySortOrderMenu"; //NOI18N
098:
099:            /** The component id for the secondary sort column menu. */
100:            public static final String SECONDARY_SORT_COLUMN_MENU_ID = "_secondarySortColumnMenu"; //NOI18N
101:
102:            /** The facet name for the secondary sort column menu. */
103:            public static final String SECONDARY_SORT_COLUMN_MENU_FACET = "secondarySortColumnMenu"; //NOI18N
104:
105:            /** The component id for the secondary sort column menu label. */
106:            public static final String SECONDARY_SORT_COLUMN_MENU_LABEL_ID = "_secondarySortColumnMenuLabel"; //NOI18N
107:
108:            /** The facet name for the secondary sort column menu label. */
109:            public static final String SECONDARY_SORT_COLUMN_MENU_LABEL_FACET = "secondarySortColumnMenuLabel"; //NOI18N
110:
111:            /** The component id for the secondary sort order menu. */
112:            public static final String SECONDARY_SORT_ORDER_MENU_ID = "_secondarySortOrderMenu"; //NOI18N
113:
114:            /** The facet name for the secondary sort order menu. */
115:            public static final String SECONDARY_SORT_ORDER_MENU_FACET = "secondarySortOrderMenu"; //NOI18N
116:
117:            /** The facet name for the sort panel. */
118:            public static final String SORT_PANEL_ID = "_sortPanel"; //NOI18N
119:
120:            /** The component id for the sort panel cancel button. */
121:            public static final String SORT_PANEL_CANCEL_BUTTON_ID = "_sortPanelCancelButton"; //NOI18N
122:
123:            /** The facet name for the sort panel cancel button. */
124:            public static final String SORT_PANEL_CANCEL_BUTTON_FACET = "sortPanelCancelButton"; //NOI18N
125:
126:            /** The component id for the sort panel submit button. */
127:            public static final String SORT_PANEL_SUBMIT_BUTTON_ID = "_sortPanelSubmitButton"; //NOI18N
128:
129:            /** The facet name for the sort panel submit button. */
130:            public static final String SORT_PANEL_SUBMIT_BUTTON_FACET = "sortPanelSubmitButton"; //NOI18N
131:
132:            /** The component id for the tertiary sort column menu. */
133:            public static final String TERTIARY_SORT_COLUMN_MENU_ID = "_tertiarySortColumnMenu"; //NOI18N
134:
135:            /** The facet name for the tertiary sort column menu. */
136:            public static final String TERTIARY_SORT_COLUMN_MENU_FACET = "tertiarySortColumnMenu"; //NOI18N
137:
138:            /** The component id for the tertiary sort column menu label. */
139:            public static final String TERTIARY_SORT_COLUMN_MENU_LABEL_ID = "_tertiarySortColumnMenuLabel"; //NOI18N
140:
141:            /** The facet name for the tertiary sort column menu label. */
142:            public static final String TERTIARY_SORT_COLUMN_MENU_LABEL_FACET = "tertiarySortColumnMenuLabel"; //NOI18N
143:
144:            /** The component id for the tertiary sort order menu. */
145:            public static final String TERTIARY_SORT_ORDER_MENU_ID = "_tertiarySortOrderMenu"; //NOI18N
146:
147:            /** The facet name for the tertiary sort order menu. */
148:            public static final String TERTIARY_SORT_ORDER_MENU_FACET = "tertiarySortOrderMenu"; //NOI18N
149:
150:            // The Table ancestor enclosing this component.
151:            private Table table = null;
152:
153:            /** Default constructor */
154:            public TablePanels() {
155:                super ();
156:            }
157:
158:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
159:            // Child methods
160:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
161:
162:            /**
163:             * Get the closest Table ancestor that encloses this component.
164:             *
165:             * @return The Table ancestor.
166:             */
167:            public Table getTableAncestor() {
168:                if (table == null) {
169:                    UIComponent component = this ;
170:                    while (component != null) {
171:                        component = component.getParent();
172:                        if (component instanceof  Table) {
173:                            table = (Table) component;
174:                            break;
175:                        }
176:                    }
177:                }
178:                return table;
179:            }
180:
181:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
182:            // Sort panel methods
183:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
184:
185:            /**
186:             * Get primary sort column menu used in the sort panel.
187:             *
188:             * @return The primary sort column menu.
189:             */
190:            public UIComponent getPrimarySortColumnMenu() {
191:                UIComponent facet = getFacet(PRIMARY_SORT_COLUMN_MENU_FACET);
192:                if (facet != null) {
193:                    return facet;
194:                }
195:
196:                // Get child.
197:                DropDown child = new DropDown();
198:                child.setId(PRIMARY_SORT_COLUMN_MENU_ID);
199:                child.setItems(getSortColumnMenuOptions());
200:                child.setSelected(getSelectedSortColumnMenuOption(1));
201:
202:                // Set JS to initialize the sort column menu.
203:                Table table = getTableAncestor();
204:                if (table != null) {
205:                    child.setTabIndex(table.getTabIndex());
206:                    child.setOnChange("document.getElementById('"
207:                            + //NOI18N
208:                            table.getClientId(getFacesContext())
209:                            + "').initPrimarySortOrderMenu()"); //NOI18N
210:                } else {
211:                    log("getPrimarySortColumnMenu", //NOI18N
212:                            "Tab index & onChange not set, Table is null"); //NOI18N
213:                }
214:
215:                // Save facet and return child.
216:                getFacets().put(child.getId(), child);
217:                return child;
218:            }
219:
220:            /**
221:             * Get primary sort column menu label used in the sort panel.
222:             *
223:             * @return The primary sort column menu label.
224:             */
225:            public UIComponent getPrimarySortColumnMenuLabel() {
226:                UIComponent facet = getFacet(PRIMARY_SORT_COLUMN_MENU_LABEL_FACET);
227:                if (facet != null) {
228:                    return facet;
229:                }
230:
231:                // Get child.
232:                Label child = new Label();
233:                child.setId(PRIMARY_SORT_COLUMN_MENU_LABEL_ID);
234:                child.setText(getTheme().getMessage(
235:                        "table.panel.primarySortColumn")); //NOI18N
236:                child.setLabelLevel(2);
237:
238:                // Save facet and return child.
239:                getFacets().put(child.getId(), child);
240:                return child;
241:            }
242:
243:            /**
244:             * Get primary sort order menu used in the sort panel.
245:             *
246:             * @return The primary sort order menu.
247:             */
248:            public UIComponent getPrimarySortOrderMenu() {
249:                UIComponent facet = getFacet(PRIMARY_SORT_ORDER_MENU_FACET);
250:                if (facet != null) {
251:                    return facet;
252:                }
253:
254:                // Get child.
255:                DropDown child = new DropDown();
256:                child.setId(PRIMARY_SORT_ORDER_MENU_ID);
257:                child.setItems(getSortOrderMenuOptions());
258:                child.setSelected(getSelectedSortOrderMenuOption(1));
259:
260:                // Set JS to initialize the sort order menu.
261:                Table table = getTableAncestor();
262:                if (table != null) {
263:                    child.setTabIndex(table.getTabIndex());
264:                    child.setOnChange("document.getElementById('"
265:                            + //NOI18N
266:                            table.getClientId(getFacesContext())
267:                            + "').initPrimarySortOrderMenuToolTip()"); //NOI18N
268:                } else {
269:                    log("getPrimarySortOrderMenu", //NOI18N
270:                            "Tab index & onChange not set, Table is null"); //NOI18N
271:                }
272:
273:                // Save facet and return child.
274:                getFacets().put(child.getId(), child);
275:                return child;
276:            }
277:
278:            /**
279:             * Get secondary sort column menu used in the sort panel.
280:             *
281:             * @return The secondary sort column menu.
282:             */
283:            public UIComponent getSecondarySortColumnMenu() {
284:                UIComponent facet = getFacet(SECONDARY_SORT_COLUMN_MENU_FACET);
285:                if (facet != null) {
286:                    return facet;
287:                }
288:
289:                // Get child.
290:                DropDown child = new DropDown();
291:                child.setId(SECONDARY_SORT_COLUMN_MENU_ID);
292:                child.setItems(getSortColumnMenuOptions());
293:                child.setSelected(getSelectedSortColumnMenuOption(2));
294:
295:                // Set JS to initialize the sort column menu.
296:                Table table = getTableAncestor();
297:                if (table != null) {
298:                    child.setTabIndex(table.getTabIndex());
299:                    child.setOnChange("document.getElementById('"
300:                            + //NOI18N
301:                            table.getClientId(getFacesContext())
302:                            + "').initSecondarySortOrderMenu()"); //NOI18N
303:                } else {
304:                    log("getSecondarySortColumnMenu", //NOI18N
305:                            "Tab index & onChange not set, Table is null"); //NOI18N
306:                }
307:
308:                // Save facet and return child.
309:                getFacets().put(child.getId(), child);
310:                return child;
311:            }
312:
313:            /**
314:             * Get secondary sort column menu label used in the sort panel.
315:             *
316:             * @return The secondary sort column menu label.
317:             */
318:            public UIComponent getSecondarySortColumnMenuLabel() {
319:                UIComponent facet = getFacet(SECONDARY_SORT_COLUMN_MENU_LABEL_FACET);
320:                if (facet != null) {
321:                    return facet;
322:                }
323:
324:                // Get child.
325:                Label child = new Label();
326:                child.setId(SECONDARY_SORT_COLUMN_MENU_LABEL_ID);
327:                child.setText(getTheme().getMessage(
328:                        "table.panel.secondarySortColumn")); //NOI18N
329:                child.setLabelLevel(2);
330:
331:                // Save facet and return child.
332:                getFacets().put(child.getId(), child);
333:                return child;
334:            }
335:
336:            /**
337:             * Get secondary sort order menu used in the sort panel.
338:             *
339:             * @return The secondary sort order menu.
340:             */
341:            public UIComponent getSecondarySortOrderMenu() {
342:                UIComponent facet = getFacet(SECONDARY_SORT_ORDER_MENU_FACET);
343:                if (facet != null) {
344:                    return facet;
345:                }
346:
347:                // Get child.
348:                DropDown child = new DropDown();
349:                child.setId(SECONDARY_SORT_ORDER_MENU_ID);
350:                child.setItems(getSortOrderMenuOptions());
351:                child.setSelected(getSelectedSortOrderMenuOption(2));
352:
353:                // Set JS to initialize the sort order menu.
354:                Table table = getTableAncestor();
355:                if (table != null) {
356:                    child.setTabIndex(table.getTabIndex());
357:                    child.setOnChange("document.getElementById('"
358:                            + //NOI18N
359:                            table.getClientId(getFacesContext())
360:                            + "').initSecondarySortOrderMenuToolTip()"); //NOI18N
361:                } else {
362:                    log("getSecondarySortOrderMenu", //NOI18N
363:                            "Tab index & onChange not set, Table is null"); //NOI18N
364:                }
365:
366:                // Save facet and return child.
367:                getFacets().put(child.getId(), child);
368:                return child;
369:            }
370:
371:            /**
372:             * Get sort panel cancel button.
373:             *
374:             * @return The sort panel cancel button.
375:             */
376:            public UIComponent getSortPanelCancelButton() {
377:                UIComponent facet = getFacet(SORT_PANEL_CANCEL_BUTTON_FACET);
378:                if (facet != null) {
379:                    return facet;
380:                }
381:
382:                // Get child.
383:                Button child = new Button();
384:                child.setId(SORT_PANEL_CANCEL_BUTTON_ID);
385:                child.setMini(true);
386:                child.setText(getTheme().getMessage("table.panel.cancel")); //NOI18N
387:                child.setToolTip(getTheme().getMessage(
388:                        "table.panel.cancelChanges")); //NOI18N
389:
390:                // Set JS to close the sort panel.
391:                Table table = getTableAncestor();
392:                if (table != null) {
393:                    child.setTabIndex(table.getTabIndex());
394:                    child.setOnClick("document.getElementById('"
395:                            + //NOI18N
396:                            table.getClientId(getFacesContext())
397:                            + "').toggleSortPanel(); return false"); //NOI18N
398:                } else {
399:                    log("getSortPanelCancelButton", //NOI18N
400:                            "Tab index & onClick not set, Table is null"); //NOI18N
401:                }
402:
403:                // Save facet and return child.
404:                getFacets().put(child.getId(), child);
405:                return child;
406:            }
407:
408:            /**
409:             * Get sort panel submit button.
410:             *
411:             * @return The sort panel submit button.
412:             */
413:            public UIComponent getSortPanelSubmitButton() {
414:                UIComponent facet = getFacet(SORT_PANEL_SUBMIT_BUTTON_FACET);
415:                if (facet != null) {
416:                    return facet;
417:                }
418:
419:                // Get child.
420:                Button child = new Button();
421:                child.setId(SORT_PANEL_SUBMIT_BUTTON_ID);
422:                child.setMini(true);
423:                child.setPrimary(true);
424:                child.setText(getTheme().getMessage("table.panel.submit")); //NOI18N
425:                child.setToolTip(getTheme().getMessage(
426:                        "table.panel.applyChanges")); //NOI18N
427:                child.addActionListener(new TableSortActionListener());
428:
429:                // Set JS to validate user selections.
430:                Table table = getTableAncestor();
431:                if (table != null) {
432:                    child.setTabIndex(table.getTabIndex());
433:                    child.setOnClick("return document.getElementById('"
434:                            + //NOI18N
435:                            table.getClientId(getFacesContext())
436:                            + "').validateSortPanel()"); //NOI18N
437:                } else {
438:                    log("getSortPanelSubmitButton", //NOI18N
439:                            "Tab index & onClick not set, Table is null"); //NOI18N
440:                }
441:
442:                // Save facet and return child.
443:                getFacets().put(child.getId(), child);
444:                return child;
445:            }
446:
447:            /**
448:             * Get tertiary sort column menu used in the sort panel.
449:             *
450:             * @return The tertiary sort column menu.
451:             */
452:            public UIComponent getTertiarySortColumnMenu() {
453:                UIComponent facet = getFacet(TERTIARY_SORT_COLUMN_MENU_FACET);
454:                if (facet != null) {
455:                    return facet;
456:                }
457:
458:                // Get child.
459:                DropDown child = new DropDown();
460:                child.setId(TERTIARY_SORT_COLUMN_MENU_ID);
461:                child.setItems(getSortColumnMenuOptions());
462:                child.setSelected(getSelectedSortColumnMenuOption(3));
463:
464:                // Set JS to initialize the sort column menu.
465:                Table table = getTableAncestor();
466:                if (table != null) {
467:                    child.setTabIndex(table.getTabIndex());
468:                    child.setOnChange("document.getElementById('"
469:                            + //NOI18N
470:                            table.getClientId(getFacesContext())
471:                            + "').initTertiarySortOrderMenu()"); //NOI18N
472:                } else {
473:                    log("getTertiarySortColumnMenu", //NOI18N
474:                            "Tab index & onChange not set, Table is null"); //NOI18N
475:                }
476:
477:                // Save facet and return child.
478:                getFacets().put(child.getId(), child);
479:                return child;
480:            }
481:
482:            /**
483:             * Get tertiary sort column menu label used in the sort panel.
484:             *
485:             * @return The tertiary sort column menu label.
486:             */
487:            public UIComponent getTertiarySortColumnMenuLabel() {
488:                UIComponent facet = getFacet(TERTIARY_SORT_COLUMN_MENU_LABEL_FACET);
489:                if (facet != null) {
490:                    return facet;
491:                }
492:
493:                // Get child.
494:                Label child = new Label();
495:                child.setId(TERTIARY_SORT_COLUMN_MENU_LABEL_ID);
496:                child.setText(getTheme().getMessage(
497:                        "table.panel.tertiarySortColumn")); //NOI18N
498:                child.setLabelLevel(2);
499:
500:                // Save facet and return child.
501:                getFacets().put(child.getId(), child);
502:                return child;
503:            }
504:
505:            /**
506:             * Get tertiary sort order menu used in the sort panel.
507:             *
508:             * @return The tertiary sort order menu.
509:             */
510:            public UIComponent getTertiarySortOrderMenu() {
511:                UIComponent facet = getFacet(TERTIARY_SORT_ORDER_MENU_FACET);
512:                if (facet != null) {
513:                    return facet;
514:                }
515:
516:                // Get child.
517:                DropDown child = new DropDown();
518:                child.setId(TERTIARY_SORT_ORDER_MENU_ID);
519:                child.setItems(getSortOrderMenuOptions());
520:                child.setSelected(getSelectedSortOrderMenuOption(3));
521:
522:                // Set JS to initialize the sort order menu.
523:                Table table = getTableAncestor();
524:                if (table != null) {
525:                    child.setTabIndex(table.getTabIndex());
526:                    child.setOnChange("document.getElementById('"
527:                            + //NOI18N
528:                            table.getClientId(getFacesContext())
529:                            + "').initTertiarySortOrderMenuToolTip()"); //NOI18N
530:                } else {
531:                    log("getTertiarySortOrderMenu", //NOI18N
532:                            "Tab index & onChange not set, Table is null"); //NOI18N
533:                }
534:
535:                // Save facet and return child.
536:                getFacets().put(child.getId(), child);
537:                return child;
538:            }
539:
540:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
541:            // UIComponent methods
542:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
543:
544:            /**
545:             * If the rendered property is true, render the begining of the current
546:             * state of this UIComponent to the response contained in the specified
547:             * FacesContext.
548:             *
549:             * If a Renderer is associated with this UIComponent, the actual encoding 
550:             * will be delegated to Renderer.encodeBegin(FacesContext, UIComponent).
551:             *
552:             * @param context FacesContext for the current request.
553:             *
554:             * @exception IOException if an input/output error occurs while rendering.
555:             * @exception NullPointerException if FacesContext is null.
556:             */
557:            public void encodeBegin(FacesContext context) throws IOException {
558:                // Clear cached variables -- bugtraq #6300020.
559:                table = null;
560:                super .encodeBegin(context);
561:            }
562:
563:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
564:            // Private methods
565:            // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
566:
567:            /** 
568:             * Helper method to get selected option value used by the sort column menu
569:             * of the table sort panel.
570:             *
571:             * @param level The sort level.
572:             * @return The selected menu option value.
573:             */
574:            private String getSelectedSortColumnMenuOption(int level) {
575:                String result = null;
576:                Table table = getTableAncestor();
577:                TableRowGroup group = (table != null) ? table
578:                        .getTableRowGroupChild() : null;
579:
580:                // Find the column that matches the given sort level and return the
581:                // SortCriteria key value.
582:                if (group != null) {
583:                    Iterator kids = group.getTableColumnChildren();
584:                    while (kids.hasNext()) {
585:                        TableColumn col = (TableColumn) kids.next();
586:                        if (!col.isRendered()) {
587:                            continue;
588:                        }
589:                        result = getSelectedSortColumnMenuOption(col, level);
590:                        if (result != null) {
591:                            break;
592:                        }
593:                    }
594:                } else {
595:                    log("getSelectedSortColumnMenuOption", //NOI18N
596:                            "Cannot obtain select sort column menu option, TableRowGroup is null"); //NOI18N
597:                }
598:                return result;
599:            }
600:
601:            /**
602:             * Helper method to get selected option value for nested TableColumn 
603:             * components, used by the sort column menu of the table sort panel.
604:             *
605:             * @param level The sort level.
606:             * @param component The TableColumn component to render.
607:             * @return The selected menu option value.
608:             */
609:            private String getSelectedSortColumnMenuOption(
610:                    TableColumn component, int level) {
611:                String result = null;
612:                if (component == null) {
613:                    log("getSelectedSortColumnMenuOption", //NOI18N
614:                            "Cannot obtain select sort column menu option, TableColumn is null"); //NOI18N
615:                    return result;
616:                }
617:
618:                Iterator kids = component.getTableColumnChildren();
619:                if (kids.hasNext()) {
620:                    while (kids.hasNext()) {
621:                        TableColumn kid = (TableColumn) kids.next();
622:                        result = getSelectedSortColumnMenuOption(kid, level);
623:                        if (result != null) {
624:                            return result;
625:                        }
626:                    }
627:                }
628:
629:                Table table = getTableAncestor();
630:                TableRowGroup group = (table != null) ? table
631:                        .getTableRowGroupChild() : null;
632:
633:                // Get SortCriteria.
634:                if (group != null) {
635:                    SortCriteria criteria = component.getSortCriteria();
636:                    if (criteria != null) {
637:                        // Get initial selected option value.
638:                        int sortLevel = group.getSortLevel(criteria);
639:                        if (sortLevel == level) {
640:                            result = criteria.getCriteriaKey();
641:                        }
642:                    }
643:                } else {
644:                    log("getSelectedSortColumnMenuOption", //NOI18N
645:                            "Cannot obtain select sort column menu option, TableRowGroup is null"); //NOI18N
646:                }
647:                return result;
648:            }
649:
650:            /** 
651:             * Helper method to get selected option value used by the sort order menu of
652:             * the table sort panel.
653:             *
654:             * @param level The sort level.
655:             * @return The selected menu option value.
656:             */
657:            private String getSelectedSortOrderMenuOption(int level) {
658:                String result = null;
659:                Table table = getTableAncestor();
660:                TableRowGroup group = (table != null) ? table
661:                        .getTableRowGroupChild() : null;
662:
663:                // Find the column that matches the given sort level and return the
664:                // sort order.
665:                if (group != null) {
666:                    Iterator kids = group.getTableColumnChildren();
667:                    while (kids.hasNext()) {
668:                        TableColumn col = (TableColumn) kids.next();
669:                        if (!col.isRendered()) {
670:                            continue;
671:                        }
672:                        result = getSelectedSortOrderMenuOption(col, level);
673:                        if (result != null) {
674:                            break;
675:                        }
676:                    }
677:                } else {
678:                    log("getSelectedSortOrderMenuOption", //NOI18N
679:                            "Cannot obtain select sort order menu option, TableRowGroup is null"); //NOI18N
680:                }
681:                return result;
682:            }
683:
684:            /** 
685:             * Helper method to get selected option value for nested TableColumn 
686:             * components, used by the sort order menu of the table sort panel.
687:             *
688:             * @param level The sort level.
689:             * @param component The TableColumn component to render.
690:             * @return The selected menu option value.
691:             */
692:            private String getSelectedSortOrderMenuOption(
693:                    TableColumn component, int level) {
694:                String result = null;
695:                if (component == null) {
696:                    log("getSelectedSortOrderMenuOption", //NOI18N
697:                            "Cannot obtain select sort column order option, TableColumn is null"); //NOI18N
698:                    return result;
699:                }
700:
701:                Iterator kids = component.getTableColumnChildren();
702:                if (kids.hasNext()) {
703:                    while (kids.hasNext()) {
704:                        TableColumn kid = (TableColumn) kids.next();
705:                        result = getSelectedSortColumnMenuOption(kid, level);
706:                        if (result != null) {
707:                            return result;
708:                        }
709:                    }
710:                }
711:
712:                Table table = getTableAncestor();
713:                TableRowGroup group = (table != null) ? table
714:                        .getTableRowGroupChild() : null;
715:
716:                // Get SortCriteria.
717:                if (group != null) {
718:                    SortCriteria criteria = component.getSortCriteria();
719:                    if (criteria != null) {
720:                        // Get initial selected option value.
721:                        int sortLevel = group.getSortLevel(criteria);
722:                        if (sortLevel == level) {
723:                            result = Boolean.toString(group
724:                                    .isDescendingSort(criteria));
725:                        }
726:                    }
727:                } else {
728:                    log("getSelectedSortOrderMenuOption", //NOI18N
729:                            "Cannot obtain select sort order menu option, TableRowGroup is null"); //NOI18N
730:                }
731:                return result;
732:            }
733:
734:            /**
735:             * Helper method to get options used by the sort column menu of the table
736:             * sort panel.
737:             *
738:             * @return An array of menu options.
739:             */
740:            private Option[] getSortColumnMenuOptions() {
741:                ArrayList list = new ArrayList();
742:                Table table = getTableAncestor();
743:                TableRowGroup group = (table != null) ? table
744:                        .getTableRowGroupChild() : null;
745:
746:                // Add default "None" option -- an empty string represents no sort.
747:                list.add(new Option("", getTheme().getMessage(
748:                        "table.panel.none"))); //NOI18N
749:
750:                // For each sortable TableColumn, use the header text for each label and
751:                // the SortCriteria key as the value.
752:                if (group != null) {
753:                    Iterator kids = group.getTableColumnChildren();
754:                    while (kids.hasNext()) {
755:                        TableColumn col = (TableColumn) kids.next();
756:                        if (!col.isRendered()) {
757:                            continue;
758:                        }
759:                        // Get header text and sort value binding expression string.
760:                        initSortColumnMenuOptions(col, list);
761:                    }
762:                } else {
763:                    log("getSortColumnMenuOptions", //NOI18N
764:                            "Cannot obtain sort column menu options, TableRowGroup is null"); //NOI18N
765:                }
766:                // Set options.
767:                Option[] options = new Option[list.size()];
768:                return (Option[]) list.toArray(options);
769:            }
770:
771:            /** 
772:             * Helper method to get options for the sort order menu used in the table
773:             * sort panel.
774:             *
775:             * @return An array of menu options.
776:             */
777:            private Option[] getSortOrderMenuOptions() {
778:                ArrayList results = new ArrayList();
779:
780:                // Add default option.
781:                results.add(new Option("false", getTheme().getMessage( //NOI18N
782:                        "table.sort.augment.undeterminedAscending"))); //NOI18N
783:                results.add(new Option("true", getTheme().getMessage( //NOI18N
784:                        "table.sort.augment.undeterminedDescending"))); //NOI18N
785:
786:                // Set default options. Other options will be added client-side when
787:                // menu is initialized.
788:                Option[] options = new Option[results.size()];
789:                return (Option[]) results.toArray(options);
790:            }
791:
792:            /**
793:             * Helper method to get Theme objects.
794:             *
795:             * @return The current theme.
796:             */
797:            private Theme getTheme() {
798:                return ThemeUtilities.getTheme(getFacesContext());
799:            }
800:
801:            /**
802:             * Helper method to get options for nested TableColumn components, used by 
803:             * the sort column menu of the table sort panel.
804:             *
805:             * @param component The TableColumn component to render.
806:             * @param list The array used to store menu options.
807:             * @return An array of menu options.
808:             */
809:            private void initSortColumnMenuOptions(TableColumn component,
810:                    List list) {
811:                if (component == null) {
812:                    return;
813:                }
814:
815:                Iterator kids = component.getTableColumnChildren();
816:                if (kids.hasNext()) {
817:                    while (kids.hasNext()) {
818:                        TableColumn kid = (TableColumn) kids.next();
819:                        initSortColumnMenuOptions(kid, list);
820:                    }
821:                }
822:
823:                // Get header text and sort value binding expression string.
824:                SortCriteria criteria = component.getSortCriteria(); //NOI18N
825:                if (criteria == null) {
826:                    log("initSortColumnMenuOptions", //NOI18N
827:                            "Cannot initialize sort column menu options, SortCriteria is null"); //NOI18N
828:                    return;
829:                }
830:
831:                // Get label.
832:                String label = (component.getSelectId() != null) ? getTheme()
833:                        .getMessage("table.select.selectedItems") //NOI18N
834:                        : component.getHeaderText();
835:
836:                // Add option.
837:                list.add(new Option(criteria.getCriteriaKey(),
838:                        (label != null) ? label : "")); //NOI18N
839:            }
840:
841:            /**
842:             * Log fine messages.
843:             */
844:            private void log(String method, String message) {
845:                // Get class.
846:                Class clazz = this .getClass();
847:                if (LogUtil.fineEnabled(clazz)) {
848:                    // Log method name and message.
849:                    LogUtil.fine(clazz, clazz.getName() + "." + method + ": "
850:                            + message); //NOI18N
851:                }
852:            }
853:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.