Source Code Cross Referenced for TabbedPaneUIContributor.java in  » Web-Framework » webonswing » net » ar » webonswing » ui » 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 » webonswing » net.ar.webonswing.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //WebOnSwing - Web Application Framework
002:        //Copyright (C) 2003 Fernando Damian Petrola
003:        //	
004:        //This library is free software; you can redistribute it and/or
005:        //modify it under the terms of the GNU Lesser General Public
006:        //License as published by the Free Software Foundation; either
007:        //version 2.1 of the License, or (at your option) any later version.
008:        //	
009:        //This library is distributed in the hope that it will be useful,
010:        //but WITHOUT ANY WARRANTY; without even the implied warranty of
011:        //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
012:        //Lesser General Public License for more details.
013:        //	
014:        //You should have received a copy of the GNU Lesser General Public
015:        //License along with this library; if not, write to the Free Software
016:        //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
017:
018:        package net.ar.webonswing.ui;
019:
020:        import java.awt.*;
021:        import java.util.*;
022:        import java.util.List;
023:
024:        import javax.swing.*;
025:
026:        import net.ar.webonswing.*;
027:        import net.ar.webonswing.helpers.*;
028:        import net.ar.webonswing.managers.script.*;
029:        import net.ar.webonswing.managers.templates.*;
030:        import net.ar.webonswing.remote.*;
031:        import net.ar.webonswing.render.*;
032:        import net.ar.webonswing.render.markup.*;
033:        import net.ar.webonswing.render.templates.*;
034:        import net.ar.webonswing.render.templates.html.*;
035:        import net.ar.webonswing.wrapping.*;
036:        import net.ar.webonswing.wrapping.swing.*;
037:
038:        import org.apache.commons.logging.*;
039:
040:        public class TabbedPaneUIContributor extends
041:                AbstractSwingComponentUIContributor {
042:            StringBuffer theScript = new StringBuffer();
043:
044:            public void doRenderingContribution(
045:                    RenderingContributionContainer theContribManager) {
046:                try {
047:                    JTabbedPane theTabbedPane = (JTabbedPane) getJComponent();
048:
049:                    Template theTemplate = WosSwingHelper
050:                            .getTemplateForComponent("JTabbedPane",
051:                                    theTabbedPane);
052:                    HtmlTemplate theMainTemplate = HtmlTemplateManager
053:                            .getSubTemplate(theTemplate, "theMainTag");
054:
055:                    Tag theMainTag = new Tag("div");
056:
057:                    if (theTabbedPane.getWidth() + theTabbedPane.getHeight() > 0)
058:                        theMainTag
059:                                .addAttribute(new TagStyleAttribute()
060:                                        .addElement("width",
061:                                                theTabbedPane.getWidth())
062:                                        .addElement("height",
063:                                                theTabbedPane.getHeight()));
064:
065:                    JComponent theSelectedPane = (JComponent) theTabbedPane
066:                            .getComponentAt(theTabbedPane.getSelectedIndex());
067:
068:                    theMainTag
069:                            .getTheMarkupContainer()
070:                            .addElement(
071:                                    new Tag("input")
072:                                            .setNeedsClosure(false)
073:                                            .addAttribute(
074:                                                    new TagAttribute("type",
075:                                                            "hidden"))
076:                                            .addAttribute(
077:                                                    new TagAttribute("name",
078:                                                            theComponent
079:                                                                    .getName()))
080:                                            .addAttribute(
081:                                                    new TagAttribute(
082:                                                            "value",
083:                                                            WosFramework
084:                                                                    .getInstance()
085:                                                                    .getHierarchyWrapper()
086:                                                                    .getComponentWrapper(
087:                                                                            theSelectedPane)
088:                                                                    .getName())));
089:                    theMainTemplate.mergeFoundTag(theMainTag);
090:
091:                    createTabPane(theContribManager, theTabbedPane,
092:                            theTemplate, theMainTemplate);
093:
094:                    theContribManager.doContribution(theComponent,
095:                            theMainTemplate, theMainTag, getInitScript());
096:                } catch (Exception e) {
097:                    LogFactory.getLog(TabbedPaneUIContributor.class).error("",
098:                            e);
099:                }
100:            }
101:
102:            private StringBuffer createTabPane(
103:                    RenderingContributionContainer theContribManager,
104:                    JTabbedPane theTabbedPane, Template theTemplate,
105:                    HtmlTemplate theMainTemplate)
106:                    throws CloneNotSupportedException {
107:                HtmlTemplate theTabPaneTemplate = HtmlTemplateManager
108:                        .getSubTemplate(theTemplate, "theMainTag.theTabPane");
109:
110:                StringBuffer theResult = new StringBuffer();
111:                theScript = new StringBuffer();
112:                HtmlTemplate theTabTemplate = HtmlTemplateManager
113:                        .getSubTemplate(theTemplate, "theMainTag.theBar.theTab");
114:                StringBuffer theTabsResult = new StringBuffer();
115:                Component[] theComponents = theTabbedPane.getComponents();
116:
117:                for (int i = 0; i < theComponents.length; i++) {
118:                    Container theSubComponent = (Container) theComponents[i];
119:                    VisualComponent theTabComponent = WosFramework
120:                            .getInstance().getHierarchyWrapper()
121:                            .getComponentWrapper(theSubComponent);
122:
123:                    if (theSubComponent.isVisible()
124:                            || theSubComponent instanceof  JPanel) {
125:                        Tag theTabPaneTag = new Tag("div");
126:                        theTabPaneTag.addAttribute(new TagAttribute("id",
127:                                theTabComponent.getName()));
128:                        TagStyleAttribute theStyle = new TagStyleAttribute();
129:                        theStyle
130:                                .addElement("width", theSubComponent.getWidth())
131:                                .addElement("height", "100%").addElement(
132:                                        "left", 2).addElement("top", "20")
133:                                .addElement("position", "absolute");
134:                        if (!theSubComponent.isVisible())
135:                            theStyle.addElement("display", "none");
136:                        theTabPaneTag.addAttribute(theStyle);
137:
138:                        HtmlTemplate theClonedTabPaneTemplate = (HtmlTemplate) theTabPaneTemplate
139:                                .clone();
140:                        theClonedTabPaneTemplate.mergeFoundTag(theTabPaneTag);
141:                        theClonedTabPaneTemplate
142:                                .addElement(new IdTagTemplateElement(
143:                                        "theContent",
144:                                        new TagContent(
145:                                                new ContentRenderer(
146:                                                        theContribManager
147:                                                                .getContainerRenderer()
148:                                                                .render(
149:                                                                        theTabComponent))
150:                                                        .getResult())));
151:
152:                        theResult.append(new TextTemplateRenderer(
153:                                theClonedTabPaneTemplate).getResult());
154:                        theScript.append(theContribManager
155:                                .getComponentInitScripts(theTabComponent)[0]);
156:
157:                        Tag theTabTag = new Tag("div");
158:                        theTabTag.addAttribute(new TagAttribute("onclick",
159:                                "getElement('" + theComponent.getName()
160:                                        + "').value+='-"
161:                                        + theTabComponent.getName()
162:                                        + "'; ed.dispatch(new ChangeEvent('"
163:                                        + theComponent.getName() + "'));"));
164:                        theTabTag
165:                                .addAttribute(new TagAttribute(
166:                                        "class",
167:                                        theTabbedPane.getSelectedIndex() == i ? "tabDown"
168:                                                : "tabUp"));
169:                        theTabTag.addAttribute(new TagAttribute("id",
170:                                theComponent.getName() + "_"
171:                                        + theTabComponent.getName()));
172:
173:                        HtmlTemplate theClonedTabTemplate = (HtmlTemplate) theTabTemplate
174:                                .clone();
175:                        theClonedTabTemplate.mergeFoundTag(theTabTag);
176:                        theClonedTabTemplate
177:                                .addElement(new IdTagTemplateElement(
178:                                        "theContent", new TagContent(
179:                                                theTabbedPane.getTitleAt(i))));
180:
181:                        theTabsResult.append(new TextTemplateRenderer(
182:                                theClonedTabTemplate).getResult());
183:
184:                    }
185:                }
186:
187:                theMainTemplate.addElement(new IdTagTemplateElement("theBar",
188:                        new TextContent(theTabsResult)));
189:                theMainTemplate.addElement(new IdTagTemplateElement(
190:                        "theTabPane", new TextContent(theResult), null));
191:
192:                return theResult;
193:            }
194:
195:            public void dispatchEvents(List anEvents) {
196:                for (Iterator i = anEvents.iterator(); i.hasNext();) {
197:                    RemoteEvent theEvent = (RemoteEvent) i.next();
198:                    JTabbedPane theTabbedPane = (JTabbedPane) ((ComponentWrapper) theEvent
199:                            .getSource()).getWrappedComponent();
200:
201:                    if (theEvent.getType().equals("stateChanged")
202:                            || theEvent.getType().equals("update")) {
203:                        String theTab = (String) theEvent.getParameters()[0];
204:
205:                        SwingComponentWrapper theTabComponent = (SwingComponentWrapper) WosFramework
206:                                .getInstance().getHierarchyWrapper()
207:                                .getComponentWrapper(theTabbedPane)
208:                                .getTopParent().findComponent(theTab);
209:
210:                        theTabbedPane.setSelectedComponent(theTabComponent
211:                                .getJComponent());
212:                    }
213:                }
214:            }
215:
216:            public String getInitScript() {
217:                String theComponentName = theComponent.getName();
218:                //		theScriptTag.getTheMarkupContainer().addAll(RemoteHelper.getListenersAdds(theComponent));
219:                return theScript.toString() + "getComponent('"
220:                        + theComponentName
221:                        + "').addListener(new TabbedPaneChangeListener());";
222:            }
223:
224:            public void doScriptContribution(
225:                    ScriptContributionContainer aContributionManager) {
226:                aContributionManager.addInclude(WosFramework.getInstance()
227:                        .getCompleteResourcePath()
228:                        + "/js/JTabbedPane.js");
229:            }
230:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.