Source Code Cross Referenced for XTree.java in  » XML-UI » XUI » net » xoetrope » swing » 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 » XML UI » XUI » net.xoetrope.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.swing;
002:
003:        import java.awt.event.MouseEvent;
004:        import java.awt.event.MouseListener;
005:        import javax.swing.JTree;
006:        import javax.swing.event.TreeSelectionEvent;
007:        import javax.swing.event.TreeSelectionListener;
008:        import javax.swing.tree.TreePath;
009:
010:        import net.xoetrope.swing.tree.XTreeModelAdapter;
011:        import net.xoetrope.xui.XAttributedComponent;
012:        import net.xoetrope.xui.XPage;
013:        import net.xoetrope.xui.data.XModel;
014:        import net.xoetrope.xui.events.XHandlerInvoker;
015:        import net.xoetrope.xui.events.XListenerHelper;
016:        import net.xoetrope.xui.style.XStyleComponent;
017:
018:        /**
019:         * @todo add listeners
020:         * @todo add data bindings
021:         * @todo add simple path/node selection interfaces
022:         */
023:
024:        /**
025:         * A tree control, wraps JTree
026:         * <p>Copyright (c) Xoetrope Ltd., 1998-2004<br>
027:         * License:      see license.txt
028:         * $Revision: 1.7 $
029:         */
030:        public class XTree extends JTree implements  XAttributedComponent,
031:                TreeSelectionListener, XListenerHelper, XStyleComponent,
032:                MouseListener {
033:            private XHandlerInvoker invoker;
034:            private XModel selectedNode, lastSelectedNode;
035:            private String styleName;
036:
037:            public XTree() {
038:                setScrollsOnExpand(true);
039:                addTreeSelectionListener(this );
040:                addMouseListener(this );
041:            }
042:
043:            /**
044:             * Set one or more attributes of the component.
045:             * @param attribName the name of the attribute
046:             * @param attribValue the value of the attribute
047:             */
048:            public void setAttribute(String attribName, String attribValue) {
049:            }
050:
051:            /**
052:             * Called whenever the value of the selection changes.
053:             * @param e the event that characterizes the change.
054:             */
055:            public void valueChanged(TreeSelectionEvent e) {
056:                invokeSelection();
057:            }
058:
059:            private void invokeSelection() {
060:                getSelectedNode();
061:                if ((selectedNode != null) && (invoker != null))
062:                    invoker.invoke();
063:            }
064:
065:            /**
066:             * Get the selected model node.
067:             * @return
068:             */
069:            public XModel getSelectedNode() {
070:                TreePath tp = getSelectionPath();
071:                if (tp != null) {
072:                    Object path[] = tp.getPath();
073:                    if ((path != null) && (path.length > 0))
074:                        selectedNode = ((XTreeModelAdapter) path[path.length - 1])
075:                                .getModel();
076:                    else
077:                        selectedNode = null;
078:
079:                    return selectedNode;
080:                }
081:
082:                return null;
083:            }
084:
085:            /**
086:             * Add an event handler response method to a component such that the page's
087:             * response method is invoked when the event occurs
088:             * @param page the page containing the method
089:             * @param handlerType the type of event handler
090:             * @param methodName the method to invoke
091:             * @throws NoSuchMethodException
092:             */
093:            public void addHandler(XPage page, String handlerType,
094:                    String methodName) throws NoSuchMethodException {
095:                invoker = new XHandlerInvoker(page, this , methodName);
096:            }
097:
098:            public void setStyle(String style) {
099:                styleName = style;
100:            }
101:
102:            public String getStyleName() {
103:                return styleName;
104:            }
105:
106:            public void mouseEntered(MouseEvent me) {
107:            }
108:
109:            public void mouseExited(MouseEvent me) {
110:            }
111:
112:            /**
113:             * Allow a mouse event to trigger the event if it is the same as the last
114:             * selection. In other cases the tree selection listener will handle the event.
115:             * @param me
116:             */
117:            public void mouseClicked(MouseEvent me) {
118:                if (lastSelectedNode == getSelectedNode())
119:                    invokeSelection();
120:                lastSelectedNode = selectedNode;
121:            }
122:
123:            public void mouseReleased(MouseEvent me) {
124:            }
125:
126:            public void mousePressed(MouseEvent me) {
127:            }
128:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.