Source Code Cross Referenced for SchemaNode.java in  » Database-Client » iSQL-Viewer » org » isqlviewer » model » 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 » Database Client » iSQL Viewer » org.isqlviewer.model 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the Mozilla Public License
003:         * Version 1.1 (the "License"); you may not use this file except in
004:         * compliance with the License. You may obtain a copy of the License at
005:         * http://www.mozilla.org/MPL/
006:         *
007:         * Software distributed under the License is distributed on an "AS IS"
008:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
009:         * License for the specific language governing rights and limitations
010:         * under the License.
011:         * 
012:         * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
013:         *
014:         * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
015:         * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
016:         *
017:         * Contributor(s): 
018:         *  Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
019:         *  
020:         * If you didn't download this code from the following link, you should check
021:         * if you aren't using an obsolete version: http://www.isqlviewer.com
022:         */
023:        package org.isqlviewer.model;
024:
025:        import java.awt.datatransfer.DataFlavor;
026:        import java.awt.datatransfer.Transferable;
027:        import java.awt.datatransfer.UnsupportedFlavorException;
028:        import java.io.IOException;
029:
030:        import javax.swing.tree.DefaultMutableTreeNode;
031:
032:        /**
033:         * TreeNode class for distinguinshing different nodes by a given type within a tree.
034:         * <p>
035:         * This node class should alleviate and provide more flexiblility to the structure of the JdbcSchema tree so that nodes
036:         * can be indentified by an enumerated type instead of making a guess by the name of the node itself as to what data it
037:         * actually represents in the JDBC Schema.
038:         * 
039:         * @author Mark A. Kobold &lt;mkobold at isqlviewer dot com&gt;
040:         * @version 1.0
041:         */
042:        public final class SchemaNode extends DefaultMutableTreeNode implements 
043:                Transferable {
044:
045:            public static final String MIME_TYPE = "java-x-object/org.isqlviewer.model.SchemaNode";
046:            public static final DataFlavor DATA_FLAVOR = new DataFlavor(
047:                    SchemaNode.class, MIME_TYPE);
048:
049:            private static final long serialVersionUID = 1L;
050:            private SchemaNodeType nodeType = null;
051:            private boolean hasError = false;
052:
053:            private static DataFlavor[] supportedDataFlavors;
054:
055:            static {
056:                supportedDataFlavors = new DataFlavor[2];
057:                supportedDataFlavors[0] = DATA_FLAVOR;
058:                supportedDataFlavors[1] = DataFlavor.stringFlavor;
059:            }
060:
061:            /**
062:             * Creates a tree node that has no parent and no children, but which allows children.
063:             * <p>
064:             * 
065:             * @param nodeType type of node this instance represents.
066:             * @throws NullPointerException if nodeType is null.
067:             */
068:            public SchemaNode(SchemaNodeType nodeType) {
069:
070:                this (null, true, nodeType);
071:            }
072:
073:            /**
074:             * Creates a tree node with no parent, no children.
075:             * <p>
076:             * This instance will be one that allows children, and initializes it with the specified user object.
077:             * 
078:             * @param userObject an Object provided by the user that constitutes the node's data
079:             * @param nodeType type of node this instance represents.
080:             * @throws NullPointerException if nodeType is null.
081:             */
082:            public SchemaNode(Object userObject, SchemaNodeType nodeType) {
083:
084:                this (userObject, true, nodeType);
085:            }
086:
087:            /**
088:             * Creates a tree node with no parent, no children.
089:             * <p>
090:             * This instance will be initialized with the specified user object, and that allows children only if specified.
091:             * 
092:             * @param userObject an Object provided by the user that constitutes the node's data
093:             * @param allowsChildren if true, the node is allowed to have child nodes -- otherwise, it is always a leaf node
094:             * @param nodeType type of node this instance represents.
095:             * @throws NullPointerException if nodeType is null.
096:             */
097:            public SchemaNode(Object userObject, boolean allowsChildren,
098:                    SchemaNodeType nodeType) {
099:
100:                super (userObject, allowsChildren);
101:                if (nodeType == null) {
102:                    throw new NullPointerException();
103:                }
104:                this .nodeType = nodeType;
105:            }
106:
107:            /**
108:             * Gets the current type of schema node this represenents.
109:             * <p>
110:             * 
111:             * @return type of node within the JDBC Schema is being represented.
112:             */
113:            public SchemaNodeType getNodeType() {
114:
115:                return nodeType;
116:            }
117:
118:            /**
119:             * Return true if this node loaded with an error.
120:             * <p>
121:             * Since most schema nodes are loaded via the database this allows a state to be saved to the node if parent or
122:             * child had an error during the loading process.
123:             * 
124:             * @return <tt>true</tt> if this node expierenced some sort of SQL Exception during initialization.
125:             */
126:            public boolean isHasError() {
127:
128:                return hasError;
129:            }
130:
131:            /**
132:             * @return
133:             */
134:            public boolean isNoncached() {
135:
136:                if (nodeType == SchemaNodeType.NON_CACHED) {
137:                    return true;
138:                }
139:                if (allowsChildren && (children != null && children.size() > 0)) {
140:                    SchemaNode firstChild = (SchemaNode) children.get(0);
141:                    return firstChild == null ? false : firstChild
142:                            .isNoncached();
143:                }
144:                return false;
145:            }
146:
147:            @Override
148:            public String getUserObject() {
149:
150:                Object obj = super .getUserObject();
151:                return obj == null ? "" : obj.toString();
152:            }
153:
154:            /**
155:             * Sets the error flag to the appropriate value.
156:             * <p>
157:             * 
158:             * @param hasError value to indicate if the node expierenced and error.F
159:             */
160:            public synchronized void setHasError(boolean hasError) {
161:
162:                this .hasError = hasError;
163:            }
164:
165:            public Object getTransferData(DataFlavor flavor)
166:                    throws UnsupportedFlavorException, IOException {
167:
168:                if (flavor != null) {
169:                    if (flavor.equals(supportedDataFlavors[0])) {
170:                        return this ;
171:                    } else if (flavor.equals(supportedDataFlavors[1])) {
172:                        return toString();
173:                    }
174:                }
175:                throw new UnsupportedFlavorException(flavor);
176:            }
177:
178:            public DataFlavor[] getTransferDataFlavors() {
179:
180:                return supportedDataFlavors;
181:            }
182:
183:            public boolean isDataFlavorSupported(DataFlavor flavor) {
184:
185:                if (flavor != null) {
186:                    if (flavor.equals(supportedDataFlavors[0])) {
187:                        return true;
188:                    } else if (flavor.equals(supportedDataFlavors[1])) {
189:                        return true;
190:                    }
191:                }
192:                return false;
193:            }
194:
195:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.