Source Code Cross Referenced for TabWidget.java in  » Web-Framework » aranea-mvc-1.1.1 » org » araneaframework » uilib » tab » 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 » aranea mvc 1.1.1 » org.araneaframework.uilib.tab 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.araneaframework.uilib.tab;
002:
003:        import org.araneaframework.Component;
004:        import org.araneaframework.Environment;
005:        import org.araneaframework.Scope;
006:        import org.araneaframework.Widget;
007:        import org.araneaframework.core.Assert;
008:        import org.araneaframework.core.BaseApplicationWidget;
009:        import org.araneaframework.core.WidgetFactory;
010:        import org.araneaframework.http.util.EnvironmentUtil;
011:
012:        /**
013:         * Represents a tab managed by {@link TabContainerContext} implementation {@link TabContainerWidget}.
014:         * Tab consists of <i>label</i> and <i>content</i>, represented either by {@link Widget}s (for stateful tabs)
015:         * or {@link WidgetFactory}ies (for stateless tabs). Difference between stateful and stateless tabs is that
016:         * stateless tabs forget the state when they become inactive (deselected).
017:         * 
018:         * @author Taimo Peelo (taimo@araneaframework.org)
019:         * @since 1.1
020:         */
021:        public class TabWidget extends BaseApplicationWidget {
022:            private static final long serialVersionUID = 1L;
023:
024:            /** Child key for tab's label widget. */
025:            public static final String LABEL_WIDGET_KEY = "tlw";
026:            /** Child key for tab's content widget. */
027:            public static final String CONTENT_WIDGET_KEY = "tcw";
028:
029:            protected String labelId;
030:            protected Widget labelWidget;
031:            protected Widget tabContentWidget;
032:            protected WidgetFactory tabContentWidgetFactory;
033:            protected boolean disabled = false;
034:
035:            /* CONSTRUCTORS of all kinds */
036:            protected TabWidget(Widget tabContentWidget) {
037:                this .tabContentWidget = tabContentWidget;
038:            }
039:
040:            protected TabWidget(WidgetFactory tabContentWidgetFactory) {
041:                this .tabContentWidgetFactory = tabContentWidgetFactory;
042:            }
043:
044:            public TabWidget(String labelId, Widget tabContentWidget) {
045:                this (tabContentWidget);
046:                this .labelId = labelId;
047:            }
048:
049:            public TabWidget(Widget labelWidget, Widget tabContentWidget) {
050:                this (tabContentWidget);
051:                this .labelWidget = labelWidget;
052:            }
053:
054:            public TabWidget(String labelId,
055:                    WidgetFactory tabContentWidgetFactory) {
056:                this (tabContentWidgetFactory);
057:                this .labelId = labelId;
058:            }
059:
060:            public TabWidget(Widget labelWidget,
061:                    WidgetFactory tabContentWidgetFactory) {
062:                this (tabContentWidgetFactory);
063:                this .labelWidget = labelWidget;
064:            }
065:
066:            /* enabling/disabling/deselecting */
067:            public void enableTab() {
068:                disabled = false;
069:                if (_getDisabledChildren().containsKey(CONTENT_WIDGET_KEY)) {
070:                    enableWidget(CONTENT_WIDGET_KEY);
071:                } else if (!_getChildren().containsKey(CONTENT_WIDGET_KEY)) {
072:                    if (isStateless())
073:                        addWidget(CONTENT_WIDGET_KEY, tabContentWidgetFactory
074:                                .buildWidget(getEnvironment()));
075:                    else
076:                        addWidget(CONTENT_WIDGET_KEY, tabContentWidget);
077:                }
078:            }
079:
080:            public void disableTab() {
081:                disabled = true;
082:                if (_getDisabledChildren().containsKey(CONTENT_WIDGET_KEY))
083:                    disableWidget(CONTENT_WIDGET_KEY);
084:            }
085:
086:            public void deleselectTab() {
087:                if (isStateless()) {
088:                    removeWidget(CONTENT_WIDGET_KEY);
089:                }
090:            }
091:
092:            /* PUBLIC GETTERS */
093:            public String getLabel() {
094:                if (labelId != null)
095:                    return EnvironmentUtil.requireLocalizationContext(
096:                            getEnvironment()).localize(labelId);
097:                return null;
098:            }
099:
100:            public Widget getLabelWidget() {
101:                return labelWidget;
102:            }
103:
104:            public Widget getTabContentWidget() {
105:                return isStateless() ? getWidget(CONTENT_WIDGET_KEY)
106:                        : tabContentWidget;
107:            }
108:
109:            public boolean isTabDisabled() {
110:                return disabled;
111:            }
112:
113:            public boolean isSelected() {
114:                if (!isInitialized())
115:                    return false;
116:                return getTabContainerContext().isTabSelected(
117:                        getScope().getId().toString());
118:            }
119:
120:            public boolean isStateless() {
121:                return tabContentWidgetFactory != null;
122:            }
123:
124:            /* ****************** COMPONENT LIFECYCLE METHODS ************************** */
125:            public Component.Interface _getComponent() {
126:                return new ComponentImpl();
127:            }
128:
129:            protected class ComponentImpl extends
130:                    BaseApplicationWidget.ComponentImpl {
131:                public synchronized void init(Scope scope, Environment env) {
132:                    super .init(scope, env);
133:                    TabContainerContext tabContainer = getTabContainerContext();
134:                    Assert
135:                            .notNull(
136:                                    this ,
137:                                    tabContainer,
138:                                    "TabWidget initialization failed due to TabContainerContext missing from Environment. Make sure that TabWidget is child of TabContainerWidget");
139:
140:                    TabRegistrationContext tabRegistrationContext = getTabRegistrationContext();
141:                    Assert
142:                            .notNull(
143:                                    this ,
144:                                    tabRegistrationContext,
145:                                    "TabWidget initialization failed due to TabRegistrationContext missing from Environment. Make sure that TabWidget is child of TabRegistrationContext");
146:                    tabRegistrationContext.registerTab(TabWidget.this );
147:
148:                    if (labelWidget != null)
149:                        addWidget(LABEL_WIDGET_KEY, labelWidget);
150:                }
151:            }
152:
153:            protected void destroy() throws Exception {
154:                TabRegistrationContext tabRegistrationContext = (TabRegistrationContext) getEnvironment()
155:                        .requireEntry(TabRegistrationContext.class);
156:                tabRegistrationContext.unregisterTab(TabWidget.this );
157:
158:                super .destroy();
159:            }
160:
161:            /* ****************** PROTECTED METHODS ************************** */
162:            protected TabContainerContext getTabContainerContext() {
163:                return (TabContainerContext) getEnvironment().getEntry(
164:                        TabContainerContext.class);
165:            }
166:
167:            protected TabRegistrationContext getTabRegistrationContext() {
168:                return (TabRegistrationContext) getEnvironment().getEntry(
169:                        TabRegistrationContext.class);
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.