Source Code Cross Referenced for HTMLDefaultTreeCellRenderer.java in  » Swing-Library » Swinglets » com » javelin » swinglets » plaf » html » 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 » Swing Library » Swinglets » com.javelin.swinglets.plaf.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright Javelin Software, All rights reserved.
003:         */
004:
005:        package com.javelin.swinglets.plaf.html;
006:
007:        import javax.swing.tree.*;
008:
009:        import com.javelin.swinglets.*;
010:        import com.javelin.swinglets.plaf.*;
011:        import com.javelin.swinglets.tree.*;
012:        import com.javelin.swinglets.theme.*;
013:
014:        /**
015:         * Defines the requirements for an object that displays a tree node in HTML.
016:         * <P>
017:         * The renderer reloads the whole web page when a leaf node is selected.
018:         *
019:         * @author Robin Sharp
020:         */
021:
022:        public class HTMLDefaultTreeCellRenderer extends SPanel implements 
023:                STreeCellRenderer {
024:            /**
025:             * Create a new HTMLDefaultTreeCellRenderer
026:             */
027:            public HTMLDefaultTreeCellRenderer() {
028:                add(node);
029:                add(label);
030:            }
031:
032:            /**
033:             * Sets the value of the current tree cell to <code>value</code>.
034:             * Currently component.setName( "" + row ) MUST be called.
035:             */
036:            public SComponent getTreeCellRendererComponent(STree tree,
037:                    Object value, boolean expanded, boolean leaf, int row,
038:                    boolean isSelected) {
039:                if (theme == null
040:                        || theme != tree.getSwingletManager().getTheme()) {
041:                    theme = tree.getSwingletManager().getTheme();
042:
043:                    open = theme.getIcon(STheme.TREE_OPEN_ICON);
044:                    closed = theme.getIcon(STheme.TREE_CLOSED_ICON);
045:                    doc = theme.getIcon(STheme.TREE_LEAF_ICON);
046:
047:                    selectedBackground = theme.getTextHighlightColor();
048:                }
049:
050:                open.setLookAndFeel(getLookAndFeel());
051:                closed.setLookAndFeel(getLookAndFeel());
052:                doc.setLookAndFeel(getLookAndFeel());
053:
054:                node.setName("" + row);
055:
056:                if (leaf) {
057:                    node.setIcon(doc);
058:                    node.setLink(getNodeLink(tree, row));
059:                    label.setLink(getLabelLink(tree, row));
060:                } else if (expanded) {
061:                    node.setIcon(open);
062:                    node.setLink(getNodeLink(tree, row));
063:                    label.setLink(getLabelLink(tree, row));
064:                } else {
065:                    node.setIcon(closed);
066:                    node.setLink(getNodeLink(tree, row));
067:                    label.setLink(getLabelLink(tree, row));
068:                }
069:
070:                if (isSelected) {
071:                    label.setForeground(SColor.blue);
072:                } else {
073:                    label.setForeground(SColor.black);
074:                }
075:
076:                if (value != null) {
077:                    if (value instanceof  DefaultMutableTreeNode
078:                            && ((DefaultMutableTreeNode) value).getUserObject() != null
079:                            && ((DefaultMutableTreeNode) value).getUserObject() instanceof  SComponent) {
080:                        return (SComponent) ((DefaultMutableTreeNode) value)
081:                                .getUserObject();
082:                    }
083:
084:                    label.setText(value.toString());
085:                } else {
086:                    label.setText("");
087:                }
088:
089:                return this ;
090:            }
091:
092:            /**
093:             * Get the link for selecting the node
094:             */
095:            protected SLink getNodeLink(STree tree, int row) {
096:                if (linkBuffer == null) //Only update buffer once
097:                {
098:                    linkBuffer = new StringBuffer(tree.getComponentUrl());
099:                    linkLength = linkBuffer.length();
100:                }
101:
102:                //Remove the old column from the end of the buffer
103:                linkBuffer.setLength(linkLength);
104:
105:                //Now append the new row
106:                linkBuffer.append("&");
107:                linkBuffer.append(row);
108:                linkBuffer.append("=");
109:                linkBuffer.append(STree.NODE);
110:
111:                nodeLink.setUrl(linkBuffer.toString());
112:                return nodeLink;
113:            }
114:
115:            /**
116:             * Get the link for selecting the label
117:             */
118:            protected SLink getLabelLink(STree tree, int row) {
119:                if (linkBuffer == null) //Only update buffer once
120:                {
121:                    linkBuffer = new StringBuffer(tree.getComponentUrl());
122:                    linkLength = linkBuffer.length();
123:                }
124:
125:                //Remove the old column from the end of the buffer
126:                linkBuffer.setLength(linkLength);
127:
128:                //Now append the new row
129:                linkBuffer.append("&");
130:                linkBuffer.append(row);
131:                linkBuffer.append("=");
132:                linkBuffer.append(STree.LABEL);
133:
134:                labelLink.setUrl(linkBuffer.toString());
135:                return labelLink;
136:            }
137:
138:            protected SLabel node = new SLabel();
139:            protected SLabel label = new SLabel();
140:
141:            //Theme stuff
142:            protected STheme theme;
143:            protected static SColor selectedBackground;
144:            protected SIcon open;
145:            protected SIcon closed;
146:            protected SIcon doc;
147:
148:            protected SLink nodeLink = new SLink(null, SFrame.SELF);
149:            protected SLink labelLink = new SLink(null, SFrame.SELF);
150:
151:            //This is for cached links
152:            private StringBuffer linkBuffer;
153:            private int linkLength;
154:            private String treeName;
155:            private String containerName;
156:
157:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.